Skip to content

Diff navigation: skip collapsed sidebar folders and auto-reveal deleted/binary files #1794

Open

Description

@amrmelsayed

Problem

When a reviewer steps through a builder's diff with codev.diffNextFile / codev.diffPreviousFile, the Builders sidebar does not fully follow along:

  1. Collapsed folders are not skipped. Navigation order comes from flattenTreeOrder in apps/vscode/src/views/file-path-tree.ts, which walks the whole folder tree depth-first with no knowledge of which folder rows the user has collapsed. Stepping into a file under a collapsed folder also forcibly re-expands it, because the auto-reveal calls reveal({ expand: true }).
  2. Auto-reveal misses deleted / binary files. The reveal hook in extension.ts (revealActiveBuilderFile, vscode: sync Builders sidebar selection with the active builder-diff file #1066) gates on getDiffInjectEntry(activeFsPath). A deleted or binary file's right side is a codev-diff: placeholder, never registered, so the sidebar selection stays on the previous file and does not scroll.

Expected

  • Next / previous file walks only the files that are visible in the tree: a collapsed folder's entire subtree (including nested folders) is skipped. Flat-list mode is unaffected.
  • If the current file sits inside a folder the user just collapsed, next / previous step out of that folder (to the next / previous visible file) rather than flashing "current file is not in this diff".
  • Auto-reveal selects and scrolls to the sidebar row for every navigated file, including deleted / binary ones.

Fix shape (hypothesis; verify in source)

  • Track collapse state per builder: subscribe to buildersView.onDidCollapseElement / onDidExpandElement for BuilderFolderTreeItem rows (the view already subscribes to expand for the builder accordion at extension.ts:659) and keep a set of collapsed folder fullPaths keyed by builder id. Clear it when the builder's file list is rebuilt.
  • Thread that set into navigationOrder / flattenTreeOrder (pure, unit-testable) so a collapsed node's subtree is dropped.
  • When currentIdx < 0 because the current file is hidden, locate it in the full order and resolve the nearest visible neighbour in the requested direction instead of bailing.
  • Auto-reveal: when the active editor's path has no diff-inject entry, fall back to the navigation anchor (peekDiffNavPosition, already seeded on every open by recordDiffNavPosition) before giving up. Keep the standalone-text-tab guard.

Caveat to decide

VS Code exposes no read API for a tree's collapse state, only the events. A folder collapsed in an earlier window session is restored by VS Code but invisible to the extension until it is toggled again. Either treat folders as expanded unless an event says otherwise (matches the Expanded default in builder-folder-tree-item.ts), or force-expand folder rows on first render so the tracked set and the view agree. The builder should pick one and state it in the plan.

Verification

Exercise the real path at the dev gate: collapse a folder in the sidebar, press next-file across it, confirm the walk skips the folder and the folder stays collapsed; navigate onto a deleted file and confirm the sidebar scrolls to and selects its row.

Protocol

AIR. Extension-only change (apps/vscode), no contract surface. Owner: vscode architect.

Activity

  1. added
    area/vscode
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/vscode

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions