Skip to content

🐛 fix: Wait for Side Chat Target Readiness - #18480

Merged
dustinhealy merged 1 commit into
devfrom
fix/side-chat-target-readiness
Nov 19, 2026
Merged

dustinhealy merged 1 commit into
devfrom
fix/side-chat-target-readiness

Conversation

@dustinhealy

@dustinhealy dustinhealy commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Continuing a finished subagent in a side chat can leave the question in the composer without starting a reply. This happens when conversation history loads before the saved agent's details: the one automatic send runs too early, the submission guard refuses it, and the question becomes an unsent draft.

Wait for the existing authoritative agent query alongside history before attempting that send. A successful continuation sends once and replies in the side chat. If the target cannot be read, the history stays visible and the question remains an editable draft.

How it works

The app's side-chat host warms the same React Query entry that the submission guard checks. It reuses a matching successful entry and shares an in-flight request with existing agent consumers. History and metadata load in parallel. A metadata failure settles separately so it cannot hide successfully loaded history. The existing one-shot composer and refusal behavior remain unchanged.

Open side chat → history + authoritative target query in parallel
              → history ready after target settles → existing one-shot send
Target denied → readable history + existing submission guard → editable draft

Type of change

  • Bug fix

Testing

Tested environments/configuration:

Local production app in Chrome, deterministic provider and MCP fixtures, disposable local storage. The same continued-child scenario delays only the agent-detail response by 500 ms: it fails on current dev and succeeds with this change, using the existing assertions and timeouts.

Automated tests:

  • Eight app side-chat host tests: delayed metadata, 403/404 history preservation, matching-cache reuse, in-flight deduplication, and existing transport behavior.
  • Twenty-nine shared side-panel and driven-chat tests, including refused text that is edited or withdrawn without later automatic replay.
  • Normal-entry browser checks: delayed successful continuation, second turn and navigation; 403 and 404 target responses preserve history and the question draft without starting a generation.
  • Production package/client builds, client/chat no-emit typechecks, normal commit hooks and the full local pre-push verifier passed. The standard verifier skips config migration tests and skipped unused-package checking because depcheck is absent.

Screenshots / recordings

Continue a finished child's conversation with “What did you find?” while its metadata response is delayed. Before, the question remains unsent in the composer. After, it appears as a message, receives a reply, and the composer clears. Both captures use the same 1280×720 viewport and frame the same portion of the side chat without scaling.

Before After
Question remains an unsent draft Question is sent and receives a reply

Risk / compatibility

The side-chat host receives the conversation's existing optional agent_id; no wire, configuration, or persisted-data shape changes. Other endpoint types and ephemeral agents keep their existing loading behavior. Closing the panel retains the shared query's ownership, while the existing follower fence prevents a late send.

A cold saved-agent target may require a metadata request; existing consumers share the same query. Matching successful metadata adds no fetch, including subsequent history reads. Initial readiness waits for the slower of history and target metadata rather than adding a serial wait. No polling or automatic retry of refused messages is introduced. Production latency and fleet-level request volume have not been measured.

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 01:16
@dustinhealy

Copy link
Copy Markdown
Collaborator Author

/quality ignore

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@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-19T01:19:33.361562Z 38c56c2 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.

@github-actions

Copy link
Copy Markdown
Contributor

Quality report

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

  • Commit: 38c56c2fffe07f8885597eafe901db6267caf585
  • 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.

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 remain for the change that defers side-chat continuation until saved-agent metadata settles.

No open issues 🎉

What changed in this PR

Fixes side-chat continuation sending too early by waiting for saved-agent metadata alongside conversation history. This lets the existing one-shot send run after the target query settles, while preserving readable history and an editable draft if metadata fails.

Changes:

  • Passes the optional agent_id through the shared side-chat host interface.
  • Reuses cached metadata and shares in-flight queries without loading history and metadata serially.
  • Adds regression coverage for delayed metadata, failed target reads, cache reuse, and refused drafts without automatic replay.
File Description
packages/​chat/​src/​react/​side/​host.tsx Adds agent_id to the host’s conversation input.
packages/​chat/​src/​components/​side/​__tests__/​panel.spec.tsx Tests editing and clearing refused drafts without automatic replay.
e2e/​specs/​mock/​subagent-activity.spec.ts Delays agent metadata in the continuation browser test.
client/​src/​Providers/​SideChatHostContext.tsx Coordinates history and target readiness using the shared agent query.
client/​src/​Providers/​__tests__/​SideChatHostContext.spec.tsx Tests readiness, failure handling, cache reuse, and request deduplication.

Review effort: Balanced

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 38c56c2fff

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

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