Skip to content

feat(android): durable offline chat with attachments and history-proof retirement - #104089

Merged
steipete merged 8 commits into
mainfrom
claude/android-durable-offline-chat-594abf
Jul 11, 2026
Merged

steipete merged 8 commits into
mainfrom
claude/android-durable-offline-chat-594abf

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Android chat could lose or duplicate submitted user input around process death and reconnects, and offline sends with attachments were rejected outright. Closes #104087.

Confirmed on main before this change:

  • Healthy sends bypassed the durable outbox: kill the app between composer-clear and history persistence and the message is gone with no recovery owner.
  • Queued rows were deleted on a non-terminal chat.send ACK. The gateway ACKs status:"started" before the user turn is written ([Bug] WebChat: optimistic USER messages are lost (not just hidden) when chat.send returns before the durable transcript lands — full-replace history reconcile drops them #86946), and its idempotency dedupe is an in-memory 5-minute map, so delete-on-ACK loses input on a gateway crash and blind replay can duplicate agent runs.
  • Picked images and voice notes lived only in in-memory base64 composer state; offline attachment sends were refused.
  • Bare main rows re-resolved against current defaults at every flush, so a default-agent change could redirect captured input.
  • The Room store used destructive migration while the shipped v2 schema (release tag v2026.7.1-beta.3) holds queued user input: schema bumps dropped unsent messages.
  • Slash-command text queued offline auto-replayed silently on reconnect.

Why This Change Was Made

Bring Android to the durability bar iOS (OpenClawKit outbox) and web (#102781) already ship, with an Android-native design that matches the verified gateway contract: only a chat.history row carrying idempotencyKey = "<rowId>:user" proves delivery; an ACK proves nothing durable.

Design highlights:

  • Journal-all sends. Every send (online or offline; text, images, voice notes) is admitted to the per-gateway Room outbox before the composer clears or any network attempt; the row id is the chat.send idempotency key across every retry and restart.
  • History-proof retirement. ACKs move rows to accepted; only canonical-history proof deletes them (late proof also retires parked rows, so a manual retry can never double-send a delivered turn). Ambiguous outcomes — crash mid-send, lost ACK, gateway restart before the transcript write, timeout without proof after a double-read — park as delivery unconfirmed for explicit Retry/Delete. An ambiguous row blocks only its own session's queue; retrying it keeps queued same-session successors behind it.
  • Durable attachments. Bytes persist as chunked BLOBs (512 KB chunks under Android's ~2 MB CursorWindow row cap; 8 MB/message, 48 MB/gateway) admitted and retired in the same transaction as their command row, so bytes can never orphan; cleanup covers confirm, delete, expiry, session delete, and gateway sign-out/forget.
  • Pinned routing. Pre-hello main rows resolve exactly once, at first dispatch, and are pinned; later default-agent changes never retarget captured input.
  • Connection-gated commands. Slash-command rows carry the capturing connection epoch and park (connection changed; retry manually) instead of auto-replaying across reconnects.
  • Real migrations. Room v2 -> v3 preserves queued rows; v1 -> v3 rebuilds the disposable transcript cache; the destructive-migration fallback is removed and the outbox-vs-cache migration contract is documented at the builder. Draft contract stays "durability starts at submission" (documented in docs/platforms/android.md), matching iOS and web.

Builds on the reviewed fail-closed ambiguous-delivery model from #103862 (its head commit is cherry-picked as the first commit of this branch, with authorship preserved); landing this supersedes #103862 and #103273.

User Impact

Sending a chat message on Android now survives app kills, device reboots, gateway restarts, and reconnects: it is either visible in canonical history exactly once, or visibly parked with explicit Retry/Delete. Offline composing now works with images and voice notes, with bounded on-device storage and actionable queue/storage-full errors that never eat the draft. Queued input survives app upgrades.

Evidence

  • Unit gates: :app:testPlayDebugUnitTest 1135 tests, 0 failures and :app:ktlintCheck clean (local run of the CI lane command; new coverage: Room v2/v1 migration fixtures built from shipped DDL, attachment byte round-trip across reopen, both storage caps with recovery-after-delete, cascade deletes, gated-epoch persistence, retry ordering, restart-orphan confirm-vs-park, not-enqueued direct sends, per-session ambiguity blocking, queue-full draft preservation).
  • Live emulator scenario (scratch source gateway + mock model, real pairing): text + picked image queued offline -> app force-stop and a full device reboot -> row restored from Room with its attachment -> reconnect -> sent exactly once -> canonical history bubble. The gateway transcript contains exactly one user turn with the row's idempotency key, and the on-device outbox drained to 0 commands/attachments/chunks afterwards:
    • Queued offline with attachment: queued offline
    • Restored after force-stop + reboot, still offline: restored
    • Reconciled to canonical history after reconnect: reconciled
    • Transcript proof: exactly one "idempotencyKey":"aba661c2-f3c6-407e-9e85-5392779b1880:user" row in the session JSONL, matching the on-device Room row id; device DB after confirmation: 0 outbox commands / 0 attachments / 0 chunks.
  • Autoreview (Codex gpt-5.5, xhigh): three rounds; rounds 1-2 findings (not-enqueued direct sends must requeue not delete; history-confirming a blocking head must restart the flush; retry must not reorder past queued successors) each fixed with regression tests; final round clean — "patch is correct (0.86), no accepted/actionable findings".
  • The emulator pass also exposed a pre-existing restore-visibility race (failed reconnect attempts clear published outbox rows and never republish, hiding queued sends on offline cold start) — fixed in onDisconnected and verified live.
  • Known gaps: voice notes are byte-covered in unit tests but were not mic-driven in the emulator scenario; CI variant lanes (Linux, thirdParty, Android lint) run on this PR.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android size: XL maintainer Maintainer-authored PR labels Jul 11, 2026

@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: 4e4f9a05c4

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

item: ChatOutboxItem,
attachments: List<OutgoingAttachment>,
) {
if (normalizeRequestedSessionKey(item.sessionKey) != _sessionKey.value) return

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 ownership for hidden flushed sends

When the outbox flush dispatches a row for a session other than the one currently open, this return skips adding the row id to any pending/unresolved ownership. Accepted rows without local ownership are treated as blockers, and handleChatEvent ignores terminal events for non-current sessions, so if that hidden-session run is still in flight during the two immediate history probes, the row stays Accepted and later queued rows in the same session never flush until the user opens that session or reconnects. Please track non-UI run ownership or otherwise reconcile hidden-session completions before returning here.

Useful? React with 👍 / 👎.

@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 11, 2026, 1:08 AM ET / 05:08 UTC.

Summary
The PR adds a Room-backed Android chat outbox for all sends and attachments, canonical-history retirement, connection-gated command replay, pinned routing, preserved migrations, and explicit ambiguous-delivery recovery.

PR surface: Docs +1, Other +2317. Total +2318 across 13 files.

Reproducibility: yes. Source inspection gives a high-confidence concurrency path: render Delete for a queued row, let reconnect flush claim queued-to-sending, then execute the already-captured Delete callback while the claimed send continues.

Review metrics: 2 noteworthy metrics.

  • Persisted schema: 1 version bump, 2 tables added, 1 column added. Queued user input and attachment bytes become migration-protected state, making upgrade behavior merge-critical.
  • Attachment limits: 512 KB chunks, 8 MB/message, 48 MB/gateway. These limits define durable admission and recovery behavior under device storage pressure.

Stored data model
Persistent data-model change detected: database schema: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatTranscriptCache.kt, migration/backfill/repair: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatTranscriptCache.kt. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #104087
Summary: This PR is the implementation candidate for the paired Android durability issue and incorporates the narrower ambiguous-send work.

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] Make deletion status-conditional and add deterministic claim/delete race coverage.
  • Rebase and rerun exact-head Android behavior plus v1/v2 upgrade validation.

Risk before merge

  • [P1] A stale queued-row Delete action can race a reconnect or direct-send claim, causing input the user canceled to reach the gateway after its durable command and attachment ownership were removed.
  • [P1] The PR changes persisted Room state and message-retirement semantics; fresh-install and shipped-schema upgrade validation must apply to the eventual rebased exact head.

Maintainer options:

  1. Make delete and dispatch mutually exclusive (recommended)
    Require a deletable status in the transaction that removes the command and attachments, then add deterministic claim-before-delete and delete-before-claim tests.
  2. Pause for deletion-semantics review
    If Delete is intentionally best-effort during reconnect, define the visible cancellation contract and prove behavior when dispatch wins the race.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Make outbox deletion status-conditional so a stale queued Delete tap cannot remove a row after queued→sending claim; add focused concurrent claim/delete regression tests for both orderings and preserve history reconciliation for dispatched sends.

Next step before merge

  • [P2] The blocker has a narrow mechanical repair in the outbox DAO/controller boundary, and focused regression coverage can verify both race orderings.

Security
Cleared: The patch adds bounded local Room BLOB storage but no new dependency, permission, secret access, workflow, package-resolution, or downloaded-code execution surface.

Review findings

  • [P1] Make Delete lose once dispatch has claimed the row — apps/android/app/src/main/java/ai/openclaw/app/chat/ChatCommandOutbox.kt:567-570
Review details

Best possible solution:

Make user deletion a queued-or-failed compare-and-set operation that loses once dispatch claims the row, while preserving canonical-history reconciliation for every request that entered the transport.

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

Yes. Source inspection gives a high-confidence concurrency path: render Delete for a queued row, let reconnect flush claim queued-to-sending, then execute the already-captured Delete callback while the claimed send continues.

Is this the best way to solve the issue?

No, not in its current form. Journal-all admission and canonical-history retirement are the correct maintainable design, but deletion must participate in the same atomic state transition as dispatch so ownership cannot disappear mid-send.

Full review comments:

  • [P1] Make Delete lose once dispatch has claimed the row — apps/android/app/src/main/java/ai/openclaw/app/chat/ChatCommandOutbox.kt:567-570
    deleteOutboxCommand can run from a queued bubble while reconnect flush or the direct path concurrently wins claimForSending. Because this method deletes by id regardless of status, the command and attachment rows disappear even though sendOutboxItem continues the already-claimed network send; the later Accepted update returns 0, leaving a delivered-or-in-flight request without its durable reconciliation owner. Make deletion atomically require Queued or Failed, and add a claim-before-delete regression test.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR changes a core Android chat-delivery workflow where a race can send input the user attempted to delete.
  • merge-risk: 🚨 compatibility: The patch changes the shipped Room schema and upgrade behavior for persisted queued input.
  • merge-risk: 🚨 message-delivery: The new state machine and delete/claim race can change whether a queued message is canceled or delivered.
  • merge-risk: 🚨 session-state: The patch changes per-session queue ownership, routing pinning, and canonical-history reconciliation.
  • 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 (screenshot): The PR includes after-fix emulator proof of offline text-plus-image admission, force-stop and device-reboot restoration, exactly-once canonical-history delivery, and transactional cleanup; it does not cover the delete/claim race.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes after-fix emulator proof of offline text-plus-image admission, force-stop and device-reboot restoration, exactly-once canonical-history delivery, and transactional cleanup; it does not cover the delete/claim race.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR includes after-fix emulator proof of offline text-plus-image admission, force-stop and device-reboot restoration, exactly-once canonical-history delivery, and transactional cleanup; it does not cover the delete/claim race.
Evidence reviewed

PR surface:

Docs +1, Other +2317. Total +2318 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 12 2684 367 +2317
Total 13 2685 367 +2318

Acceptance criteria:

  • [P1] cd apps/android && ./gradlew :app:testPlayDebugUnitTest --tests ai.openclaw.app.chat.RoomChatCommandOutboxTest --tests ai.openclaw.app.chat.ChatControllerOutboxTest --tests ai.openclaw.app.chat.ChatCacheDatabaseMigrationTest.
  • [P1] cd apps/android && ./gradlew :app:ktlintCheck.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • NianJiuZst: Authored the merged Android interrupted-send fix that established the fail-closed outbox model extended by this PR. (role: introduced ambiguous-delivery behavior; confidence: high; commits: df36c821a484; files: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt, apps/android/app/src/main/java/ai/openclaw/app/chat/ChatCommandOutbox.kt)
  • steipete: Authored the current broader Android durability branch and the adjacent merged web offline-outbox implementation. (role: recent area contributor; confidence: high; commits: d9d6046b01db, 71445ce98f8d, 188535b097ef; files: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt, apps/android/app/src/main/java/ai/openclaw/app/chat/ChatCommandOutbox.kt, apps/android/app/src/main/java/ai/openclaw/app/chat/ChatTranscriptCache.kt)
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 (1 earlier review cycle)
  • reviewed 2026-07-11T03:03:41.839Z sha 1bb30d3 :: found issues before merge. :: [P1] Retain ownership for flushed background-session sends

steipete added 8 commits July 10, 2026 20:26
…f retirement

Every chat send is journaled to the per-gateway Room outbox before any
network attempt, so process death always has one durable recovery owner.
Rows survive gateway ACKs as 'accepted' and retire only once the turn is
proven in canonical chat.history by idempotency key; ambiguous outcomes
(lost ACK, kill mid-send, gateway restart before the transcript write)
park as delivery-unconfirmed for explicit retry, per the fail-closed
model #103273 landed. An unproven accepted head briefly holds only its
own session's queue, and retrying a parked head re-orders still-queued
successors behind it. Offline sends now accept picked images and voice
notes; attachment bytes persist as chunked BLOBs (512 KB chunks, 8 MB
per message, 48 MB per gateway) admitted and retired atomically with
their row. Pre-hello 'main' rows pin to the canonical session at first
dispatch so later default-agent changes cannot retarget captured input;
slash commands are connection-gated by a persisted epoch (legacy queued
command rows migrate to a never-matching sentinel) and never auto-replay
across reconnects. The Room store moves to schema v4 on top of v3's
data-parking migration, adding the epoch column and attachment tables
while preserving queued rows. The queued->sending claim is an atomic
compare-and-set shared by the direct dispatch and the flush loop, the
direct path waits for the startup recovery sweep before claiming, and
failed reconnect attempts republish outbox rows so queued sends stay
visible on offline cold starts.

Proof: 1151 Android unit tests and :app:ktlintCheck green (new
migration, storage, and controller coverage for admission, restarts,
claims, pinning, gating, ordering, and byte round-trips); a live
emulator scenario on the pre-integration build queued text+image
offline, survived force-stop plus a device reboot, resent exactly once
on reconnect (single <rowId>:user turn in the gateway transcript), and
drained the outbox after canonical-history confirmation.

Closes #104087.
The direct send's network phase now runs in the controller scope, so a
cancelled UI scope (leaving the chat screen mid-send) can no longer
strand a claimed row in 'sending' with no user action available; the
dispatch completes and settles the row exactly once. Direct-path state
persistence failures also re-arm the startup recovery sweep, mirroring
the flush path's fail-closed handling.
A direct-send claim that fails to persist no longer reads as a lost race:
the admitted row is handed to the flush lane so a healthy connection still
delivers it, and the flush path's fail-closed handling owns any repeated
storage failure instead of the UI reporting success with no active owner.
…ery send path

The direct dispatch now rechecks a slash command's connection epoch after
its durable claim, so a reconnect between admission and dispatch parks the
command instead of replaying it on the new connection. Parking a stale
gated row only counts once the write persists; a storage failure drops
health, re-arms recovery, and halts the flush pass instead of spinning or
dispatching the stale row.
…hip checks

A chat.send ACK can return a run id that differs from the row's
idempotency key (the direct path transfers local run ownership to it).
Ownership, in-flight, backlog, and timeout-park checks now consider both
ids, so reconciliation can no longer park — and Retry can no longer
duplicate — a turn that is still running on the gateway.
…aps in the outbox

Flushed sends acked under a divergent run id now transfer local run
ownership like the direct path, so live runs cannot time out and surface
spurious errors for delivered turns. A session pin that cannot persist
stops the dispatch while the row is still safely queued. Reconcile and
timeout parking only report changes their writes actually persisted,
failing closed on storage errors.
@steipete
steipete force-pushed the claude/android-durable-offline-chat-594abf branch from 1bb30d3 to b1aaa64 Compare July 11, 2026 04:58

@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: b1aaa64be7

ℹ️ 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 on lines +865 to +868
if (journaled.gatedEpoch != null && journaled.gatedEpoch != currentCacheScope()?.connectionGeneration) {
// A reconnect landed between admission and this claim; command-shaped input never
// auto-replays across connection epochs, so the claimed row parks for explicit retry.
persistJournaledSendState(journaled, ChatOutboxStatus.Failed, OUTBOX_CONNECTION_CHANGED_ERROR)

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 Re-check the connection epoch at send time

When a slash-command row is claimed while healthy, this is the last epoch check before dispatch; the later chat.send is only bound to the stable gateway id, and GatewaySession.readyConnection accepts any ready connection with that same id. If the gateway reconnects after this check but before the request selects a connection, the command is sent on the new connection instead of being parked as connection changed, which defeats the new manual-retry protection for slash commands. Re-check the captured epoch immediately around the actual send (the flush path has the same stable-id-only request gap).

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 1c08d96 into main Jul 11, 2026
79 checks passed
@steipete
steipete deleted the claude/android-durable-offline-chat-594abf branch July 11, 2026 05:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…f retirement (openclaw#104089)

* feat(android): durable offline chat with attachments and history-proof retirement

Every chat send is journaled to the per-gateway Room outbox before any
network attempt, so process death always has one durable recovery owner.
Rows survive gateway ACKs as 'accepted' and retire only once the turn is
proven in canonical chat.history by idempotency key; ambiguous outcomes
(lost ACK, kill mid-send, gateway restart before the transcript write)
park as delivery-unconfirmed for explicit retry, per the fail-closed
model openclaw#103273 landed. An unproven accepted head briefly holds only its
own session's queue, and retrying a parked head re-orders still-queued
successors behind it. Offline sends now accept picked images and voice
notes; attachment bytes persist as chunked BLOBs (512 KB chunks, 8 MB
per message, 48 MB per gateway) admitted and retired atomically with
their row. Pre-hello 'main' rows pin to the canonical session at first
dispatch so later default-agent changes cannot retarget captured input;
slash commands are connection-gated by a persisted epoch (legacy queued
command rows migrate to a never-matching sentinel) and never auto-replay
across reconnects. The Room store moves to schema v4 on top of v3's
data-parking migration, adding the epoch column and attachment tables
while preserving queued rows. The queued->sending claim is an atomic
compare-and-set shared by the direct dispatch and the flush loop, the
direct path waits for the startup recovery sweep before claiming, and
failed reconnect attempts republish outbox rows so queued sends stay
visible on offline cold starts.

Proof: 1151 Android unit tests and :app:ktlintCheck green (new
migration, storage, and controller coverage for admission, restarts,
claims, pinning, gating, ordering, and byte round-trips); a live
emulator scenario on the pre-integration build queued text+image
offline, survived force-stop plus a device reboot, resent exactly once
on reconnect (single <rowId>:user turn in the gateway transcript), and
drained the outbox after canonical-history confirmation.

Closes openclaw#104087.

* fix(android): rearm outbox recovery when direct-send state persistence fails

* fix(android): keep direct dispatch alive across caller cancellation

The direct send's network phase now runs in the controller scope, so a
cancelled UI scope (leaving the chat screen mid-send) can no longer
strand a claimed row in 'sending' with no user action available; the
dispatch completes and settles the row exactly once. Direct-path state
persistence failures also re-arm the startup recovery sweep, mirroring
the flush path's fail-closed handling.

* fix(android): hand claim-persistence failures to the flush lane

A direct-send claim that fails to persist no longer reads as a lost race:
the admitted row is handed to the flush lane so a healthy connection still
delivers it, and the flush path's fail-closed handling owns any repeated
storage failure instead of the UI reporting success with no active owner.

* fix(android): enforce connection gating and fail-closed parking on every send path

The direct dispatch now rechecks a slash command's connection epoch after
its durable claim, so a reconnect between admission and dispatch parks the
command instead of replaying it on the new connection. Parking a stale
gated row only counts once the write persists; a storage failure drops
health, re-arms recovery, and halts the flush pass instead of spinning or
dispatching the stale row.

* fix(android): recognize gateway-acknowledged run ids in outbox ownership checks

A chat.send ACK can return a run id that differs from the row's
idempotency key (the direct path transfers local run ownership to it).
Ownership, in-flight, backlog, and timeout-park checks now consider both
ids, so reconciliation can no longer park — and Retry can no longer
duplicate — a turn that is still running on the gateway.

* fix(android): close remaining ack-ownership and persistence-failure gaps in the outbox

Flushed sends acked under a divergent run id now transfer local run
ownership like the direct path, so live runs cannot time out and surface
spurious errors for delivered turns. A session pin that cannot persist
stops the dispatch while the row is still safely queued. Reconcile and
timeout parking only report changes their writes actually persisted,
failing closed on storage errors.

* docs(android): record why acknowledged run ids stay in-memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

Android chat: submitted input not durable across process death; offline attachments rejected

1 participant