Repository navigation
fix(ui): complete mobile pairing after code redemption - #120933
Patrick-Erichsen merged 38 commits into
Conversation
8ec88a8 to
b774de2
Compare
|
Codex review: needs changes before merge. Reviewed August 14, 2026, 12:34 PM ET / 16:34 UTC. ClawSweeper reviewWhat this changesThis PR adds durable completion and expiry handling for Control UI mobile pairing codes, including protocol metadata, status reconciliation, and visible paired or expired states. Merge readinessKeep open: the pairing UI proof is strong, but generic bootstrap redemption still creates setup-only SQLite schema before the credential is known to be correlated. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway creates and redeems short-lived device bootstrap credentials, while the Control UI presents them as pairing QR codes. The new lifecycle state flows from credential redemption through durable Gateway records and events back to the dialog. flowchart LR
A[Operator opens pairing] --> B[Gateway issues setup code]
B --> C[Control UI shows QR]
C --> D[Mobile device redeems code]
D --> E[Gateway records outcome]
E --> F[Event or status reconciliation]
F --> G[Control UI shows paired or expired]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +1488, Tests +1863, Docs +22, Generated +12, Other +119. Total +3504 across 61 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Read the bootstrap row in its existing shape, then initialize setup-only state in the same transaction only for a correlated setup credential, with an old-schema generic-redemption regression. Do we have a high-confidence way to reproduce the issue? Yes. On an older state database without setup correlation storage, redeem a generic fully redeemed bootstrap credential; the source path reaches unconditional schema creation before it can establish that the record is uncorrelated. Is this the best way to solve the issue? No. The latest commit avoids startup mutation, but the shared redemption owner must make the same distinction before creating setup-only schema. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e74671df05e8. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (27 earlier review cycles; latest 8 shown)
|
b774de2 to
cdbf77b
Compare
a091830 to
950c5c9
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
e1907d8 to
1b2ed8c
Compare
261956e to
d20ad65
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Retry after the exact-review installation rate-limit reset. Review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer rank-up response for exact head b7c5990acaee: Owner review is complete in a functioning read-only environment. I reviewed the Gateway bootstrap and completion boundary, additive SQLite lifecycle storage, protocol compatibility, and Control UI event/status reconciliation on this exact head. The exact-head review artifact is clean, focused merge-result proof passed 172 tests with 1 skip, and final autoreview reported no findings. The native prepare gate will refresh the current-main merge result before landing. The macOS failure is an unchanged-surface test timeout; I will rerun the failed job on this same head and require green exact-head CI before landing. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Closes #120753
What Problem This Solves
Fixes an issue where the mobile pairing modal kept an already redeemed or expired QR code active, so users could not tell that pairing had completed and could continue interacting with stale credentials. The Pairing help link also opened a new tab without the platform's external-link affordance.
Why This Change Was Made
The Gateway now records a random, opaque, non-authorizing
setupIdbeside the bootstrap credential and returns its authoritativeexpiresAtMs. A dedicateddevice.pair.setup.completedevent is emitted only after that exact bootstrap redemption completes successfully; the event carries no token, token hash, request ID, or public key. Completion is persisted in SQLite before the best-effort broadcast, anddevice.pair.setupStatuslets a client that missed the frame reconcile the outcome the Gateway already recorded.The Control UI correlates only the active
setupId. Exact success and expiry retire the credential immediately, while unrelated pairing events leave the QR untouched. The QR payload is unchanged, and the SQLite table is additive without a schema-version bump.Both new response fields stay optional at the wire boundary. Protocol version 4 is unchanged, so a separately shipped native client can still be pointed at an older Gateway that omits
setupIdandexpiresAtMs; requiring them in the generated Swift model would have broken decoding an existingdevice.pair.setupCoderesponse before the client could use the code. The Control UI ships with the Gateway, so it requires the lifecycle metadata and surfaces a visible, actionable error rather than silently falling back to the stale-QR behavior this PR fixes.The pairing modal is a lazily imported chunk. When that import rejects while the overlay is already open, the shell now records the rejection and renders a recoverable dialog with a reason, a retry, and a close action, so the Pair mobile device action always ends in a visible outcome instead of an empty overlay.
Owner review requested for the Gateway/protocol security boundary, shared state storage, and Control UI lifecycle.
User Impact
Users now see a clear waiting, paired, expired, error, or regeneration state. Successful pairing removes the QR and shows the authoritative device name when available, the granted access level, Done, and Manage devices. Expired codes are removed and can be regenerated. Full and limited mobile access remain distinct, and the node bootstrap sibling follows the same completion contract.
If the pairing dialog itself fails to load, users get an explicit message and a retry instead of a modal that renders nothing.
Existing native clients keep working against older Gateways: the added lifecycle fields decode as absent instead of failing the whole response.
Pairing help now includes the up-right arrow, a visible focus/hover treatment, an accessible new-tab name,
_blank, andnoopener noreferrer.Evidence
Exact current head:
760aeae4407b3f6d3b1168b1748325ef07e68083Crash-consistency repair
Provenance: The restart gap was introduced by this PR's original lifecycle commit
8b99d5cef01e1117fdbf775933008242e67396bd, not pre-existing onmain. The earlier flow consumed the bootstrap credential before delivery but had no durable setup-completion fact; this PR initially added that fact only after delivery, creating the loss window.Canonical repair: One shared owner now rereads the authoritative bootstrap and paired-device rows, revalidates token binding, transaction-time TTL, and (for Watch) pairing identity/generation, then deletes the credential and inserts terminal completion in one synchronous Kysely SQLite transaction. WS and Watch deliver only after commit; delivery or broadcast failure leaves the terminal fact durable.
Review resolution: Atomic persistence and both interruption regressions are implemented. The suggested send-failure rollback is intentionally skipped because completion records committed pairing and device-credential issuance, not response receipt; reactivating the bearer would permit replay and make
device.pair.setupStatusuntruthful again.Scope: The repair adds no schema-version bump, SQLite schema change, or pairing protocol change.
Interruption red proof: 31510402323 failed exactly the new WS and Watch assertions before the repair because setup status had no terminal record at the handoff boundary.
Post-rebase focused proof: 31526426368 passed 101 tests across setup-code integration, WS, Watch, shared completion, and bootstrap storage, including transaction-time expiry.
Latest-rebase local focused proof: 111 tests passed across setup-code integration, WS, Watch, setup methods, shared completion, and bootstrap storage on
760aeae4407b3f6d3b1168b1748325ef07e68083.Current exact-head CI: 31560240867 reached attempt 2; all non-Swift lanes passed, but the remote macOS Swift rerun was blocked by a runner TLS failure cloning ElevenLabsKit (
SSL certificate problem: self signed certificate). No local fallback was used. at760aeae4407b3f6d3b1168b1748325ef07e68083, includingopenclaw/ci-gate.Prior exact-head CI before the latest mechanical rebase: 31528565462 completed with
openclaw/ci-gatesuccess after same-head reruns cleared unrelated UI and macOS timing flakes.Full changed-surface proof before the final mechanical rebase: 31523043858 passed formatting, generated API contracts, dead-export scans, core/test/UI typechecks, all lint shards, the unchanged v6 schema-version guard, database-first guards, and platform-related tests.
Sequential repair review passes completed cleanly after the TTL revalidation was folded into the transaction.
Backward-decode regressions:
apps/shared/OpenClawKit/Tests/OpenClawKitTests/GatewayModelsCompatibilityTests.swiftdecodes an older Gateway setup-code payload that omits both lifecycle fields, andpackages/gateway-protocol/src/schema/devices.test.tsaccepts that legacy result while still rejecting an emptysetupIdor a negativeexpiresAtMs. The macOS Swift lane executes that OpenClawKit test on this head.ui/src/lib/device-pair-setup.test.tscovers the missing-lifecycle-metadata path so the failure stays visible instead of silent.ui/src/app/app-host-pairing-access.test.tscovers the rejected pairing-chunk path: the shell keeps a dialog on screen with the failure reason, and Retry clears the failed state and refetches.pnpm protocol:gen:swift --checkpasses on this tree, so the committed generated Swift model matches its generator with no drift.Exact-head CI run 31480607307 exposed a missing release-train expectation for the new
device.pair.setupStatusmethod;src/gateway/methods/core-descriptors.since.test.tsnow records it under2026.8, and the focused regression passes.The generated Plugin SDK API baseline was refreshed after the rebase because the pairing protocol types change exported closure hashes;
pnpm plugin-sdk:api:checkpasses.Blacksmith Testbox changed-surface proof passed on run 31477771177, including typechecks, lint, schema guards, macOS-related Node tests, and generated API verification.
Diff versus current
main: production +1169/-262, tests +1703/-232, docs +16/-2, generated +30/-19, support +2. The crash-consistency repair itself is production +204/-186 (net +18), tests +388/-99 (net +289), and generated +19/-19; the positive production delta is the shared transaction owner plus authoritative binding/TTL checks, after removing the obsolete restore path and duplicate settlement flow.Selected permanent visual proof. The complete capture covers access selection, loading, waiting, full success, limited success, expiry, error, regenerate loading/waiting, Pairing help focus/hover/new-tab, and responsive mobile states.
Exact redemption success
Expired credential
Pairing help
Responsive states