resume: ask before launching restored sessions · Entire

resume: ask before launching restored sessions

Sessions

Changes

5

15 unmodified lines

With no argument, opens an interactive picker of stopped sessions across all worktrees so you don't have to remember which branch you left work on. Picking a session checks out its branch and shows the command to continue the agent. If the branch is already checked out in another worktree, you'll be pointed there instead.

  1. Checks out the specified branch
  2. Finds the session ID from commits unique to this branch (not on main)
  3. Restores the session log if it doesn't exist locally (an existing local log is kept as-is; use --force to overwrite it from the checkpoint)
  4. Shows the command to resume the session
  5. In an interactive terminal, asks whether to start the agent; otherwise prints the command to resume the session

If the branch doesn't exist locally but exists on origin, you'll be prompted to fetch it.

if err != nil || len(sessions) == 0 {
    return err
}
return displayRestoredSessions(w, sessions)
return continueSessionRestoredSessions(ctx, w, sessions)
}

func restoreByCheckpointID(ctx context.Context, w, errW io.Writer, checkpointID id.CheckpointID, force bool) ([]strategy.RestoredSession, error) {
func continueSessionRestoredSessions(ctx context.Context, w io.Writer, sessions []strategy.RestoredSession) error {
    return continueRestoredSessions(ctx, w, sessions, restoredSessionContinueOptions{
        CanPrompt:     interactive.CanPromptInteractively(),
        PromptSession: promptTrailRestoredSession,
        Launch:        launchTrailRestoredSession,
        Display:       displayRestoredSessions,
    })
}
if err != nil || len(sessions) == 0 {
    return err
}
return displayRestoredSessions(w, sessions)
return continueSessionRestoredSessions(ctx, w, sessions)
func restoreFromCurrentBranch(ctx context.Context, w, errW io.Writer, branchName string, force bool) ([]strategy.RestoredSession, error) {
4 unmodified lines

// runResumePicker lists stopped sessions across all worktrees and lets the user // pick one to resume. Selecting a session checks out its branch (or, when the // branch is already checked out in another worktree, points there) and prints // the command to continue the agent. func runResumePicker(ctx context.Context, cmd *cobra.Command, force bool) error { }

The trail may be given as the first argument or via --trail, as a number, id, or branch. Without one, the trail for the current branch is used.

By default, interactive terminals show the trail context and let you choose between checkpoint sessions on the trail branch when there are multiple. Non-interactive runs show the same context and resume the latest checkpoint on the trail branch. Use --session or --checkpoint to resume an exact session or checkpoint.

func continueTrailRestoredSessions(ctx context.Context, cmd *cobra.Command, sessions []strategy.RestoredSession, preferredSessionID string) error {
}
4 unmodified lines

func printTrailRestoredSessionSummary(w io.Writer, sessions []strategy.RestoredSession) { }

4 unmodified lines

func TestContinueRestoredSessionsTTYDeclinePrintsAgentCommands(t *testing.T) { }

696 unmodified lines

func TestContinueRestoredSessionsTTYStartSingleLaunchesSession(t *testing.T) { }

4 unmodified lines

func TestContinueRestoredSessionsTTYStartMultipleLaunchesPickerSelection(t *testing.T) { }

4 unmodified lines

func TestContinueRestoredSessionsPreferredDeclinePrintsOnlyPreferredSession(t *testing.T) { }

4 unmodified lines