Description
Add directory-aware resume to dispatch open. Let dispatch open --current resume the most recent session for the git repository and branch of the working directory, and let --last be combined with --repo, --branch, and --cwd to resume the newest session matching a filter.
Use Case
dispatch open --last resumes the single most recently active session across every repo. dispatch --current opens the full TUI filtered to the current repo, but there is no one-shot way to jump straight back into the last Copilot session for the project you are already in. Terminal session managers like sesh make "pick up where you left off in this project" a core move, and the docs already suggest a dc alias for dispatch --current. A resume-in-place counterpart closes that gap.
Proposed Solution
Extend parseOpenArgs and runOpen in cmd/dispatch/open.go:
--current reads the repo slug and branch from the working directory (or --cwd <path>) using the existing detectGitRepo helper, then resumes the newest matching session.
--repo, --branch, --cwd can be combined with --last to resume the newest session matching those filters.
- Reuse
data.FilterOptions + store.ListSessions with an updated-descending sort and a limit of 1, the same path search and open --last already use.
- Keep
--mode and --print working with the filtered selection.
- A clear nonzero error when no session matches, or when
--current runs outside a git repo.
Acceptance criteria
dispatch open --current resumes the newest session for the current repo and branch.
dispatch open --last --repo owner/repo (and --branch, --cwd) resume the newest matching session.
--current, --repo, --branch, --cwd compose with --mode and --print.
- No match prints a clear message and exits nonzero; running
--current outside a git repo errors cleanly.
- Tests cover current-directory detection, filtered selection, no-match, and the print path.
Alternatives Considered
Adding a separate dispatch resume command, rejected to avoid a second launch path parallel to open. Relying on the TUI --current filter, rejected because it still needs a manual selection step.
Complexity
M
Description
Add directory-aware resume to
dispatch open. Letdispatch open --currentresume the most recent session for the git repository and branch of the working directory, and let--lastbe combined with--repo,--branch, and--cwdto resume the newest session matching a filter.Use Case
dispatch open --lastresumes the single most recently active session across every repo.dispatch --currentopens the full TUI filtered to the current repo, but there is no one-shot way to jump straight back into the last Copilot session for the project you are already in. Terminal session managers like sesh make "pick up where you left off in this project" a core move, and the docs already suggest adcalias fordispatch --current. A resume-in-place counterpart closes that gap.Proposed Solution
Extend
parseOpenArgsandrunOpenincmd/dispatch/open.go:--currentreads the repo slug and branch from the working directory (or--cwd <path>) using the existingdetectGitRepohelper, then resumes the newest matching session.--repo,--branch,--cwdcan be combined with--lastto resume the newest session matching those filters.data.FilterOptions+store.ListSessionswith an updated-descending sort and a limit of 1, the same pathsearchandopen --lastalready use.--modeand--printworking with the filtered selection.--currentruns outside a git repo.Acceptance criteria
dispatch open --currentresumes the newest session for the current repo and branch.dispatch open --last --repo owner/repo(and--branch,--cwd) resume the newest matching session.--current,--repo,--branch,--cwdcompose with--modeand--print.--currentoutside a git repo errors cleanly.Alternatives Considered
Adding a separate
dispatch resumecommand, rejected to avoid a second launch path parallel toopen. Relying on the TUI--currentfilter, rejected because it still needs a manual selection step.Complexity
M