Skip to content

fix(source-control): highlight the open file's Committed on Branch row - #35915

Closed
simon-caignart wants to merge 1 commit into
stablyai:mainfrom
simon-caignart:feat/source-control-branch-open-file-highlight
Closed

simon-caignart wants to merge 1 commit into
stablyai:mainfrom
simon-caignart:feat/source-control-branch-open-file-highlight

Conversation

@simon-caignart

Copy link
Copy Markdown

ELI5

When you click a file in Source Control's Committed on Branch list, its diff opens but nothing in the list shows which file you're looking at.
Uncommitted files already get a highlighted row for this.
This PR gives committed files the same highlight, so reviewing an agent's work file by file no longer means re-reading the list to find your place.

What Changed

Before: opening a branch diff left every Committed on Branch row unstyled.
After: the row of the branch diff in the active editor tab gets bg-accent and data-current="true", the same current-row recipe as uncommitted rows (docs/STYLEGUIDE.md), in both list and tree views.

Mechanism:

  • active-open-file-keys.ts: the signature parsing is extracted into parseActiveOpenFileSignature, and a new resolveActiveOpenBranchPath returns the path only for a single-file branch diff.
  • use-row-opening.ts derives activeOpenBranchPath from the existing active-tab signature selector, so no new store subscription. It flows through use-file-listing and panel-content to SourceControlBranchSection.
  • BranchEntryRow takes isOpenFile and gains the same data-testid / data-source-control-path / data-current attributes as UncommittedEntryRow.
  • The list-mode branch rows compare entry.path, tree-mode rows compare node.entry.path.

Unchanged on purpose:

  • buildActiveOpenRowKeys still returns nothing for branch tabs, so a branch diff never lights a pending row with the same path.
  • combined-branch ("View all"), commit and other combined diffs highlight no branch row.
  • A plain editor tab doesn't light a branch row: the row opens a diff, not the file.
  • Matching is by path, like the uncommitted highlight. A branch diff tab kept open across a base-ref change still marks the row for its path.

Why

The branch section is where you review committed agent work, and it was the only file list in Source Control without an open-file marker.
Adding a branch:: key to activeOpenRowKeys was the other option, but that set is filtered against the visible pending rows and is tested to stay empty for branch tabs.
A separate string | null keeps that contract intact and costs one string comparison per rendered row.

Linked Issue

Fixes #35905

Visual Proof

Same branch with 3 committed files and index.ts open as a branch diff. Before on the left, after on the right.

Dark:

Before and after, dark theme

Light:

Before and after, light theme

In light theme the current row is #f5f5f5 on the #fafafa sidebar, so it's faint. That's the existing recipe shared with uncommitted rows, not something this PR introduces; happy to open a separate issue for it.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Two cases added to SourceControl.open-file-highlight.test.tsx, next to the existing branch case: the active branch diff highlights only its Committed on Branch row (not the other branch row, not the unstaged row with the same path), and a combined-branch tab highlights none. The first fails without the fix.

  • pnpm check:changed passes (format, lint, typecheck, affected tests, ratchets).

  • Verified in the real app on Linux with a Playwright Electron run against a worktree with a committed change: clicking the row opens the branch diff and the row gets data-current="true". The screenshots above come from that run. I didn't keep that spec since the render test covers the behavior faster.

AI Disclosure

Written with Claude Code (Claude Opus 5.5). Reviewed by two separate Claude Fable 5.1 agents (code conventions, integration across surfaces) before opening; their findings are applied.

Review

AI review summary:

  • Cross-platform: no platform, process, shortcut or path logic added; both sides of the comparison are the same git-relative entry.path string.
  • SSH / remote / paired servers: no new IPC or runtime call; the highlight is derived from renderer state that already exists for remote worktrees. Mixed client/server versions are unaffected.
  • Folder workspaces: the branch section only renders with a ready compare summary, which folder workspaces don't have.
  • Mobile: mobile/src/source-control shows branch diffs in a drawer over the list, with no persistent open-file row to mirror, so no change there.
  • Agents and integrations: provider-neutral, no GitHub-specific code.
  • Performance: no new store subscription; the derived value is a primitive and rows add one ===.
  • UI: reuses the style guide's current-row recipe verbatim.
  • Security: no new inputs, IPC or file access.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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)

Opening a file from Committed on Branch left its row unmarked, while
uncommitted rows already show the open file with bg-accent and
data-current. Resolve the open branch diff's path from the active editor
tab and give branch rows the same current-row styling, in list and tree
views. Combined and commit diffs still highlight nothing.

Fixes stablyai#35905
@simon-caignart
simon-caignart marked this pull request as ready for review October 29, 2026 11:20
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Adds an open-file highlight to Committed on Branch rows in list and tree views.

  • The open branch diff highlights its matching Committed on Branch row.

No actionable issues found. Tests and visual checks were not run during this review.

Acknowledged by simon-caignart: the faint light-theme highlight is existing shared styling and is intentionally outside this change.

Reviews (1) · Last reviewed commit: "fix(source-control): highlight the open ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 75ee3d93-232a-467c-b612-275bacda5fa5
Commits

Reviewing files that changed from the base of the PR and between 4e9e320 and 4bb4112.

Files selected for processing: 7
  • src/renderer/src/components/right-sidebar/SourceControl.open-file-highlight.test.tsx
  • src/renderer/src/components/right-sidebar/source-control/listing/active-open-file-keys.ts
  • src/renderer/src/components/right-sidebar/source-control/listing/branch-entry-row.tsx
  • src/renderer/src/components/right-sidebar/source-control/listing/branch-section.tsx
  • src/renderer/src/components/right-sidebar/source-control/listing/use-file-listing.ts
  • src/renderer/src/components/right-sidebar/source-control/listing/use-row-opening.ts
  • src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx

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

Walkthrough

The source-control listing now resolves the active file path for branch diffs and passes it to branch rows. A matching row receives open-file styling in both tree and list views. Tests cover highlighting the matching “Committed on Branch” row and not highlighting that row for a combined-branch tab.

Priority: Low

Severity of issue fixed: Low

Merge Risk: Minimal · up to 4bb41

The change is limited to highlighting the matching committed-branch row, with no established merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed 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 with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: highlighting the open file's Committed on Branch row.
Description check Passed The description is complete and focused. It explains the user impact, implementation, rationale, linked issue, visual proof, testing, AI disclosure, compatibility considerations, and checklist status.
Linked Issues check Passed Issue #35905 requires the open file under Committed on Branch to use the current-row styling. The change resolves the active single-file branch diff path and passes it to branch rows in list and tre…
Out of Scope Changes check Passed The changes remain within issue #35905. Signature parsing extraction, row-opening data flow, branch-row attributes and styling, and the added tests directly support the required open-file marker. No u…
Full details: Linked Issues check

Explanation

Issue #35905 requires the open file under Committed on Branch to use the current-row styling. The change resolves the active single-file branch diff path and passes it to branch rows in list and tree views. BranchEntryRow sets data-current="true" and bg-accent for the matching path. The added Source Control tests verify the matching branch row, exclude the unstaged row with the same path, and exclude combined-branch tabs.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue #35905. Signature parsing extraction, row-opening data flow, branch-row attributes and styling, and the added tests directly support the required open-file marker. No unrelated product behavior or unrelated files are identified. The repository diff was unavailable, so this scope conclusion relies on the supplied change summary and the reviewed test and row files.

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 with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 7 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · 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.

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.

[Bug]: Committed on Branch rows don't highlight the file whose diff is open

1 participant