Skip to content

fix(ui): queue chat input while reconnecting - #102781

Merged
steipete merged 5 commits into
mainfrom
codex/web-offline-input-queue
Jul 10, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/web-offline-input-queue

Conversation

@steipete

@steipete steipete commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #102700

What Problem This Solves

The Control UI disabled ordinary chat input whenever the Gateway disconnected. During intermittent connectivity, users could neither keep composing nor safely queue new text and attachments for delivery after reconnect.

Why This Change Was Made

  • Persist drafts and bounded outboxes in sessionStorage, scoped by Gateway, conversation, and agent.
  • Admit ordinary text and attachments while disconnected, retain the same idempotency key across retries, and replay scopes independently after reconnect.
  • Preserve FIFO ownership across split panes and keep captured route/agent settings with each queued turn.
  • Confirm ambiguous sends against canonical history before retiring them; park unresolved delivery for manual action instead of guessing.
  • Keep slash commands, voice, compaction, goal edits, retry, and steer controls connection-gated.
  • Treat storage capacity, quota, and privacy-mode failures explicitly. Split-pane draft writes use monotonic revisions, clear tombstones, and exact revision-token retries so stale timers cannot overwrite or resurrect newer input.

This deliberately reuses current-tab browser storage. It does not add cross-tab synchronization, background sync, or cold offline app launch.

User Impact

An already-loaded Control UI remains writable through an intermittent Gateway outage. Text and attachments show as Waiting for reconnect, survive a same-tab reload when browser storage succeeds, and continue automatically after the socket reconnects. Inputs remain visible with an actionable failure state when delivery or durable admission cannot be proven safe.

Mobile audit, unchanged by this PR:

  • iOS has mature submitted-message offline support: a SQLite-backed text-and-attachment outbox, cold-relaunch restore, FIFO reconnect replay, captured route/agent scope, stable idempotency UUIDs, and canonical-history ambiguity checks. Unsubmitted composer text and staged attachments remain memory-only, and a healthy direct send still has a pre-journal hard-kill window.
  • Android has partial text-only support through a Room outbox and reconnect replay. Offline attachments are rejected; process-kill/no-ACK recovery lacks canonical-history proof and can duplicate after the Gateway dedupe window or restart; ACK currently removes the row before canonical-history confirmation; and destructive Room migration can drop the queue.

This PR does not claim mobile parity and changes only the web Control UI.

Evidence

  • Focused unit/integration suite across sessions, composer persistence, queue/send, state, pane, page, command execution, and lifecycle: 11 entry files, 55 suites, 563 tests passed.
  • Core and UI test typechecks: node scripts/run-tsgo.mjs -p tsconfig.core.json and node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.ui.json: passed.
  • Targeted Oxlint and oxfmt --check across all 29 changed UI TypeScript files, plus git diff --check: passed.
  • Browser-level offline scenario: 1 passed, 39 skipped. It selects an attachment while offline, verifies its exact data URL in sessionStorage across reload, observes zero sends while offline, reconnects, verifies one chat.send with the stored attachment and idempotency key, and confirms the request count remains exactly one after outbox retirement.
  • Final bundle-based Codex autoreview and three independent persistence, replay, and session/reset reviews: clean on rebased head c252e78cdf97dedb049b8ff6fed04cc4c7e2e841.
  • Exact-head hosted CI/Testbox: run 29111026579, completed successfully on c252e78cdf97dedb049b8ff6fed04cc4c7e2e841; the repo-native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 102781 gate passed in hosted_exact_or_recent_rebase mode and verified the remote PR tree matches the prepared tree.

AI Assistance

Codex assisted with implementation, regression tests, mobile/web source audits, and review. No transcript is attached.

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

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Visual reconnect proof

Offline: the composer and Send button remain enabled while the Gateway reconnects; the prompt is visibly stored as Waiting for reconnect.

Offline queued reconnect input

Reconnected: the same prompt is delivered once, the queue clears, and the assistant final event renders.

Delivered after reconnect

[email protected]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d481ccb2e7

ℹ️ 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".

Comment thread CHANGELOG.md Outdated

### Fixes

- **Control UI offline chat:** keep ordinary text and attachment input available during recoverable Gateway disconnects, persist queued sends in the existing session-scoped store, and resume delivery after reconnect.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove normal-fix changelog entry

Root AGENTS.md says CHANGELOG.md is release-only and must not be edited for normal fixes or direct main changes; release generation derives these entries from merged PRs and direct commits. This fix(ui) change adds a manual changelog line, which can duplicate or skew the generated release notes, so keep this note in the commit/PR metadata instead and remove the changelog edit.

Useful? React with 👍 / 👎.

@steipete steipete self-assigned this Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 10, 2026, 12:24 PM ET / 16:24 UTC.

Summary
The PR enables ordinary Control UI text and attachment sends while reconnecting and reworks the existing sessionStorage composer queue into gateway/session/agent-scoped durable outboxes with hardened replay, command, route, and recovery handling.

PR surface: Source +2940, Tests +5088, Docs +4. Total +8032 across 30 files.

Reproducibility: yes. at source level. Current main has two connection gates that disable composition, and the proposed reset-success/history-failure path deterministically reaches durable failed-command persistence.

Review metrics: 1 noteworthy metric.

  • Persistent queue compatibility: 1 existing v1 browser-state format migrated in place. The PR changes outbox ownership and scoping while retaining and normalizing already-shipped composer state.

Stored data model
Persistent data-model change detected: serialized state: ui/src/lib/sessions/index.test.ts, serialized state: ui/src/lib/sessions/index.ts, serialized state: ui/src/lib/sessions/navigation.test.ts, serialized state: ui/src/pages/chat/chat-pane.ts, serialized state: ui/src/test-helpers/control-ui-e2e.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #102700
Summary: This PR is the direct implementation candidate for the linked Control UI reconnect-composition bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Handle reset-success/history-refresh-failure as completed /clear and add focused regression coverage.

Risk before merge

  • [P1] A user can manually retry a persisted /clear item after its first reset already succeeded, clearing conversation state created after that first attempt.

Maintainer options:

  1. Fix Clear Completion Before Merge (recommended)
    After reset succeeds, convert a rejected history refresh into a visible non-retryable refresh error and prove the persisted /clear row is removed.
  2. Pause Landing
    Hold the PR until the destructive command retry path is corrected because the existing browser proof does not exercise that failure mode.

Next step before merge

  • [P2] The repair is narrow, but the protected maintainer label requires explicit maintainer handling rather than ClawSweeper repair dispatch.

Security
Cleared: The diff stays within first-party UI, docs, and tests and introduces no concrete dependency, workflow, permission, secret-handling, or supply-chain concern.

Review findings

  • [P1] Do not retry /clear after a successful reset — ui/src/pages/chat/chat-history.ts:821
Review details

Best possible solution:

Keep the scoped durable reconnect outbox, but treat a successful destructive command mutation as authoritative; surface any subsequent history refresh failure separately and remove the completed command from the outbox.

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

Yes at source level. Current main has two connection gates that disable composition, and the proposed reset-success/history-failure path deterministically reaches durable failed-command persistence.

Is this the best way to solve the issue?

No in its current form. Reusing the existing durable outbox is the right architectural boundary, but destructive command completion must not be reversed by a later read-only refresh failure.

Full review comments:

  • [P1] Do not retry /clear after a successful reset — ui/src/pages/chat/chat-history.ts:821
    If sessions.reset succeeds but the follow-up loadChatHistory rejects, this await rejects after the session was already cleared. The durable command catch then stores /clear as failed/retryable, so retrying can clear newer conversation state. Treat the reload failure as a post-reset UI error and complete the queued command.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 session-state: The current queued /clear path can apply a destructive session mutation again against newer conversation state.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (recording): Directly inspected screenshots and a browser recording show the offline queued state and delivery after reconnection; this proves the main flow but not the separate queued /clear failure path.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a normal-priority Control UI reconnect bug fix with browser-only, limited blast radius.
  • merge-risk: 🚨 session-state: The current queued /clear path can apply a destructive session mutation again against newer conversation state.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (recording): Directly inspected screenshots and a browser recording show the offline queued state and delivery after reconnection; this proves the main flow but not the separate queued /clear failure path.
  • proof: sufficient: Contributor real behavior proof is sufficient. Directly inspected screenshots and a browser recording show the offline queued state and delivery after reconnection; this proves the main flow but not the separate queued /clear failure path.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. Directly inspected screenshots and a browser recording show the offline queued state and delivery after reconnection; this proves the main flow but not the separate queued /clear failure path.
Evidence reviewed

PR surface:

Source +2940, Tests +5088, Docs +4. Total +8032 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 18 3488 548 +2940
Tests 11 5704 616 +5088
Docs 1 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 30 9197 1165 +8032

What I checked:

  • Current main still reproduces the central bug: Current main requires both props.connected and props.canSend to compose, while the pane also sets canSend false when disconnected, so an already-mounted reconnecting chat remains unwritable. (ui/src/pages/chat/chat-view.ts:176, cbfa7d4aa73c)
  • Successful mutation can become a retryable failure: After sessions.reset succeeds and local chat state is cleared, clearChatHistory awaits loadChatHistory without handling a refresh-only rejection as completed mutation success. (ui/src/pages/chat/chat-history.ts:821, e040e1a526e2)
  • Durable command caller persists the escaped rejection: The outbox drain catch writes the claimed local command back with sendState: "failed", leaving /clear available for manual retry after the reset already completed. (ui/src/pages/chat/chat-send.ts:1738, e040e1a526e2)
  • Existing regression coverage misses this distinction: The focused queued-clear test verifies retry when sessions.reset itself fails, but does not cover reset success followed by chat.history failure. (ui/src/pages/chat/chat-send.test.ts:4176, e040e1a526e2)
  • Shipped browser-state compatibility is intentionally covered: The branch retains the v1 storage key and adds tests for shipped bare-main aliases, legacy tombstones, migration write failures, queue consolidation, and offline reload. (ui/src/pages/chat/composer-persistence.test.ts:366, e040e1a526e2)
  • Real browser proof supports the main reconnect flow: Direct inspection of the supplied screenshots and WebM shows the composer available with a visible Waiting for reconnect item, followed by a cleared queue and delivered response after reconnection. (e040e1a526e2)

