Repository navigation
fix(frontend): keep a first message when the user opens another chat before it is sent - #7838
Conversation
…before it is sent A message typed on Home or an agent's page waits on the chat screen until the transcript, the vault and the setup step answer. Opening another chat during that wait unmounted the only code that sends it, so it never went out, the session got no rail row, and the rail link carries no agent, so coming back showed "This chat does not exist". When the chat screen leaves a session whose task was not on its way, mark the task failed and list the session in the rail. On return the chat screen takes the agent from the task and shows the "Message not sent" card with Retry. Retry also waits for a template's connect step.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Held-task lifecycle web/mobile/src/features/home/pendingTask.ts, web/mobile/src/features/chat/useLeaveHeldTask.ts, web/mobile/src/features/chat/ChatScreen.tsx, web/mobile/tests/unit/chatScreenLeaveHeldTask.render.test.tsx |
ChatScreen tracks its session and project. When the last screen for a session closes, eligible held tasks are marked failed and registered as local sessions. The chat screen resolves the agent ID from the route or pending task. Tests cover task state, session retention, and screen lifecycle cases. |
Retry setup blocking gate web/mobile/src/features/chat/LiveConversation.tsx, web/mobile/tests/unit/liveConversationOffScreenFailure.render.test.tsx |
Failed-task retries are disabled while setup is blocking. The retry handler returns without sending under that condition. Tests check retry availability while setup blocks and after it stops blocking. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Sequence Diagram(s)
sequenceDiagram
participant ChatScreen
participant useLeaveHeldTask
participant leaveHeldTaskAtom
participant registerLocalSessionAtom
ChatScreen->>useLeaveHeldTask: provide sessionId and projectId
useLeaveHeldTask->>leaveHeldTaskAtom: set after the last screen closes
leaveHeldTaskAtom->>registerLocalSessionAtom: register eligible task session
Merge Risk: 
Minimal · up to 0c4b7
-
The change appears mergeable after normal checks; no actionable failure is established.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: a first message is kept when the user opens another chat before it is sent. The title is short, specific, and matches the changeset (useLeaveHeldTask, leaveHeldTaskAtom, ChatScreen changes). It uses the fix(frontend) prefix and states the user-visible effect without file lists or vague terms.
Full details: Description check
-
Explanation
The description explains the symptom, cause, fix, and tests. It matches the changeset: marking held tasks failed on leave, listing the session in the sidebar, taking the agent from the pending task, gating Retry on the connect step, and the new render tests.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Railway Preview Environment
Provisioning failed; no manual review time granted. Environment absence verified; retained storage requires separate provider accounting. Post |
|
🤖 The AI agent says: Merged into release/v0.125.2 as b7eb664. Codex (gpt-6-astra, medium) reviewed it. Its points are in this PR: a failed task stays listed in the sidebar, and Retry waits for a template's connect step. CodeRabbit had no actionable items. All non-web checks passed. The web unit test job was still running at merge. The mobile unit tests (685), |
Symptom
In /m, a user sends the first message of a new chat from an agent's page and opens another chat in the sidebar within about 1.5 s. On staging (release/v0.125.2, which already has #7834) this lost the message in 3 of 4 runs: no
/invokerequest, no turn, the chat left the sidebar, and its URL showed "This chat does not exist". No "Message not sent" card appeared.Cause
The agent page hands the first message to the chat screen as a pending task. The chat screen holds it until the transcript, the vault and the setup step answer, and only then sends it. The sidebar row is also added at that send. A switch during the hold unmounted the chat screen, so nothing was left to send the task and no row was added. The sidebar link carries no
?agent=, so the chat screen could not resolve the agent of a session the server does not know. #7834 covered only a send that had already started.Fix
useLeaveHeldTask,leaveHeldTaskAtom). The check runs one task later, so a remount in place (strict mode) is not a leave.A full page reload still loses the in-memory task. That is unchanged.
Tests
chatScreenLeaveHeldTask.render.test.tsxrenders the realChatScreen. It switches away at 0.3, 0.6 and 1.5 s. These cases failed before the fix and pass now. It also covers a send already on its way, a task that already failed, a quick switch back, a project switch and strict mode.liveConversationOffScreenFailure.render.test.tsxchecks the Retry setup gate.tscis clean andpnpm lint-fixis clean.