Skip to content

Resume the most recent session for a repo, branch, folder, or current dir #276

Description

@jongio

Problem

dispatch open --last resumes the single most recently active session across everything, and dispatch open <id> resumes an exact session. Neither helps the common case: "resume the last session I had in this repo" or "in this branch". Today you have to run dispatch search --repo owner/repo --ids, read the first line, and pass it back to dispatch open. That is two commands and a copy/paste for something people do many times a day, and it is awkward to bind to a shell alias.

flowchart TD
    A[dispatch open --current] --> B[Detect git repo and branch from cwd]
    A2[dispatch open --repo/--branch/--folder] --> C[Build FilterOptions]
    B --> C
    C --> D[List sessions, updated desc, limit 1]
    D --> E{Match found?}
    E -->|yes| F[Resume with existing launch path]
    E -->|no| G[Clear error, exit non-zero]
Loading

Proposed solution

Teach dispatch open to resume the most recently active session that matches a filter, reusing the same filter fields as dispatch search and the same git detection as the --current startup filter:

  • dispatch open --current resumes the newest session for the current git repo and branch (read from the working dir, or --cwd <path>).
  • dispatch open --repo owner/repo, --branch <name>, and --folder <path> resume the newest session matching those filters, and can be combined.
  • All of these keep working with --mode and --print, so dispatch open --current --print writes the resume command without launching.
  • When no session matches, print a clear message and exit non-zero (do not fall through to launching something unrelated).

This complements --last rather than replacing it. --last stays the "newest anywhere" shortcut; the new filters scope it.

Acceptance criteria

  • dispatch open --repo owner/repo resumes the most recently active session for that repo.
  • dispatch open --branch <name> and --folder <path> scope the same way and can be combined with --repo.
  • dispatch open --current resumes the newest session for the git repo and branch detected from the working dir, honoring --cwd.
  • --mode and --print work with the scoped forms.
  • A non-git dir with --current, or no matching session, prints a helpful error and exits non-zero.
  • --last still behaves as before and cannot be combined with the scoped filters (clear error if it is).
  • Help text and completion list the new flags; unit tests cover match, no-match, and flag-conflict cases.

Notes

The git repo/branch detection already exists for the --current startup filter in startup.go. Session selection can reuse the ListSessions path with SortByUpdated/Descending and limit 1, the same ordering defaultOpenGetLastSession uses.

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