Skip to content

[codex] Cancel Android gateway pending RPCs on close#98067

Merged
steipete merged 4 commits into
openclaw:mainfrom
NianJiuZst:codex/android-gateway-pending-cleanup
Jul 2, 2026
Merged

[codex] Cancel Android gateway pending RPCs on close#98067
steipete merged 4 commits into
openclaw:mainfrom
NianJiuZst:codex/android-gateway-pending-cleanup

Conversation

@NianJiuZst

Copy link
Copy Markdown
Contributor

What Problem This Solves

Android GatewaySession kept pending RPC waiters in a session-wide map, but an intentional disconnect/reconnect path closed the socket without cancelling pending requests. Those callers could wait until their request timeout even though the owning WebSocket had already been closed.

Why This Change Was Made

This gives each Connection its own pending request id set. RPC registration, response, timeout, cancellation, send failure, and close now remove ids consistently, and closeQuietly() cancels only the pending ids owned by that connection. The extra closed-connection check covers the race where a request registers against a connection that has just started closing.

User Impact

Android callers no longer sit on stale Gateway RPCs after an intentional disconnect or reconnect. Newer connections are not affected by cleanup from an older socket.

Evidence

  • cd apps/android && ./gradlew :app:testThirdPartyDebugUnitTest --tests ai.openclaw.app.gateway.GatewaySessionInvokeTest --tests ai.openclaw.app.gateway.GatewaySessionReconnectTest --tests ai.openclaw.app.gateway.GatewaySessionInvokeTimeoutTest
  • cd apps/android && ./gradlew :app:ktlintCheck fails only on untouched upstream files: apps/android/app/src/main/java/ai/openclaw/app/GatewayExecApprovals.kt and apps/android/app/src/main/java/ai/openclaw/app/ui/design/ClawSurfaces.kt.
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main

@NianJiuZst
NianJiuZst marked this pull request as ready for review June 30, 2026 06:54
@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 2, 2026, 9:12 AM ET / 13:12 UTC.

Summary
The PR moves Android GatewaySession RPC waiters into each WebSocket Connection, cancels that connection's waiters on close, adds disconnect/reconnect regression tests, and updates native i18n line inventory.

PR surface: Other +152. Total +152 across 4 files.

Reproducibility: yes. source-reproducible: current main stores waiters in a session-wide map and closeQuietly closes sockets without draining pending RPCs, so a slow RPC can wait for timeout after disconnect. This read-only review did not run local tests, but the PR adds focused regression coverage for the failing path.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit ✨ media proof bonus
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Rank-up moves:

  • [P2] Wait for the remaining required CI check runs to finish before merge.

Risk before merge

  • [P1] Live GitHub checks still showed QA Smoke CI and two compact whole-check jobs in progress during this review, so final merge should wait for required checks to complete.

Maintainer options:

  1. Decide the mitigation before merge
    Land the per-connection pending-RPC cleanup after required checks finish, keeping the disconnect-cancellation and replacement-connection regression tests.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No ClawSweeper repair is needed; this open PR already contains the focused fix and proof, with only normal maintainer/check completion remaining.

Security
Cleared: The diff changes Android gateway lifecycle code, tests, and line-only i18n inventory metadata without adding dependency, workflow, secret, permission, or package-resolution surface.

Review details

Best possible solution:

Land the per-connection pending-RPC cleanup after required checks finish, keeping the disconnect-cancellation and replacement-connection regression tests.

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

Yes, source-reproducible: current main stores waiters in a session-wide map and closeQuietly closes sockets without draining pending RPCs, so a slow RPC can wait for timeout after disconnect. This read-only review did not run local tests, but the PR adds focused regression coverage for the failing path.

Is this the best way to solve the issue?

Yes. Per-Connection waiter ownership with synchronized registration and drain fixes the lifecycle boundary; a session-wide close drain would risk canceling replacement-connection waiters, which the new reconnect test guards.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Sufficient: the PR comments include Android 16 emulator before/after screenshots for the disconnect/restart path, and the only later head commit is non-runtime i18n inventory alignment.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Sufficient: the PR comments include Android 16 emulator before/after screenshots for the disconnect/restart path, and the only later head commit is non-runtime i18n inventory alignment.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Sufficient: the PR comments include Android 16 emulator before/after screenshots for the disconnect/restart path, and the only later head commit is non-runtime i18n inventory alignment.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded Android gateway lifecycle bug fix with limited blast radius and no evidence of a core-wide outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Sufficient: the PR comments include Android 16 emulator before/after screenshots for the disconnect/restart path, and the only later head commit is non-runtime i18n inventory alignment.
  • proof: sufficient: Contributor real behavior proof is sufficient. Sufficient: the PR comments include Android 16 emulator before/after screenshots for the disconnect/restart path, and the only later head commit is non-runtime i18n inventory alignment.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Sufficient: the PR comments include Android 16 emulator before/after screenshots for the disconnect/restart path, and the only later head commit is non-runtime i18n inventory alignment.
Evidence reviewed

PR surface:

Other +152. Total +152 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 4 178 26 +152
Total 4 178 26 +152

What I checked:

Likely related people:

  • vincentkoc: git blame on the current pending map, request registration, and closeQuietly paths points to 87178b8, whose GitHub commit metadata maps to @vincentkoc. (role: introduced current main behavior; confidence: high; commits: 87178b84668b; files: apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt)
  • obviyus: CONTRIBUTING.md lists @obviyus for the Android app, and git history shows Ayaan Zaidi among the most frequent contributors to GatewaySession and its tests, including the earlier Android app package move that carried this path. (role: Android app area owner and historical contributor; confidence: high; commits: 5568b393a86d, 98d593956493; files: CONTRIBUTING.md, apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt, apps/android/app/src/test/java/ai/openclaw/app/gateway/GatewaySessionInvokeTest.kt)
  • steipete: git history shows prior Android GatewaySession auth/connect work, and this PR's later commits refine the branch to per-connection waiter ownership and i18n alignment. (role: recent adjacent contributor and PR branch refiner; confidence: medium; commits: 589aca0e6d73, 29512c8a9084, 4f20fd82b0cb; files: apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt, apps/android/app/src/test/java/ai/openclaw/app/gateway/GatewaySessionReconnectTest.kt, apps/.i18n/native-source.json)
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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 30, 2026
@steipete steipete self-assigned this Jul 2, 2026
@steipete
steipete force-pushed the codex/android-gateway-pending-cleanup branch from b405058 to 8c6f818 Compare July 2, 2026 12:23
@steipete

steipete commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Maintainer verification on exact head 726982e4d269427788d613e67ca0dc1fb0d262c3:

  • Refactored pending RPC ownership into each Connection; closing an old socket now drains only that generation's waiters.
  • Added deterministic disconnect cancellation and overlapping reconnect-generation regressions.
  • Passed focused GatewaySessionInvokeTest + GatewaySessionReconnectTest, Android ktlint, native i18n inventory, git diff --check, and fresh exact-tree autoreview (no actionable findings, confidence 0.94).
  • Hosted CI is green: 61 passed, 13 skipped.

Live Android 16 emulator proof: the exact-head APK moved from Not connected after the isolated Gateway stopped to Online and ready after restart. The deterministic overlap-generation test is the proof that an old connection's delayed close cannot cancel a replacement connection's RPC.

Gateway stopped Gateway restarted
Android Settings showing Gateway not connected Android Settings showing Gateway online and ready

@steipete
steipete force-pushed the codex/android-gateway-pending-cleanup branch from addd263 to 4f20fd8 Compare July 2, 2026 13:01
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 2, 2026
@steipete
steipete force-pushed the codex/android-gateway-pending-cleanup branch from 4f20fd8 to 726982e Compare July 2, 2026 13:28
@steipete
steipete merged commit 0ccdef5 into openclaw:main Jul 2, 2026
74 checks passed
@steipete

steipete commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

LeonidasLux pushed a commit to LeonidasLux/openclaw that referenced this pull request Jul 3, 2026
* fix: cancel Android gateway pending RPCs on close

* fix(android): isolate pending RPCs per connection

* style(android): separate RPC waiter invariant

* chore(android): align native i18n inventory

---------

Co-authored-by: NianJiuZst <180004567+users.noreply.github.com>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 3, 2026
* fix: cancel Android gateway pending RPCs on close

* fix(android): isolate pending RPCs per connection

* style(android): separate RPC waiter invariant

* chore(android): align native i18n inventory

---------

Co-authored-by: NianJiuZst <180004567+users.noreply.github.com>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

2 participants