Skip to content

Add startup filters for current repo and branch#252

Merged
jongio merged 3 commits into
mainfrom
idea/startup-filters
Jul 7, 2026
Merged

Add startup filters for current repo and branch#252
jongio merged 3 commits into
mainfrom
idea/startup-filters

Conversation

@jongio

@jongio jongio commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Adds startup filter flags so dispatch can open straight into the sessions for a repo, branch, or folder instead of the global list.

  • --current reads the git repository and branch from the working directory (or from --cwd <path> when given).
  • --cwd <path> filters to sessions under a folder and doubles as the base directory for --current.
  • --repo <name> filters to a repository in owner/repo form.
  • --branch <name> filters to a branch.
  • --query <text> pre-fills the search box with free text.

Flags can be combined, for example dispatch --repo owner/repo --branch main --query auth.

Why

Closes #177. Dispatch is most useful when opened from inside a project, but it starts at the global session list. Binding dispatch --current to a shell alias jumps to the sessions for the repo you are already in and cuts repeated filtering.

How

The filters route through the existing search-token grammar (repo:, branch:, folder: plus free text). handleArgs parses the flags into a startupOptions value whose SeedQuery() renders the token string that seeds the model, so the active filters show up in the search header and drive the first query. Values with spaces are quoted so the tokenizer keeps them intact.

Repository detection reuses the same owner/repo normalization used for reference URLs, so a detected remote matches the form stored on sessions. Explicit --repo and --branch flags take precedence over detected values. Git detection sits behind a seam for testing.

A non-git directory or a missing --cwd path prints a clear error and does not start the TUI.

Testing

  • go build ./...
  • go test ./... (all packages pass)
  • go vet ./...
  • golangci-lint run
  • New tests cover flag parsing (spaced and inline forms), query combination, --cwd validation, --current detection and precedence, and the non-git and missing-value error paths.

Docs

README gains a "Startup filters" section and the new flags are listed in the CLI flags table, the usage banner, and all four shell completion scripts.

Add CLI flags that seed the initial session list so developers can jump
straight to the sessions for the repo or branch they are working in:

- --current reads the git repo and branch from the working directory
- --cwd <path> filters to sessions under a folder and is the base dir
  for --current
- --repo <name> and --branch <name> filter to a repository or branch
- --query <text> pre-fills the search box with free text

Filters route through the existing search-token grammar (repo:, branch:,
folder:) so they appear in the search header and drive the first query.
Non-git directories and missing --cwd paths print a clear error and do
not start the TUI. Explicit --repo/--branch win over detected values.

Closes #177

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 7, 2026
@jongio jongio self-assigned this Jul 7, 2026
jongio and others added 2 commits July 7, 2026 11:35
The deadcode CI check flagged startupOptions.active as unreachable: it was only referenced from tests, never from production code, since SeedQuery already handles the empty-filter case. Drop the method and its test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jongio
jongio merged commit 179a652 into main Jul 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add startup filters for current repo and branch

1 participant