Skip to content

Feat/vscode context mentions - #842

Merged
will-lamerton merged 8 commits into
Nano-Collective:mainfrom
addyCooks:feat/vscode-context-mentions
Aug 17, 2026
Merged

will-lamerton merged 8 commits into
Nano-Collective:mainfrom
addyCooks:feat/vscode-context-mentions

Conversation

@addyCooks

@addyCooks addyCooks commented Aug 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #747.

Summary

Implements @ mention autocomplete in the VS Code extension's chat composer, allowing users to explicitly attach workspace files, folders, and open editors as context. Typing @ displays a dropdown with fuzzy-matched suggestions; selecting an item attaches it as a chip that's expanded into the AI's context on submit.

Files Changed

New Modules

  • mention-search.ts
  • mention-search.spec.ts
  • mention-utils.js
  • mention-utils.spec.ts
  • context-attachment.ts
  • context-attachment.spec.ts

Modified Files

  • webview-protocol.ts
  • chat-webview-provider.ts
  • chat-panel.js
  • chat-panel.html
  • .changeset/vscode-context-mentions.md

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Testing

Automated Tests

  • New features include passing tests in .spec.ts/tsx files
  • All existing tests pass (pnpm test:all completes successfully)
  • Tests cover both success and error scenarios

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

###Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)
  • Appropriate logging added using structured logging

Typing `@` in the chat input opens a floating dropdown of workspace files,
folders, and open editors. Selecting one attaches it as a context chip.

Reuses the existing attachment pipeline rather than adding a parallel one:
completions push into the same `attachedPaths` state the attach button
already feeds, so chip rendering, `@[file]` serialization and host-side
expansion are untouched.

- Search runs on the extension host via workspace.findFiles, which honours
  files.exclude/search.exclude; open editor tabs resolve with no disk I/O
- Requests carry an id so out-of-order postMessage responses are dropped
- `@` triggers only at line start or after whitespace, so emails and
  decorators do not open the dropdown
- Cap attached file reads at 100 KB and skip binaries, since `@` makes
  attaching cheap enough to exhaust the context window by accident
CI runs ava with FORCE_COLOR=1, so Ink emits the themed indicator wrapped
in escape sequences and the frame line starts with \x1b[34m rather than
`>`. The anchored regexes could therefore never match, while locally the
colours are stripped and the tests passed.

Strip the frame with strip-ansi before splitting, matching the existing
convention in app-container.spec.tsx. Verified under both
CI=true FORCE_COLOR=1 and a plain local run.
The "reports and restores submitted drafts with attachments" test flaked in
CI. Instrumenting it showed the frame rendered the typed text but onSubmit
was called zero times, so the poll for the submitted value ran out its
budget with nothing pending - the Enter had been swallowed, not delayed.

Ink's useInput unsubscribes from stdin and resubscribes across a re-render,
so an Enter written while React is still flushing the typed characters is
lost. Raising the deadline cannot help when no submit is in flight.

Route every Enter through a helper that first waits for the frame to stop
changing, which keeps the keystroke clear of that window. Resending Enter
was rejected as an alternative: handleSubmit has no empty-input guard, so a
duplicate would submit '' and clobber the captured value.

Verified with the full file under CI=true FORCE_COLOR=1: six consecutive
clean runs, against a one-in-three failure rate beforehand.
The first pass spread this feature across four new modules plus three spec
files, and picked up changes unrelated to Nano-Collective#747. Reviewing it meant reading
1.4k added lines for what is a dropdown over a workspace search.

Everything now lives in the files the feature already had to touch:

- mention-search.ts collapses into a single _searchMentions method on
  ChatWebviewProvider. Ranking and matching are unchanged; the injectable
  MentionSearchDeps seam and the hand-rolled posix path helpers are gone,
  since path.relative/basename/dirname already handle both separators.
- mention-utils.js collapses into chat-panel.js. findMentionQuery moves in
  as-is; removeMentionToken was three lines at its only call site, so it is
  inlined there. That drops the extra <script> tag, its CSP-nonce wiring and
  the globalThis handoff.
- MentionItem moves to webview-protocol.ts next to the two messages that
  carry it, and its source enum narrows to an isEditor flag.

Reverted as out of scope for this issue:

- context-attachment.ts and the 100 KB cap / binary sniff it added to
  _expandContextAttachments. Worth doing, but it is not @ autocomplete and
  the attach button has always had the same exposure - separate PR.
- The user-input and styled-select-input spec fixes, which are already
  their own branches.
- chat-panel.css, a Tailwind rebuild whose only delta was an unrelated
  .container rule; every class the dropdown uses was already compiled.

The three spec files go with their modules. AVA only globs source/**, so
plugins/vscode specs never ran in CI and none of them were executing.

No behaviour change: same trigger rules, same ranking, same keyboard
handling, same postMessage protocol.
@addyCooks
addyCooks force-pushed the feat/vscode-context-mentions branch from 9230511 to 7dc000d Compare August 10, 2026 20:31
@will-lamerton

Copy link
Copy Markdown
Member

Hey @addyCooks - thanks for this, the design is solid - host-side search, the request-id staleness guard, mousedown over click, and folding the keys into the existing keydown listener are all the right calls.

A few things before merge:

The description doesn't match the diff. The body describes mention-search.ts, mention-utils.js, context-attachment.ts and 56 tests, but the final refactor: fold @ mention support into the existing files commit collapsed all of that back inline and took the specs with it. Six files changed, no specs. That leaves ~480 lines of ranking/glob/caret logic uncovered, and the "New features include passing tests" boxes ticked for tests that aren't there. The split you originally described was the better structure - could you restore it?

The 100 KB read cap isn't in the diff either. _expandContextAttachments is still a bare readFileSync with no size check. Your reasoning for adding it was right and matters more now that @ makes hitting a lockfile one keystroke.

Escape while streaming kills the agent turn. The mention Escape branch calls preventDefault() but not stopPropagation(), so it bubbles to the document handler that cancels on Escape when isProcessing. Drafting a message mid-stream and dismissing the dropdown cancels the run.

files.exclude isn't actually honoured. Passing an explicit exclude glob to findFiles replaces the default excludes rather than adding to them (and search.exclude never applies to findFiles). So .env and friends show up in the dropdown, and the changeset currently claims the opposite in the public changelog.

Stale mentionToken. It's only assigned inside requestMentions, after the mentionLastQuery === token.query early return. With @foo @foo, moving the caret from the second mention to the first short-circuits the dedupe and leaves start pointing at the second one, so accepting adds the chip but leaves the literal @foo in the message. Assigning it in syncMentionState fixes it.

Smaller stuff: accepting mid-token leaves the suffix behind (@src/foo with the caret after src leaves /foo); the absPath.toLowerCase() dedupe key collides case-sensitive siblings; @** degrades to a full workspace scan that then filters to nothing; and the listbox has role="option" but no aria-activedescendant linking it to the textarea. The styled-select-input.spec.tsx change is a no-op on main (I ran it) and unrelated to this feature, so probably worth splitting out.

Reverses the structural half of "fold @ mention support into the existing
files" and addresses the defects found in review of Nano-Collective#842.

The fold's argument for dropping the specs was that AVA only globs
source/**, so none of them executed. That is fixed rather than worked
around: ava.files now includes plugins/**, so the three spec files run in
`pnpm test:ava` and in CI. acp-client and acp-process-manager are excluded
explicitly — they transitively require('vscode'), which does not resolve
outside the extension host. They stay in the state they are in today.

Restored:

- mention-search.ts, carrying the fold's improvements forward: MentionItem
  comes from webview-protocol.ts and the source enum stays collapsed to an
  isEditor flag. The injectable MentionSearchDeps seam is back, since
  testability without an extension host is the whole point.
- mention-utils.js and context-attachment.ts, with their specs.

Fixed:

- files.exclude was not honoured. An explicit exclude *replaces* VS Code's
  defaults rather than merging, so .env and anything else hidden by the
  user showed up in the dropdown. _mentionExcludeGlob now folds
  files.exclude and search.exclude into the always-on list, scoped to the
  workspace folder being searched, skipping `when`-clause entries.
- mentionToken was assigned after the dedupe guard in requestMentions.
  With `@foo @foo`, moving the caret between the two short-circuited the
  guard and left start pointing at the wrong mention, so accepting added
  the chip but stripped the other one. Assigned in syncMentionState now.
- Accepting mid-token sliced only up to the caret, stranding the tail:
  `@src/foo` accepted from after `src` left `/foo` behind.
  removeMentionToken takes the whole token.
- The dedupe key folded case unconditionally, so on a case-sensitive
  filesystem `Foo.ts` and `foo.ts` collapsed and one silently vanished.
  Folding is now conditional on the filesystem, injectable for tests.
- `@**` widened to a match-everything glob, scanned the workspace, then
  filtered every result away against the raw `**` needle. Queries with no
  literal characters no longer touch disk, and result filtering uses the
  metacharacter-stripped query so `*app*` still finds app.ts.
- The listbox had role=option rows but nothing tied them to the textarea.
  Added aria-activedescendant, plus role=combobox / aria-expanded /
  aria-controls and stable row ids.
- The mention Escape branch called preventDefault without
  stopPropagation. No handler above it cancels on Escape today, so this is
  not reachable, but the branch should not depend on that.
- The fold had swapped the hand-rolled posix path helpers for node's
  `path`. `path` binds to the host separator, so the Windows-path tests
  passed locally and meant nothing on Linux. Helpers are hand-rolled
  against the posix form again.

Also restores the 100 KB read cap and binary sniff on attached files,
scoped out of the fold as a separate concern — @ makes attaching a
lockfile one keystroke, so it belongs with this change.

The styled-select-input spec fix is dropped from this branch; it is
byte-identical to fix/styled-select-input-ansi-assertions.
Per review feedback, these ANSI stripping changes are unrelated to the @ mention feature and should be in a separate PR.
@addyCooks
addyCooks force-pushed the feat/vscode-context-mentions branch from 7dc000d to ac5abf5 Compare August 13, 2026 21:36
@addyCooks

Copy link
Copy Markdown
Collaborator Author

Hey @will-lamerton,
Thank you for the detailed review again : )
I've addressed all 10 issues

The PR description has been updated to accurately reflect the current implementation.
All tests pass, and the feature is ready for re-review.

Resolves the chat-panel.js conflicts against main:

- `addImageBtn` was removed by the upload consolidation on main, so the
  mention state block lands without it.
- `closeAllDropdowns` was extracted on main; kept it and appended the
  mention block after it.

Also corrects two comments that main's Escape-cancel handler made stale
or wrong: the mention Escape branch now names the document-level handler
it stops propagating to, and the requestMentionCompletions docblock no
longer claims findFiles honours files.exclude on its own.

@will-lamerton will-lamerton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed. All 10 points from my earlier review are addressed:

  • Split restored as mention-search.ts / mention-utils.js / context-attachment.ts with 67 passing specs, and package.json now globs plugins/** into ava so they actually run.
  • 100 KB read cap, binary sniff, explicit truncation marker, and a 200-entry folder cap in readCappedFile / readCappedDirectory.
  • Escape mid-stream now calls stopPropagation(); verified against the bubble-phase document handler main has since gained.
  • _mentionExcludeGlob folds files.exclude and search.exclude into the exclude list by hand, folder-scoped, skipping non-boolean when entries.
  • mentionToken is assigned in syncMentionState ahead of the dedupe early return.
  • mentionTokenEnd takes the whole token so a mid-token accept leaves no suffix.
  • Dedupe keys on caseInsensitiveFs rather than folding case unconditionally.
  • A glob-only query answers from open editors instead of scanning the workspace.
  • aria-activedescendant wired up, plus role=combobox / aria-expanded / aria-controls and per-row ids.
  • The styled-select-input.spec.tsx change landed on main independently, so it is a no-op here.

I pushed a merge of main into the branch to clear the conflicts in chat-panel.js: addImageBtn was removed by the upload consolidation, and closeAllDropdowns was extracted, so the mention block now sits after it. Also corrected two comments main had made stale - the Escape branch now names the handler it stops propagating to, and the requestMentionCompletions docblock no longer claims findFiles honours files.exclude on its own.

Verified locally at the merge commit: root and extension typechecks clean, biome check and lint clean, extension bundles, 67/67 specs pass.

Thanks for the thorough follow-up on this.

@will-lamerton
will-lamerton merged commit 317e7c8 into Nano-Collective:main Aug 17, 2026
10 of 11 checks passed
@addyCooks

Copy link
Copy Markdown
Collaborator Author

Thanks for the thorough re-review, @will-lamerton!
Glad I could address all the points and get everything verified.
Really appreciate the detailed feedback throughout the review,
it helped improve the implementation quite a bit.

addyCooks added a commit to addyCooks/nanocoder that referenced this pull request Aug 17, 2026
…ns-actions

Resolves three conflicts with main:

- package.json: main's ava globs (`plugins/**/*.spec.ts` + `.tsx`) subsume
  this branch's narrower `plugins/*/src/**/*.spec.ts`, and they pick up the
  new code lens specs. Took main's side.
- webview-protocol.ts: both sides appended to the
  `ExtensionToWebviewMessage` union. Kept both `ExtensionMessageRunPrompt`
  (this branch) and `ExtensionMessageMentionCompletions` (Nano-Collective#842).
- chat-panel.js: this branch moved the send out of `submitMessage()` into
  `dispatchPrompt()` so an editor-driven prompt can bypass the composer,
  while Nano-Collective#842 added a `closeMention()` before the input is cleared. Kept
  `closeMention()` and the `dispatchPrompt()` delegation, dropping the
  inline `postMessage` that `dispatchPrompt` now owns — keeping both would
  have sent every composer message twice.
addyCooks added a commit to addyCooks/nanocoder that referenced this pull request Aug 17, 2026
chat-panel.html loads mention-utils.js ahead of chat-panel.js, and
chat-panel.js destructures globalThis.NanocoderMentionUtils at IIFE time.
The harness only ran chat-panel.js, so every spec that booted a panel died
on `Cannot destructure property 'findMentionQuery' of
'globalThis.NanocoderMentionUtils' as it is undefined` before reaching its
assertions — 28 failures across chat-panel-thoughts and
chat-panel-tool-cards.

The harness (Nano-Collective#847/Nano-Collective#867) and the mention-utils extraction (Nano-Collective#842) landed
independently, so neither PR saw the break; it only appears once both are
on main. Loading the two scripts into the VM in the same order the page
does fixes it.
will-lamerton pushed a commit that referenced this pull request Aug 20, 2026
* feat(vscode): add Explain Code / Generate Tests code lenses

Reaching the agent about a specific function meant switching to the sidebar
and pasting the code in. Every function, method and class now carries two
inline links instead.

Clicking one reveals the chat view and submits the symbol as a prompt: the
instruction, a `file:startLine-endLine` locator and the source fenced with
the document's language. The snippet is inlined rather than attached as an
`@[file]` chip so the agent sees the one symbol that was clicked instead of
the whole file.

Symbols come from `vscode.executeDocumentSymbolProvider`, so the lenses
follow whatever language servers the user already has and nothing here
parses source. Lenses anchor on the symbol's selectionRange - the
declaration line - while the command receives the full body range, so a
preceding doc comment doesn't push the links away from the signature.

A lens can be clicked before the sidebar has ever been opened, so the prompt
is held in `_pendingPrompt` and flushed from `_initializeSessionIfReady`,
which already runs both on webview ready and on ACP connect - whichever
lands last.

The two commands are hidden from the palette: they take a uri and a symbol
range, so a bare invocation would have nothing to act on. `nanocoder.codeLens`
turns the lenses off.

Closes #750.

* fix(vscode): stop losing an editor prompt across a chat view re-reveal

_isWebviewReady was latched on the first shell and never cleared, so once
the Nanocoder view had been disposed - hidden from its container, or moved
to another one - the next lens click posted runPrompt into a replacement
webview that had not run its script yet. The message went nowhere and the
prompt was cleared, so the click did nothing at all. Reset the flag on
every resolve and drop the view on dispose.

The queued prompt is also bounded now. It used to sit indefinitely when the
CLI was down and then fire from onConnectionReady whenever the agent
happened to come up, answering about code the user had long moved past,
with no feedback in the meantime. It expires after 30s with a warning
instead, and the timer is disarmed once the prompt is handed over.

* fix(vscode): send a lens prompt without disturbing the composer

runPrompt drove the composer: it overwrote chat-input and called
submitMessage, which then folded in attachedPaths and pendingImages. So
clicking Explain Code discarded whatever the user was typing and sent any
file chip or pasted image they had staged for a different question, then
cleared them.

Split the send tail out of submitMessage as dispatchPrompt and route the
editor prompt straight through it, leaving the draft and the staged
context untouched.

* fix(vscode): harden the code lens commands and provider

explainCode/generateTests are hidden from the palette but a keybinding or
another extension can still invoke them bare. uri and range were assumed
present, so openTextDocument(undefined) opened an untitled document and
range.start then threw; guard and point the user at the lenses instead.

Also dispose the onDidChangeCodeLenses emitter with the extension rather
than leaking it, and resolve nanocoder.codeLens against the document so a
folder-level override wins in a multi-root workspace - it is declared
scope: resource to match.

* fix(vscode): address code lens review feedback

Ends the turn when a prompt is rejected for a pending permission: the
webview had already drawn the user bubble and flipped to the loading
state, so with nothing posting prompt_response the composer spun until
the user hit Escape. Pre-existing, but a lens click while an approval
sat unattended made it easy to hit.

Moves NanocoderCodeLensProvider and sendCodeLensPrompt out of
extension.ts into code-lens-provider.ts so they can be tested. The
sibling specs cited as precedent never actually ran - the root AVA glob
only matched source/, and `vscode` is not resolvable outside the
extension host - so this also adds a runtime stub behind a test-only
tsconfig paths entry and widens the glob to plugins/*/src. That revives
acp-client.spec.ts and acp-process-manager.spec.ts as a side effect. The
stub is kept out of the packaged .vsix and the bundle still builds with
--external:vscode.

Caps the source inlined into a lens prompt at 200 lines / 8000 chars,
whichever binds first, with a truncation marker. Generate Tests on a
large class would otherwise paste the whole body into the conversation.
The file:start-end locator survives truncation, so the agent can still
read the rest.

ChatWebviewProvider now implements Disposable and is registered with the
extension's subscriptions, so the pending-prompt timer cannot outlive
it. The clear deliberately does not happen in onDidDispose: a view
disposal is usually a re-reveal in progress, and dropping the queued
prompt there would reintroduce the bug 9a9d5bf fixed. onDidDispose also
guards on view identity so a late teardown cannot null out a newer view.

Adds Constructor to LENS_SYMBOL_KINDS - every sibling method already got
a lens.

* fix(test): boot mention-utils.js in the chat panel harness

chat-panel.html loads mention-utils.js ahead of chat-panel.js, and
chat-panel.js destructures globalThis.NanocoderMentionUtils at IIFE time.
The harness only ran chat-panel.js, so every spec that booted a panel died
on `Cannot destructure property 'findMentionQuery' of
'globalThis.NanocoderMentionUtils' as it is undefined` before reaching its
assertions — 28 failures across chat-panel-thoughts and
chat-panel-tool-cards.

The harness (#847/#867) and the mention-utils extraction (#842) landed
independently, so neither PR saw the break; it only appears once both are
on main. Loading the two scripts into the VM in the same order the page
does fixes it.
will-lamerton added a commit that referenced this pull request Aug 20, 2026
…910)

#842 added plugins/** to ava.files but blocklisted these two by name,
because they transitively import 'vscode', which does not resolve outside
the extension host. That blocker is gone: the root tsconfig now maps the
bare 'vscode' specifier to plugins/vscode/test-stubs/vscode.ts, and tsx
honours those paths - which is exactly what the stub's docstring says it
is for. The exclusions outlived their reason, so six tests silently never
ran, including the two #869 just added.

Both files pass inside the full serial suite, not just standalone.

Also typecheck the extension. The root tsconfig only includes source/**,
and plugins/vscode builds through esbuild, which strips types without
checking them, so nothing in CI ever typechecked the extension's own
sources or specs. tsc -p plugins/vscode/tsconfig.json is clean today;
this keeps it that way.
AryanNandanwar added a commit to AryanNandanwar/nanocoder that referenced this pull request Aug 21, 2026
* Update status badges [skip ci]

* Update status badges [skip ci]

* feat: vscode extension settings tab (Nano-Collective#838)

* feat: implement settings manager and integrate persistent configuration for chat webview

* style: restore settings UI CSS classes lost during merge

* refactor: redesign chat panel UI components and settings layout

* feat: add settings tab to VS Code extension webview for configuration management

* fix: address PR feedback on settings dashboard

* chore: remove accidental tasks.json

* fix(deps): sync pnpm-lock.yaml with package.json

PR Nano-Collective#838 was branched before the chalk and @types/node dependabot bumps
and merged without a rebase, reverting the lockfile to its pre-bump
state while package.json kept the new specifiers. This broke the
release workflow with ERR_PNPM_OUTDATED_LOCKFILE.

Regenerated the lockfile so chalk resolves to 6.0.0 and @types/node to
26.2.0. Verified with pnpm install --frozen-lockfile and tsc --noEmit.

* feat: headless api mode (Nano-Collective#851)

* headless api with --acp flag

* changeset added

* fixed

* removed unused import

* changes made

* unused deps removed

* pass tests

* feat(settings): sunset /setup-providers and /setup-mcp in favour of /… (Nano-Collective#848)

* feat(settings): sunset /setup-providers and /setup-mcp in favour of /settings

Make /settings the single entry point for provider and MCP configuration.

- Remove both commands from the slash registry, delete their stub files,
  and drop the SETUP_PROVIDERS/SETUP_MCP special commands, the mcpWizard
  app mode and its handlers. configWizard stays: the first-run and
  all-providers-failed bootstrap in useAppInitialization still uses it.
- Forward the retired names to the matching /settings tab with a notice
  instead of erroring, since they are still printed across the docs.
- Accept a tab argument: /settings providers, /settings mcp, etc. An
  unknown tab opens the default tab rather than failing.
- Give MCP its own settings tab so tab arguments map onto the tab bar.
- Apply provider edits made from settings to the running session; the
  panel previously discarded the wizard's config path, so a provider
  added there stayed inert until the next launch.
- Update the docs and the /mcp hint that pointed at /setup-providers.

* chore: add changeset for /settings consolidation

* fix(settings): address PR Nano-Collective#848 review feedback

Replays the review fixes on top of the restored sunset commits.

- reloadProviders reloads config and rebuilds the client for the current
  provider/model, leaving messages and the settings panel untouched,
  instead of routing provider edits through handleConfigWizardComplete.
- The providers panel lets the parent own closing, so it no longer sets
  state on an unmounting component.
- The active settings tab is preserved across Tune/IDE launches.
- /settings validates its tab argument through an isSettingsTabId() type
  guard rather than a double cast, and reports unknown tabs instead of
  silently falling back to the default tab.
- SettingsTabId and SETTINGS_TAB_IDS move to settings-constants.ts, so
  app-util no longer pulls the settings panel graph in, and every
  reference uses a top-level `import type`.
- TABS is derived from SETTINGS_TAB_IDS through a Record<SettingsTabId,
  string> label map, so an id without a label is a compile error. This
  caught the missing 'mcp' tab id that /setup-mcp forwards to.
- Drops the removed onEnterConfigWizardMode from context-max-handler.spec.
- Covers the /settings tab argument paths and reloadProviders in specs.

* feat(settings): edit or delete a provider/server from its own row

Completes the remaining settings work from Nano-Collective#832. Selecting a row in the
providers or MCP panel opened the same generic wizard as every other row,
so there was no way to act on one specific entry and no delete affordance.

The wizard steps already had per-entry edit-or-delete modes; they just
could not be reached directly. Adds an optional `initialEditName` threaded
from panel to wizard to step, which opens that entry's edit/delete choice
instead of the template menu. Each row now carries its own entry and a
separate row adds a new one.

Keyed by name rather than index: the panel lists the resolved config
(project + global + env merged) while the wizard loads a single config
file, so positions need not line up and an index would edit the wrong
entry. An unknown name falls back to the normal menu.

BaseConfigWizard is untouched and the prop is optional, so the first-run
onboarding flow is unchanged.

Also points the OrcaRouter provider doc at `/settings providers`; it was
added after the sunset commit was written, so it still referenced the
retired command.

* Update status badges [skip ci]

* add Explain Code / Generate Tests code lenses (Nano-Collective#866)

* feat(vscode): add Explain Code / Generate Tests code lenses

Reaching the agent about a specific function meant switching to the sidebar
and pasting the code in. Every function, method and class now carries two
inline links instead.

Clicking one reveals the chat view and submits the symbol as a prompt: the
instruction, a `file:startLine-endLine` locator and the source fenced with
the document's language. The snippet is inlined rather than attached as an
`@[file]` chip so the agent sees the one symbol that was clicked instead of
the whole file.

Symbols come from `vscode.executeDocumentSymbolProvider`, so the lenses
follow whatever language servers the user already has and nothing here
parses source. Lenses anchor on the symbol's selectionRange - the
declaration line - while the command receives the full body range, so a
preceding doc comment doesn't push the links away from the signature.

A lens can be clicked before the sidebar has ever been opened, so the prompt
is held in `_pendingPrompt` and flushed from `_initializeSessionIfReady`,
which already runs both on webview ready and on ACP connect - whichever
lands last.

The two commands are hidden from the palette: they take a uri and a symbol
range, so a bare invocation would have nothing to act on. `nanocoder.codeLens`
turns the lenses off.

Closes Nano-Collective#750.

* fix(vscode): stop losing an editor prompt across a chat view re-reveal

_isWebviewReady was latched on the first shell and never cleared, so once
the Nanocoder view had been disposed - hidden from its container, or moved
to another one - the next lens click posted runPrompt into a replacement
webview that had not run its script yet. The message went nowhere and the
prompt was cleared, so the click did nothing at all. Reset the flag on
every resolve and drop the view on dispose.

The queued prompt is also bounded now. It used to sit indefinitely when the
CLI was down and then fire from onConnectionReady whenever the agent
happened to come up, answering about code the user had long moved past,
with no feedback in the meantime. It expires after 30s with a warning
instead, and the timer is disarmed once the prompt is handed over.

* fix(vscode): send a lens prompt without disturbing the composer

runPrompt drove the composer: it overwrote chat-input and called
submitMessage, which then folded in attachedPaths and pendingImages. So
clicking Explain Code discarded whatever the user was typing and sent any
file chip or pasted image they had staged for a different question, then
cleared them.

Split the send tail out of submitMessage as dispatchPrompt and route the
editor prompt straight through it, leaving the draft and the staged
context untouched.

* fix(vscode): harden the code lens commands and provider

explainCode/generateTests are hidden from the palette but a keybinding or
another extension can still invoke them bare. uri and range were assumed
present, so openTextDocument(undefined) opened an untitled document and
range.start then threw; guard and point the user at the lenses instead.

Also dispose the onDidChangeCodeLenses emitter with the extension rather
than leaking it, and resolve nanocoder.codeLens against the document so a
folder-level override wins in a multi-root workspace - it is declared
scope: resource to match.

* fix(vscode): address code lens review feedback

Ends the turn when a prompt is rejected for a pending permission: the
webview had already drawn the user bubble and flipped to the loading
state, so with nothing posting prompt_response the composer spun until
the user hit Escape. Pre-existing, but a lens click while an approval
sat unattended made it easy to hit.

Moves NanocoderCodeLensProvider and sendCodeLensPrompt out of
extension.ts into code-lens-provider.ts so they can be tested. The
sibling specs cited as precedent never actually ran - the root AVA glob
only matched source/, and `vscode` is not resolvable outside the
extension host - so this also adds a runtime stub behind a test-only
tsconfig paths entry and widens the glob to plugins/*/src. That revives
acp-client.spec.ts and acp-process-manager.spec.ts as a side effect. The
stub is kept out of the packaged .vsix and the bundle still builds with
--external:vscode.

Caps the source inlined into a lens prompt at 200 lines / 8000 chars,
whichever binds first, with a truncation marker. Generate Tests on a
large class would otherwise paste the whole body into the conversation.
The file:start-end locator survives truncation, so the agent can still
read the rest.

ChatWebviewProvider now implements Disposable and is registered with the
extension's subscriptions, so the pending-prompt timer cannot outlive
it. The clear deliberately does not happen in onDidDispose: a view
disposal is usually a re-reveal in progress, and dropping the queued
prompt there would reintroduce the bug 9a9d5bf fixed. onDidDispose also
guards on view identity so a late teardown cannot null out a newer view.

Adds Constructor to LENS_SYMBOL_KINDS - every sibling method already got
a lens.

* fix(test): boot mention-utils.js in the chat panel harness

chat-panel.html loads mention-utils.js ahead of chat-panel.js, and
chat-panel.js destructures globalThis.NanocoderMentionUtils at IIFE time.
The harness only ran chat-panel.js, so every spec that booted a panel died
on `Cannot destructure property 'findMentionQuery' of
'globalThis.NanocoderMentionUtils' as it is undefined` before reaching its
assertions — 28 failures across chat-panel-thoughts and
chat-panel-tool-cards.

The harness (Nano-Collective#847/Nano-Collective#867) and the mention-utils extraction (Nano-Collective#842) landed
independently, so neither PR saw the break; it only appears once both are
on main. Loading the two scripts into the VM in the same order the page
does fixes it.

* fix(vscode): drop duplicate MENTION_UTILS_SOURCE in chat-panel harness

Nano-Collective#866 landed the constant twice at module top level, which is a
redeclaration error. main has been failing test:types, test:lint,
test:format, the build and every spec that imports the harness since.

The surviving declaration is the mediaUrl() one-liner, matching
PANEL_SOURCE next to it; the deleted block's comment is already covered
by the file docblock.

* fix(vscode): silence false-positive semgrep findings in settings-manager

Nano-Collective#838 merged with a red Semgrep check. Both rules are false positives:
resolveConfigPath's fileName is a string literal at both call sites, and
updatePreferencesNested's keys come from this file's own call sites, so
neither takes user input. Marked with nosemgrep following the existing
convention in source/config/index.ts, which does the same path.join.

* fix: make the stop button end the turn it was pressed during (Nano-Collective#869)

Closes Nano-Collective#864.

- `acp-session.ts` / `acp-agent.ts`: `cancel()` now only aborts. The controller is rotated by a new `beginTurn()` called synchronously at the top of `prompt()`, before it awaits `acpContentToUserMessage`, so a cancel landing during the file-reading window is no longer dropped.
- `acp-client.ts`: `_clearPendingPermissions()` now runs above the connection guard in `cancel()`, and on `setConnection()` so a crashed-and-restarted agent process cannot leave the client permanently blocked.
- `chat-panel.js`: the ToolAggregator status predicate now treats a `failed` update carrying 'Denied by user' as denied rather than an error.

* test(vscode): run the acp-client and acp-process-manager specs in CI (Nano-Collective#910)

Nano-Collective#842 added plugins/** to ava.files but blocklisted these two by name,
because they transitively import 'vscode', which does not resolve outside
the extension host. That blocker is gone: the root tsconfig now maps the
bare 'vscode' specifier to plugins/vscode/test-stubs/vscode.ts, and tsx
honours those paths - which is exactly what the stub's docstring says it
is for. The exclusions outlived their reason, so six tests silently never
ran, including the two Nano-Collective#869 just added.

Both files pass inside the full serial suite, not just standalone.

Also typecheck the extension. The root tsconfig only includes source/**,
and plugins/vscode builds through esbuild, which strips types without
checking them, so nothing in CI ever typechecked the extension's own
sources or specs. tsc -p plugins/vscode/tsconfig.json is clean today;
this keeps it that way.

* Update status badges [skip ci]

* fix: reset tool aggregator whenever something other than a tool card gets inserted (Nano-Collective#870)

Fixes Nano-Collective#856.

currentAggregator only reset at the end of a turn, not when a thought or text chunk interrupted a tool-call phase, so Tool -> Thought -> Tool merged the second tool into the first card. The reset is now one closeAggregatorIfIdle() helper called from all four insertion points (agent text, thought, plan card, edit card).

Also fixes close() re-expanding a manually collapsed card (toggle now honours its force argument), one footer per agent turn instead of one per text segment, and a turn's copy button grabbing a newer turn's text.

* test(vscode): cover the tool-card and turn-footer fixes from Nano-Collective#870

Nano-Collective#870 landed four behaviour fixes with no tests. Each of the 19 added here
was checked against the pre-fix code and fails there:

- tool phases: a thought, reply, edit card or plan card between two tool
  calls starts a fresh aggregated card, and the run stays in one card
  when nothing interrupts it
- an unfinished tool holds its card open, so a late completion reuses the
  original row instead of building a second, permanently spinning one.
  Covers queued ('pending') as well as running, which the merge with the
  queued/running icon split in Nano-Collective#847 had to reconcile
- a card the user collapsed by hand is not re-expanded when the phase
  closes, and can still be reopened
- one footer per response rather than one per text segment, following the
  newest text block, copying its own response (every segment of it) and
  not a newer turn's, and dropped when the session is cleared

Harness: element.addEventListener now records handlers and element.click()
dispatches them, so a test can drive the real copy button rather than only
the onclick properties the panel assigns directly; navigator.clipboard
records what was written. createMessageFooter gains a 'message-footer'
class so the footers can be selected the way .tool-card already is.

* fix: show resolved path in setup wizard's config location picker (Nano-Collective#855)

* fix: show resolved path in setup wizard's config location picker

* chore: add changeset

* fix: anchor homeRelative to a path separator boundary

* fix: derive path truncation budget from actual terminal width, render path on its own line

* fix: size path truncation budget to the wizard box, not raw terminal width

Also drops the 76-char cap, replaces the null-separator label hack with a
typed path field on LocationOption, adds a regression test that renders
inside the real wizard box, and fixes a circular test assertion.

* fix: indent the path row properly and name its magic numbers

---------

Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Sk Akram <[email protected]>
Co-authored-by: Will Lamerton <[email protected]>
Co-authored-by: Aditya Mishra <[email protected]>
Co-authored-by: Will Lamerton <[email protected]>
Co-authored-by: kishore280 <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Context-Aware Mentions (@ referencing) in VS Code Extension

2 participants