Repository navigation
fix(ui): a message sent right after opening a session reaches it - #6733
dam-application[bot] wants to merge 2 commits into
Conversation
A session/resume that answered after the chat moved to another session bound the chat's connection to the old one, and every later send, Retry included, failed with "the conversation changed" until the person switched sessions. A reset now voids an engagement in flight, a binding to another session than the shown one engages the shown one again, and a send whose connection still answers for another session goes over a connection of its own instead of failing. Fixes #6732 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🛡️ Code Guardian 🛡️ — ✅ Code Review @ 2cc394a
PR #6733: fix(ui): a message sent right after opening a session reaches it
Author: dam-application[bot] | Branch: fix/6732-chat-first-message-conversation-changed → main | Changes: +156 −11 (5 files)
Summary
This PR stops a late session/resume from binding the chat's connection to a session the person left. A stale binding now follows the shown session, and a mismatched send goes over a one-off connection.
Limits: 1 skill(s) did not run: react-ui-engineering.
Findings
- 🟢 Suggestion: Page promises that a move never fails a send (
docs/architecture/sessions.md:200). - ✅ Looks good: The new engagement and send tests fail with the base hooks and pass at HEAD (
packages/ui/src/modules/sessions/hooks/use-acp-session-engagement.ts:30).
Documentation Check (doc-drift)
✅ No findings.
Issue Fit
✅ No findings.
TypeScript Engineering Review
✅ No findings.
Verdict
APPROVE — No blocking finding remains, and the new tests prove the reset guard and the send fallback.
Review by Code Guardian 🛡️ · automated code guardian · ibm/aws/claude-opus-5-5 on pi
| Unacknowledged this long means it never arrived, and the failure carries the socket's stated cause when it gave one. | ||
| Until the acceptance arrives the person's own message says it is **sending**, or that the agent is **waking** when the send woke it, after a second so a fast send shows nothing; the reply, the working indicator and the session's row in the sidebar wait for the acceptance, so none says the agent is working on a message it does not have. | ||
| A send whose chat moves to another session before it went out goes over a connection of its own, engaged to its session, so the move cannot strand it. | ||
| The chat's own connection is engaged to the session on screen alone: a resume that answers after the person moved on never engages it, and one left engaged to another session engages the shown one again at the next send, so a send or its retry never fails for the move. |
There was a problem hiding this comment.
🟢 Suggestion: The new sentence says that a send or its retry never fails for the move. This is not true when the person moves away and back while the send sets up its connection. Each move resets the connection, so the send's ensureLive returns null. The send then fails with "Failed to establish connection" (use-acp-prompt.ts:337), as it does on main. Reported by Documentation Check (doc-drift).
| The chat's own connection is engaged to the session on screen alone: a resume that answers after the person moved on never engages it, and one left engaged to another session engages the shown one again at the next send, so a send or its retry never fails for the move. | |
| The chat's own connection is engaged to the session on screen alone: a resume that answers after the person moved on never engages it, and one left engaged to another session engages the shown one again at the next send, so a stale engagement never fails a send or its retry. |
What and why
In the web chat, a message sent right after a person opened a session could fail with "Couldn't send — the conversation changed while the message was on its way". Retry failed in the same way until the person switched sessions and came back.
The cause: a
session/resumethat answered after the chat moved to another session bound the chat's connection to the old session. Every later send then got the old session back, and the send path refused it. This change stops the late bind, repairs a stale binding at the next send, and makes the send path deliver instead of refusing.Reviewer guide
What changes in substance
clear()now bumps a counter.engage()binds only when noclear()ran while its resume was in flight; otherwise it returnsnull. Before, the late answer bound the old session.engage()resumes the shown session on the same connection and binds it. This is what makes Retry work without a session switch. The chat's update handler already drops frames for sessions that are not on screen, so the old engagement shows nothing.engageAside, from fix(sessions): a message sent before leaving the chat runs, and says it is sending until the agent has it #6239). The error text "the conversation changed while the message was on its way" is gone.Where to look closely
use-acp-session-engagement.ts: when no session is on screen (the new-chat page),engage()still returns the existing binding, as before. That path only starts sessions throughbeginSession.use-acp-prompt.ts(open): with the engagement fix, the chat's connection should not answer for another session while that session is on screen. If it does, the message reaches the right session over the one-off connection, but its reply does not stream into the chat until the chat engages that session again. I chose delivery over an error here.Ruled out
engage()already runs on every send and Retry, so the repair belongs there.openConnectionopens two sockets. That leaves a second socket that a reset does not close, and is one way a resume answers late. The guard above makes the late answer harmless. Sharing the open is a separate change.Scope
packages/ui/src/modules/sessions/hooks/use-acp-session-engagement.ts: the reset guard and the shown-session check.packages/ui/src/modules/sessions/hooks/use-acp-prompt.ts: the send-path branch.session-engagement-after-reset.test.ts, one new case insend-after-switch.test.ts.docs/architecture/sessions.md: one sentence on the chat's engagement, and theLast verifieddate.Testing
mainand pass with this change.mise run checkpasses.mise run teststops invm-runneronboot::tests::an_entry_holding_a_locked_file_is_kept_whole. That test fails in this sandbox onmaintoo, and this change does not touchvm-runner.uisuite alone: 342 files, 2274 tests pass.Fixes #6732
Written by this agent — https://dam-dev.apps.dam-cl.fmaas.res.ibm.com/a/agent-677ca492fbca62dd?s=b3ac5afb-7836-4ba7-9257-b423d940a2e9
🤖 Generated with Claude Code