Skip to content

fix(server): wait for web search plugin activation - #46916

Open
Hona wants to merge 1 commit into
anomalyco:v2from
Hona:websearch-readiness
Open

fix(server): wait for web search plugin activation#46916
Hona wants to merge 1 commit into
anomalyco:v2from
Hona:websearch-readiness

Conversation

@Hona

@Hona Hona commented Sep 2, 2026

Copy link
Copy Markdown
Member
  • Wait for Location plugin activation before listing web-search providers or running queries, including debounced reloads. Keep registration asynchronous and plugin-internal reads non-blocking.
  • Cover immediate requests during startup and reload with an explicit activation gate, without sleeps or retries.
  • Correct the SDK subscriber-abort assertion to expect clean iterator completion. Host-close and source-failure behavior is unchanged.
yield* opencode.plugin(plugin)
yield* opencode.websearch.query({ providerID, query: "opencode", location })

Copilot AI lite review requested due to automatic review settings September 2, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated Promise subscription-abort test expectation doesn’t match the current embedded fetch/SSE implementation, which surfaces abort as a transport error.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR ensures web search routes don’t observe an empty/partial plugin-backed provider registry during Location startup or plugin reload by gating provider listing and queries on plugin activation, and updates SDK tests to reflect the intended subscription abort semantics.

Changes:

  • Gate websearch.providers and websearch.query handlers on Plugin.awaitActivation to avoid reading plugin-provided state before activation settles.
  • Add an embedded test that asserts web search calls block until plugin activation completes during both startup and reload scenarios.
  • Update the Promise SDK event-subscription abort test expectation.
File summaries
File Description
packages/server/src/handlers/websearch.ts Adds an activation gate before listing providers and running web search queries.
packages/sdk/test/promise.test.ts Changes the expected behavior when aborting a Promise event subscription.
packages/sdk/test/embedded.test.ts Adds coverage ensuring web search waits for plugin activation during startup and reload.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 45 to +47
const pending = events.next()
controller.abort()
const error = await pending.catch((error: unknown) => error)
expect(error).toMatchObject({ name: "ClientError", reason: "Transport" })
expect(await pending).toEqual({ done: true, value: undefined })
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.

2 participants