Skip to content

vscode: sync Builders sidebar selection with the active builder-diff file #1066

Closed

Description

@amrmelsayed

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 matching BuilderFileTreeItem and buildersView.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 dedicated codev.* 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:

  1. getParent is builder-row-only today. BuildersProvider.getParent returns parents only for BuilderTreeItem (for the accordion); for BuilderFileTreeItem / BuilderFolderTreeItem it returns undefined. reveal needs the full parent chain: file → folder(s) (tree mode) → builder → group.
  2. File/folder rows have no stable id. reveal matches recreated elements by id; file and folder rows need stable, unique ids (e.g. <builderId>::<relPath>).
  3. 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 so reveal can match what getChildren returns.
  4. Tree-mode folder hierarchy. In file-tree view mode, a file's parent is a folder row from buildFilePathTree; getParent has 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.autoReveal or add a codev.* 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

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

  1. added
    area/vscode
    on Jun 17, 2026
  2. added a commit that references this issue on Jun 17, 2026
  3. self-assigned this
    on Jun 17, 2026
  4. amrmelsayed commented on Jun 17, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).

  5. added 18 commits that reference this issue on Jun 17, 2026
  6. added 3 commits that reference this issue on Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/vscode

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions