Repository navigation
🏍️ fix: Preserve Loading Side Chat Drafts - #18484
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the conversation-specific draft preservation and handoff changes.
No open issues 🎉
What changed in this PR
Preserves continuation questions as conversation-specific, in-memory drafts while a side chat loads, preventing loss when the pane is closed, switched, or opened as the main chat.
Changes:
- Seeds drafts before the side panel mounts and preserves existing drafts without automatic submission.
- Clears only matching captured drafts after accepted sends or main-composer transfers, with ownership checks against stale callbacks.
- Adds state, component, and browser regression coverage for draft preservation and handoff behavior.
| File | Description |
|---|---|
packages/chat/src/react/side/state.ts |
Seeds conversation drafts and adds ownership-checked draft clearing. |
packages/chat/src/react/side/__tests__/state.spec.ts |
Tests draft isolation, precedence, and ownership guards. |
packages/chat/src/react.ts |
Exports the draft-consumption atom. |
packages/chat/src/components/side/panel.tsx |
Coordinates draft submission, editing, and main-composer transfer. |
packages/chat/src/components/side/__tests__/panel.spec.tsx |
Tests loading-time preservation and one-shot handoffs. |
e2e/specs/mock/subagent-activity.spec.ts |
Covers continuation, closing, switching, and early promotion in browser scenarios. |
client/src/components/Chat/Presentation.tsx |
Wires draft clearing and guards callbacks against replacement panes. |
client/src/components/Chat/Presentation.test.tsx |
Tests stale callbacks against same- and different-destination replacements. |
Review effort: Balanced
|
@codex review |
|
/quality ignore |
Quality reportGate: open. Quality checks explicitly ignored for this commit.
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Continuing a finished subagent with a question opens a side chat while its destination loads. Closing or switching the pane before it is ready currently loses the question; opening it as the main chat leaves the main composer empty. Keep the question as that destination’s draft immediately, so those actions preserve it without submitting it later in the background.
How it works
Opening a side chat seeds its existing conversation-keyed, in-memory draft before the pane mounts. An existing draft takes precedence, including identical text, and remains manual. Closing or switching drops the pending automatic-send intent while leaving the draft available when that conversation is reopened.
An accepted send clears only the captured draft when its owner and words still match. Opening as the main chat transfers the words through the existing main-composer handoff and retires the side draft. Captured-owner checks prevent callbacks from an older pane from closing a replacement or consuming its question. Editing or clearing a refused question does not replay it automatically; standalone panel callers retain their existing conversation-level one-shot behavior.
Type of change
Testing
Tested environments/configuration: Chrome, production client build, local API with disposable MongoDB, Agents and side chats enabled, deterministic streaming provider. The destination agent response is held while using the pane’s normal controls.
Automated tests:
devbefore the fix; four draft ownership assertions also failed before the fix.Screenshots / recordings
Continue a finished child with “What did you find?”, then choose Open as the main chat while its destination is still loading. The matched crops show the main composer after loading: empty before, preserved as an editable draft after. Both use the same 1280 × 720 viewport and crop bounds; no UI content was edited.
Risk / compatibility
Drafts remain browser-memory-only and are isolated by conversation. This adds no requests, polling, database writes, persisted schema or configuration. It reuses the existing side draft family and main-composer transfer; destination readiness and submission admission are unchanged. The cost is a bounded atom lookup/write at opening and accepted consumption; render latency and heap growth were not benchmarked.
Checklist