Skip to content

feat(git): choose current branch or all branches in commit history - #25541

Open
matbrgz wants to merge 5 commits into
stablyai:mainfrom
UndefinedDump:feat/git-history-branch-scope
Open

matbrgz wants to merge 5 commits into
stablyai:mainfrom
UndefinedDump:feat/git-history-branch-scope

Conversation

@matbrgz

@matbrgz matbrgz commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

ELI5

The Commits panel used to show only the history of the branch you are on. Now there is a switch at the top of the panel: "Current branch" keeps the old view, "All branches" also shows commits from your other branches, remote branches and tags.

What Changed

  • Loader (src/shared/git-history.ts): new optional scope: 'current' | 'all'. current (the default) still runs git log … HEAD. all runs the same single bounded git log -n51 --topo-order with --branches --remotes --tags HEAD. The result now echoes scope.
  • Plumbing: scope is passed through desktop IPC (git:history, normalized to current/all), the SSH relay handler, the runtime RPC schema (z.enum(['current','all']).optional(), unknown values rejected), and the web preload API. The SSH provider, local runtime and renderer client already forward the whole options object.
  • UI: a Current branch / All branches toggle group (existing ToggleGroup primitive, labelled "Commit history scope") under the Commits header. Switching drops the shown result and any in-flight read for that worktree before refetching, so the old list is never labelled with the new scope. The choice is kept per worktree for the session and dropped when the worktree goes away.
  • Strings: three new keys, translated in every locale.

