Skip to content

fix(android): preserve QR pairing when setup permissions change - #157569

Merged
fuller-stack-dev merged 1 commit into
mainfrom
openclaw/qr-handoff-repro-20260924
Sep 24, 2026
Merged

fuller-stack-dev merged 1 commit into
mainfrom
openclaw/qr-handoff-repro-20260924

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes Android QR pairing failing when a permission or capability changes while the gateway is exchanging the one-use setup credential for permanent device credentials.

User Impact

Users can finish setup without a camera-permission change interrupting pairing and leaving the app retrying a consumed setup credential. No credential format, approval policy, or migration changes; explicit disconnect and replacement setup still take effect.

This fixes a reproduced setup race. It does not claim to explain every previously reported disconnect or prove overnight/network-transition recovery.

Why This Change Was Made

Keep the in-flight bootstrap connection alive during internal capability refreshes. After the credential handoff completes, reconnect with the saved device credentials and latest capabilities. Connection-identity checks prevent a deferred refresh from replacing a newer setup attempt.

Evidence

  • Regression uses the actual NodeRuntime.configureGatewayAndConnect path and a loopback WebSocket gateway: consume bootstrap, hold the response, enable camera, then return both role grants. It failed before the fix and passes afterward, verifying permanent authentication, refreshed camera capability, bootstrap retirement, and access after recreating runtime/preferences.
  • 130 focused Android tests passed, with no failures/errors/skips, across GatewayBootstrapRefreshTest, GatewayBootstrapAuthTest, GatewaySessionInvokeTest, and DeviceAuthStoreTest. The new regression took 0.114 seconds in JUnit; the combined Gradle test/lint invocation took 1m56s. Current-head hosted Android test steps passed: Play 554 seconds, third-party 596 seconds, and Wear 611 seconds (whole-step durations, not the new test alone).
  • Android app/benchmark/Wear lint, pnpm android:i18n:check, and git diff --check passed. Fourteen selected local guard stages passed across the initial run and a repaired tooling continuation, not one clean aggregate invocation.
  • Independent API-backed review found an ordering race in the initial candidate; it was fixed. Final scoped review had no P0–P2 findings. ClawSweeper exact-head review also found no actionable findings.
  • Installed candidate APK on a Blacksmith Android emulator: fresh setup through setup-code UI, force-stop/relaunch, and isolated gateway restart/shared-token change all passed. Both node and operator credentials were used after each phase. Testbox lifecycle run. The scenario driver finished successfully (exit 0, 69.081 seconds); the lease was then intentionally stopped during cleanup, so the Actions lifecycle run is canceled, not a successful CI run, and its logs are no longer available. Actual camera scanning and long-duration recovery were not exercised.
  • Whole new test file audited, including fixture, imports, setup/teardown, and cleanup: private preferences, allocated loopback port, handshake signals rather than sleeps, joined runtime/socket cleanup. No skipped or removed coverage and no live phone/gateway state.

The published patch has the same reviewed production/test bytes. An unrelated local parent commit was excluded before publication. Exact-head CI passed for the unchanged reviewed head: both Android app test variants, Wear tests, ktlint, i18n, security-fast, and native Access crypto on 4 KiB and 16 KiB Android emulators. The ktlint step took 433 seconds; native Access steps took 506 and 527 seconds. Attempt 1 was deferred before tests by Full Release Validation. After its owner cleared runner priority, attempt 2 ran the full selected CI and passed; no product change or blind rerun was used to clear a test failure.

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 24, 2026 20:38
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 24, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 5:18 PM ET / 21:18 UTC (Revision 3).

ClawSweeper review

What this changes

The Android companion app defers capability-triggered Gateway reconnection until QR setup credentials are saved, with a loopback WebSocket regression covering the handoff.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still reconnects during the one-use setup credential exchange, and this PR addresses that race with a focused regression. I found no actionable defect in the introduced patch.

Priority: P1
Reviewed head: 39ca86ce9078c17b75dd345726ad5b4d77e46903

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused lifecycle code and a before-and-after WebSocket regression give this a solid review signal, with installed-APK evidence for adjacent setup and relaunch behavior.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The Android connection owner is exercised by a loopback WebSocket regression that withholds the consumed setup response, changes camera capability, and observes device-token reconnect and relaunch access. The PR also reports installed-APK setup and relaunch, though not the exact camera transition; the ordinary contributor-proof gate does not apply to this MEMBER PR. No stored-data model changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The Android connection owner is exercised by a loopback WebSocket regression that withholds the consumed setup response, changes camera capability, and observes device-token reconnect and relaunch access. The PR also reports installed-APK setup and relaunch, though not the exact camera transition; the ordinary contributor-proof gate does not apply to this MEMBER PR. No stored-data model changes.
Evidence reviewed 7 items Introduced patch: The pinned merge-base-to-head patch adds a per-connection deferred refresh and a regression test; the verified test merge changes the same two Android files.
Current-main behavior: Fetched main still calls the replacement connection immediately after a capability refresh, without checking whether bootstrap credential handoff is complete.
Credential handoff boundary: The existing Gateway session retires the bootstrap credential only after both node and operator device tokens have been persisted for the current socket.
Findings None None.
Security None None.

How this fits together

The Android app uses a QR or setup code to connect to the Gateway and save permanent node and operator credentials. Permission changes alter the capabilities advertised on that connection and can trigger a reconnect.

flowchart LR
  A[QR setup code] --> B[Android Gateway connection]
  C[Permission change] --> D{Setup handoff complete?}
  B --> D
  D -->|No| E[Keep setup socket]
  E --> F[Save device credentials]
  F --> G[Reconnect with current capabilities]
  D -->|Yes| G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +213, Other +14. Total +227 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 213 0 +213
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 17 3 +14
Total 2 230 3 +227

Review metrics

Metric Value Why it matters
Production and test growth production net +14 lines, tests +213 lines The test exercises the real Android connection path against a loopback WebSocket Gateway; the PR reports a 0.114-second local JUnit case.

Technical review

Best possible solution:

Preserve the in-flight setup handoff, reconnect with current capabilities after durable credentials arrive, and show an inline pairing recovery action if a setup code has already expired.

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

Yes, from source and the submitted regression: a capability refresh can replace the socket after the Gateway consumes the one-use code but before Android receives durable role credentials. I did not execute the regression in this read-only checkout.

Is this the best way to solve the issue?

Yes. Deferring the internal reconnect at the Android connection owner is a narrow repair that leaves credential issuance and storage contracts intact.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A permission change during first pairing can strand Android on a consumed setup credential and interrupt a real setup workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The Android connection owner is exercised by a loopback WebSocket regression that withholds the consumed setup response, changes camera capability, and observes device-token reconnect and relaunch access. The PR also reports installed-APK setup and relaunch, though not the exact camera transition; the ordinary contributor-proof gate does not apply to this MEMBER PR. No stored-data model changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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 (2 earlier review cycles)
  • reviewed 2026-09-24T20:53:54.267Z sha 39ca86c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-24T21:05:09.995Z sha 39ca86c :: needs maintainer review before merge. :: none

@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) September 24, 2026 21:42
@fuller-stack-dev
fuller-stack-dev merged commit 0179bdb into main Sep 24, 2026
181 of 182 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/qr-handoff-repro-20260924 branch September 24, 2026 21:44
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
roboclaw-bot added a commit that referenced this pull request Sep 26, 2026
Backport #157569: 0179bdb
Backport #157865: ebdf8ab

Keep the consumed bootstrap handoff alive until durable grants are accepted
and retry owed transcript invalidations under captured connection/session/agent
ownership. Preserve physical-enqueue fences and the earlier Sidebar CI fixture repair.

Both real fixture entrypoints failed before repair; 157 focused cases and
i18n checks pass. Independent review is clean. JVM/local-WebSocket proof is
not live QR, permission, emulator, relaunch or token-rotation qualification.

Co-authored-by: Jason (Json) <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant