Skip to content

Resume the most recent session for the current repo from the CLI #270

Description

@jongio

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestideaFeature idea from the idea pipeline

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions