Skip to content

fix(android): keep deleted queued messages from reappearing - #136161

Merged
steipete merged 2 commits into
mainfrom
codex/android-outbox-publication
Sep 2, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/android-outbox-publication

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: #135796, #135961.

What Problem This Solves

Android could display a deleted queued message again when an older completed outbox read resumed after the deletion refresh. An older successful read could also mark restoration complete after a newer read failed. Both are stale presentation, not evidence that deleted database rows or network sends were recreated.

Why This Change Was Made

The original publisher fenced different Gateway scopes, but not two reads for the same scope. Each publication now registers a revision and its exact Gateway scope under the existing UI-application lock, reads outside that lock, and applies only if both still match. Explicit Gateway UI invalidation advances the same revision, including when the endpoint remains selected. A failed latest read preserves the last rows while leaving restoration incomplete; an older success cannot override that result.

The first candidate serialized the complete read and publication. Review exposed a real drawback: an unrelated suspended read could hold up visible Delete or a newly claimed direct send. That load-held mutex is removed. Publication stays best-effort at caller cancellation because the existing send path may already own a durable Sending claim and must still transfer dispatch to the controller-owned coroutine. Room transactions and attempt/status comparisons remain the persistence and delivery owners.

User Impact

Deleted input stays removed when delayed refreshes finish, and sends do not wait behind an unrelated publication. Gateway separation, queue order, delivery receipts, retries, and Stop semantics are retained. Delete removes the local queued copy; it cannot undo a message already accepted by the Gateway. There are no layout, configuration, dependency, storage-schema, migration, or wire-protocol changes.

Evidence

Current source: 14c1787cad7cb836ae1df2dd71284d014941b312, based on c35350c92d8609d28dfcf190197ec22583e62ea3.

  • Original-main RED: the final regression tests ran against the exact original ChatController.kt from the base commit. Two tests ran and failed at observable assertions: a deleted row was emitted again through StateFlow, and an older successful read masked a newer load failure. Neither failure was a timeout. The revision candidate was restored byte-for-byte afterward.
  • Rejected-mutex RED: two tests failed on the previous PR head because visible Delete and an active caller's claimed send waited behind an unrelated held read. A separate existing Gateway-switch test failed when a retired read repopulated explicitly cleared UI state. These are distinct from the original-main defect.
  • Current candidate GREEN: all 77 outbox tests in Play and 77 in ThirdParty passed, with zero failures/errors/skips, plus Kotlin lint. The tests cover collected StateFlow emissions after Delete, latest failed-load ownership and subsequent recovery, explicit same-scope invalidation and A→B→A delivery, and cancellation during an own publication or network response. The active-caller case requires exactly one dispatch before either caller cancellation or release of the unrelated read.
  • Fresh full build: all 2,578 Play tests across 207 suites, plus the 77 ThirdParty outbox tests, passed with zero failures/errors/skips; Kotlin lint and both normal app/test APKs passed in the same invocation. Source and dependency-selection metadata were unchanged. The two APK signatures match the fresh task debug key.
  • Fresh live UI at this head: normal onboarding against an isolated real Gateway, an offline queued message, its actual Delete action, offline Refresh, cold relaunch, saved-auth reconnect and another actual Refresh. The deleted command and related delivery rows were absent after deletion and cold relaunch. Five distinct native methods passed; see the retained setup failures below. Reconnect is additional bounded UI observation, not a sixth native test or another database assertion.
  • Exact-head CI: run 33616002483, attempt 2 and the required CI gate are successful, including Android Play, ThirdParty, Wear, builds and Kotlin lint.
  • Review: a fresh managed Codex review is scoped-clean at P0. Independent manual review covered the complete publication owner, its startup, lifecycle, history, direct-send, FIFO, retry and deletion callers, the Room implementation, and the pinned coroutine cancellation contract. No further actionable finding remains from those reviews.

The same original unordered publication owner is present in source at stable tag v2026.8.2; that is source provenance, not a claim about an Android store upload. The historical CI failure that prompted this investigation did not record its interleaving, so its exact cause is not claimed as established.

Production: +12/-15, net -3. Tests: +160/-30, net +130. Docs: +1. Existing regression fixtures are extended, with one focused failure-state test in the same suite; there is no production test seam or new test file.

Review Follow-through and Proof Limits

The prior review's identical pre-Delete Queued snapshot does not itself prove an intermediate reappearance: StateFlow suppresses equal values, and the UI does not optimistically remove that row. The stronger tests instead require visible deletion while the old read is still held and then observe every emitted row list; they reproduce a real re-emission on the original publisher. The separately demonstrated head-of-line delay is repaired by revision fencing rather than serialized I/O.

The latest ClawSweeper review at this exact head has no actionable finding. Its Rank-up move to finish the current-head Android checks is satisfied. This is an explicitly requested maintainer repair and landing; current CODEOWNERS does not restrict the touched Android paths, and live main rules require the CI gate and linear history, not an independent PR approval.

The live run used a fresh API36 emulator, fresh task credentials and APKs built from this head. It used one normal device-role approval and one normal node-capability approval, not a preseeded pairing database. Two onboarding attempts are preserved as failures: the first waited for an automatic reconnect after a terminal role-upgrade response that requires a normal retry; the second reached node approval, but the operator response missed the harness deadline and its stale approval basis was correctly refused before any approval RPC. A third normal attempt completed without changing the APK, increasing timeouts, clearing data or resetting authentication. All five distinct native methods then passed (seven executions total).

The actual cold-relaunch PIDs were 2896 and 3073. The earlier test process had already exited before force-stop, so this is not a forced mid-flight kill. The final reconnect/Refresh observation lasted 20.287 seconds with two samples over 4.188 seconds before Refresh and two over 4.165 seconds afterward. These bounded observations do not force the stale-read race or establish indefinite stability; the separate owner tests prove those interleavings. Live multi-Gateway switching, a real provider turn and physical Android hardware are not claimed.

The first CI security job failed its unauthenticated Git history fetch before the scan. One same-head retry through the workflow's normal alternate runner passed; no credential policy, security check or source was changed. The fresh local harness also retained a missing emulator-registration port setting and an absent-package preflight exit as setup failures, not product regressions. The previous head's proof remains retained but is not substituted for this head.

All new disposable Gateway credentials/state, emulator data, ADB/debug keys and task processes have now been removed. Allocated ports are free, retained text contains no exact task-token match, and the operator's Android metadata is unchanged. Screenshots and native results were independently inspected; media remains local and unuploaded.

Named build follow-up: Android release-task detection mistakes a --tests filter containing AfterRelease for a release-build request. That first attempt stopped during configuration before any test ran. An exact selector then produced the original RED. No signing credentials, timeouts, or assertions were weakened; that build-owner repair is separate.

Release note: Android keeps deleted queued messages removed when delayed refreshes finish without making sends wait behind an unrelated refresh.

@clawsweeper

clawsweeper Bot commented Sep 2, 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: android App: android size: S maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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. labels Sep 2, 2026
@steipete
steipete force-pushed the codex/android-outbox-publication branch from 9dbf4e2 to 079471c Compare September 2, 2026 08:34
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 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. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 6:44 AM ET / 10:44 UTC.

ClawSweeper review

What this changes

The PR makes Android queued-message refreshes discard stale results so deleting an offline message remains visible while other refreshes or sends continue independently.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The patch is correct and still needed: current main retains the unfenced outbox publisher. No introduced defect was found; this maintainer-labelled Member PR needs an explicit maintainer merge decision rather than automated closure.

Priority: P1
Reviewed head: 14c1787cad7cb836ae1df2dd71284d014941b312
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, production-net-negative repair with strong race coverage and no actionable review finding; final landing remains maintainer-owned.
Proof confidence 🌊 off-meta tidepool Not applicable: This Member-authored PR is exempt from the external-contributor proof gate; its supplied exact-head Android emulator and CI evidence is consistent with the reviewed UI publication path.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This Member-authored PR is exempt from the external-contributor proof gate; its supplied exact-head Android emulator and CI evidence is consistent with the reviewed UI publication path.
Evidence reviewed 7 items Revision-fenced publication owner: The PR captures the gateway scope and increments a publication revision under the existing UI-application lock, loads outside that lock, then applies only the latest matching revision and scope.
Lifecycle caller preserves the fence: Gateway teardown calls ChatController scope invalidation before clearing the connected endpoint, and the controller invalidation increments the same revision while clearing queued UI state.
Durable deletion remains the owner: Delete performs the Room-backed durable outbox mutation before refreshing presentation; the revision fence only controls stale UI publication and does not recreate rows or dispatch messages.
Findings None None.
Security None None.

How this fits together

Android ChatController reads durable, gateway-scoped outbox rows and publishes them to queued-message UI state. Reconnect, deletion, and gateway replacement trigger publications; durable outbox ownership remains responsible for deletion and sending.

flowchart LR
  A[Durable Android outbox] --> B[Chat controller]
  C[Reconnect, delete, or gateway change] --> B
  B --> D[Revision and scope fence]
  D --> E[Queued message UI]
  E --> F[Retry, delete, or send]
  F --> A
Loading

Decision needed

Question Recommendation
Should this clean, exact-head Android outbox repair be merged? Merge the current head: Land the revision-fenced publication repair with its focused race coverage and successful exact-head Android checks.

Why: The PR is authored by a repository Member and carries the protected maintainer label, so automated cleanup must leave the landing decision to a maintainer despite the clean technical review.

Before merge

  • Complete next step (P2) - A maintainer must make the final merge decision for this protected maintainer-labelled PR.
Agent review details

Security

None.

PR surface

Tests +130, Docs +1, Other -3. Total +128 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 160 30 +130
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 12 15 -3
Total 3 173 45 +128

Review metrics

Metric Value Why it matters
Production versus test delta production +12/-15 (net -3); tests +160/-30 (net +130); docs +1 The bug fix is production-net-negative while adding focused interleaving and cancellation coverage.

Technical review

Best possible solution:

Merge the focused revision fence, retaining the existing durable outbox and controller-owned dispatch boundaries.

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

Yes, source-reproducible: current main applies delayed same-scope outbox reads without ordering them, while the added focused tests model the held-read/delete and newer-failure interleavings. No tests were executed in this read-only review.

Is this the best way to solve the issue?

Yes. The revision is recorded at the presentation owner under the existing scope lock, so it rejects stale reads without serializing storage I/O or changing durable delete and send ownership.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.

Label justifications:

  • P1: The PR repairs a visible Android offline-message deletion regression and prevents refresh contention from delaying claimed sends.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This Member-authored PR is exempt from the external-contributor proof gate; its supplied exact-head Android emulator and CI evidence is consistent with the reviewed UI publication path.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-02T08:41:39.253Z sha 079471c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T08:54:35.406Z sha 079471c :: needs changes before merge. :: [P1] Fence a snapshot invalidated by deletion before publishing it | [P1] Keep a stalled publication off the direct-send path
  • reviewed 2026-09-02T09:58:37.882Z sha 14c1787 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 2, 2026 08:47
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. 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 Sep 2, 2026
@steipete steipete self-assigned this Sep 2, 2026
Keep publication reads independent, invalidate retired Gateway UI, and preserve claimed dispatch when its UI caller is cancelled. Extend native coverage for visible deletion, active-caller progress, scope retirement and newer load failures.

Release note: Android keeps deleted queued messages removed when delayed refreshes finish without making sends wait behind an unrelated refresh.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 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. labels Sep 2, 2026
@steipete
steipete merged commit 3f21062 into main Sep 2, 2026
113 of 115 checks passed
@clawsweeper clawsweeper Bot removed merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Sep 2, 2026
@steipete
steipete deleted the codex/android-outbox-publication branch September 2, 2026 10:45
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
…#136161)

* fix(android): keep deleted queued messages from reappearing

* fix(android): fence stale outbox refresh results

Keep publication reads independent, invalidate retired Gateway UI, and preserve claimed dispatch when its UI caller is cancelled. Extend native coverage for visible deletion, active-caller progress, scope retirement and newer load failures.

Release note: Android keeps deleted queued messages removed when delayed refreshes finish without making sends wait behind an unrelated refresh.
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 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