Repository navigation
Description
Problem
When reviewing a builder's diff, the file shown in the diff editor and the file selected/highlighted in the Builders sidebar can drift out of sync.
This became visible once cross-file keyboard navigation landed (#1060: codev.diffNextFile / codev.diffPreviousFile, Ctrl+Alt+] / Ctrl+Alt+[). Stepping through files moves the diff editor correctly, but the Builders sidebar keeps whatever row was last clicked highlighted — so the tree no longer tells you "this is the file you're looking at." The same drift happens when clicking a file inside the multi-file View Diff editor: the editor moves, the sidebar selection doesn't follow.
Proposed mechanic
A single, general "reveal active builder-diff file in the Builders view" sync — analogous to the Explorer's Reveal active file / explorer.autoReveal:
- On
onDidChangeActiveTextEditor, if the active editor is a tracked builder-diff file (resolve via the diff-inject registry →{ builderId, relPath }), locate the matchingBuilderFileTreeItemandbuildersView.reveal(item, { select: true, expand: true }). - Gate it so it only reveals tracked builder files (never hijacks selection for unrelated editors), and consider honoring
explorer.autoReveal(or a dedicatedcodev.*setting) so users who dislike auto-reveal can turn it off.
One listener covers every entry point — keyboard navigation (#1060), clicking a file inside the multi-file View Diff editor, and the per-file diff opened from a sidebar click — instead of bolting sync onto each command.
Why this is its own issue (and not part of #1060)
buildersView is created with createTreeView, so reveal() is available — but revealing a file row needs groundwork that #1060 deliberately stayed out of:
getParentis builder-row-only today.BuildersProvider.getParentreturns parents only forBuilderTreeItem(for the accordion); forBuilderFileTreeItem/BuilderFolderTreeItemit returnsundefined.revealneeds the full parent chain: file → folder(s) (tree mode) → builder → group.- File/folder rows have no stable
id.revealmatches recreated elements byid; file and folder rows need stable, unique ids (e.g.<builderId>::<relPath>). - Accordion id-versioning (vscode: accordion shouldn't affect builder area-group headers, and group expansion state should be ephemeral #913). Builder row ids churn via
AccordionRowIds; the reconstructed parent chain must use the current version sorevealcan match whatgetChildrenreturns. - Tree-mode folder hierarchy. In file-tree view mode, a file's parent is a folder row from
buildFilePathTree;getParenthas to reconstruct that hierarchy to find it.
This is real work in a recently-reworked, fiddly view, so it's cleanly separable from the navigation feature.
Acceptance criteria
- Changing the active builder-diff editor (via keyboard nav, multi-file View Diff click, or per-file diff) selects/highlights the matching row in the Builders sidebar, expanding ancestors as needed.
- Works in both Builders view modes (flat list and file-tree), and under both grouping axes (stage / area).
- No selection hijack for non-builder editors (a normal source file or unrelated diff leaves the sidebar selection alone).
- Plays nicely with the accordion (vscode: accordion shouldn't affect builder area-group headers, and group expansion state should be ephemeral #913) — revealing a file expands its builder without fighting the collapse-others behavior.
- Respects an opt-out (honor
explorer.autoRevealor add acodev.*toggle). - No regression to existing Builders tree behavior (accordion, decorations, per-file diff open).
Suggested protocol
PIR — the dev-approval gate is load-bearing here ("looks fine in unit tests, subtly off when you actually walk it across modes"), and the getParent / id-versioning interaction with the accordion deserves a look at the running tree.
Related
- vscode: next-file / previous-file navigation across files in a Codev View Diff session #1060 — cross-file diff navigation (the feature that surfaced this gap).
- vscode: accordion shouldn't affect builder area-group headers, and group expansion state should be ephemeral #913 — Builders-view accordion + row id-versioning (the constraint the parent chain must respect).
- VSCode native precedent: Explorer's Reveal active file +
explorer.autoReveal.
Out of scope
- Reverse sync beyond selection (e.g. scrolling the diff to a hunk when a row is clicked — already opens the file).
- Persisting selection across sessions.
Activity
[PIR #1060] Thread: filed sidebar-sync follow-up #1066
amrmelsayed commentedon Jun 17, 2026
On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).
[PIR #1066] Plan draft
[PIR #1066] Stable file-row id + getParent/findFileItem for reveal
[PIR #1066] Auto-reveal active builder-diff file in Builders tree
[PIR #1066] Unit tests for findParentNode, file-row id, findFileItem,…
[PIR #1066] Thread: implement phase complete, awaiting dev-approval
[PIR #1066] Fix stale sidebar selection: re-reveal on diff-inject reg…
[PIR #1066] Thread: dev-approval iteration 1 (stale-selection fix)
[PIR #1066] Navigate files in visible tree order (depth-first) in tre…
[PIR #1066] Thread: dev-approval iteration 2 (navigation tree order)
[PIR #1066] Extract builderWithWorktree helper to dedup the changed-f…
[PIR #1066] Wrap file navigation at the ends to match built-in hunk nav
[PIR #1066] Thread: dev-approval iteration 3 (navigation wrap-around)
[PIR #1066] Review: retrospective + arch/lessons updates
[PIR #1066] Thread: review phase, PR #1075, consultation running
[PIR #1066] Gate reveal to diff tabs only (fix standalone-open hijack…
[PIR #1066] Review: record consultation dispositions
[PIR #1066] Consultation rebuttals (iteration 1)
[PIR #1066] Thread: pr gate pending, consultation addressed
Merge pull request #1075 from cluesmith/builder/pir-1066
release notes: #1066 builders-sidebar auto-reveals active diff file (PR
Merge docs/vscode-changelog for v3.2.1 Karnak release