Skip to content

feat(android): reconnect gateway when validated network returns#100347

Merged
steipete merged 5 commits into
openclaw:mainfrom
ly85206559:feat/android-network-reconnect-on-validated-transport
Jul 6, 2026
Merged

feat(android): reconnect gateway when validated network returns#100347
steipete merged 5 commits into
openclaw:mainfrom
ly85206559:feat/android-network-reconnect-on-validated-transport

Conversation

@ly85206559

@ly85206559 ly85206559 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

When Android lost and regained network connectivity, OpenClaw could remain disconnected from the gateway until the app foregrounded or the current GatewaySession backoff elapsed. That left node/operator sessions offline longer than necessary after Wi-Fi or cellular recovery.

Why This Change Was Made

Android now tracks validated networks and wakes existing desired gateway sessions only when the validated-network set moves from empty to non-empty.

The maintainer rewrite keeps each responsibility at its owner:

  • NetworkMonitor consumes the ordered onCapabilitiesChanged callback and only reports a validated offline-to-online transition. It does not synchronously query capabilities from onAvailable; Android documents that pattern as race-prone.
  • GatewaySession owns a conflated wake signal for its single reconnect loop, so restoration actually interrupts an active delay without creating a parallel loop.
  • Network restoration cannot create a desired connection or clear an authentication-failure pause. Explicit refresh retains its existing ability to resume an auth-paused session.
  • Multiple validated networks remain deduped: losing Wi-Fi while another validated transport remains available does not retry.
  • Callback registration precedes the initial active-network snapshot so a network lost during startup cannot remain as a ghost validated entry.

No permission, config, migration, protocol, dependency, or command surface is added. The existing ACCESS_NETWORK_STATE permission is reused.

User Impact

After all validated networks disappear and one returns, Android retries saved gateway sessions immediately instead of waiting for the current backoff slot. Routine capability churn, partial network loss, captive/unvalidated networks, explicit disconnects, and deliberate authentication pauses do not trigger a retry.

Evidence

Final rewritten head: 0bdf7e34a542220b813587bb95ac49848dbc5f32.

  • Sanitized AWS Crabbox cbx_1fdce258694b, run run_91884324b24a: bootstrap verified rewritten head bf37f31e61aa1d266d5f9f8efc5c5cdd0740b842, no IAM credentials endpoint, public networking with no Tailscale, pinned Node/pnpm, and isolated HOME; testThirdPartyDebugUnitTest, testPlayDebugUnitTest, and assemblePlayDebug passed (82 tasks, Gradle 2m51s). The final head is the same reviewed implementation cleanly rebased over current main, plus regenerated native i18n inventory.
  • Final-head hosted CI 28771116526 and Workflow Sanity 28771116539: passed.
  • node --import tsx scripts/native-app-i18n.ts check: passed.
  • git diff --check: passed.
  • Four GPT-5.5 autoreview closeout passes, including focused reruns after the startup ordering fix and final rebase: no actionable findings.

Contributor real-emulator proof used airplane mode against a local mock WebSocket gateway:

Device: emulator-5554 device product:sdk_gphone16k_x86_64 model:sdk_gphone16k_x86_64
Gateway: local mock WebSocket gateway on host 127.0.0.1:18789, reached by emulator as 10.0.2.2:18789
Initial Android debug receiver result: {"ok":true,"mode":"connect","connected":true}
Network action: adb shell cmd connectivity airplane-mode enable; then adb shell cmd connectivity airplane-mode disable
Final airplane mode state: disabled
Mock gateway observation: completed gateway connections increased after restoration.

Source-blind limitation: no interactive emulator was available for the exact maintainer rewrite, so exact timing, per-session attribution, auth-pause, captive-portal, multi-network, and explicit-disconnect probes remain unclaimed. Those branches have source-aware state coverage, full Android unit/build proof, and maintainer review.

AI-assisted: yes. The contributor implementation was reviewed and substantially rewritten by a maintainer agent, then independently autoreviewed and remotely validated.

@ly85206559
ly85206559 force-pushed the feat/android-network-reconnect-on-validated-transport branch from 9c78f95 to bd19196 Compare July 5, 2026 14:29
@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 1:54 AM ET / 05:54 UTC.

Summary
Adds an Android NetworkMonitor and GatewaySession wake signal so validated-network restoration wakes desired gateway sessions out of reconnect backoff, plus state tests and native i18n/Android changelog updates.

PR surface: Docs +2, Other +199. Total +201 across 6 files.

Reproducibility: not applicable. as a strict bug reproduction because this PR adds a new immediate reconnect trigger rather than fixing a documented current contract. Source inspection confirms current main only reconnects from foreground/backoff paths, and the PR body includes emulator live output for airplane-mode restoration.

Review metrics: 1 noteworthy metric.

  • Config and permission surface: 0 added, 0 changed. The PR changes reconnect timing without adding a user/operator knob or new Android permission, so maintainers are accepting the new default behavior directly.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
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:

  • none.

Risk before merge

  • [P1] Merging changes Android reconnect timing to wake GatewaySession from ConnectivityManager validated-network callbacks, so device, VPN, captive-portal, and callback-ordering variance can affect connection availability.
  • [P1] The exact maintainer rewrite has source-aware unit/build proof rather than an interactive device proof for every branch; maintainers may still ask for one more Android proof path if platform variance is the concern.

Maintainer options:

  1. Accept callback-timing risk and land (recommended)
    Land the clean branch if maintainers are comfortable with Android validated-network callbacks nudging the existing guarded reconnect path sooner after transport recovery.
  2. Ask for one more Android proof path
    Require a second device, VPN handoff, captive-portal, or attached diagnostic-log proof before merge if callback variance remains the main concern.
  3. Defer to a broader reconnect design
    Pause this PR if reconnect pacing should stay entirely inside GatewaySession and foreground refresh behavior rather than being woken by Android reachability.

Next step before merge

  • [P2] No repair is queued; the branch has no actionable code finding and needs maintainer acceptance of the Android availability timing tradeoff.

Maintainer decision needed

  • Question: Should Android accept ConnectivityManager validated-network callbacks as an immediate gateway reconnect wake signal while preserving GatewaySession's desired-connection and auth-pause guards?
  • Rationale: The patch is narrow and proven enough for review, but the availability behavior depends on Android platform callback timing across devices and network configurations, which is a maintainer-owned merge-risk decision.
  • Likely owner: steipete — Peter authored the rewrite commits and is already assigned to this Android gateway reconnect PR.
  • Options:
    • Accept the callback trigger (recommended): Merge the current branch after ordinary exact-head gates because it wakes the existing GatewaySession loop without adding config, permissions, or parallel reconnect ownership.
    • Require broader Android proof: Ask for one more device, VPN handoff, captive-portal, or diagnostic-log run before landing if platform callback variance needs stronger evidence.
    • Keep reconnect pacing centralized: Pause or close this PR if Android network-return reconnects should remain exclusively governed by existing GatewaySession backoff and foreground refresh behavior.

Security
Cleared: No security or supply-chain concern found: the diff adds Android connectivity monitoring and tests without new permissions, dependencies, workflows, lockfiles, scripts, or secret handling.

Review details

Best possible solution:

Land the current branch after exact-head maintainer review if Android owners accept validated-network callbacks as a wake signal; otherwise require one more device, VPN, or diagnostic-log proof path before merge.

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

Not applicable as a strict bug reproduction because this PR adds a new immediate reconnect trigger rather than fixing a documented current contract. Source inspection confirms current main only reconnects from foreground/backoff paths, and the PR body includes emulator live output for airplane-mode restoration.

Is this the best way to solve the issue?

Yes, if maintainers accept the platform timing tradeoff. Routing the wake through GatewaySession keeps desired-connection and auth-pause decisions in the existing owner instead of adding a parallel reconnect loop.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a focused Android availability improvement with limited blast radius, not a core runtime outage or security emergency.
  • merge-risk: 🚨 availability: The PR changes when Android starts gateway reconnect attempts based on platform network callbacks, which can affect connection availability across device and transport callback ordering.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes real emulator live output showing airplane-mode restoration and an increased mock gateway connection count after the validated transport returned, with exact-head unit/build proof for the maintainer rewrite.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes real emulator live output showing airplane-mode restoration and an increased mock gateway connection count after the validated transport returned, with exact-head unit/build proof for the maintainer rewrite.
Evidence reviewed

PR surface:

Docs +2, Other +199. Total +201 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 5 212 13 +199
Total 6 214 13 +201

What I checked:

Likely related people:

  • steipete: Recent current-main blame for the foreground reconnect helper and GatewaySession reconnect path points to Peter, and he authored the maintainer rewrite commits on this PR. (role: recent area contributor and assigned reviewer; confidence: high; commits: 62ecc2306c90, 589aca0e6d73, c3a2701c45b1; files: apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt, apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt, apps/android/app/src/main/java/ai/openclaw/app/gateway/NetworkMonitor.kt)
  • obviyus: CONTRIBUTING.md lists Ayaan Zaidi as Android app owner, and commit history shows Ayaan introduced Android gateway auto-connect on app open. (role: Android app owner and introduced related behavior; confidence: high; commits: 0443ee82be77, 5568b393a86d; files: apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt, apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.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 (7 earlier review cycles)
  • reviewed 2026-07-05T14:43:20.701Z sha 019d812 :: needs real behavior proof before merge. :: [P2] Track online state per network
  • reviewed 2026-07-05T16:06:48.005Z sha 0def6f0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T16:14:54.363Z sha 0def6f0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T18:23:58.966Z sha 0def6f0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T19:49:37.309Z sha 0def6f0 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T23:05:09.193Z sha 0def6f0 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-06T02:51:47.399Z sha 3927215 :: needs maintainer review before merge. :: none

@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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 5, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 5, 2026
@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@ly85206559
ly85206559 force-pushed the feat/android-network-reconnect-on-validated-transport branch from 0def6f0 to 3927215 Compare July 6, 2026 02:38
@steipete steipete self-assigned this Jul 6, 2026
@steipete
steipete force-pushed the feat/android-network-reconnect-on-validated-transport branch from 3927215 to bf37f31 Compare July 6, 2026 05:37
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Land-ready maintainer rewrite completed.

  • Replaced the race-prone synchronous onAvailable capability lookup with Android's ordered onCapabilitiesChanged data.
  • Moved immediate retry ownership into GatewaySession, where a conflated signal now wakes the single backoff loop without creating parallel reconnects.
  • Network restoration now preserves explicit disconnects and authentication-failure pauses, while independently retrying desired node/operator sessions.
  • Closed the callback-registration startup race and preserved multi-network transition dedupe.
  • Added Android changelog coverage and refreshed native i18n inventory.

Proof for final head 0bdf7e34a542220b813587bb95ac49848dbc5f32:

  • Sanitized AWS Crabbox run_91884324b24a: both Android flavor unit suites and assemblePlayDebug passed on rewritten head bf37f31e61a (82 tasks, Gradle 2m51s); the final head is its clean rebase plus regenerated i18n inventory.
  • Final-head CI 28771116526 and Workflow Sanity 28771116539: passed.
  • Native i18n check and diff check: passed.
  • Four GPT-5.5 autoreview closeout passes, including the final rebased branch: no actionable findings.

The source-blind exact-head emulator probes remain an explicit gap; the contributor's real airplane-mode proof predates the rewrite, while the rewritten timing and suppression branches are covered by source-aware review plus exact-head unit/build proof.

@steipete
steipete force-pushed the feat/android-network-reconnect-on-validated-transport branch from bf37f31 to 0bdf7e3 Compare July 6, 2026 06:00
@steipete
steipete merged commit eda99cb into openclaw:main Jul 6, 2026
80 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 6, 2026
…claw#100347)

* feat(android): reconnect gateway when validated network returns

Co-authored-by: Cursor <[email protected]>

* fix(android): dedupe validated network reconnects

* fix(android): wake gateway reconnect backoff safely

* fix(android): close network monitor startup race

* chore(android): refresh native i18n inventory

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…claw#100347)

* feat(android): reconnect gateway when validated network returns

Co-authored-by: Cursor <[email protected]>

* fix(android): dedupe validated network reconnects

* fix(android): wake gateway reconnect backoff safely

* fix(android): close network monitor startup race

* chore(android): refresh native i18n inventory

---------

Co-authored-by: Cursor <[email protected]>
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. 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