Why

  • Named ref namespaces instead of --all: --all also walks refs/stash and provider refs like refs/pull/*, which are noise in a branch graph. Adding HEAD keeps a detached checkout in the list.
  • One query, still bounded by the same limit, so cost and Git Scan Safety are unchanged; no per-ref fan-out.
  • Mixed versions: scope is a new optional param (safe per the remote wire rules), and the host echoes it in the result. The panel shows the scope the result actually came from, so a host that predates this change reads as "Current branch" instead of lying.
  • Git compatibility: --branches, --remotes and --tags predate the Git 2.25 baseline by many years, so no capability probe or fallback is needed.
  • Folder workspaces: unchanged — the history hook already refuses to fetch for folders and the panel is not shown there.

Linked Issue

Fixes #25539

Visual Proof

Before/after screenshots will be attached by the author (Commits panel with the scope toggle in each state).

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

New/updated tests (10 failed before the change, all pass after):

  • src/shared/git-history.test.ts — default walks only HEAD and reports current; all passes --branches --remotes --tags HEAD, never --all, in one log call.
  • src/relay/git-handler.test.ts — real Git repo over the relay: a side-branch commit appears only in all; a stash commit never appears.
  • src/main/runtime/rpc/methods/git.test.ts — scope forwarded; unknown scope rejected.
  • src/renderer/src/web/web-preload-api-git.test.ts — web preload forwards scope to git.history.
  • use-source-control-git-history.test.tsx — switching clears the old result and refetches with the new scope; an older host that ignores the scope reads as current; scope is remembered per worktree and forgotten when the worktree is removed.
  • GitHistoryPanel.test.tsx — labelled toggle group marks the shown scope.

Commands run:

  • pnpm vitest run --config config/vitest.config.ts on the six files above — 79 passed
  • pnpm lint — pass
  • pnpm typecheck — pass
  • Full pnpm test and pnpm build were not run locally; relying on CI. Not manually exercised on Windows or against a live SSH host.

AI Disclosure

Implemented with Claude Code (Claude Opus 5.5); reviewed by the author.

Review

  • Cross-platform: Git arguments only; no paths or shell differences.
  • SSH/remote: scope flows through the relay and runtime RPC; older hosts ignore it and the UI reports the scope they actually returned.
  • Git providers: provider-neutral; provider refs are deliberately excluded.
  • Performance: same single bounded git log call; history is still fetched only when the panel is expanded and visible.
  • Security: the scope is a closed enum on every boundary; no user text reaches the Git argv.
  • UI: existing ToggleGroup primitive and type scale; no new tokens.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — lint and typecheck pass locally; full test and build left to CI

The Commits panel only ever walked HEAD. Add a scope option:

- current (default) keeps today's HEAD-only walk.
- all runs the same single bounded git log over --branches --remotes
  --tags plus HEAD, so refs/stash and provider refs such as refs/pull/*
  stay out and a detached checkout is still listed. All three options
  predate the Git 2.25 baseline.

The scope travels through desktop IPC, the SSH relay, runtime RPC (a
closed enum) and the web preload API, and the host echoes it in the
result so a host that predates this change reads as current instead of
being mislabelled. The panel gets a Current branch / All branches toggle
group; switching drops the shown result and any in-flight read before
refetching, and the choice is kept per worktree for the session. Folder
workspaces are unchanged: the hook already skips them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@matbrgz
matbrgz requested a review from brennanb2025 as a code owner October 5, 2026 11:17
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 319d1dbe-1541-41b3-9025-fee581068f18
📥 Commits

Reviewing files that changed from the base of the PR and between e2da3a1 and 76e4143.

📒 Files selected for processing (25)
  • src/main/git/history-unborn-head-real-git.test.ts
  • src/main/ipc/filesystem/filesystem-git-status-handlers.ts
  • src/main/runtime/rpc/methods/git.test.ts
  • src/main/runtime/rpc/methods/git.ts
  • src/relay/git-handler-read-operations.ts
  • src/relay/git-handler.test.ts
  • src/renderer/src/components/right-sidebar/GitHistoryPanel.test.tsx
  • src/renderer/src/components/right-sidebar/source-control/listing/use-file-listing.ts
  • src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/git-history-panel.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/git-history-scope-control.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/use-git-history.ts
  • src/renderer/src/components/right-sidebar/use-source-control-git-history.test.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/web/preload-api/web-git-api.ts
  • src/renderer/src/web/web-preload-api-git.test.ts
  • src/shared/git-history-types.ts
  • src/shared/git-history.test.ts
  • src/shared/git-history.ts
  • src/shared/rpc-contract/git-params.ts
📝 Walkthrough

Walkthrough

The change adds current and all scopes to Git history requests. The loader includes local branches, remote branches, tags, and HEAD for all, and returns the scope used. The selected scope passes through local, relay, and runtime request paths. The Source Control panel adds a scope toggle and tracks the selection per worktree.

Priority: ⬇️ Low

Severity of issue fixed: Low

Merge Risk: 🔵 Low · up to ec102

All branches can incorrectly appear empty on an unborn branch. The issue is narrow and straightforward to fix before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to ec102

The new modes use fixed Git options within the selected repository rather than granting additional command authority. The remaining concern is history ownership during host switches: a broader cached commit list can remain visible under a different host until refresh succeeds.

Retained concerns

  • Low · reliability · inferred: The new all-branches payload inherits an existing host-identity weakness. When an owner host changes without removal of the bare worktree ID, cached history is retained during refresh and after failure, and remains renderable under the new host context. Genuine cross-host ID collisions are documented in the worktree index. This is a conditional history-ownership and failure-containment concern, not a verified unauthorized disclosure; the retention mechanism already existed at the PR base.
Security review details

Security Blast Radius

  • inferred — The incremental read surface is history reachable from additional refs in an already selected repository. The traced scope path does not add a tenant selector, execution-host selector, arbitrary command, or write operation.

Trust Boundaries and Controls

  • observed — Caller-controlled scope crosses RPC validation as a closed enum. The relay additionally normalizes it, and runtime execution continues to resolve a concrete worktree and execution host before dispatch. These are preserved input and routing controls, not evidence of complete transport-authentication coverage.

Hardening Proposals

  • proposed — Use host-qualified worktree identity for history, scope, and request tokens, and retire cached results when that identity changes. This would contain the existing ownership mismatch as broader history modes are added.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 18 files. (6 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: choosing current-branch or all-branches commit history.
Description check ✅ Passed The description is detailed and covers the change, rationale, linked issue, testing, compatibility, and review considerations. It says visual proof will be attached, but the required screenshots or vi…
Linked Issues check ✅ Passed #25539 requests a default Current branch view and an All branches view covering local branches, remote branches, tags, and HEAD without stash or provider refs. The loader implements these scopes with …
Out of Scope Changes check ✅ Passed The changes support #25539. The added plumbing, UI control, translations, and tests implement or validate the requested scope selection and its worktree and transport behavior. No unrelated changes ar…
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 18 files. (6 skipped: 6 unsupported.)

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one rough edge on mixed-version hosts.

Reviewed changes

  • Loader scope (src/shared/git-history.ts) — scope: 'all' switches the single bounded git log to --branches --remotes --tags HEAD (deliberately not --all), and the result now echoes scope.
  • End-to-end plumbing — scope threads through desktop IPC goroutine normalization, the SSH provider, the relay handler, the runtime RPC schema (z.enum(['current','all']).optional()), and the web preload.
  • Panel control (git-history-scope-control.tsx) — new ToggleGroup toggle wired through git-history-panel.tsx, use-git-history.ts, use-file-listing.ts, and panel-content.tsx.
  • Per-worktree scope state — remembered for the session, pruned with the tracked worktrees, dropped and refetched on switch so a stale result is never relabelled.
  • Strings — three keys added to every locale.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

matbrgz and others added 2 commits October 5, 2026 09:59
An older host omits `scope` from the history result, so the toggle shows
"Current branch" while the requested scope stays "all". Clicking "All
branches" again early-returned and the refresh effect never re-ran, leaving
the toggle dead. Re-read when the shown scope differs from the request.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Drop the type assertions from the relay scope test, mark the runtime stub
assertion with a SAFETY rationale like its neighbours, keep the pre-existing
history pruning effect verbatim, and stop restyling ToggleGroupItem.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@matbrgz

matbrgz commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review notes from the review summary:

Separately, ec1024a clears the changed-code quality gate for this PR (ORCA_CODE_QUALITY_BASE=upstream/main pnpm check:code-quality:changed now passes). The relay scope test asserts with toMatchObject instead of as casts. The runtime stub's assertion carries a SAFETY rationale, the same way its neighbours do. The history pruning effect is restored verbatim, so its pre-existing React Doctor finding is not re-flagged. The scope toggle no longer restyles ToggleGroupItem with padding or font size.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Fixed the mixed-version toggle dead-end — setGitHistoryScope now returns early only when the scope matches both the requested and the shown scope, and when an older host answered with a different scope it calls refreshGitHistory() directly, since the trigger effect won't re-run on an unchanged requestedScope.
  • Hook tests for the fix — new cases cover the re-request after an older host ignores scope (2 → 3 calls) and confirm a host that honours the scope gets no redundant refetch.
  • RPC test quality — the git.history scope test now uses toMatchObject/toHaveProperty instead of as HistoryReply casts; the assertions remain exact (items.length is pinned to 2).
  • Scope toggle styling — dropped the custom px-1 text-[10px] classes from the toggle items, leaving the default type scale.

The previously open concern about the toggle becoming unresponsive on a host that ignores scope is addressed by 86604b440e; that thread is resolved.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@matbrgz

matbrgz commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 419aeeec-0dc1-4144-a7dd-ca522caa1311
📥 Commits

Reviewing files that changed from the base of the PR and between e2da3a1 and ec1024a.

📒 Files selected for processing (24)
  • src/main/ipc/filesystem/filesystem-git-status-handlers.ts
  • src/main/runtime/rpc/methods/git.test.ts
  • src/main/runtime/rpc/methods/git.ts
  • src/relay/git-handler-read-operations.ts
  • src/relay/git-handler.test.ts
  • src/renderer/src/components/right-sidebar/GitHistoryPanel.test.tsx
  • src/renderer/src/components/right-sidebar/source-control/listing/use-file-listing.ts
  • src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/git-history-panel.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/git-history-scope-control.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/use-git-history.ts
  • src/renderer/src/components/right-sidebar/use-source-control-git-history.test.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/web/preload-api/web-git-api.ts
  • src/renderer/src/web/web-preload-api-git.test.ts
  • src/shared/git-history-types.ts
  • src/shared/git-history.test.ts
  • src/shared/git-history.ts
  • src/shared/rpc-contract/git-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment thread src/shared/git-history.ts Resolved
matbrgz and others added 2 commits October 5, 2026 11:19
An orphan checkout or a fresh worktree has no HEAD commit, so the loader
returned empty before git log even when branches, remotes or tags existed.
The current scope keeps the early empty result; the all scope now walks
--branches --remotes --tags without HEAD.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Unborn-HEAD all-scope fix — extracted the bounded git log into a shared runHistoryLog, and made the all scope list --branches --remotes --tags even when HEAD is unborn (fresh repo or orphan checkout), degrading to empty on failure, while current still returns empty without issuing a git log.
  • Real-Git coverage — new history-unborn-head-real-git.test.ts builds an orphan checkout beside a committed main and asserts all lists the other branch while current stays empty; verified passing locally.
  • Docstrings — one-line JSDoc added to the functions this change touches; no behavior change.

The prior concern about the scope toggle dead-ending on an older host is already resolved and its thread closed; the CodeRabbit unborn-HEAD finding is addressed by 76e414331c.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@matbrgz

matbrgz commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 3 minutes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Let the Commits panel show all branches, not only the current branch

1 participant