Skip to content

Notify the parent from the shared interaction lifecycle - #7729

Merged
ymichael merged 3 commits into
mainfrom
bb/class-fix-one-parent-notification-hook-for-inter-thr_vycwbdfhq2
Nov 18, 2026
Merged

ymichael merged 3 commits into
mainfrom
bb/class-fix-one-parent-notification-hook-for-inter-thr_vycwbdfhq2

Conversation

@ymichael

@ymichael ymichael commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

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

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

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.
  • 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

@ymichael
ymichael force-pushed the bb/class-fix-one-parent-notification-hook-for-inter-thr_vycwbdfhq2 branch 2 times, most recently from 6fcec6e to 1da4ed9 Compare November 17, 2026 20:30
ymichael and others added 2 commits November 17, 2026 16:02
Provider registration and plugin interaction creation now share one
announcement step in PendingInteractionLifecycle: timeline event,
interactions-changed, interaction.pending, and the parent needs-attention
notice. The provider route no longer requests the notice itself, so plugin
cards (AskUserQuestion on Codex, Pi, and ACP) reach the parent too.

Fixes #7457

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createInteraction is now the lifecycle's only caller of
createPendingInteraction. It inserts the row (after the provider's lookup
for an existing row, in the same transaction) and then announces it, so a
new creation path cannot store an interaction without the timeline event,
interaction.pending, or the parent notice. The plugin path registers its
waiter after the announcement; plugin handlers, hub notifications and the
parent notice are all deferred, so nothing can answer the card in between.
A test fails if anything else in apps, packages or plugins src calls
createPendingInteraction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/class-fix-one-parent-notification-hook-for-inter-thr_vycwbdfhq2 branch from 1da4ed9 to c8a9078 Compare November 18, 2026 00:03
A plugin card does not hold the child's turn, so the parent notice now reads
"Pending plugin request: <title>" plus "Interaction: <id>" instead of
"Blocked on plugin request:", which lets the parent answer it directly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit d89f5ce into main Nov 18, 2026
32 checks passed
@ymichael
ymichael deleted the bb/class-fix-one-parent-notification-hook-for-inter-thr_vycwbdfhq2 branch November 18, 2026 04:19
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.

A child thread's AskUserQuestion does not notify the parent thread (parent notifications miss non-blocking questions)

1 participant