feat(tui): add git status overlay with inline + preview push/pull stats#316
Merged
Conversation
Add an "i" keybinding (and command-palette entry) that opens a modal overlay showing the git status of the folder a session is mapped to: current branch and upstream, the standard push/pull stats (commits ahead to push, behind to pull), working-tree counts (staged, modified, untracked, deleted, conflicts), and a scrollable list of changed files. The status is gathered off the UI thread with a single bounded `git status --porcelain=v2 --branch` command. Non-repo, missing, detached-HEAD, and no-upstream folders are reported without error. Security: harden all git invocations in gitstate.go with `-c core.fsmonitor=false -c core.hooksPath=` so a session pointing at an untrusted repository cannot execute arbitrary code via repo-local git config during status collection (CWE-829). Covered by a positive-control regression test. Also fixes three pre-existing CI breakages on main from earlier PRs (#299 parseOpenArgs arity + open.go gofmt, #284 duplicated test block). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 524cf702-8922-4cfd-b23f-4069b734e09b
Show the git push/pull state everywhere a session appears, not only in the on-demand overlay: - Session row: a compact, colored `↑N ↓N ●` segment (commits ahead to push, behind to pull, plus a dirty marker) at wider terminals. The single-glyph badge is suppressed on rows that show the inline stats so there is never a duplicate git indicator; a missing-workspace marker folds into the segment. - Preview pane: a git section under the Branch field with branch -> upstream, push/pull counts, and per-category working-tree counts (or a clean label). To feed both surfaces without scanning twice, DetectGitStatus becomes the single git-scanning entry point: GitStatus.State() derives the badge enum and ScanGitStatuses replaces the old enum-only DetectGitState/ScanGitStates (one `git status --porcelain=v2 --branch` per session instead of up to three commands). All badge rendering and git-dirty/missing filters keep working off the derived enum. Also fix a pre-existing preview rendering bug: wordWrap only broke on spaces, so a message containing a long unbreakable token (a path or URL) overflowed the chat bubble and corrupted the preview's outer border. It now hard-breaks tokens longer than the wrap width. Covered by regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 524cf702-8922-4cfd-b23f-4069b734e09b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 524cf702-8922-4cfd-b23f-4069b734e09b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a Git Status feature for the folder each session is mapped to, surfaced in three places:
i/ command palette): branch → upstream, push/pull stats (commits ahead/behind), working-tree counts (staged, modified, untracked, deleted, conflicts), and a scrollable list of changed files. Esc closes, ↑↓ scroll,ccopies a summary.↑N ↓N ●segment (ahead to push, behind to pull, dirty marker) at wider terminals. The old single-glyph badge is suppressed on rows that show the inline stats, so there's never a duplicate indicator.Why
Sessions map to working directories, but the list only showed a single collapsed git badge - hiding the numbers that matter when triaging many sessions: how far ahead/behind you are, whether you owe a push or a pull, and how much uncommitted work is sitting there. Answering that meant leaving dispatch to run
git status.How
DetectGitStatusis the single git-scanning entry point: onegit status --porcelain=v2 --branchper session (a pure parser makes it testable).GitStatus.State()derives the badge enum, andScanGitStatusesreplaces the old enum-only scanners (DetectGitState/ScanGitStates), so the inline row, preview, and badge all come from one scan instead of up to three git commands. The overlay follows the existing Compare/CommandPalette pattern. Non-repo, missing, detached-HEAD, and no-upstream folders are handled without error.Security: all git invocations pass
-c core.fsmonitor=false -c core.hooksPath=so a session pointing at an untrusted repo can't execute arbitrary code via repo-local git config during status collection (CWE-829). Verified by a positive-control regression test.Coupled fix:
wordWrapnow hard-breaks tokens longer than the wrap width. Previously it only broke on spaces, so a message with a long path/URL overflowed the chat bubble and corrupted the preview's border.Also fixes three pre-existing CI breakages on
mainfrom earlier PRs (#299parseOpenArgsarity +open.gogofmt, #284 duplicated test block).Testing
go build ./cmd/dispatch/passesgo test ./...passes (full suite green, incl. race detector viamage install)go vet ./...passesQuality Gates
mq(max-quality)cr(code-review)pf(preflight)secops(security)th(test-health)Screenshots
Terminal UI (no static image). Inline row shows
↑N ↓N ●; the preview git section shows branch → upstream, push/pull, and change counts; theioverlay adds the scrollable changed-files list.