Add interactive resume picker for stopped/idle sessions

Commit

Soph3mo ago

entire resume with no argument now opens an interactive picker of resumable 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 prints the command to continue the agent; if the branch is already checked out in another worktree, it points you there instead of failing a checkout. entire resume <branch> is unchanged.

Details:

  • Resumable = any session not currently mid-turn (idle + ended), not just sessions explicitly ended via session stop. Exiting an agent leaves a session idle (only a real SessionEnd marks it ended), so idle is the common "walked away" case and must be included.
  • Adds a Branch field to session state, captured on each turn start, and surfaced in session list --json. For sessions recorded before the field existed, the branch is derived by matching the session's last checkpoint ID against branch-only commit trailers. Internal entire/ refs (metadata branch + shadow branches) are excluded from that index, both to avoid mis-resolving to a non-resumable ref and to keep the scan fast (the index is also built lazily and avoids go-git MergeBase).
  • Resume now keeps an existing local session log as-is by default; only a missing log is restored from the checkpoint. --force overwrites. This is driven by file existence, not transcript timestamps.

Tests cover the picker filtering/sorting, labels, branch derivation, internal-ref exclusion, worktree-clash detection, and keep-existing-log behavior. Obsolete overwrite-prompt tests removed; timestamp resume integration tests updated to keep-by-default semantics.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com Entire-Checkpoint: 5f34a04f3d49

Checkpoints

Interactive Resume Picker for Sessions

Claude CodeOpus 4.8[1m]
View session
Checkpoint 1

Review CLI Repository Pull Requests

Claude CodeOpus 4.8[1m]
View session
Checkpoint 1