vscode: forward symbol/hunk at cursor to builder (Cmd/Ctrl+K H) - #1447
Merged
Conversation
amrmelsayed
added a commit
that referenced
this pull request
Aug 13, 2026
amrmelsayed
added a commit
that referenced
this pull request
Aug 13, 2026
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: Keyboard shortcut to forward the symbol/hunk under the cursor to the builder
Fixes #1073
Summary
Adds
codev.forwardCursorContextToBuilder(bound toCmd/Ctrl+K H), the keyboardequivalent of clicking a "Forward to Builder" codelens in the builder-diff editor.
Pressing the key resolves the cursor's current line to the most specific enclosing
symbol (first), else the containing changed hunk, else the bare file path, and
injects that reference into the builder PTY with no Enter — closing the gap where
every granular forward surface was mouse-only (
Cmd/Ctrl+K Brequired a textselection first; codelens has no keyboard activator in VS Code).
Files Changed
apps/vscode/src/diff-inject-ref.ts(+48 / -0) — newCursorReftype + pureresolveCursorRef(relPath, symbols, hunks, cursorLine)implementing thesymbol → hunk → file resolution order.
apps/vscode/src/diff-inject-codelens.ts(+4 / -1) — export thetoSymbolNodemapper (was private) so the command handler reuses it.
apps/vscode/src/extension.ts(+28 / -2) — register the new command (thinhandler: fetch live document symbols, call
resolveCursorRef, reuse the sharedcodev.forwardToBuilderinject path, status-bar note on the file fallback).apps/vscode/package.json(+10 / -0) — command declaration +Cmd/Ctrl+K Hkeybinding (
when: codev.activeEditorIsBuilderFile && editorTextFocus).apps/vscode/src/__tests__/diff-inject-ref.test.ts(+70 / -0) — 7 unit testscovering the resolution order.
Commits
6b1a07b4a[PIR vscode: keyboard shortcut to forward the symbol/hunk under the cursor to the builder (codelens keyboard equivalent) #1073] Add forwardCursorContextToBuilder command + Cmd/Ctrl+K H bindingea5c541ad[PIR vscode: keyboard shortcut to forward the symbol/hunk under the cursor to the builder (codelens keyboard equivalent) #1073] Unit tests for resolveCursorRef resolution order35cbc3090[PIR vscode: keyboard shortcut to forward the symbol/hunk under the cursor to the builder (codelens keyboard equivalent) #1073] Thread log: implement phaseTest Results
pnpm check-types: ✓ passpnpm lint: ✓ passpnpm test:unit: ✓ pass (819 tests, 68 files; 7 new)dev-approvalgate (cursorinside a symbol / in a hunk / on an unchanged line → correct reference injected,
no Enter, focus retained on the diff editor).
Architecture Updates
No arch changes. This is an additive VS Code command + keybinding that reuses the
existing diff-inject registry, pure helpers (
diff-inject-ref.ts), and inject path(
codev.forwardToBuilder); it introduces no new module boundary, state, orcross-cutting invariant. The "VS Code Extension" section of
arch.mdintentionallydoes not enumerate every command/keybinding (exhaustive enumeration is explicitly
out of scope for the arch docs), so no entry is warranted.
Lessons Learned Updates
No lessons captured — the change is small and additive, and the reuse-the-existing-
lens-model decision is already documented inline in
resolveCursorRef. (The onegotcha hit during implementation — vitest reports 18 test-file load failures when
the workspace deps
@cluesmith/codev-types/@cluesmith/codev-sdkhaven't beenbuilt — is pre-existing build-order behavior, not a durable cross-cutting lesson;
it's flagged under "Things to Look At" for the reviewer's awareness.)
Things to Look At During PR Review
resolveCursorRefderives its symbolcandidates from
buildSymbolLensDescriptors(the exact forwardable-symbol setthe codelens renders) rather than walking the raw symbol tree, so the keyboard
lands on the same range a lens click would, and never forwards a scalar const or
a nested block the lens wouldn't. Among overlapping candidates the smallest span
wins (a method beats its enclosing class).
cursor, the symbol wins (verified by a dedicated test). Hunk is a fallback for
brand-new files / top-level edits / languages without a symbol provider.
unbound commands —
forwardCurrentHunkToBuilder(hunk-only) andforwardCurrentFileToBuilder(file-only). This change adds a new unifiedcommand rather than binding those, because neither does the symbol step or the
file fallback the issue requires. If consolidating/removing the older two is
desired, that's a separate follow-up.
packages/vscode/...; the code nowlives under
apps/vscode/.... All work landed under the realapps/vscode/root.pnpm --filter @cluesmith/codev-types --filter @cluesmith/codev-sdk buildbeforepnpm test:unit, or ~18 unrelatedtest files fail to load on unbuilt workspace-dep exports. After building deps the
full suite is green (819 tests).
How to Test Locally
afx dev pir-1073.Cmd/Ctrl+K Hinjectspath/to/file.ts:L<symbol-start>-L<symbol-end>matching the symbol's codelens.path and shows the status-bar note.
Cmd/Ctrl+K Hdoes nothing.Cmd/Ctrl+K B(with a selection) and codelens clicks still work.