Repository navigation
Emit pending events for committed plugin interactions - #3398
Merged
Merged
Conversation
ymichael
added a commit
that referenced
this pull request
Nov 18, 2026
## Human comments ## What was wrong Creating an interaction has two entry points in `PendingInteractionLifecycle`: `registerPendingInteraction` for provider requests from the daemon, and `requestPluginInteraction` for plugin cards (`bb.ui.requestInput`, which `AskUserQuestion` uses on Codex, Pi and ACP). Each path ran its own copy of the side effects that follow creation. The parent needs-attention notice was not in either copy. It lived in the HTTP route `/internal/session/interactive-request`, so only the provider path sent it. A child's plugin question therefore never reached its parent in `auto` or `stuck` mode (#7457). #3397 was the same split: the plugin copy was missing `interaction.pending`. ## What changed - **One creation method:** `PendingInteractionLifecycle.createInteraction` is now the only caller of `createPendingInteraction`. In one transaction it inserts the row, after the provider's lookup for an existing row. It then calls `announceCreatedInteraction`, which appends the timeline event, sends `interactions-changed`, emits `interaction.pending`, and requests the parent notice. Both `registerPendingInteraction` and `requestPluginInteraction` go through it, so a new creation path can't store an interaction without those effects. A retried provider registration (`outcome: "existing"`) returns before the announcement, so the parent is still notified once. - **Plugin waiter order:** the plugin path now registers its waiter after the announcement rather than before. Nothing can answer the card in between: plugin event handlers run on `setImmediate`, the hub notification goes over the WebSocket, and the parent notice is deferred. The two `signal.aborted` checks between the insert and the announcement are gone; nothing asynchronous happens there, so they could never be true. On setup failure the row is still interrupted ("Plugin interaction setup failed") and the error rethrown. - The parent notice and the blocker summary builder moved from `internal/interactive-requests.ts` to `services/interactions/pending-interaction-parent-notice.ts`. The code is unchanged, except that it reuses the thread row the lifecycle already loaded. The route now only registers the interaction. - No wire, protocol, schema, CLI or SDK changes. Third-party plugins see no API change. Plugins that call `bb.ui.requestInput` on a child thread now cause a parent notice. **Patches this deletes or supersedes** - The route-only notice call (`requestChildThreadNeedsAttentionNotification` in `interactive-requests.ts`). - The duplicate post-creation blocks in `registerPendingInteraction` and `requestPluginInteraction`, which is the per-path emit #3398 had to patch. - #7458 (closed), which added a second notice call to `requestPluginInteraction` and left two call sites. This PR leaves one and keeps #7458's notice wording. **Issues and fixes from this root cause (separate per-path producers of creation side effects)** | Item | What happened | Prevented by this change? | |---|---|---| | #3397 / #3398 | Plugin cards never emitted `interaction.pending`; #3398 added the emit to the plugin copy | Yes. The emit is in the shared step, and the guard fails if a path skips it | | #7457 (this) | Plugin cards never notified the parent | Yes | | #7458 (closed) | Per-call-site patch for #7457 | Superseded; its wording is kept | **Remaining follow-up: #7457 point 6.** When someone answers the child's question, the parent is not told that a decision was made. Resolution, expiry and dismissal notices are tracked in #3614 and are out of scope here. Not in this class, and not changed here: turn-end notices (#3956/#4356, #6820/#6821), and parents never learning that a child was unblocked (#3614). ## Decisions for review - **Plugin cards in child threads now notify the parent.** This is the #7457 ask. It also covers any third-party plugin that calls `bb.ui.requestInput` on a child thread. The same filters apply as for provider requests: `auto` and `stuck` notify, `off` and fork children do not. - **Wording.** Plugin cards don't hold the child's turn, so their notice reads `Pending plugin request: <title>` followed by `Interaction: <id>` (the wording from #7458), for example `Pending plugin request: Which color?` / `Interaction: pint_…`. The ID lets the parent answer with `bb thread interactions answer`. Provider requests keep `Blocked on <kind>:`, because they do block the turn. ## How you verified - **Guard (contract table):** `apps/server/test/services/interaction-parent-notifications.test.ts` covers 4 creation paths and 4 child kinds, 16 cases. The paths are a provider command approval, a provider user question and a provider plugin-defined request, all sent over the real HTTP route with a retried registration, plus a plugin card. The child kinds are `auto`, `stuck`, `off` and a fork child. Each case holds parent delivery and asserts that exactly one `interaction.pending` was emitted and that the parent has exactly the expected number (0 or 1) of `child-needs-attention` notices. - On main: 2 of 16 fail, the plugin card in `auto` and `stuck` (`expected [] to have a length of 1 but got +0`). That is #7457. - On main with the plugin path's `emitPluginInteractionPending` removed (the pre-#3398 shape): all 4 plugin-card cases fail (`expected [] to deeply equal [ 'pint_…' ]`). - With this change: 16 of 16 pass. - **Live reproduction on a `pnpm start:worktree` instance:** a Codex parent and a Codex child (`--parent-thread`, `auto`), where the child calls `AskUserQuestion`. - main: the card stays `pending`, and the parent gets only `child-completed`. No `child-needs-attention` arrives. - This branch: the parent gets one `child-needs-attention` in the same second the card is created, then `child-completed`. With a `stuck` child, the parent gets only the notice: `@thread:… needs help.` / `Pending plugin request: Which color?` / `Interaction: pint_…`. - **Single-caller check:** the `interaction creation ownership` test scans every `apps/*/src`, `packages/*/src` and `plugins/*/src` file outside tests. It fails if `createPendingInteraction` is called anywhere except the lifecycle; the function's own definition is excluded. Adding a stray call in `internal/interactive-requests.ts` made it fail and name that file. The `packages/db/scripts/query-costs` seed scripts are dev tools that write fixture rows, so the check doesn't scan them. - **Moved tests:** the route tests for `stuck`/`off` filtering and fork-child filtering are now covered for every path by the contract table, so they were removed. The route's message-content and retry test stays. - `pnpm exec turbo run test --filter=@bb/server -- test/services/interaction-parent-notifications.test.ts test/services/pending-interaction-blocker-summary.test.ts test/internal/internal-interactive-requests.test.ts test/services/pending-interactions.test.ts test/threads/system-notice-dispatch.test.ts test/services/plugins/plugin-thread-events.test.ts test/threads/thread-send-dispatch.test.ts test/internal/internal-tool-call-regressions.test.ts test/public/public-thread-interactions.test.ts test/services/plugins/plugin-background.test.ts`: 10 files, 218 tests pass. - `pnpm exec turbo run typecheck --filter=@bb/server` passes. `oxfmt` is clean on the changed files. Fixes #7457 > 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
The plugin interaction creation path persisted pending prompts and notified the UI but omitted the existing plugin event emitter. Subscribers therefore missed the pending announcement. Reproduction report.
What changed
Call the existing emitter after plugin prompt creation notifications. Add a regression test for matching thread/interaction identity and no duplicate announcements from reads. The change is 38 total text lines: 38 additions, zero deletions, two files in the server interaction subsystem. Unread timestamp policy is outside this fix.
How you verified
pnpm exec turbo run test --filter=@bb/server -- test/services/pending-interactions.test.ts test/services/plugins/plugin-background.test.ts: 47 tests passed after the fix.pnpm exec turbo run typecheck --filter=@bb/server: passed.git diff --check: passed; no binary changes.Fixes #3397