Likely related people:

  • steipete: Current-main blame and merged history connect him to the Control UI composer gate, reconnect shell, pane wiring, and central chat-state paths beyond this proposal. (role: recent area contributor; confidence: high; commits: a14bbd1f1f55, e596e2850d8e; files: ui/src/pages/chat/chat-view.ts, ui/src/pages/chat/chat-pane.ts, ui/src/pages/chat/chat-send.ts)
  • BunsDev: Earlier merged Control UI chat work associated with the existing queue and composer surface makes this contributor relevant to the original behavior and compatibility boundary. (role: feature introducer; confidence: medium; commits: e596e2850d8e; files: ui/src/ui/app-chat.ts, ui/src/test-helpers/control-ui-e2e.ts)
  • JC: Recent current-main history touches the central chat-send path, making this contributor relevant to replay and chat-dispatch review. (role: recent adjacent contributor; confidence: medium; commits: 59e95fe3fd8d; files: ui/src/pages/chat/chat-send.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (3 earlier review cycles)
  • reviewed 2026-07-09T12:29:20.749Z sha d481ccb :: found issues before merge. :: [P2] Remove the normal-fix changelog entry
  • reviewed 2026-07-09T14:07:42.636Z sha de35b83 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-09T14:25:17.022Z sha de35b83 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Jul 9, 2026
@steipete
steipete force-pushed the codex/web-offline-input-queue branch from de35b83 to e040e1a Compare July 10, 2026 15:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e040e1a526

ℹ️ 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".

clearSideResultTerminalRuns: true,
clearRunStatus: !hadActiveRun,
});
await loadChatHistory(state);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle post-reset history reload failures

When sessions.reset succeeds but the follow-up chat.history request rejects (for example during a transient reconnect), this await is now outside the try/catch, so /clear rejects after already clearing/resetting the session. In the durable queued-command path that means the clear item is marked failed/retryable even though the reset happened, and a user retry can clear a later conversation state; keep the history reload failure handled as a post-reset UI refresh error instead of making the command fail.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed 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 Jul 10, 2026
@steipete
steipete force-pushed the codex/web-offline-input-queue branch from e040e1a to c252e78 Compare July 10, 2026 17:27
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof

Reviewed exact head: c252e78cdf97dedb049b8ff6fed04cc4c7e2e841.

  • Addressed the ClawSweeper /clear finding: reset success is authoritative even if the follow-up history refresh fails, so a completed destructive command cannot become retryable. Focused regressions cover reset-success/history-failure and the surrounding uncertain-command/reconnect paths.
  • Focused unit/integration proof: 11 entry files, 55 suites, 563 tests passed.
  • Type proof: node scripts/run-tsgo.mjs -p tsconfig.core.json and node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.ui.json passed.
  • Static proof: targeted Oxlint and oxfmt --check across all 29 changed UI TypeScript files, plus git diff --check origin/main...HEAD, passed.
  • Browser proof: the focused Control UI offline/reconnect E2E passed (1 passed, 39 skipped), including offline attachment persistence across reload and exactly one reconnect send with the stored idempotency key.
  • Fresh branch-mode Codex autoreview: clean. Three independent exact-diff reviews of persistence, replay, and session/reset behavior: clean.
  • Hosted exact-head CI/Testbox: run 29111026579 completed successfully on the reviewed SHA; all 46 executed jobs passed and 8 inapplicable jobs skipped.
  • Native landing gate: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 102781 passed in hosted_exact_or_recent_rebase mode and verified the remote PR tree matches the prepared tree.

Known scope limits are intentional and documented in the PR: current-tab sessionStorage, no cross-tab/background sync/cold offline launch, and no claim of iOS/Android parity.

@steipete
steipete merged commit 188535b into main Jul 10, 2026
84 checks passed
@steipete
steipete deleted the codex/web-offline-input-queue branch July 10, 2026 17:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c252e78cdf

ℹ️ 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".

return "failed";
}
removeQueuedMessageWithoutReleasing(host, id, sessionKey);
const retireOnAck = ack.status === "ok" || storageMode === "memory";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep accepted sends visible before terminal events

For ordinary connected sends the Gateway accepts with a nonterminal started ACK, not ok (checked src/gateway/server-methods/chat.ts, where accepted chat.send responds with { status: "started" }). This new gate therefore leaves every durable send in sending instead of appending/materializing the user's turn, and renderChatQueue filters sending rows, so the submitted prompt disappears from both the transcript and visible queue until a final chat event arrives; during streaming the assistant can render without the user message. Please keep accepted nonterminal sends visible while still retaining the durable row for recovery.

Useful? React with 👍 / 👎.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
* fix(ui): queue chat input while reconnecting

* test(ui): strengthen offline reconnect proof

* chore: follow release-only changelog policy

* fix(ui): harden offline queue replay

* fix(ui): harden offline replay recovery
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 merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Control UI cannot queue input while Gateway reconnects

1 participant