Skip to content

fix(vscode): load mention-utils.js in the chat-panel test harness - #900

Open
addyCooks wants to merge 1 commit into
Nano-Collective:mainfrom
addyCooks:fix/vscode-chat-panel-harness
Open

fix(vscode): load mention-utils.js in the chat-panel test harness#900
addyCooks wants to merge 1 commit into
Nano-Collective:mainfrom
addyCooks:fix/vscode-chat-panel-harness

Conversation

@addyCooks

Copy link
Copy Markdown
Contributor

Description

chat-panel.js destructures globalThis.NanocoderMentionUtils, which media/mention-utils.js
defines. The webview loads both scripts in that order (chat-webview-provider.ts:486,489), but
source/vscode/chat-panel-harness.ts only ran chat-panel.js so createPanel() threw before
any assertion could run:

TypeError: Cannot destructure property 'findMentionQuery' of
'globalThis.NanocoderMentionUtils' as it is undefined.
    at evalmachine.<anonymous>:150:10
    at createPanel (source/vscode/chat-panel-harness.ts:240:2)

That is 28 failures chat-panel-thoughts (13) and chat-panel-tool-cards (15) — on main
and on every branch cut from it. The harness was missed when the mention helpers were split out
into their own script in #842; mention-utils.js even documents the contract in its header
("Loaded as a plain script before chat-panel.js").

Runs mention-utils.js in the same VM context first, matching the load order the webview
already uses. One file, +8 lines.

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

  • If this was for an open issue, I was assigned to it
  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)
  • Appropriate logging added using structured logging

chat-panel.js destructures globalThis.NanocoderMentionUtils, which
mention-utils.js defines. The real webview loads both scripts in that
order, but the test harness only ran chat-panel.js, so every chat-panel
spec threw "Cannot destructure property 'findMentionQuery' of
'globalThis.NanocoderMentionUtils' as it is undefined" — 28 failures on
main and on every PR branched from it.

Run mention-utils.js in the same VM context first, matching the load
order chat-webview-provider.ts already uses.
@github-actions

Copy link
Copy Markdown
Contributor

No changeset found

This PR does not add a changeset, so it will not appear in the changelog or trigger a release.

If the change is user-facing, add one:

pnpm changeset

Pick a bump (patch / minor / major) and write the changelog entry in our usual voice ("Added X... Thanks to @you. Closes #123."), then commit the generated .changeset/*.md file.

If this PR is docs-only or a chore that needs no release note, you can ignore this - or run pnpm changeset --empty to record that intentionally.

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.

1 participant