Skip to content

Abort mention searches the person has typed past - #8047

Merged
ymichael merged 1 commit into
mainfrom
bb/8003-fix-bound-pending-plugin-mention-searches-thr_6zafbv9pwj
Nov 23, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/8003-fix-bound-pending-plugin-mention-searches-thr_6zafbv9pwj

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The composer already cancels a stale mention search request when the person types past it, but the plugin was never told. GET /api/v1/plugins/mentions/search dropped the request signal, and PluginMentionSearchContext had no signal, so a provider couldn't stop. The 2s time box also stopped waiting without aborting anything. Since #8003 limited each provider to one running search, a slow provider's stale search held up the newest query until it finished on its own.

What changed

  • Route: apps/server/src/routes/plugins.ts forwards context.req.raw.signal to searchMentions, which takes a required signal.
  • Search slots (plugin-mention-search-slots.ts):
    • Each running search gets one signal that aborts when its request disconnects, when its time box runs out, or when the plugin unloads (the last through invokeWrapped's existing caller-signal link, the same path RPC handlers use).
    • A waiting query whose request disconnects never starts.
    • A request that disconnects returns right away, without logging a plugin error.
  • SDK: new PluginMentionSearchContext.experimental_signal (required; the host always supplies it). The search JSDoc now describes one-search-at-a-time queueing. @get-bb/plugin-sdk is bumped to 0.6.183.
  • Docs plugin: stops scanning further vaults once its search is aborted. It's the only in-repo provider with async work; the others search synchronously.
  • Documentation: a new docs/api_to_audit.md entry, and backend-ui-lifecycle.md now shows a fetch example and describes queueing and abort.
  • Tests: in-repo test calls to provider.search(...) (Docs, Tasks, GitHub) now pass a signal. Third-party test code that calls search directly will need the same change after upgrading the SDK.
  • No host daemon or protocol changes.

This can't interrupt a filesystem call that is already blocked (#8002). File Manager needs its own change to check the signal between directory reads.

How you verified

  • New tests in apps/server/test/services/plugins/plugin-mention-providers.test.ts: request disconnect aborts the provider's signal (through the HTTP route), the time box aborts it, aborting the running search starts the newest waiting query, and a waiting query whose caller left never starts. All 4 fail on main and pass here. The file passes 21/21.
  • New Docs test stops scanning further vaults once the search is aborted: fails on main's Docs plugin and passes here. Docs 50/50, Tasks 4/4.
  • pnpm exec turbo run typecheck lint:type-aware for @bb/server, @get-bb/plugin-sdk, bb-plugin-simple-notes and bb-plugin-tasks, plus typecheck for bb-plugin-github: all pass. The plugin authoring doc example and docs tests pass.
  • Live check on a pnpm start:worktree server: a QA plugin with a 400 ms provider that honours the signal, and six queries sent 120 ms apart over real HTTP, each cancelling the previous request the way the composer does. The plugin log shows each stale search aborted before the next started (start:r abort:r start:re abort:re … start:readme done:readme). The final query returned in about 400 ms, and the plugin's error count stayed at 0.

Follow-up to #8003.

AGENT GENERATED

🤖 Generated with Claude Code

The composer already cancels a stale mention search request, but the
server never told the plugin: the search route dropped the request
signal, and providers had no way to receive one. A slow provider kept
working on a query nobody wanted, and with one search per provider the
newest query waited for it.

The search route now forwards its request signal. Each running search
gets a signal that aborts when its request disconnects, when its time box
runs out, or when the plugin unloads, exposed to providers as
PluginMentionSearchContext.experimental_signal. A waiting query whose
request disconnects never starts, and aborting the running search lets
the newest waiting query start as soon as the provider settles. Docs
stops scanning further vaults once its search is aborted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 1c8e743 into main Nov 23, 2026
52 checks passed
@ymichael
ymichael deleted the bb/8003-fix-bound-pending-plugin-mention-searches-thr_6zafbv9pwj branch November 23, 2026 19:49
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