Skip to content

Highlight the open file in the Source Control sidebar - #5667

Merged
brennanb2025 merged 3 commits into
stablyai:mainfrom
devajmeireles:highlight-selected-file
Jun 18, 2026
Merged

brennanb2025 merged 3 commits into
stablyai:mainfrom
devajmeireles:highlight-selected-file

Conversation

@devajmeireles

@devajmeireles devajmeireles commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Selecting a pending (uncommitted) file in the right-hand Source Control sidebar gave no persistent visual cue for which file was open in the editor. A plain single click cleared the bulk selection and only opened the diff, so no row stayed highlighted.

This adds a "current row" highlight to the open file's Source Control row:

  • The active editor file for the worktree is derived from the store (activeFileIdByWorktree + openFiles) and its row is marked with the full bg-accent + data-current="true" treatment per the styleguide's "List rows: hover, selected, current" convention, outranking the lighter bulk-selection tint (bg-accent/60).
  • Matching is area-aware: a partially staged file highlights only the row that is actually open (staged vs working tree). Untracked files (opened as an unstaged diff) and plain edit/changes tabs fold into the working-tree rows.
  • The highlight clears when the visible tab is not an editor (terminal/browser), so it always reflects what you are looking at.

Scope is limited to pending/uncommitted rows (UncommittedEntryRow), covering both the tree and flat list views.

Screenshots

UI change (no screen recording captured in this headless environment — please attach one before merge):

  • Open a worktree with uncommitted changes → Source Control panel.
  • Click a pending file: its row now stays highlighted (full accent) while it is the file open in the editor; clicking another pending file moves the highlight.

Testing

  • pnpm lint (every sub-step run individually and green: oxlint, lint:switch-exhaustiveness, check-styled-scrollbars, verify:localization-catalog, verify:localization-coverage)
  • pnpm typecheck (all 3 projects clean)
  • pnpm test — ran the affected suites: right-sidebar + editor store (725 passing), plus the new unit + render tests (19 passing). Full monorepo run and pnpm build were not executed in this environment.
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI Review Report

Reviewed by the AI agent for correctness and reuse risks:

  • Re-render safety: the new zustand selector returns a stable primitive string signature (${diffSource}::${relativePath}) instead of a fresh object, so the panel only re-renders when the active file actually changes.
  • Crash safety: the selector dereferences per-worktree store maps; added optional chaining so absent maps (e.g. test harnesses / early hydration) don't throw. Verified no regression by running the full right-sidebar + editor store suites (725 tests).
  • Key-format coupling: confirmed the ${area}::${path} row keys match exactly between the tree builder, the flat list, and the new mapping; logic extracted into source-control-active-open-file-keys.ts and unit-tested (staged-only, working-tree, untracked, edit-tab, null/malformed).
  • Tailwind precedence: open-file and bulk-selected backgrounds are mutually exclusive in the cn() ternary to avoid bg-accent vs bg-accent/60 conflict.
  • Cross-platform (macOS / Linux / Windows): explicitly checked. The change is renderer-only state derivation plus a CSS class — no keyboard shortcuts, accelerators, shortcut labels, filesystem paths, shell invocation, or Electron platform-specific code is touched. No SSH/remote assumptions added (reads existing store state that already supports remote runtimes).

Security Audit

Low risk. No input handling, command execution, path handling, authentication, secrets, dependency changes, or IPC are involved. The change reads existing in-memory renderer store state (active editor tab + git status entries) and applies a presentational CSS class plus a data-current attribute. No user-controlled value is interpolated into anything executable; the only string interpolation builds DOM class names and a comparison key. No follow-up needed.

Notes

  • Committed/branch rows (BranchEntryRow) intentionally keep their existing behavior — this PR is scoped to pending files as requested. Adding the same highlight there would be a small follow-up.

Open in Stage

Pending (uncommitted) rows had no persistent indicator for the file
currently open in the editor: a plain single click cleared the bulk
selection and only opened the diff, leaving no visual cue for which row
was active.

Derive the active editor file for the worktree from the store and mark
its Source Control row as the current row (full bg-accent + data-current),
outranking the lighter bulk-selection tint. Matching is area-aware so a
partially staged file lights up only the row that is actually open, and
the highlight clears when the visible tab is not an editor.

Extract the row-key mapping into source-control-active-open-file-keys.ts
and cover it with unit tests plus render tests for the highlight wiring.
@ghost

ghost commented Jun 18, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Define logic for active file signature matching
2 Integrate active file tracking into SourceControl
3 Apply highlight styling to uncommitted entry rows
4 Verify sidebar highlight behavior with integration tests
Open in Stage

Chapters generated by Stage for commit cfd354e on Jun 18, 2026 7:06pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f3f9b09c-efe3-4117-a270-03356071a5b1

📥 Commits

Reviewing files that changed from the base of the PR and between 801652c and cfd354e.

📒 Files selected for processing (4)
  • src/renderer/src/components/right-sidebar/SourceControl.open-file-highlight.test.tsx
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/right-sidebar/source-control-active-open-file-keys.test.ts
  • src/renderer/src/components/right-sidebar/source-control-active-open-file-keys.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/right-sidebar/source-control-active-open-file-keys.test.ts
  • src/renderer/src/components/right-sidebar/SourceControl.tsx

📝 Walkthrough

Walkthrough

A new module source-control-active-open-file-keys.ts is introduced with exported type ActiveOpenFileDiffSource and two functions: buildActiveOpenFileSignature encodes a diff source and relative path as a stable ${diffSource ?? 'edit'}::${relativePath} string, while buildActiveOpenRowKeys parses that signature, optionally filters against available row keys, and returns a ReadonlySet of matching Source Control row keys (staged::<path> or unstaged::<path> plus untracked::<path>). SourceControl.tsx imports these utilities, derives activeOpenFileSignature from store selectors only when the active tab type is 'editor', memoizes activeOpenRowKeys, and passes an isOpenFile boolean to UncommittedEntryRow in both tree and list render paths. UncommittedEntryRow gains the optional isOpenFile prop, sets data-current="true", and applies bg-accent styling with higher priority than bulk-selection tinting. Unit tests cover signature encoding, key mapping, fallback behavior, and malformed signature rejection. A component integration test validates the highlight behavior across multiple scenarios: unstaged/staged area discrimination, untracked mapping, tab-type gating, branch-compare suppression, staged-only fallback, and UI-state-dependent fallback when sections collapse.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 directly and clearly describes the main feature added: highlighting the currently open file in the Source Control sidebar, which is the core objective of this PR.
Description check ✅ Passed The description is well-structured and covers most required sections. It includes a clear summary, screenshots note, comprehensive testing checklist (5 of 5 items addressed), detailed AI review report covering re-render safety, crash safety, key-format coupling, Tailwind precedence, and cross-platform compatibility, plus a security audit and implementation notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@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: Pro

Run ID: 97db179d-9e62-421f-8182-31a2c667e894

📥 Commits

Reviewing files that changed from the base of the PR and between 994d02d and 29d7954.

📒 Files selected for processing (4)
  • src/renderer/src/components/right-sidebar/SourceControl.open-file-highlight.test.tsx
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/right-sidebar/source-control-active-open-file-keys.test.ts
  • src/renderer/src/components/right-sidebar/source-control-active-open-file-keys.ts

…ile-highlight.test.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@brennanb2025 brennanb2025 self-assigned this Jun 18, 2026

@brennanb2025 brennanb2025 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.

Thanks! I reviewed this and made a small follow-up to cover edge cases before merge:

  • Prevent branch/commit compare tabs from marking pending rows as current.
  • Make ordinary editor tabs prefer visible working-tree rows, with staged-only fallback.
  • Keep the current row at the full accent state on hover.
  • Added regression coverage for staged-only, collapsed-section, compare-tab, and non-editor cases.

Validated with lint, typecheck, targeted tests, Electron UI checks, and a two-reviewer code-review loop.

