You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🪟 fix: Wait for Side Chat Destination Readiness - #18453
Continuing a finished child in a side chat can leave its question unsent while agent details, workspace discovery or existing history are still loading. Cached errors and partially loaded catalogs must stay distinguishable from final denial or missing data. Preserve the question as a conversation draft until the actual attempt is accepted or definitively refused, and let a newer manual action supersede automatic intent.
How it works
The existing side-chat atom seeds only an empty memory-only draft; existing drafts stay manual. Replay prevention uses the captured handoff, so a new continuation for the same mounted conversation can still send. A successful driven publication consumes captured intent for every entry point: composer, transcript edit, regenerate, continue, preview and automatic continuation. A different transcript action preserves the unsent question as a manual draft. Driven turns prepare their submission without draining composer inputs, publish through the actual follower, and commit only captured skills, quotes, reasoning, file entries and app-owned deletion markers after acceptance. Rejected publication preserves those inputs and releases the synchronous send lock; newly staged or replaced inputs survive accepted cleanup. Main-chat submission keeps its existing effect and launch order. A feature-owned atomic draft action compares the captured normalized side-chat object, so accepted cleanup cannot erase a replacement handoff even for the same conversation and words. Captured identity fences an old callback from a newer opening; edits and clearing remain explicit cancellation.
The automatic adapter reuses the actual shared turn admission and its accepted/pending/blocked result. Manual asks retain false/undefined returns. One canonical workspace derivation preserves valid without-attached choices; only unavailable admission consults pending status/recovery/replacement/catalog state. The app carries native active/paused status from existing workspace observers only while a handoff is live. Warmup remains pending even over a cached completed/error result. The existing Root catalog observer supplies lifecycle separately from its incremental map, so later pages can resolve missing linked agents without a second query or delaying already-complete graphs.
The existing handoff-only readiness subscription observes the current target and exact history key, using the shared history-revalidation guard. Same-row success, failure or cancellation can wake the attempt without another history loader, subscription or retry timer. Follow-owned phase completion also wakes a refused send check when message/status identity does not change. Eligibility includes the core-owned request-availability projection, covering live pauses and hidden answer claims; ordinary sends wait while question/approval answers remain usable. Expired-pause cleanup and reentrant request checks remain authoritative. Later expired-pause supersession and answer completion publish newly free ownership once, including hidden answer claims. An automatic handoff waits through an older turn’s synchronous lock; manual duplicate submission still declines.
File cleanup checks the live composer’s key/server/temp/source aliases and opaque app-owned upload operation identity, including preassigned uploads not yet visible in the composer. Cancellation/discard recheck through callbacks; same-JSON replacement drafts keep their deletion markers. Actual accepted server references stay protected from deletion when reattached. Main and no-guard callers retain their previous behavior.
Promotion moves unsent words through the existing main-composer handoff. A known withdrawn turn restores its words before awaiting stop acknowledgement or reconciliation, preserving ordinary close/remount and one-owner promotion without re-arming automatic intent.
Type of change
Bug fix
Tests / tooling / CI
Testing
Environment: Node.js 24.16.0, Chrome/macOS, deterministic provider fixtures and disposable MongoDB; isolated ports, configuration, authentication and artifacts. No paid provider or production traffic.
2,385 shared tests across 124 core/React/panel suites pass, followed by 257 core tests after the final no-duplicate-notification control. Coverage includes pause/answer expiry and reentrancy, actual post-preflight refusal retaining all staged inputs, snapshot cleanup preserving reentrant edits/uploads, same-ID handoff replacement, previous-turn completion, transcript edits, withdrawal and optional host compatibility.
1,140 app tests across 49 suites pass, including main submit/textarea/draft migration, all Chat-hook/regenerate callers and real host/Presentation/Surface/menu paths. The expanded native file matrix covers pre-UI registration, same-ID/alias replacement, reentrant cancellation/discard, actual composer upload completion, accepted resource protection, identical serialized markers and denied storage. Native query tests cover cached-error/paused workspace refetch, paged catalog present/missing/error, initial failure, warmup and disabled/unavailable owners, and external same-row history success/failure/cancellation with key-switch and disabled cleanup.
Native query observers retain one required HTTP request per page/refetch, with no request in fresh/inactive cases. Catalog maps keep per-observer identity. Unchanged workspace refetch adds zero normal-pane renders and two live-handoff renders, returning to zero when handoff tracking is disabled. One canonical workspace derivation per attempt is asserted. Twenty unchanged pause notifications produce zero renders, while retirement produces exactly one availability wake. Unrelated/subquery cache writes do not render handoff readiness.
Thirteen no-retry browser cases pass against stable normal output: automatic second turn, ordinary desktop/mobile, close/switch, promotion with main send/clear and SPA reopening, genuine cached-success refetch success/403, held native workspace status and accepted transcript edit during held refetch. The matrix also covers answering a side-chat question and approving a side-chat tool. The worker case proves client HTTP admission, not real worker execution.
Exact-source shared/frontend builds, both workspace typechecks, scoped static/format/import checks pass.
Lighthouse passes three navigations with 250 ms added per Mongo query: median LCP 1,508 ms against 4,500 ms, median CLS 0.0124 against 0.1, lowest reference-CPU TBT 13 ms against 500 ms.
Reproduce the browser workflows:
npx playwright test --config=e2e/playwright.config.mock.ts subagent-activity.spec.ts scenarios/side-chat-open-beside.spec.ts scenarios/side-chat-pauses.spec.ts --grep 'subagent-continue-opens-side-chat|side-chat-opens-conversation-beside|side-chat-opens-beside-on-a-small-screen|side-chat-answers-ask-user-question|side-chat-approves-tool-call' --retries=0
Screenshots / recordings
Both clips start with the completed Research assistant task open in the right pane. Type “What did you find?” and click Continue in a new chat. The test releases the destination’s agent details after its history loads in both runs.
Before. Watch the right-hand composer after the click. The new chat opens, but the question stays in the composer and no reply appears.
before-reviewed.webm
After. Watch the question move into the transcript automatically. The composer clears and the Research assistant replies, “The checklist is missing a rollback test.”
after-reviewed.webm
Risk / compatibility
The shared submission path and optional driven/host inputs change; existing hosts keep defaults, and manual/regenerate caller regressions pass. Side-chat composer acceptance owns only its captured draft; other accepted transcript actions consume intent without clearing that draft. Ordinary manual turns do not rewrite the side-chat selection. Query keys, retries, polling intervals, provider request shapes, backend authorization, configuration and persisted formats are unchanged. Drafts remain memory-only across layout remounts and do not survive a full reload.
There are no added backend/database operations. Optional host ownership capture/guards preserve existing single-argument implementations and add no loader or observer. Upload operation snapshots and live alias scans run only for driven file submissions; main submissions do not capture upload ownership. Per-effect scans use the current composer/cache so callbacks cannot invalidate a stale ownership decision. Very large custom attachment limits have not been benchmarked. Handoff readiness shares the canonical agent query/request and adds no observer to main chat. Workspace/catalog/history changes add no loader or independent query observer. Local work includes a driven acceptance ref and synchronous composer-call ref, captured-input scans at driven submission, one primitive core-availability snapshot per follower, a follow eligibility state cell/interest flag, the catalog lifecycle provider, a key-filtered handoff cache subscription and a status scan when code admission is unavailable. Catalog lifecycle changes may notify workspace consumers; ordinary 10-second status polling retains its prior render bound. The availability getter performs a constant-time ownership check and allocates nothing on notifications; unchanged availability does not render. A refused follow check may cause one bounded completion wake. Lighthouse measures startup; provider/handoff latency and the full provider/browser matrix are not measured. The recordings retain their reviewed source revisions and illustrate the same interaction.
Checklist
I reviewed my own changes
Relevant tests have been added or updated
Existing relevant tests pass
The change does not introduce new warnings or errors
User-facing or complex behavior is documented where necessary
Required dependency changes have been merged/published: N/A
The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.
This PR makes side-chat continuations wait for destination readiness after the transcript loads, connecting the app’s existing query cache to the shared chat host.
Changes:
Adds reactive admission states for automatic handoffs without starting new requests.
Delays pending handoffs, keeps blocked or rejected submissions as drafts, and cancels automatic submission when the composer is edited.
Adds regression coverage for delayed destination details, draft handling, conversation switches, and unmounting.
File
Description
packages/chat/src/react/chat/index.ts
Exports the readiness type.
packages/chat/src/react/chat/host.tsx
Adds optional readiness to host turn services.
packages/chat/src/react/chat/driven.ts
Exposes readiness through the driven chat contract.
packages/chat/src/components/side/panel.tsx
Gates automatic handoffs and cancels them on edits.
The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.
The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.
Wait for workspace readiness before consuming handoff intent
client/src/hooks/Chat/ask/readiness.ts:33
[P2] For a destination with an attached code workspace, or one using the legacy workspace protocol, agent details can finish loading while environment-status queries are still pending. This returns ready, but resolveTurnCode rejects the automatic ask and the panel consumes its intent, leaving the question unsent even after the workspace becomes ready. Include pending workspace admission in handoff readiness while keeping terminal refusals as editable drafts.
The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Automatic handoffs mishandle pending catalog and workspace fetches, remain armed after some manual submissions, and may fail to retry after history revalidation.
The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.
The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Pending-action restoration can leave subscribers with stale availability, while deferred commit can cancel and suppress updates to a replacement upload sharing the same ID.
The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Releasing IDs individually synchronously rewrites the full ledger for each alias, causing 20 writes for ten ID pairs instead of one guarded batch release.
#18480 fixed the side-chat send-readiness issue. Closing this PR in favor of a focused follow-up that preserves the question as a draft when the pane is closed, switched, or opened as the main chat while the destination is loading.
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
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.
Summary
Continuing a finished child in a side chat can leave its question unsent while agent details, workspace discovery or existing history are still loading. Cached errors and partially loaded catalogs must stay distinguishable from final denial or missing data. Preserve the question as a conversation draft until the actual attempt is accepted or definitively refused, and let a newer manual action supersede automatic intent.
How it works
The existing side-chat atom seeds only an empty memory-only draft; existing drafts stay manual. Replay prevention uses the captured handoff, so a new continuation for the same mounted conversation can still send. A successful driven publication consumes captured intent for every entry point: composer, transcript edit, regenerate, continue, preview and automatic continuation. A different transcript action preserves the unsent question as a manual draft. Driven turns prepare their submission without draining composer inputs, publish through the actual follower, and commit only captured skills, quotes, reasoning, file entries and app-owned deletion markers after acceptance. Rejected publication preserves those inputs and releases the synchronous send lock; newly staged or replaced inputs survive accepted cleanup. Main-chat submission keeps its existing effect and launch order. A feature-owned atomic draft action compares the captured normalized side-chat object, so accepted cleanup cannot erase a replacement handoff even for the same conversation and words. Captured identity fences an old callback from a newer opening; edits and clearing remain explicit cancellation.
The automatic adapter reuses the actual shared turn admission and its accepted/pending/blocked result. Manual asks retain false/undefined returns. One canonical workspace derivation preserves valid without-attached choices; only unavailable admission consults pending status/recovery/replacement/catalog state. The app carries native active/paused status from existing workspace observers only while a handoff is live. Warmup remains pending even over a cached completed/error result. The existing Root catalog observer supplies lifecycle separately from its incremental map, so later pages can resolve missing linked agents without a second query or delaying already-complete graphs.
The existing handoff-only readiness subscription observes the current target and exact history key, using the shared history-revalidation guard. Same-row success, failure or cancellation can wake the attempt without another history loader, subscription or retry timer. Follow-owned phase completion also wakes a refused send check when message/status identity does not change. Eligibility includes the core-owned request-availability projection, covering live pauses and hidden answer claims; ordinary sends wait while question/approval answers remain usable. Expired-pause cleanup and reentrant request checks remain authoritative. Later expired-pause supersession and answer completion publish newly free ownership once, including hidden answer claims. An automatic handoff waits through an older turn’s synchronous lock; manual duplicate submission still declines.
File cleanup checks the live composer’s key/server/temp/source aliases and opaque app-owned upload operation identity, including preassigned uploads not yet visible in the composer. Cancellation/discard recheck through callbacks; same-JSON replacement drafts keep their deletion markers. Actual accepted server references stay protected from deletion when reattached. Main and no-guard callers retain their previous behavior.
Promotion moves unsent words through the existing main-composer handoff. A known withdrawn turn restores its words before awaiting stop acknowledgement or reconciliation, preserving ordinary close/remount and one-owner promotion without re-arming automatic intent.
Type of change
Testing
Environment: Node.js 24.16.0, Chrome/macOS, deterministic provider fixtures and disposable MongoDB; isolated ports, configuration, authentication and artifacts. No paid provider or production traffic.
Reproduce the browser workflows:
Screenshots / recordings
Both clips start with the completed Research assistant task open in the right pane. Type “What did you find?” and click Continue in a new chat. The test releases the destination’s agent details after its history loads in both runs.
Before. Watch the right-hand composer after the click. The new chat opens, but the question stays in the composer and no reply appears.
before-reviewed.webm
After. Watch the question move into the transcript automatically. The composer clears and the Research assistant replies, “The checklist is missing a rollback test.”
after-reviewed.webm
Risk / compatibility
The shared submission path and optional driven/host inputs change; existing hosts keep defaults, and manual/regenerate caller regressions pass. Side-chat composer acceptance owns only its captured draft; other accepted transcript actions consume intent without clearing that draft. Ordinary manual turns do not rewrite the side-chat selection. Query keys, retries, polling intervals, provider request shapes, backend authorization, configuration and persisted formats are unchanged. Drafts remain memory-only across layout remounts and do not survive a full reload.
There are no added backend/database operations. Optional host ownership capture/guards preserve existing single-argument implementations and add no loader or observer. Upload operation snapshots and live alias scans run only for driven file submissions; main submissions do not capture upload ownership. Per-effect scans use the current composer/cache so callbacks cannot invalidate a stale ownership decision. Very large custom attachment limits have not been benchmarked. Handoff readiness shares the canonical agent query/request and adds no observer to main chat. Workspace/catalog/history changes add no loader or independent query observer. Local work includes a driven acceptance ref and synchronous composer-call ref, captured-input scans at driven submission, one primitive core-availability snapshot per follower, a follow eligibility state cell/interest flag, the catalog lifecycle provider, a key-filtered handoff cache subscription and a status scan when code admission is unavailable. Catalog lifecycle changes may notify workspace consumers; ordinary 10-second status polling retains its prior render bound. The availability getter performs a constant-time ownership check and allocates nothing on notifications; unchanged availability does not render. A refused follow check may cause one bounded completion wake. Lighthouse measures startup; provider/handoff latency and the full provider/browser matrix are not measured. The recordings retain their reviewed source revisions and illustrate the same interaction.
Checklist