You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: [AI-7743] mcp-add question hangs — share question state + event bus across bundled module copies
`/discover-and-add-mcps` rendered the "which MCP / what scope" question but,
after answering, the chat sat on "Thinking…" and the server was never added.
Root cause: after the v1.17.9 upstream merge, `src/question/index.ts` is bundled
as TWO separate module instances (a module-scoped id differs between the tool's
`ask()` and the HTTP route's `reply()`; normalizing to `@/question` imports did
NOT make Bun dedupe it). Each copy ran its own `makeRuntime` runtime, which broke
the flow two independent ways:
1. State split — the `question` tool registered the pending `Deferred` in one
copy's `InstanceState` map, while `POST /question/:id/reply` looked it up in
the OTHER copy's empty map. The reply 404'd and the `Deferred` never resolved,
so the agent loop blocked forever ("Thinking…").
2. Event never reached the IDE webview — `question.asked` was published only via
`EventV2Bridge` -> `GlobalBus`, but the `/event` SSE stream the webview reads
is fed by the Bus *wildcard PubSub* (`Bus.publish`). So `pendingQuestions`
stayed empty and the answer card's Submit had no request id -> submitting did
nothing.
Fix (all in `question/index.ts`, plus import cleanup):
- Anchor the pending-question registry on `globalThis` (keyed by instance
directory) so every module copy shares one map. Restore per-instance cleanup
via `registerDisposer` so entries don't leak across instances/tests.
- Publish `question.asked`/`replied`/`rejected` via `Bus.publish` (added
`BusEvent` mirrors) so they reach `/event` like every other webview-visible
event.
- Normalize the remaining relative `../question` imports to `@/question`.
Verified end-to-end in code-server: discover -> answer (Yes / Project) ->
datamate written to `.altimate-code/altimate-code.json` (enabled) and the chat
shows the success summary. 55 question unit tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments