Repository navigation
fix(gateway,ui): reconcile pending chat sends after reconnect - #182334
Conversation
Deduplicate recorded chat.send submissions in pre-admission using the existing session-scoped indexed user-input lookup, including non-restart-safe attachments, commands, and overrides after the in-memory cache expires. Preserve cached ACKs, active-run responses, current authority, and conflicting-payload rejection. Keep unacknowledged chat sends pending and automatically replay them FIFO with the original submission and physical-session identities after authenticated reconnect. Apply the same admission contract to new-session first messages. Remove delivery-unconfirmed UI, manual delivery checks, and passive outbox history-receipt scanning; keep explicit failures and pending Discard behavior. Explicit Retry after rejection renews the admission and physical-session binding together; intentional recovery into another conversation remains inert until Retry. Preserve saved first prompts when their original physical identity is unavailable, hold stored attempted sends without a physical target until explicit review, and resume attachment sends after private Blob adoption without bypassing retry delays. Release-note context: reconnect now settles pending sends automatically without starting a duplicate recorded turn. The Control UI is served by its paired Gateway build, so no old-Gateway compatibility shim is needed. Existing RAM reservations cover concurrent admissions; a crash before either durable input record exists leaves the original key available for retry. Validation: focused Gateway and UI owner suites, selected Chromium reconnect, rejection, attachment, and first-message scenarios, core/UI typechecks, targeted lint/format, English i18n baseline, and five edited MDX pages. Pending/rejected startup controls also remain reachable when canonical history hides the local initial bubble; Discard cannot be undone by a late ACK. Proof gap: seven individual-module browser scenarios exceeded the native initial-roster deadline before reaching their recovery assertions. The retained build became ready after 26.399 seconds; assertion deadlines were not widened.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21b647607b
ℹ️ 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".
|
Codex review: needs real behavior proof before merge. What this changesThis PR automatically retries pending chat submissions after reconnect and deduplicates recorded inputs at Gateway admission. Example: The Gateway receives submission message-stable, but its acknowledgment is lost.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 8 items remain Keep this maintainer-directed repair open: automatic reconciliation addresses a real delivery problem, but the legacy review-barrier migration and two test consumers still need correction. Priority: P1 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe browser outbox retains submissions across transport loss; authenticated chat.send admission compares their original identities with session-owned input receipts and transcript records before dispatch. flowchart LR
Composer --> Outbox
Outbox --> Reconnect
Reconnect --> Admission
Admission --> RecordedInput
RecordedInput --> Acknowledgment
Admission --> AgentTurn
Acknowledgment --> Outbox
Technical reviewBest possible solution: Keep deduplication in Gateway admission and replay in the existing outbox owners, migrate legacy review barriers to held, and complete the affected consumer contracts. Do we have a high-confidence way to reproduce the issue? The stable producer, changed codec, and current drain establish the legacy-barrier failure from source; the supplied integration report independently demonstrates the ordinary reconnect scenario, without a local reproduction run. Is this the best way to solve the issue? The existing admission and outbox owners are the right boundaries, and removing passive receipt scanning is coherent once replay is safe; the persisted-state cutover remains incomplete. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 07a637979d4c. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: Automatic replay changes when saved input can execute, and final-effect revocation safety remains unverified. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 24, 2026, 5:52 AM ET / 09:52 UTC (Revision 4). |
Live integration proofCurrent main (5e0b786) merged locally with #182334 (send reconciliation), #182292 (offline archive/delete) and #182336 (deferred-chunk precache), plus #182336's sidecar-race fix. One full build on Node 26.12.1, served by an isolated Gateway behind a TCP fault proxy, and driven by real headless Chromium with fresh browser contexts and nothing pre-warmed.
No "Delivery unconfirmed" state appeared in any scenario. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a81673452
ℹ️ 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".
|
The landing repair in 1c55ec2 addresses the verified findings: interrupted-input recovery retains its private current-authority path; first-message and memory-only sends retry on healthy connections; reservation-only duplicate responses preserve browser custody until Gateway acceptance. Attachment/display handoff now uses the existing shared outbox owner, and consumed receipts carry their existing committed transcript position. The PR body links the already-posted live integration proof and records focused repair checks plus the earlier E2E failures still requiring final-head hosted CI. No assertions, skips, timeouts, budgets or baselines were weakened. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…182651) Main red after #182334 (11cb698): its durable retry lookup let the fixture's immediate mock run finish before /stop selected it, so 'preserves stop-command reason when /stop lands during the accepted ack yield' failed deterministically. The fixture now controls its timer explicitly; every cancellation and stop-reason assertion stays. Live isolated Gateway /stop, partial preservation and recovery verified.
Reduce the durable submitted-input source lookup from five SQL statements to one snapshot-consistent autocommit SELECT on SQLite and PostgreSQL. Keep restart, expired-memory, and attachment duplicate-dispatch protection, with the original bounded recovery transaction unchanged. The normal new-input path saves four statements without adding a worker request. The accepted rare recovery tradeoff is one additional statement for pending or committed input. Verified with both-engine count regressions, 56 focused behavior/prompt-prefix tests, three synthetic Gateway baseline/candidate pairs, and PostgreSQL owner review. Exact-head CI passes all static gates; the inherited PostgreSQL shard 2 fixture failure was independently fixed in #182990. Follow-up to #182334; single-statement precedent #182883.
…aw#182334) * fix(gateway,ui): reconcile pending chat sends after reconnect Deduplicate recorded chat.send submissions in pre-admission using the existing session-scoped indexed user-input lookup, including non-restart-safe attachments, commands, and overrides after the in-memory cache expires. Preserve cached ACKs, active-run responses, current authority, and conflicting-payload rejection. Keep unacknowledged chat sends pending and automatically replay them FIFO with the original submission and physical-session identities after authenticated reconnect. Apply the same admission contract to new-session first messages. Remove delivery-unconfirmed UI, manual delivery checks, and passive outbox history-receipt scanning; keep explicit failures and pending Discard behavior. Explicit Retry after rejection renews the admission and physical-session binding together; intentional recovery into another conversation remains inert until Retry. Preserve saved first prompts when their original physical identity is unavailable, hold stored attempted sends without a physical target until explicit review, and resume attachment sends after private Blob adoption without bypassing retry delays. Release-note context: reconnect now settles pending sends automatically without starting a duplicate recorded turn. The Control UI is served by its paired Gateway build, so no old-Gateway compatibility shim is needed. Existing RAM reservations cover concurrent admissions; a crash before either durable input record exists leaves the original key available for retry. Validation: focused Gateway and UI owner suites, selected Chromium reconnect, rejection, attachment, and first-message scenarios, core/UI typechecks, targeted lint/format, English i18n baseline, and five edited MDX pages. Pending/rejected startup controls also remain reachable when canonical history hides the local initial bubble; Discard cannot be undone by a late ACK. Proof gap: seven individual-module browser scenarios exceeded the native initial-roster deadline before reaching their recovery assertions. The retained build became ready after 26.399 seconds; assertion deadlines were not widened. * fix(gateway,ui): preserve send custody and retry pending admissions
…penclaw#182651) Main red after openclaw#182334 (66d9c47): its durable retry lookup let the fixture's immediate mock run finish before /stop selected it, so 'preserves stop-command reason when /stop lands during the accepted ack yield' failed deterministically. The fixture now controls its timer explicitly; every cancellation and stop-reason assertion stays. Live isolated Gateway /stop, partial preservation and recovery verified.
…182971) Reduce the durable submitted-input source lookup from five SQL statements to one snapshot-consistent autocommit SELECT on SQLite and PostgreSQL. Keep restart, expired-memory, and attachment duplicate-dispatch protection, with the original bounded recovery transaction unchanged. The normal new-input path saves four statements without adding a worker request. The accepted rare recovery tradeoff is one additional statement for pending or committed input. Verified with both-engine count regressions, 56 focused behavior/prompt-prefix tests, three synthetic Gateway baseline/candidate pairs, and PostgreSQL owner review. Exact-head CI passes all static gates; the inherited PostgreSQL shard 2 fixture failure was independently fixed in openclaw#182990. Follow-up to openclaw#182334; single-statement precedent openclaw#182883.
What Problem This Solves
When a chat message's socket died after the frame was written, the Control UI parked it as "Delivery unconfirmed" with Retry / Discard (and "Check delivery" for a new session's first message). The user had to decide whether it had been sent. Peter: "we can't really have an unconfirmed state. Either it's pending (needs sending or not confirmed) or sent - we can reconcile when we are connected to the network."
Why It Happened
The client sends each message with a stable idempotency key, but the Gateway only deduplicated a resend in two cases: within a 5-minute in-memory window on the same process, or durably for "restart-safe" requests. Outside those cases a resend could dispatch a second turn, so the client couldn't safely resend on its own and asked the user instead.
Solution
src/gateway/server-methods/chat-send-pre-admission.ts): before dispatching a request it would otherwise treat as new,chat.sendchecks for that session's recorded user row${runId}:user(or its durable input receipt) through the existing session-scoped indexed reader (readSessionSubmittedInput). If it finds one, the request is a duplicate: no new turn is dispatched and nothing is appended. It returns the existing cached ACK orin_flight/okshape. The same key with different content still returnschat-request-conflict. This covers attachments, commands and overrides. Accepted edge: a crash before either durable record exists leaves the key available, so the retry simply sends it.chat-outbox-receipts.ts,chat-outbox-history.ts, the passive history-receipt reconciliation, paused-unconfirmed handling, and the "Check delivery" / "Delivery unconfirmed" UI and copy.docs/web/control-ui/chat.md,docs/web/control-ui/offline-and-reconnect.md,docs/web/control-ui/sessions-and-sidebar.mdand the chat.send protocol docs describe the delivery states, automatic reconciliation and the server idempotency guarantee.Merge repair
Merged current main
07a637979d4c1df3da8cf65103cd7ccad00dee3awithout rewriting branch history. The capacity, payload, and recovery E2E conflicts preserve main's retained coverage and the intentional consolidations from #182358. Pending sends reconcile through their original keys and duplicate ACKs; rejection alone exposes Retry. Recovery retains unrelated-event isolation, nonmatching history, exact durable user-row identity, and no duplicate bubble while readback is held.The reported type error and seven unit failures were branch-caused:
pause.The failed CI run also exposed a pending telemetry-row regression. ACK handling now publishes accepted run activity before retiring queued progress across an await. Mobile motion is branch-caused: all four motion cases pass on the pinned main checkout; the branch footer shrinks during ACK and causes an instant virtualizer retarget. The existing scroll-command owner now preserves smooth movement when the endpoint shrinks during that journey; growth and cancellation behavior remain unchanged. The original browser assertions remain unchanged. No assertion, timeout, skip, or baseline was relaxed.
Codex review also identified two additional boundary bugs. Legacy uncertain local commands now require explicit Retry after reload, and attempted sends with missing/unavailable attachment bytes stay held with their original key and FIFO position until retry or discard. Both have regressions proven red before the repair. The proposed memory-only rejection finding was rejected: the recoverable branch explicitly excludes nonretryable Gateway errors, which already fall through to the failed state and visible error.
Evidence
Final repair head:
c949ed13090c84c2a5350d7c999751c928f9db0d.pnpm tsgo:ui,pnpm tsgo:core, and the UI-app, UI-chat, and UI-chat-E2E test type configurations pass.oxfmt --check, and staged/working-treegit diff --checkpass.Review rejection details: nonretryable memory-only errors are excluded from recoverable handling (
chat-send-queue-state.ts:281) and already become failed with a visible error. Required profile placement explicitly bypassessessions.dispatch(session-placement-startup.ts:420); existing initial/retry/resend tests assert the permitted RPC lists. The detached route is restricted to/approve(chat-send-submit.ts:351), retains main's existing explicit composer restoration, never auto-replays on reconnect, and resolves through the same canonical approval ID. Approval settlement rejects an already-resolved ID instead of applying a second decision. Restoring an automatic detached-command queue or adding an admin-dispatch gate would change those owning contracts.Hosted CI on the new head remains the broad landing gate; this repair does not merge the PR.