Skip to content

fix(android): pause idle gateway discovery without blocking consumers - #196209

Merged
roboclaw-bot merged 8 commits into
mainfrom
openclaw/sharp-lobster-4
Nov 27, 2026
Merged

roboclaw-bot merged 8 commits into
mainfrom
openclaw/sharp-lobster-4

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Android keeps scanning for local Gateways without an active consumer. Pausing discovery must not break background recovery, connected discovery browsing, or secondary Gateway connections.

User Impact

Android can pause idle local scans. If the first connection to a saved Gateway is interrupted before an address is accepted, returning to the app can retry when the Gateway reappears. Stop cancels that pending retry.

Why This Change Was Made

Stop idle NSD scans and retire their callbacks. Resume for a visible Discovered list or onboarding, foreground enabled secondary Gateways, and the initial saved discovered-route recovery. Rebuild local results on resume; accepted sessions retain their own reconnect address. When no address has been accepted yet, the foreground path waits for the saved Gateway's fresh address and retries once without overriding a newer Gateway action.

This preserves #104226's cold sticky-service recovery with foreground-only capabilities disabled, and #111932's foreground-only secondary operator sessions with device capabilities owned only by the focused Gateway. The refresh onto main keeps discovery eligibility tied to the existing Gateway connection state instead of restoring the duplicate flag removed in #202898.

Evidence

  • On the refreshed head f4c26cfe, all three GatewayDiscoveryLifecycleTest cases passed in an isolated Android Play JVM run, including reconnect on rediscovery and Stop canceling the pending retry. Kotlin lint on the conflict resolution and git diff --check passed. Fresh hosted CI is separate from those local results.
  • The reconnect regression timed out on ccd5afac and passed with the fix on e618cb5d. Hosted CI on e618cb5d passed Play, third-party, and Wear unit suites, Kotlin lint, both Android Access jobs, and the required gate. That result predates the conflict resolution.
  • No physical-device run on the refreshed head. The original device proof applies only to dfcb5f99.

☁️ @saariuslystoned

Co-Authored-By: Bobby Bones [email protected]

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

Worked on by:
- @saariuslystoned

Co-authored-by: saariuslystoned <[email protected]>
OpenClaw-Publication: 213368b9-8196-4461-912c-33bac7fb1ce3
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 9, 2026
Worked on by:
- @saariuslystoned

Co-authored-by: saariuslystoned <[email protected]>
OpenClaw-Publication: c91763ac-0835-4a57-919f-1cf5168e9e84
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR pauses idle Android Gateway discovery while preserving recovery, visible browsing, and enabled secondary Gateway connections.

Example: A connected Android user closes Settings → Gateway → Discovered and backgrounds the app.

  • Before: The app continues browsing _openclaw-gw._tcp.
  • After: Local discovery stops unless saved-route recovery still needs it, and the next scan rebuilds local results.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused patch and exact-head Android checks support correctness, while device evidence predates the substantive lifecycle repairs.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Android continues local Gateway scanning after its consumers no longer need discovery.
Reason: The maintainer-authored direction reduces unnecessary scanning while preserving existing recovery and browsing capabilities.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a current Android discovery lifecycle problem and resolves the three earlier findings without a new concrete correctness defect.

Priority: P2
Reviewed head: ccd5afacaf5196fc9db37e82ba9b62e39a782fff

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The repaired consumer policy lacks a shipped-app run covering saved-route recovery, connected browsing, secondary discovery, and resume reconciliation; baseline-red execution of the new regression is also unshown.
Agent review details

How this fits together

Android UI visibility, connection state, and saved Gateway selections enter NodeRuntime's discovery policy; GatewayDiscovery manages Android NSD registrations and publishes endpoints for browsing and connection recovery.

flowchart TD
  A[Settings and onboarding] --> B[NodeRuntime discovery policy]
  C[Visibility and saved Gateways] --> B
  B --> D[GatewayDiscovery]
  D --> E[Android NSD]
  E --> D
  D --> F[Discovered endpoints]
  F --> G[Connection recovery and browsing]
Loading

Technical review

Best possible solution:

Keep discovery demand in NodeRuntime and scan retirement plus endpoint rebuilding in GatewayDiscovery.

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

Current-main source starts local NSD during GatewayDiscovery construction and provides no consumer-driven pause; the supplied earlier device report corroborates continued background scanning.

Is this the best way to solve the issue?

The patch uses the existing runtime and discovery owners, adds cancellable UI consumers, and preserves accepted reconnect routes without introducing another discovery manager.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9c37f5420455.

