Skip to content

fix(ui): reconnect-uncertain sends stay inline and prove delivery by run id - #131171

Merged
steipete merged 1 commit into
mainfrom
claude/red-error-investigation-867e7a
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/red-error-investigation-867e7a

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a Control UI operator whose WebSocket reconnected while a chat.send was in flight would see a red "Delivery uncertain" error chip in the composer — and keep seeing it for the entire run — even though the message was delivered and the agent was visibly replying. The message also vanished from the conversation into the composer chip area, plus a duplicate red top-bar banner.

Why This Change Was Made

Two root causes:

  1. Delivery-proof blind spot. After a reconnect loses the ack, the outbox reconcile's only delivery proof was the transcript idempotency marker — which doesn't exist until the run commits. The fact that was available the whole time (the session row reporting the send's own run id in sessionInfo.activeRunIds, or as lastRunId after completion) was never consulted, even though live terminal-event retirement (removeDeliveredQueuedChatSendForRun) already trusts exactly that identity (gateway chat runs use the client idempotency key as run id, src/gateway/server-methods/chat-send-session.ts:41). So a send admitted during the reconnect race parked as "unconfirmed" and stayed red until the run ended.
  2. Wrong failure surface. Attempted sends already have a messenger-style inline presentation: failed sends render as a normal conversation bubble with a quiet "· Not sent · Retry" footer. unconfirmed was the one attempted state excluded from that path, falling back to a red composer chip styled like a hard failure.

The reconcile now retires a queued send when the session row proves its run (active or last), and unconfirmed joins the inline bubble path: the message stays in the conversation as an ordinary bubble, and only genuine, concluded uncertainty gets an amber "Delivery unconfirmed · Retry" footer (tooltip carries the calmer diagnostic). The duplicate pane banner is suppressed for parked attempted messages since the bubble owns the outcome; hidden sessions still get the named toast, and local-command chips, never-attempted failures, and storage errors keep their existing surfaces.

User Impact

  • A send that raced a reconnect but was delivered never shows an error: the bubble stays in the conversation and silently hands off to the authoritative history row (same Lit key, no flicker) — including runs that completed while the client was disconnected.
  • Real uncertainty reads as a calm review request next to the speech bubble, not a failure: amber "Delivery unconfirmed · Retry" instead of a red chip + red banner. Red stays reserved for actual failures.
  • Copy softened: "Reconnected before delivery was confirmed. Check the conversation — retry only if your message didn't arrive."

Evidence

  • Pre-fix failure proof: pnpm test ui/src/pages/chat/chat-send.test.ts -t 'retires a reconnect send proved by' fails 2/2 on pre-fix code (active-run case stays waiting-reconnect, completed-run case stays unconfirmed); both pass post-fix.
  • pnpm test ui/src/pages/chat/chat-send.test.ts — 284 passed (new regressions: active-run proof, last-run proof, unrelated-run still parks, banner suppressed for parked bubbles).
  • pnpm test ui/src/e2e/chat-flow.history-recovery.e2e.test.ts — 7 passed (real UI + mock-gateway WebSocket reconnect: ACK-lost park, same-key Retry, uncertainty surviving unrelated history, single authoritative bubble after proof).
  • Touched-file suites (chat-thread, chat-composer-queue, chat-message, chat-responsive.browser incl. Chromium layout/theme color assertions) — 516 passed; full pnpm test ui/src/pages/chat — 11,174 passed.
  • pnpm check:changed green (typecheck, lint, styles, i18n catalog); pnpm ui:i18n:baseline byte-identical.
  • Fresh isolated Codex autoreview on the final diff: clean, no actionable findings.
  • Production LOC: +51/−9 across 6 files (delivery-proof predicate, second visual state in the existing footer renderer, banner suppression); no new storage, config, or API surface. Tests +291/−82, docs +6.
  • Before/after screenshots (mock-gateway e2e harness, sanitized) in the comment below.

…run id

After a reconnect lost the chat.send ack, the outbox reconcile only accepted
the transcript idempotency marker as delivery proof, so a send whose run was
actively streaming parked as a red 'Delivery uncertain' composer chip for the
whole run. The reconcile now also retires a queued send when the session row
reports its run id in activeRunIds or as lastRunId — the same fact live
terminal-event retirement already trusts.

Attempted unconfirmed messages now stay in the conversation as ordinary
bubbles with an amber 'Delivery unconfirmed · Retry' footer (failed keeps the
red 'Not sent'); the duplicate pane banner is suppressed for them since the
bubble owns the outcome. Command chips, never-attempted failures, and storage
errors keep their existing surfaces. Calmer copy for the remaining honest
uncertainty case.
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Before/after from the mock-gateway e2e harness (sanitized, same ACK-lost reconnect flow).

Before — message trapped in a red "Delivery uncertain" composer chip (not in the conversation), plus a duplicate red top-bar banner, even when the send was delivered:

After (genuine uncertainty) — the message stays in the conversation as an ordinary bubble with an amber "Delivery unconfirmed · Retry" footer; no chip, no banner:

After (delivery proven by run id) — the bubble is clean, run streams; no error surface at any point:

before-red-chip-and-banner

after-amber-inline-footer

after-delivery-proven-clean-bubble

@steipete
steipete marked this pull request as ready for review August 27, 2026 20:26
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 4:33 PM ET / 20:33 UTC.

ClawSweeper review

What this changes

The Control UI now treats a matching active or last Gateway run ID as delivery proof after reconnect and renders unresolved attempted sends inline with an amber retry footer.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. This maintainer-authored PR has a coherent, source-backed repair for a real reconnect race; current main still relies only on a persisted transcript marker, so the work remains necessary.

Priority: P1
Reviewed head: d662ae8191381aa7f264ac80dde2fbc2b89b9b83

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with source-backed Gateway identity semantics and targeted unit plus browser recovery coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this is maintainer-authored; the PR discussion additionally supplies sanitized mock-Gateway before/after evidence for the reconnect flow.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this is maintainer-authored; the PR discussion additionally supplies sanitized mock-Gateway before/after evidence for the reconnect flow.
Evidence reviewed 6 items Gateway identity contract: The Gateway assigns the request idempotency key to clientRunId, and terminal session lifecycle projection records that exact client run ID as lastRunId.
Introduced reconciliation repair: The PR’s exact-match helper retires an outbox item only when history contains its idempotency marker or the same session reports its run ID, then preserves the local user turn during history handoff.
Visible-state ownership: Unconfirmed attempted non-command sends now use the existing inline-thread path, while the footer renderer distinguishes the unconfirmed state and keeps its retry action.
Findings None None.
Security None None.

Live Verification

Entry: /chat

Result: FAIL (partial) — step 2 wait_for text=OpenClaw: locator.waitFor: Error: strict mode violation: locator('text=OpenClaw') resolved to 4 elements:

Steps:

  • PASS goto /chat
  • FAIL wait_for text=OpenClaw — locator.waitFor: Error: strict mode violation: locator('text=OpenClaw') resolved to 4 elements:

How this fits together

The Control UI stores attempted sends in its outbox while a browser reconnects to the Gateway. It reconciles those entries against Gateway history and session lifecycle data, then either retains a visible retryable message or hands it off to the transcript.

flowchart LR
A[Operator sends message] --> B[Control UI outbox]
B --> C[Gateway chat send]
C --> D[Session run lifecycle]
D --> E[Reconnect reconciliation]
E --> F[Transcript or inline retry footer]
Loading

Before merge

  • Resolve merge risk (P1) - The fix adds net production code to reconnect-sensitive outbox state (+42 net production lines); the added exact-ID receipt predicate and second visible state are justified by the existing Gateway lifecycle contract, and no smaller shared owner covers both concerns.
  • Complete next step (P2) - No repair lane is needed: the proposed patch has no supported actionable review finding, and maintainer-authored work remains open for normal review and merge gating.
Agent review details

Security

None.

PR surface

Source +42, Tests +212, Docs +6. Total +260 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 6 51 9 +42
Tests 6 298 86 +212
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 355 95 +260

Review metrics

Metric Value Why it matters
Production versus test delta production +42 net; tests +209 net; docs +6 The production growth is confined to receipt proof and the existing message-footer state, with focused coverage for both matching and non-matching run IDs.

Stored data model

Persistent data-model change detected: vector/embedding metadata: ui/src/pages/chat/chat-thread-items.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the exact Gateway client-run-ID proof and canonical inline pending-send renderer, with the focused reconnect regressions retained as their owner-boundary guard.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the exact Gateway client-run-ID proof and canonical inline pending-send renderer, with the focused reconnect regressions retained as their owner-boundary guard.

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

Yes, source-reproducible with high confidence: current main removes an attempted send only after finding its transcript marker, while the Gateway already exposes the matching active or terminal client run ID.

Is this the best way to solve the issue?

Yes. The patch reuses the Gateway’s exact client-run identity and the existing inline pending-send renderer rather than introducing a second delivery mechanism, setting, or compatibility path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d56e2c42c934.

Labels

Label changes:

  • add P1: A reconnect can make an already accepted operator message appear undelivered or vanish from the conversation during an active agent run.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is maintainer-authored; the PR discussion additionally supplies sanitized mock-Gateway before/after evidence for the reconnect flow.

Label justifications:

  • P1: A reconnect can make an already accepted operator message appear undelivered or vanish from the conversation during an active agent run.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is maintainer-authored; the PR discussion additionally supplies sanitized mock-Gateway before/after evidence for the reconnect flow.

Evidence

What I checked:

Likely related people:

  • Mislav Ivanda: Introduced the existing outbox reconciliation and pending-send presentation that this repair extends. (role: recent area contributor; confidence: high; commits: 3a5cb3847c77; files: ui/src/pages/chat/chat-outbox-drain.ts, ui/src/pages/chat/chat-progress.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Addressing the review checklist before landing:

  • P1 production-LOC merge risk: acknowledged and justified as the review itself concludes — the +42 net production lines are the run-id delivery-proof predicate (reusing the identity contract the live terminal-event retirement already trusts) plus the second visible state in the existing footer renderer. No smaller owner absorbs both; no new storage, config, or API surface. The net-neutral alternative (chip restyling only) would leave the false positive in place.
  • P2 next step: no repair lane needed per the review; landing under explicit maintainer authority with validated native review artifacts and exact-head green CI (run 33113304199).
  • Live-verification partial FAIL: probe artifact, not a regression — the generic text=OpenClaw locator matches 4 elements on the welcome screen, which this diff does not touch. The changed reconnect flow is covered by the 7 mock-gateway e2e flows and the before/after captures above.
  • Stored data model flag: false positive — ui/src/pages/chat/chat-thread-items.ts is a render-side reader (readPendingSendFailure); this PR adds no persistence, schema, or migration surface.

@steipete
steipete merged commit 6e82723 into main Aug 27, 2026
173 checks passed
@steipete
steipete deleted the claude/red-error-investigation-867e7a branch August 27, 2026 20:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…run id (openclaw#131171)

After a reconnect lost the chat.send ack, the outbox reconcile only accepted
the transcript idempotency marker as delivery proof, so a send whose run was
actively streaming parked as a red 'Delivery uncertain' composer chip for the
whole run. The reconcile now also retires a queued send when the session row
reports its run id in activeRunIds or as lastRunId — the same fact live
terminal-event retirement already trusts.

Attempted unconfirmed messages now stay in the conversation as ordinary
bubbles with an amber 'Delivery unconfirmed · Retry' footer (failed keeps the
red 'Not sent'); the duplicate pane banner is suppressed for them since the
bubble owns the outcome. Command chips, never-attempted failures, and storage
errors keep their existing surfaces. Calmer copy for the remaining honest
uncertainty case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant