Skip to content

feat: add one-step gateway setup pairing#98263

Closed
Solvely-Colin wants to merge 1 commit into
mainfrom
codex/gateway-qr-setup-autopair
Closed

feat: add one-step gateway setup pairing#98263
Solvely-Colin wants to merge 1 commit into
mainfrom
codex/gateway-qr-setup-autopair

Conversation

@Solvely-Colin

@Solvely-Colin Solvely-Colin commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Related: #98242
Supersedes the gateway half of #98243.

What Problem This Solves

Users setting up OpenClaw Mobile had to scan or paste a long setup code and then complete separate device/node approval steps. That made QR/setup-code onboarding feel like many steps instead of the intended one-step mobile setup.

Why This Change Was Made

This makes Setup Code and QR onboarding the primary one-step path: the app receives the Gateway URL/bootstrap auth from the setup-code payload, connects, and the Gateway silently approves only fresh baseline mobile device/node surfaces. The setup short code is a gateway-local convenience for typing the same setup-code payload on reachable local/co-resident Gateway flows; the long setup-code QR remains the durable fallback.

The node approval boundary is platform-specific for current iOS and Android app-declared capabilities/commands/permissions. Cross-platform, plugin, arbitrary, upgraded, or dangerous node command surfaces remain pending unless the Gateway owner explicitly allows them.

User Impact

A fresh mobile app can scan the QR or enter the setup code, save the Gateway URL/bootstrap auth, connect, receive bounded node/operator handoff tokens, and land connected without a separate manual approval step. Operators still get explicit pending approval flows for non-baseline or upgraded node surfaces.

Evidence

  • Physical iPhone + Tailscale QR proof succeeded locally: app connected; Gateway showed pending device/node counts at 0 after setup.
  • Redacted visual proof: https://gist.github.com/Solvely-Colin/0d647e2ffd90500925a062dc043d3764
  • node scripts/run-vitest.mjs src/gateway/server.auth.control-ui.test.ts --testNamePattern "qr setup code" passed: 7 tests, 33 skipped.
  • node scripts/run-vitest.mjs src/plugins/contracts/deprecated-internal-config-api.test.ts passed.
  • node scripts/run-vitest.mjs src/pairing/setup-short-code.test.ts src/gateway/server-http.probe.test.ts src/cli/qr-cli.test.ts passed: 3 shards, 4 + 28 + 25 tests.
  • node scripts/format-docs.mjs --check docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/check-docs-mdx.mjs docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/docs-link-audit.mjs docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/generate-docs-map.mjs --check passed.
  • git diff --check && node scripts/run-oxlint.mjs src/pairing/setup-short-code.ts src/gateway/pairing-setup-short-code-http.ts src/gateway/server.auth.control-ui.suite.ts src/gateway/server/ws-connection/message-handler.ts && node scripts/check-deprecated-api-usage.mjs passed.
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.src.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-src.gateway-comments.tsbuildinfo passed.
  • .agents/skills/autoreview/scripts/autoreview --mode local --prompt "Review the PR #98263 final comment-response patch only..." clean: no accepted/actionable findings.
  • Crabbox/Testbox not run per request to skip Crabbox.

@Solvely-Colin
Solvely-Colin requested a review from a team as a code owner June 30, 2026 20:12
Copilot AI review requested due to automatic review settings June 30, 2026 20:12
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: XL maintainer Maintainer-authored PR labels Jun 30, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 23252947130bca60aeed755558ac870292ff78a6, but the PR head is now 45941eadc017a8eb45d58914d9e0f334e9d67de1. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a one-step mobile pairing path by introducing gateway-local setup short codes that redeem into the existing setup-code payload, and extending the setup-code bootstrap flow to auto-approve baseline mobile device + first node pairing.

Changes:

  • Add a core plugin-state–backed short-code issuer/redeemer and expose a pre-auth HTTP redeem endpoint.
  • Extend gateway WS connect handling to auto-approve baseline mobile node pairing during setup-code bootstrap (and add suite coverage for the approval boundary).
  • Update openclaw qr output (text + JSON) and docs to include the short code and the new one-step behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pairing/setup-short-code.ts Implements short-code issuance, normalization/formatting, and single-use redemption backed by plugin state.
src/pairing/setup-short-code.test.ts Adds unit tests for issuing/redeeming, expiry behavior, and input normalization.
src/gateway/pairing-setup-short-code-http.ts Adds the pre-auth HTTP handler for redeeming short codes into the setup payload with rate limiting.
src/gateway/server-http.ts Routes /api/v1/pairing/setup-code/redeem to the new handler via lazy import.
src/gateway/auth-rate-limit.ts Adds a dedicated rate-limit scope for setup short-code redemption attempts.
src/gateway/hooks-test-helpers.ts Extends the HTTP request test fixture to support request bodies for JSON endpoints.
src/gateway/server-http.test-harness.ts Plumbs request bodies through the gateway HTTP in-memory test harness.
src/gateway/server-http.probe.test.ts Adds probe tests covering the redeem endpoint (success, one-time semantics, method checks, rate limiting).
src/gateway/server/ws-connection/message-handler.ts Adds setup-code bootstrap-driven auto-approval for baseline mobile node pairing on connect.
src/gateway/server.auth.control-ui.suite.ts Extends control-ui suite to cover node auto-approval for baseline mobile surfaces and pending behavior for upgrades.
src/cli/qr-cli.ts Prints/registers short codes (where appropriate) and extends JSON output with optional short-code fields.
src/cli/qr-cli.test.ts Covers CLI behavior for short-code registration, output rendering, and JSON field omission when unavailable.
docs/gateway/protocol.md Documents one-step mobile bootstrap behavior and the short-code redeem endpoint contract.
docs/cli/qr.md Documents new openclaw qr JSON fields, short-code semantics, and updated approval guidance.
docs/channels/pairing.md Updates channel pairing docs to reflect one-step baseline mobile auto-approval and upgrade approval flow.

