Skip to content

fix(chat): reconnect deletes queued messages that were never sent - #1669

Merged
shanselman merged 5 commits into
openclaw:mainfrom
SebTardif:fix/f049-keep-unsent-on-reconnect
Oct 15, 2026
Merged

shanselman merged 5 commits into
openclaw:mainfrom
SebTardif:fix/f049-keep-unsent-on-reconnect

Conversation

@SebTardif

@SebTardif SebTardif commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: reconnect deletes queued messages that the gateway never accepted.

User Impact

User impact: a message queued behind an active turn stays visible after reconnect as failed, so its text is not lost. It is not sent again automatically.

Why This Change Was Made

Reconnect previously cleared every queued message. The updated queue reset preserves only messages still in the Queued state, marks them failed, clears retry scheduling metadata, and drops ambiguous Sending entries because the gateway may already have accepted them.

Evidence

Current head 37d77d7889c20cc10522ac308a3737076f7fb01a includes current main and a real isolated WinUI regression test using the repository fixture gateway.

The proof holds the first chat.send, queues queued-1669-current-head behind it, closes the gateway connection, reconnects the app, and verifies:

  • the queued card is visible before reconnect;
  • the same card is visible after reconnect with status Failed and a Remove action;
  • the error reads The connection dropped before the gateway accepted this message.;
  • exactly one chat.send reached the fixture, so the queued message was not automatically resent;
  • the stale completion of the pre-reconnect send did not promote or remove the failed queued message.

Before reconnect

Queued message before reconnect

After reconnect

Failed queued message after reconnect

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-winui-interactive: the isolated native app used the repository fixture gateway to show the queued card before reconnect and the same failed card after reconnect.

Validation

  • .\build.ps1: passed. Shared, CLI, WinNode CLI, SetupEngine, and WinUI built successfully.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: passed, 4310 passed, 36 skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: passed, 4009 passed, 0 skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter "FullyQualifiedName~ChatQueueReconnectTests|FullyQualifiedName~Status_ReconnectKeepsUnsentQueuedMessagesAsFailed|FullyQualifiedName~ChatComposerViewModelTests": passed, 37 passed, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj -c Debug -r win-arm64 -p:Platform=ARM64 -p:DevBuild=false --no-restore --filter "FullyQualifiedName~ReconnectKeepsDefinitelyUnsentQueuedMessageFailedAndVisible": passed, 1 passed, 0 failed.

Real Behavior Proof

  • Environment tested: Windows ARM64, isolated native Debug tray, repository fixture gateway and local MCP automation.
  • PR head or commit tested: 37d77d7889c20cc10522ac308a3737076f7fb01a.
  • Exact steps or command run: ran GatewayFixtureUiTests.ReconnectKeepsDefinitelyUnsentQueuedMessageFailedAndVisible with screenshot capture enabled. The fixture held the first send, admitted a second message into the native queue, closed the connection, then accepted the automatic reconnect.
  • Evidence after fix: queued-1669-current-head changed from Queued to Failed, retained the same queue id, displayed the localized failure text and Remove action, and fixture request records contained exactly one chat.send.
  • Observed result: the definitely unsent queued text remained visible, was not automatically resent, and was not removed by the stale pre-reconnect send completion.
  • Screenshot or artifact links verified? Yes.
  • Not verified or blocked: no current-head run against an upstream OpenClaw gateway package. The current package feed did not expose the previously used gateway version, so the deterministic repository fixture gateway was used for current-head proof.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? No
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No
  • Migration needed? No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

Reconnect cleared every queued message, including ones the gateway
had not accepted. History cannot restore those, so the text was
gone.

Keep those messages and mark them failed. A message that was
already failed stays failed with its original error. Requests for
kept messages stay. Run mappings and local echoes still clear.

ChatQueueReconnectTests passed. The provider reconnect test now
expects the pending text to remain as failed. ./build.ps1 exit 0.
Shared 4262 passed, 33 skipped. Tray 3991 passed.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

The PR preserves queued chat messages across reconnects as failed cards without automatically resending them.

Example: Queue queued-1669-r behind an active turn, then stop and restart the gateway.

  • Before: Reconnect deletes the queued text even though the gateway never received it.
  • After: The same q13 card retains queued-1669-r, shows Failed, and offers Remove without sending the message.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair supported by shipped-entry-point diagnostics, regression coverage, and successful relevant CI.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): At a5943d9, an isolated Windows tray exercised ChatQueueState through native chat and a real gateway stop/restart: q13 retained queued-1669-r, changed from Pending to Failed, exposed Remove, and had zero gateway-log occurrences.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A gateway reconnect erases follow-up text that remained queued locally and cannot be restored from gateway history.
Reason: Preserving user text has clear value, and marking it Failed retains the existing protection against automatic stale sends.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: current main still deletes unsent queued text on reconnect, and this focused repair has current-head live proof with no actionable correctness findings.

Priority: P2
Reviewed head: a5943d9fb2b4cfa4163c9501c17da892794e1277

Before merge

None.

Findings

None.

Agent review details

How this fits together

Native chat passes outgoing requests through ChatConversationState and ChatQueueState; connection transitions update queue state, which is projected into visible chat cards.

flowchart TD
  A[Chat composer] --> B[ChatConversationState]
  B --> C[ChatQueueState]
  D[Gateway connection status] --> B
  C --> E[Chat snapshot]
  E --> F[Chat timeline cards]
