vscode: next-file / previous-file navigation in a Codev diff session (#1060)#1067
Merged
Conversation
…-diff internals
…file nav start)
amrmelsayed
added a commit
that referenced
this pull request
Jun 17, 2026
First entry of the post-v3.2.0 cycle. Adds back the [Unreleased] heading to packages/vscode/CHANGELOG.md (documented behavior of bump-vscode.sh: next PR adds it back). Substantive new feature so it gets its own ## section in UNRELEASED.md, not Polish.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PIR Review: Cross-file navigation in a Codev View Diff session
Fixes #1060
Summary
Adds two palette + keyboard commands,
codev.diffNextFile/codev.diffPreviousFile(Ctrl+Alt+] / Ctrl+Alt+[), that walk a builder's changed-file list and open each file's per-file diff — the keyboard equivalent of clicking the next file row in the Builders sidebar (GitHub PR review'sj/k). The implementation deliberately reuses already-shipped machinery (theBuilderDiffCachethat backs the sidebar for the ordered list, the diff-inject registry for the current position, and the per-filevscode.diffopen path) rather than driving VSCode's multi-file diff editor internals, so there is no change to howcodev.viewDiffopens.Files Changed
packages/vscode/src/commands/diff-nav.ts(+133 / -0) — new:navigateDiff+ pure helpers (orderedRelPaths,computeNavTarget,indexOfRelPath)packages/vscode/src/commands/view-diff.ts(+39 / -0) — extractedopenBuilderFileDiff(context, args, showOptions?), the shared per-file open seampackages/vscode/src/extension.ts(+11 / -14) — registered the two commands; refactoredcodev.openBuilderFileDiffto call the extracted helperpackages/vscode/package.json(+18 / -0) — twocontributes.commands+ twocontributes.keybindingsentriespackages/vscode/src/__tests__/diff-nav.test.ts(+103 / -0) — new: unit tests for the pure helperspackages/vscode/src/__tests__/contributes-commands.test.ts(+27 / -0) — assert the commands are declared, palette-discoverable, and bound (no function keys)codev/resources/lessons-learned.md— two cold-tier lessons (see below)Commits
5bda593a[PIR vscode: next-file / previous-file navigation across files in a Codev View Diff session #1060] Extract openBuilderFileDiff helper, refactor sidebar handler50f7fb25[PIR vscode: next-file / previous-file navigation across files in a Codev View Diff session #1060] Add diffNextFile/diffPreviousFile cross-file navigation commandsf9fe8b76[PIR vscode: next-file / previous-file navigation across files in a Codev View Diff session #1060] Tests for nav helpers + command declarations6649e752[PIR vscode: next-file / previous-file navigation across files in a Codev View Diff session #1060] Add Ctrl+Alt+] / Ctrl+Alt+[ keybindings (builder-diff scoped)Test Results
pnpm compile(check-types + lint + esbuild): ✓ passpnpm test:unit: ✓ pass (438 tests, 11 new indiff-nav.test.ts+ 1 extended incontributes-commands.test.ts)dev-approvalgate): walked files via the new commands in a running worktree — confirmed working ("File Navigation looks good"). The sidebar-selection-sync gap noticed during this review was spun out to a separate issue (vscode: sync Builders sidebar selection with the active builder-diff file #1066) rather than folded in.Architecture Updates
No arch changes needed. The feature introduces no new module boundaries: it reuses
BuilderDiffCache(changed-file list), the diff-inject registry (getDiffInjectEntry), and the existing per-file diff path. The one structural touch — extractingopenBuilderFileDifffrom theextension.tscommand handler intoview-diff.ts— is a same-seam refactor (the sidebar command and the nav commands now share it), not a boundary change, so it doesn't rise to anarch.md/arch-critical.mdentry.Lessons Learned Updates
Two cold-tier lessons added to
codev/resources/lessons-learned.md(UI/UX section) — both VSCode-diff-narrow, so COLD not HOT:_workbench.openMultiDiffEditor(the publicvscode.changessynthesizes a random source URI and has no file-granular nav) — but the cheaper, more robust path is to reuse an existing changed-file list + per-file diffs. Check for an existing list before reaching for an internal_workbench.*command.preview: truereuses one tab for a sequential-open walk (but is ignored when the user disabled preview editors — respect that, don't force-close); and scope a nav keybinding to the feature-specific context key (codev.activeEditorIsBuilderFile), not the broadisInDiffEditor, so it can't fire in an unrelated diff and act on stale state.3-Way Consultation (single advisory pass)
file:right side, soregisterFileInjectSessionskips them andgetDiffInjectEntrycan't resolve them; withlastPositionunset, next/prev bailed. Fix: seed the nav anchor on every open viarecordDiffNavPosition(called from thecodev.openBuilderFileDiffhandler), not just after a navigation step — so a subsequent next/prev resolves through the fallback. Regression coverage:diff-nav.test.tsnow tests the record/peek/reset anchor and that a deleted file resolves in the list. Commit<see PR>.agy/Antigravity run misfired: it went off investigating a "--sandbox" prompt and never reviewed the diff (output incodev/projects/1060-*/1060-review-iter1-gemini.txt). Not re-run (PIR consultation is single-pass advisory); flagged for the human.Things to Look At During PR Review
navigateDiffcurrent-position resolution (diff-nav.ts): it reads the active editor's fsPath via the diff-inject registry, with a module-levellastPositionfallback for when the active editor isn't a tracked diff file. Worth a look that the fallback + the no-op status messages (no session / file-not-in-list / at-edge) cover the cases sensibly.openBuilderFileDiffbehavior preservation: the sidebar command (codev.openBuilderFileDiff) now calls the helper with noshowOptions, so it runsvscode.diff(left, right, title)with no 4th arg — byte-identical to the pre-refactor call. Only navigation passes{ preview: true }. Confirm the refactor didn't change the sidebar-click path.whenclause: I usedcodev.activeEditorIsBuilderFilerather than the genericisInDiffEditorshown in the plan-gate option, to avoid the chord firing in unrelated diffs (where it would fall back to a stale position). Flagging the deliberate deviation.git --name-statusorder (matches the View Diff file list and the sidebar's flat-list mode). In the sidebar's file-tree mode the visual order differs (folders-first/alphabetical) — documented as a plan decision, not a bug.How to Test Locally
For reviewers pulling the branch:
pir-1060→ Run Dev Server, orafx dev pir-1060Changelog
Per the established workflow,
packages/vscode/CHANGELOG.mdanddocs/releases/UNRELEASED.mdare not touched on this branch — they live on the divergentdocs/vscode-changelogbranch (worktrees/changelog/) and are added by the architect post-cleanup. Flagged in the architect notification.