Milestone 3.2: Overview #8

Open
opened 2026-07-24 03:22:36 +00:00 by david · 0 comments
Owner

Overview

Offer new session creation after switching to a worktree.

Acceptance Criteria

  • After successful switch, user is prompted: "Create a new session?"
  • Options: "Yes, start fresh for this worktree" / "No, keep the current session"
  • If "Yes": creates new session with context message about the switch
  • If "No": keeps current session unchanged (except branch display)

Implementation

const choice = await ctx.ui.select("Create a new session?", [
  "Yes, start fresh for this worktree",
  "No, keep the current session"
]);

if (choice?.startsWith("Yes")) {
  await ctx.newSession({
    setup: async (sm) => {
      sm.appendMessage({
        role: "user",
        content: [{ 
          type: "text", 
          text: `Switched to worktree for branch ${branchName}. Context from previous session...` 
        }],
        timestamp: Date.now()
      });
    },
    withSession: async (newCtx) => {
      newCtx.ui.notify("New session created for this worktree.", "info");
    }
  });
}

Validation

  • Switch to a worktree and choose "Yes" — verify new session is created with appropriate context message
  • Switch to a worktree and choose "No" — verify current session continues unchanged (except branch display)
# Overview Offer new session creation after switching to a worktree. ## Acceptance Criteria - [ ] After successful switch, user is prompted: "Create a new session?" - [ ] Options: "Yes, start fresh for this worktree" / "No, keep the current session" - [ ] If "Yes": creates new session with context message about the switch - [ ] If "No": keeps current session unchanged (except branch display) ## Implementation ```typescript const choice = await ctx.ui.select("Create a new session?", [ "Yes, start fresh for this worktree", "No, keep the current session" ]); if (choice?.startsWith("Yes")) { await ctx.newSession({ setup: async (sm) => { sm.appendMessage({ role: "user", content: [{ type: "text", text: `Switched to worktree for branch ${branchName}. Context from previous session...` }], timestamp: Date.now() }); }, withSession: async (newCtx) => { newCtx.ui.notify("New session created for this worktree.", "info"); } }); } ``` ## Validation - Switch to a worktree and choose "Yes" — verify new session is created with appropriate context message - Switch to a worktree and choose "No" — verify current session continues unchanged (except branch display)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: david/pi-worktrees#8
No description provided.