Repository navigation
Description
Problem
When a reviewer steps through a builder's diff with codev.diffNextFile / codev.diffPreviousFile, the Builders sidebar does not fully follow along:
- Collapsed folders are not skipped. Navigation order comes from
flattenTreeOrderinapps/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 callsreveal({ expand: true }). - 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 ongetDiffInjectEntry(activeFsPath). A deleted or binary file's right side is acodev-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/onDidExpandElementforBuilderFolderTreeItemrows (the view already subscribes to expand for the builder accordion atextension.ts:659) and keep a set of collapsed folderfullPaths 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 < 0because 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 byrecordDiffNavPosition) 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