Provenance checked

  • Construction-time local scanning changes intended behavior with a stated reason (unknown: History across package moves carries unconditional scanner startup forward but establishes no requirement to scan while idle; this PR explains the demand-based replacement.)
  • Discovery callback identity and publication keeps the original intent (489d5d1: Prevent retired callbacks from resurrecting lost Gateways or overwriting replacement addresses while preserving serialized publication.)
  • Cold background recovery keeps the original intent (d85e8a5: Restore sticky-service Gateway recovery after process death without reviving foreground-only microphone capture.)
  • Foreground secondary Gateway sessions keeps the original intent (a52eb21: Keep enabled non-focused operator sessions available in the foreground while only the focused Gateway owns device capabilities.)
  • Onboarding discovery startup keeps the original intent (1098063: Start discovery when onboarding needs nearby Gateway information rather than displaying an uninitialized discovery state.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +89, Tests +128, Docs +6. Total +223 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 109 20 +89
Tests 1 128 0 +128
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 243 20 +223

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Avoidable Android network discovery is a bounded runtime efficiency problem; the revised implementation preserves the affected connection workflows.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-09T20:12:02.441Z sha dfcb5f9 :: needs changes before merge. :: [P1] Preserve discovery needed by cold background recovery | [P2] Allow discovery when connected users browse nearby Gateways | [P2] Reconcile retained endpoints when discovery resumes
  • reviewed 2026-11-10T17:33:04.795Z sha dfcb5f9 :: needs changes before merge. :: [P1] Preserve discovery needed by cold background recovery | [P2] Allow discovery when connected users browse nearby Gateways | [P2] Reconcile retained endpoints when discovery resumes

Reviewed November 10, 2026, 7:34 PM ET / November 11, 2026, 00:34 UTC (Revision 3).

@saariuslystoned

Copy link
Copy Markdown
Contributor

Device proof for head dfcb5f99f75d: gateway discovery stops when the app is backgrounded or connected

  • Device: Pixel 10 Pro Fold (physical, real network service discovery), Android 17 (API 37). Debug builds installed under a separate package; a local test Gateway with no model provider for the connected case.
  • Before: merge base e23c587c16f3. After: this PR's head.
  • Steps: open the app on the gateway screen (discovery runs); press HOME and wait; return, connect to the Gateway and wait. After each step, read the proof app's client block from dumpsys servicediscovery.
proof app's NSD client requests before (base) after (head)
foreground, not connected _openclaw-gw._tcp discovery active active (before, after)
backgrounded still active, queries still being sent none
connected to a Gateway still active none

Base keeps browsing for gateways in the background and after it has connected. Head stops discovery in both cases.

Dumps: backgrounded before / after, connected before / after. Logs: before, after; hashes in SHA256SUMS.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
Worked on by:
- @saariuslystoned

Co-authored-by: saariuslystoned <[email protected]>
OpenClaw-Publication: 15688554-a107-4e54-8104-1f80881c6a71
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 10, 2026
roboclaw-bot and others added 2 commits November 10, 2026 23:46
Co-authored-by: saariuslystoned <[email protected]>
Worked on by:
- @saariuslystoned

Co-authored-by: saariuslystoned <[email protected]>
OpenClaw-Publication: 434ee99e-2ffc-4636-b53a-4c221a009a15
@roboclaw-bot roboclaw-bot changed the title fix(android): stop gateway discovery while backgrounded or connected fix(android): pause idle gateway discovery without blocking consumers Nov 10, 2026
Worked on by:
- @saariuslystoned

Co-authored-by: saariuslystoned <[email protected]>
OpenClaw-Publication: 94f1a931-6a8c-44b3-bab7-476f3583fd8e
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
roboclaw-bot and others added 2 commits November 25, 2026 21:25
Keep the discovery refresh using the upstream connection state owner.

Co-authored-by: Solvely-Colin <[email protected]>
@roboclaw-bot
roboclaw-bot merged commit 55a1dcd into main Nov 27, 2026
79 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/sharp-lobster-4 branch November 27, 2026 03:13
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 27, 2026
* commit '7df6cb759f9e604921536a700e2f527c5516e7de': (185 commits)
  docs: clarify what telemetry OpenClaw sends and how to opt out
  refactor(ui): remove retired stream-follow test seams (#206316)
  fix: distinguish missing command results from unknown outcomes (#206313)
  fix(build): reuse stamps after identical pnpm installs (#206282)
  chore(ci): inventory Gateway model catalog worker lifecycles (#206251)
  fix: keep failed image inspections inside chat activity (#206283)
  fix: clarify sent-message labels and chat activity icons (#206048)
  fix(cron): use the service's free memory for extra automation runs (#206322)
  test(android): reuse the shared TLS fixture (#206280)
  fix(ui): restore New Session recovery during startup (#206319)
  test(macos): align new Gateway URL expectations (#206281)
  feat: let doctor --fix tell when its startup repairs have nothing to do (#206246)
  fix(android): pause idle gateway discovery without blocking consumers (#196209)
  fix(ci): prepare the Android SDK for scheduled CodeQL scans (#203843)
  fix(memory): read delegated cgroup pressure from the mapped leaf (#206308)
  improve(config): reuse plugin metadata during auto-enable (#206289)
  improve: copy only the selected model for agent completions (#206287)
  fix(pr): refresh tooling before preparing reviewed incoming PRs (#206236)
  fix: keep Gateway ready while plugins drain after updates (#206299)
  fix(crabbox): keep unused prepared mirrors reusable (#206267)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…openclaw#196209)

Pause Android Gateway discovery when no consumer needs it, while preserving saved-Gateway recovery, visible browsing and secondary connections. Retry once on fresh rediscovery after an interrupted foreground reconnect; respect explicit Stop.

Co-authored-by: Bobby Bones <[email protected]>
Co-authored-by: Solvely-Colin <[email protected]>
Co-authored-by: saariuslystoned <[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 docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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