Skip to content

🏍️ fix: Preserve Loading Side Chat Drafts - #18484

Merged
dustinhealy merged 1 commit into
devfrom
fix/preserve-loading-side-chat-drafts
Nov 19, 2026
Merged

dustinhealy merged 1 commit into
devfrom
fix/preserve-loading-side-chat-drafts

Conversation

@dustinhealy

Copy link
Copy Markdown
Collaborator

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.

open side chat → seed destination draft + pending intent
close / switch → retain draft, discard pending intent
accepted send → retire matching captured draft
open as main → transfer to main composer → retire side draft → close

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

  • Bug fix

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:

  • Reproduced the empty main composer on unmodified dev before the fix; four draft ownership assertions also failed before the fix.
  • Five normal-entry browser cases passed: ordinary continuation and another turn; close and reopen; switch destinations and reopen; early promotion and manual send; early promotion, clear and reopen. These assert no unexpected generation or repeated question.
  • 27 state/panel tests and 26 app Presentation/readiness tests passed, including existing-draft precedence, refused/edited/withdrawn questions, stale callbacks, replacement owners and artifact panel selection.
  • Chat and client TypeScript checks, production builds, scoped formatting/import sorting and lint passed.

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.

Before After
Question lost after early promotion Question preserved after early promotion

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

  • 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
  • Required documentation PR: N/A

Copilot AI balanced review requested due to automatic review settings November 19, 2026 02:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@dustinhealy dustinhealy changed the title 🐛 fix: Preserve Loading Side Chat Drafts 🏍️ fix: Preserve Loading Side Chat Drafts Nov 19, 2026
@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

/quality ignore

@github-actions

Copy link
Copy Markdown
Contributor

Quality report

Gate: open. Quality checks explicitly ignored for this commit.

  • Commit: 51349ecae51ebd1a6694749e81dcfc4bafd27222
  • Requested by: @dustinhealy
  • Check: ignore

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T03:13:09.067389Z 51349ec Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 51349ecae5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

@dustinhealy
dustinhealy merged commit 584102d into dev Nov 19, 2026
67 checks passed
@dustinhealy
dustinhealy deleted the fix/preserve-loading-side-chat-drafts branch November 19, 2026 03:16
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.

2 participants