Comment thread src/gateway/server/ws-connection/message-handler.ts
Comment thread src/gateway/pairing-setup-short-code-http.ts Outdated
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 30, 2026
@Solvely-Colin
Solvely-Colin force-pushed the codex/gateway-qr-setup-autopair branch from 623f361 to 2325294 Compare June 30, 2026 20:39
@Solvely-Colin

Copy link
Copy Markdown
Contributor Author

Updated this PR at 23252947130 to address the review feedback.

What changed:

  • Kept the product path framed as Setup Code / QR onboarding; setup short code remains the optional gateway-local typing helper.
  • Replaced the short-code normalizer spread with a direct character loop for oxlint.
  • Regenerated docs/docs_map.md for the protocol/docs heading changes.
  • Removed the duplicate redeem-route helper from src/gateway/pairing-setup-short-code-http.ts; routing stays centralized in src/gateway/server-http.ts.
  • Tightened setup-code/QR mobile node auto-approval so dangerous commands require explicit gateway.nodes.allowCommands, while gateway.nodes.denyCommands still removes matching commands before auto-approval.

Proof on the pushed SHA:

  • node scripts/run-vitest.mjs src/gateway/server.auth.control-ui.test.ts --testNamePattern "qr setup code" passed: 7 tests, 33 skipped.
  • node scripts/run-vitest.mjs src/pairing/setup-short-code.test.ts src/gateway/server-http.probe.test.ts src/cli/qr-cli.test.ts passed: 3 shards, 4 + 28 + 25 tests.
  • node scripts/format-docs.mjs --check docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/check-docs-mdx.mjs docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/docs-link-audit.mjs docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/generate-docs-map.mjs --check passed.
  • git diff --check && node scripts/run-oxlint.mjs src/pairing/setup-short-code.ts src/gateway/pairing-setup-short-code-http.ts src/gateway/server.auth.control-ui.suite.ts src/gateway/server/ws-connection/message-handler.ts passed.
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.src.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-src.gateway-comments.tsbuildinfo passed.
  • .agents/skills/autoreview/scripts/autoreview --mode local --prompt "Review the PR #98263 comment-response patch only..." clean: no accepted/actionable findings.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 30, 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.

@Solvely-Colin
Solvely-Colin force-pushed the codex/gateway-qr-setup-autopair branch from 2325294 to 45941ea Compare June 30, 2026 20:54
@Solvely-Colin

Copy link
Copy Markdown
Contributor Author

Updated this PR again at 45941eadc01 after CI exposed the deprecated config-write guard in the new gateway tests.

Delta since the previous review-response push:

  • Replaced the test-only writeConfigFile(...) usage in src/gateway/server.auth.control-ui.suite.ts with replaceConfigFile({ nextConfig }).
  • Verified that both failed CI lanes had the same root cause: checks-fast-contracts-plugins-b failed deprecated-internal-config-api.test.ts, and check-additional-runtime-topology-architecture failed check-deprecated-api-usage.mjs on the same file/import.

Current proof on the final local patch:

  • node scripts/run-vitest.mjs src/gateway/server.auth.control-ui.test.ts --testNamePattern "qr setup code" passed: 7 tests, 33 skipped.
  • node scripts/run-vitest.mjs src/plugins/contracts/deprecated-internal-config-api.test.ts passed.
  • node scripts/run-vitest.mjs src/pairing/setup-short-code.test.ts src/gateway/server-http.probe.test.ts src/cli/qr-cli.test.ts passed: 3 shards, 4 + 28 + 25 tests.
  • git diff --check && node scripts/run-oxlint.mjs src/pairing/setup-short-code.ts src/gateway/pairing-setup-short-code-http.ts src/gateway/server.auth.control-ui.suite.ts src/gateway/server/ws-connection/message-handler.ts && node scripts/check-deprecated-api-usage.mjs passed.
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.src.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-src.gateway-comments.tsbuildinfo passed.
  • .agents/skills/autoreview/scripts/autoreview --mode local --prompt "Review the PR #98263 final comment-response patch only..." clean: no accepted/actionable findings.

The PR is still Setup Code / QR first; setup short code is the optional gateway-local typing helper.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 30, 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.

@clawsweeper clawsweeper Bot removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Jun 30, 2026
@clawsweeper clawsweeper Bot added status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels Jun 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. labels Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants