Repository navigation
fix: bound pending plugin mention searches - #8003
Merged
Merged
Conversation
Skipping any provider with a search in flight dropped it from the results for the query the user actually stopped on whenever its search took longer than the 120 ms typing debounce. Each provider registration now runs at most one search: a query that arrives while it is busy waits as the single queued search (replacing any older queued query) and runs when the current one settles. Once a running search outlives the time box, the provider is skipped immediately until it settles, so a hung provider still never accumulates work. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 23, 2026
## 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](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚨 SLOP COP 🚨 ·
new-issue-autopilotHuman comments
What was wrong
A plugin mention search races a 2 s response timeout, but the timeout doesn't stop the underlying work. On main, every request starts a fresh call to every provider, so a provider that hangs piles up one stuck call per keystroke. In #8002, File Manager's directory scans hung on a macOS iCloud authorization prompt, and the stuck calls filled all four libuv filesystem workers.
The first version of this PR skipped any provider whose search was still running. That bounded the stuck work, but it also dropped healthy providers that were merely slower than the 120 ms typing debounce: the query the user stopped on got no results from them.
Report: https://get-bb.github.io/reports/issues/8002.html
What changed
apps/server/src/services/plugins/plugin-mention-search-slots.tslets each provider registration run at most one search at a time:searchMentionsinplugin-service.tsroutes every provider call through these slots.PluginMentionProviderRecordis now exported fromplugin-api.tsso the service can type them.How you verified
plugin-mention-providers.test.tsload a real plugin into a migrated-SQLite plugin service:keeps one pending search per registration through timeout and fulfill/reject: fails on main (Expected: "1",Received: "6") and passes here.runs only the latest query typed while a provider is still searching: fails on main (the superseded query still runs) and on this PR's first version (the latest query gets no results), and passes here.pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-mention-providers.test.ts test/services/plugins/plugin-instance-lifecycle.test.ts test/services/plugins/plugin-service.test.ts: 73 passed.pnpm exec turbo run typecheck lint:type-aware --filter=@bb/server: all 7 tasks pass.pnpm start:worktreeserver with a QA plugin that has a 400 ms provider and a provider that never resolves. Six queries were sent 120 ms apart over HTTP. The hung provider was called once in total, the slow provider returned results for the last query of each burst, and once the hung provider passed its time box, a later search came back in about 400 ms instead of 2 s.Fixes #8002
🤖 Generated with Claude Code