@brennanb2025
brennanb2025 merged commit 99bc046 into stablyai:main Jun 18, 2026
carlosbaraza added a commit to carlosbaraza/orca that referenced this pull request Jun 18, 2026
* upstream/main: (220 commits)
  Show and Filter Automation-Created Workspaces (stablyai#5697)
  Fix premature project header truncation
  Send review notes to any running agent of a worktree (stablyai#5654)
  Fix workspace sidebar appearance setting (stablyai#5725)
  Highlight the open file in the Source Control sidebar (stablyai#5667)
  release: v1.4.80-rc.1
  Fix premature Codex completion notifications (stablyai#5682)
  Improve Codex startup prompt reliability (stablyai#5686)
  Keep hibernated agent completions visible (stablyai#5689)
  Move Prompt Cache Timer setting to Agents pane, simplify expired state (stablyai#5691)
  release: v1.4.80-rc.0
  Skip GitHub CLI preflight checks if no GitHub projects exist
  fix: restore font family keyboard navigation in settings
  Update README downloads badge
  fix(landing): make GitHub CLI setup nudge dismissible and provider-aware (stablyai#5688)
  Fix nested workspace card indentation (stablyai#5684)
  Fix flaky e2e tests (stablyai#5680)
  Replace plus icon with play button on quick command entry (stablyai#5674)
  Use managed Pi and OMP extensions (stablyai#5681)
  Narrow computer-use e2e trigger (stablyai#5685)
  ...

# Conflicts:
#	mobile/src/terminal/TerminalWebView.tsx
#	mobile/src/terminal/terminal-webview-text-zoom.test.ts
carlosbaraza added a commit to carlosbaraza/orca that referenced this pull request Jun 18, 2026
* upstream/main: (78 commits)
  Show and Filter Automation-Created Workspaces (stablyai#5697)
  Fix premature project header truncation
  Send review notes to any running agent of a worktree (stablyai#5654)
  Fix workspace sidebar appearance setting (stablyai#5725)
  Highlight the open file in the Source Control sidebar (stablyai#5667)
  release: v1.4.80-rc.1
  Fix premature Codex completion notifications (stablyai#5682)
  Improve Codex startup prompt reliability (stablyai#5686)
  Keep hibernated agent completions visible (stablyai#5689)
  Move Prompt Cache Timer setting to Agents pane, simplify expired state (stablyai#5691)
  release: v1.4.80-rc.0
  Skip GitHub CLI preflight checks if no GitHub projects exist
  fix: restore font family keyboard navigation in settings
  Update README downloads badge
  fix(landing): make GitHub CLI setup nudge dismissible and provider-aware (stablyai#5688)
  Fix nested workspace card indentation (stablyai#5684)
  Fix flaky e2e tests (stablyai#5680)
  Replace plus icon with play button on quick command entry (stablyai#5674)
  Use managed Pi and OMP extensions (stablyai#5681)
  Narrow computer-use e2e trigger (stablyai#5685)
  ...

# Conflicts:
#	mobile/app/h/[hostId]/session/[worktreeId].tsx
#	mobile/src/terminal/TerminalWebView.tsx
#	mobile/src/terminal/terminal-webview-html.ts
carlosbaraza added a commit to carlosbaraza/orca that referenced this pull request Jun 18, 2026
* upstream/main: (220 commits)
  Show and Filter Automation-Created Workspaces (stablyai#5697)
  Fix premature project header truncation
  Send review notes to any running agent of a worktree (stablyai#5654)
  Fix workspace sidebar appearance setting (stablyai#5725)
  Highlight the open file in the Source Control sidebar (stablyai#5667)
  release: v1.4.80-rc.1
  Fix premature Codex completion notifications (stablyai#5682)
  Improve Codex startup prompt reliability (stablyai#5686)
  Keep hibernated agent completions visible (stablyai#5689)
  Move Prompt Cache Timer setting to Agents pane, simplify expired state (stablyai#5691)
  release: v1.4.80-rc.0
  Skip GitHub CLI preflight checks if no GitHub projects exist
  fix: restore font family keyboard navigation in settings
  Update README downloads badge
  fix(landing): make GitHub CLI setup nudge dismissible and provider-aware (stablyai#5688)
  Fix nested workspace card indentation (stablyai#5684)
  Fix flaky e2e tests (stablyai#5680)
  Replace plus icon with play button on quick command entry (stablyai#5674)
  Use managed Pi and OMP extensions (stablyai#5681)
  Narrow computer-use e2e trigger (stablyai#5685)
  ...

# Conflicts:
#	src/renderer/src/i18n/locales/en.json
#	src/renderer/src/i18n/locales/es.json
#	src/renderer/src/i18n/locales/ja.json
#	src/renderer/src/i18n/locales/ko.json
#	src/renderer/src/i18n/locales/zh.json
carlosbaraza added a commit to carlosbaraza/orca that referenced this pull request Jun 18, 2026
* upstream/main: (341 commits)
  Show and Filter Automation-Created Workspaces (stablyai#5697)
  Fix premature project header truncation
  Send review notes to any running agent of a worktree (stablyai#5654)
  Fix workspace sidebar appearance setting (stablyai#5725)
  Highlight the open file in the Source Control sidebar (stablyai#5667)
  release: v1.4.80-rc.1
  Fix premature Codex completion notifications (stablyai#5682)
  Improve Codex startup prompt reliability (stablyai#5686)
  Keep hibernated agent completions visible (stablyai#5689)
  Move Prompt Cache Timer setting to Agents pane, simplify expired state (stablyai#5691)
  release: v1.4.80-rc.0
  Skip GitHub CLI preflight checks if no GitHub projects exist
  fix: restore font family keyboard navigation in settings
  Update README downloads badge
  fix(landing): make GitHub CLI setup nudge dismissible and provider-aware (stablyai#5688)
  Fix nested workspace card indentation (stablyai#5684)
  Fix flaky e2e tests (stablyai#5680)
  Replace plus icon with play button on quick command entry (stablyai#5674)
  Use managed Pi and OMP extensions (stablyai#5681)
  Narrow computer-use e2e trigger (stablyai#5685)
  ...

# Conflicts:
#	src/main/text-generation/commit-message-text-generation.test.ts
#	src/main/text-generation/commit-message-text-generation.ts
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Highlight the open file in the Source Control sidebar

Pending (uncommitted) rows had no persistent indicator for the file
currently open in the editor: a plain single click cleared the bulk
selection and only opened the diff, leaving no visual cue for which row
was active.

Derive the active editor file for the worktree from the store and mark
its Source Control row as the current row (full bg-accent + data-current),
outranking the lighter bulk-selection tint. Matching is area-aware so a
partially staged file lights up only the row that is actually open, and
the highlight clears when the visible tab is not an editor.

Extract the row-key mapping into source-control-active-open-file-keys.ts
and cover it with unit tests plus render tests for the highlight wiring.

* Update src/renderer/src/components/right-sidebar/SourceControl.open-file-highlight.test.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Refine source control open-file highlighting

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: brennanb2025 <[email protected]>
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.

2 participants