Loading

Technical review

Best possible solution:

Land the focused queue-state repair while preserving generation checks, correlation cleanup, and manual control over resending.

Do we have a high-confidence way to reproduce the issue?

Current-main source unconditionally clears queued messages on reconnect, and the existing provider test demonstrates a pending message reaching that path; this review did not execute a reproduction.

Is this the best way to solve the issue?

The repair addresses deletion in the existing queue owner and retains failed cards without making them eligible for automatic dispatch.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2f383318b5b9.

Provenance checked

  • Reconnect queue cleanup and its provider-test expectation changes intended behavior with a stated reason (Add queued chat message UI #920: Queued-chat work established one-at-a-time dispatch and reconnect correlation cleanup; the original source and test clear uncorrelated queues. The later runtime-owner refactor preserved that behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified introduced repair: The pinned introduction diff retains queue messages, marks unfinished messages Failed, preserves existing failure errors, retains matching requests, and continues clearing correlation and scheduling state. (src/OpenClaw.Tray.WinUI/Chat/ChatQueueState.cs:550, a5943d9fb2b4)
  • Still necessary on main and latest release: ClearForReconnect still clears both message and request collections on fetched main and in the supplied latest-release commit for v2026.9.8-1. (src/OpenClaw.Tray.WinUI/Chat/ChatQueueState.cs:554, 2f383318b5b9)
  • No automatic resend or stale completion: Dispatch selects only Queued entries. Reconnect advances the connection generation before queue recovery, and send-result commits reject obsolete generations. (src/OpenClaw.Tray.WinUI/Chat/ChatConversationState.cs:305, a5943d9fb2b4)
  • Current-head shipped-entry-point proof: The full REST-read PR body records isolated Windows chat at the reviewed head with a real gateway stop and restart. Copied UI diagnostics show q13 changing from Pending to Failed while retaining queued-1669-r; the gateway marker count remains zero. Remove was not clicked, and no screenshot was uploaded. (a5943d9fb2b4)
  • Feature provenance and ownership: Add queued chat message UI #920 introduced queued chat behavior and its reconnect-clearing test; Fix queued chat message parity #935 extended queue identity and removal; refactor(chat): extract runtime state owners #1096 transferred queue mechanics into ChatQueueState. Their recorded goals concern safe dispatch, correlation, and ownership rather than preserving deletion of unsent text. Some historical blob searches hit the local partial-clone limit; REST recovered the original reconnect-clearing source. (src/OpenClaw.Tray.WinUI/Chat/ChatQueueState.cs:550, f8a8825ccbb4)
  • Validation and review policy: The body reports a successful full build, Shared tests with 4262 passed and 33 skipped, and Tray tests with 3991 passed. Exact-head CI Gate, Tray/setup/integration, UI/accessibility, and proof-pool contract checks succeeded. Root AGENTS.md and the proof-validation skill were read; no nested AGENTS.md or maintainer-notes directory exists. Copied UI diagnostics satisfy the applicable visible-proof policy. This read-only review ran no builds, tests, or additional reviewer. (AGENTS.md, a5943d9fb2b4)

Likely related people:

  • Caleb Eden: Raw commit c9b5476 adds tests/OpenClaw.Tray.Tests/OpenClawChatDataProviderTests.cs:660 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c9b5476a873f; files: tests/OpenClaw.Tray.Tests/OpenClawChatDataProviderTests.cs)
  • Barbara Kudiess: Raw commit f8a8825 adds src/OpenClaw.Tray.WinUI/Chat/ChatQueueState.cs:490 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f8a8825ccbb4; files: src/OpenClaw.Tray.WinUI/Chat/ChatQueueState.cs)

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Reconnect loses pending user text within native chat; the repair has a limited subsystem scope.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-07T03:11:52.809Z sha a5943d9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T03:57:13.172Z sha a5943d9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T05:02:59.836Z sha a5943d9 :: needs maintainer review before merge. :: none

Reviewed October 14, 2026, 9:23 PM ET / October 15, 2026, 01:23 UTC (Revision 4).

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 7, 2026
@karkarl

karkarl commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Global triage: NEEDS_HUMAN_TEST. Take confidence 55%; recommendation confidence 97%; effort small; risk medium.

Reviewed exact head a5943d9fb2b4. GitHub currently reports CLEAN with 32 passing, 0 failing, and 0 pending checks. proof label is sufficient. Durable automated signal: Codex review: needs maintainer review before merge..

Maintainer or proof-pool owner: run every declared Windows proof pool at this exact head and replace blocked or historical evidence with current-head results.

This is a triage classification, not a merge action. No branch changes were made.

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 15, 2026
Preserve only definitely unsent queued messages, localize the failure text, and cover stale completion plus post-reconnect drain behavior.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 056d2209-1ac9-4a0c-8be9-2f7086b908d6
Exercise a held chat send through the isolated fixture gateway, reconnect the real app, and verify the definitely unsent queued card remains failed and is not resent.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 056d2209-1ac9-4a0c-8be9-2f7086b908d6
@shanselman
shanselman merged commit 8115ba1 into openclaw:main Oct 15, 2026
24 checks passed
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 15, 2026
@SebTardif
SebTardif deleted the fix/f049-keep-unsent-on-reconnect branch October 16, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants