Skip to content

feat(ios): redeem gateway setup short codes#98265

Closed
Solvely-Colin wants to merge 1 commit into
mainfrom
codex/ios-setup-code-autopair
Closed

feat(ios): redeem gateway setup short codes#98265
Solvely-Colin wants to merge 1 commit into
mainfrom
codex/ios-setup-code-autopair

Conversation

@Solvely-Colin

Copy link
Copy Markdown
Contributor

Related: #98242
Pairs with gateway PR #98263.
Supersedes the iOS half of #98243.

What Problem This Solves

The iOS app could consume long setup codes/QR payloads, but it had no path for the shorter Gateway-issued setup code flow. That left the mobile side unable to complete the one-step onboarding shape where a user enters a short code and lands connected.

Why This Change Was Made

This adds a small OpenClawKit short-code redeemer, wires onboarding/settings entry points to try short-code redemption before falling back to existing setup-code parsing, and reuses the existing gateway link application/persistence paths once the gateway returns a setup-code-equivalent payload.

User Impact

On iOS, users can enter a Gateway setup short code from onboarding or settings, have the app redeem it into the Gateway URL/bootstrap auth payload, persist the connection settings, and connect through the same setup-code path used by QR.

Evidence

  • swift test --filter GatewaySetupShortCodeRedeemerTests passed from apps/shared/OpenClawKit: 4 tests passed.
  • XcodeBuildMCP iOS simulator build passed earlier on this split branch with existing unrelated warnings in GatewaySettingsStore.swift, NodeAppModel.swift, TalkModeManager.swift, ChatViewModel.swift, and RealtimeTalkRelaySession.swift.
  • Integrated local proof before splitting: simulator setup-code flow connected after redeeming a fresh setup code from the Gateway state, and physical iPhone + Tailscale QR connected successfully.
  • Redacted visual proof: https://gist.github.com/Solvely-Colin/0d647e2ffd90500925a062dc043d3764
  • git diff --check passed.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --prompt "Review the iOS split for one-step QR/setup-code mobile pairing..." clean: no accepted/actionable findings.
  • Crabbox/Testbox not run per request to skip Crabbox.

@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed June 30, 2026, 4:30 PM ET / 20:30 UTC.

Summary
Adds an OpenClawKit setup short-code redeemer, exposes gateway URL parsing, and wires iOS onboarding/settings setup-code entry points to redeem short codes before connecting.

PR surface: Other +334. Total +334 across 7 files.

Reproducibility: not applicable. as a bug reproduction; this is a feature PR. Source inspection shows current main lacks short-code redemption, and the TLS-pin issue is source-reproducible from the new URLSession.shared client versus the existing pinned manual connect path.

Review metrics: 2 noteworthy metrics.

  • New Client Auth Path: 1 pre-auth redemption request added. The PR sends a human-entered short code to a Gateway endpoint that can return bootstrap auth material, so the transport and paired server contract matter before merge.
  • OpenClawKit Public Surface: 4 public symbols added. The redeemer protocol/type/helper and gateway URL parser become shared app API surface, not only local iOS view code.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98242
Summary: This PR is the iOS-side candidate implementation for the one-step mobile setup-code pairing feature tracked by the canonical issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

Risk before merge

  • [P1] Merging only the iOS half would expose a short-code entry path that fails against current main Gateways until feat: add one-step gateway setup pairing #98263 lands.
  • [P1] The new redeem request uses URLSession.shared instead of the existing gateway TLS pin/trust path, so app-trusted self-signed WSS gateways can fail and stored pin mismatches are not enforced while redeeming credentials.
  • [P1] The pre-auth short-code flow returns bootstrap auth material that is persisted by the app, so maintainers still need explicit security acceptance of TTL, single-use, token scope, and transport behavior.

Maintainer options:

  1. Fix TLS Trust And Land With Gateway (recommended)
    Update iOS redemption to use the same gateway TLS pin/trust decision as manual connect, then review this split together with feat: add one-step gateway setup pairing #98263.
  2. Accept Temporary Version Skew
    Maintainers can intentionally merge the iOS half first, but should own that short-code entry will fail against Gateways without the paired endpoint.
  3. Pause For Security Direction
    If the pre-auth bootstrap redemption boundary or pinning behavior is not accepted, pause or close this split rather than shipping the UI path.

Next step before merge

  • [P2] The PR has a protected maintainer label, a security-sensitive auth bootstrap boundary, an open paired Gateway PR, and a blocking TLS trust-path finding that needs human review of the desired merge shape.

Security
Needs attention: The diff introduces a security-sensitive short-code-to-bootstrap-credential path, and the redeem request currently bypasses the existing gateway TLS pin/trust path.

Review findings

  • [P1] Use the gateway TLS trust path for redemption — apps/shared/OpenClawKit/Sources/OpenClawKit/GatewaySetupShortCodeRedeemer.swift:70
Review details

Best possible solution:

Route redemption through the existing gateway trust/pinning model, then review and land it with the paired Gateway PR after maintainer security acceptance.

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

Not applicable as a bug reproduction; this is a feature PR. Source inspection shows current main lacks short-code redemption, and the TLS-pin issue is source-reproducible from the new URLSession.shared client versus the existing pinned manual connect path.

Is this the best way to solve the issue?

No. The client-side owner boundary is plausible, but the current implementation is not the best merge shape until redemption shares the gateway TLS trust path and lands with the paired server endpoint.

Full review comments:

  • [P1] Use the gateway TLS trust path for redemption — apps/shared/OpenClawKit/Sources/OpenClawKit/GatewaySetupShortCodeRedeemer.swift:70
    The short-code redeemer defaults to URLSession.shared, so the HTTPS POST does not use the existing gateway fingerprint store or GatewayTLSPinningSession behavior that manual connects use. A WSS gateway that the app can already connect to via an accepted/stored pin can fail redemption under normal system trust, and a stored pin mismatch is not enforced before sending the short code and receiving bootstrap credentials. Please route redemption through a trust-aware HTTP client/session built from the same stable ID and stored fingerprint as manual gateway connect.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority iOS onboarding feature with limited blast radius, but it needs maintainer/security review before merge.
  • merge-risk: 🚨 compatibility: The iOS short-code UI depends on the still-open Gateway redeem endpoint, so merging this split alone creates user-visible version skew.
  • merge-risk: 🚨 security-boundary: The PR redeems a short human code into persisted bootstrap credentials and currently bypasses the existing gateway TLS pin/trust path for that request.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (recording): The PR body links redacted visual proof and reports after-fix simulator plus physical iPhone runs; the linked SVG artifact was downloadable, though it does not settle the TLS trust-path defect.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body links redacted visual proof and reports after-fix simulator plus physical iPhone runs; the linked SVG artifact was downloadable, though it does not settle the TLS trust-path defect.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The PR body links redacted visual proof and reports after-fix simulator plus physical iPhone runs; the linked SVG artifact was downloadable, though it does not settle the TLS trust-path defect.
Evidence reviewed

PR surface:

Other +334. Total +334 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 7 342 8 +334
Total 7 342 8 +334

Security concerns:

  • [medium] Short-code redemption bypasses gateway TLS pinning — apps/shared/OpenClawKit/Sources/OpenClawKit/GatewaySetupShortCodeRedeemer.swift:70
    The new redeemer uses URLSession.shared for credential-bearing redemption instead of the existing gateway TLS fingerprint store and pinning session, which can both break app-trusted gateways and weaken the expected pin boundary for this request.
    Confidence: 0.88

What I checked:

Likely related people:

  • eleqtrizit: Current-main blame for the iOS setup-code entry points, OpenClawKit deep-link parser, gateway manual connect, and TLS pinning path points to merged PR fix(acp): require owner for runtime controls #97953. (role: recent area contributor; confidence: medium; commits: 6ead09230284; files: apps/ios/Sources/Design/SettingsProTabActions.swift, apps/ios/Sources/Onboarding/OnboardingWizardView.swift, apps/ios/Sources/Gateway/GatewayConnectionController.swift)
  • Solvely-Colin: This account authored the iOS split, the paired Gateway PR, and the canonical feature issue for the same short-code pairing direction, so they are the best contributor-side follow-up owner for this proposed change. (role: candidate implementation owner; confidence: medium; commits: a0646a67b37b, 623f3613717a; files: apps/shared/OpenClawKit/Sources/OpenClawKit/GatewaySetupShortCodeRedeemer.swift, apps/ios/Sources/Design/SettingsProTabActions.swift, apps/ios/Sources/Onboarding/OnboardingWizardView.swift)
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.

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 iOS support for redeeming Gateway-issued setup short codes by introducing an OpenClawKit redeemer and wiring iOS onboarding/settings entry points to try short-code redemption before falling back to existing setup-code parsing.

Changes:

  • Add GatewaySetupShortCodeRedeemer (OpenClawKit) to POST short codes to the Gateway and return a setup-code-equivalent GatewayConnectDeepLink.
  • Update iOS onboarding + settings flows to accept “setup or short code” input and redeem short codes when appropriate.
  • Add unit tests for short-code normalization, redemption URL formation, and basic redemption/error mapping.

Reviewed changes

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

Show a summary per file
File Description
apps/shared/OpenClawKit/Tests/OpenClawKitTests/GatewaySetupShortCodeRedeemerTests.swift Adds unit coverage for short-code normalization and redemption behavior.
apps/shared/OpenClawKit/Sources/OpenClawKit/GatewaySetupShortCodeRedeemer.swift Implements short-code normalization + redemption HTTP call and response parsing.
apps/shared/OpenClawKit/Sources/OpenClawKit/DeepLinks.swift Adds a public fromGatewayURL(...) convenience wrapper for building GatewayConnectDeepLink.
apps/ios/SwiftSources.input.xcfilelist Ensures the new OpenClawKit source is compiled into the iOS app target.
apps/ios/Sources/Onboarding/OnboardingWizardView.swift Accepts short codes in onboarding and redeems them via the selected/manual Gateway.
apps/ios/Sources/Design/SettingsProTabSections.swift Updates settings UI copy to reflect “setup or short code” input.
apps/ios/Sources/Design/SettingsProTabActions.swift Adds short-code redemption path for settings-based setup input and connection.

guard (200..<300).contains(http.statusCode) else {
throw RedeemError.rejected(statusCode: http.statusCode)
}
let decoded = try JSONDecoder().decode(RedeemResponse.self, from: data)
Comment on lines 187 to +192
func applySetupCodeAndConnect() async {
self.setupStatusText = nil
guard self.applySetupCode() else { return }
guard let link = await self.resolveSetupInputForConnect() else { return }
self.stagedGatewaySetupLink = nil
self.setupCode = ""
self.applyGatewayLink(link)

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0646a67b3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


public let client: GatewaySetupShortCodeHTTPClient

public init(client: GatewaySetupShortCodeHTTPClient = URLSession.shared) {

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.

P2 Badge Use gateway TLS pinning for redemption

When a short code is redeemed through a TLS gateway that relies on the app's existing TOFU/pinned-certificate flow rather than a publicly trusted certificate, this default URLSession.shared client performs normal system trust and the HTTPS POST fails before the user can use the already-supported trust prompt/pin path. The normal gateway connection path explicitly probes/stores a fingerprint and then uses GatewayTLSPinningSession from GatewayTLSStore, so short-code redemption should use the same pinned/trust-aware client for the selected gateway instead of bypassing it.

Useful? React with 👍 / 👎.

@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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 30, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 30, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing this implementation after maintainer review.

The short-code product direction remains valid in #98242, but this client split is not a safe landing shape:

  • GatewaySetupShortCodeRedeemer sends the pre-auth redemption request through URLSession.shared, bypassing the stored TLS fingerprint/trust path already used by manual Gateway connections. That can both reject an app-trusted self-signed Gateway and fail to enforce a stored-pin mismatch before the short code is exchanged for bootstrap credentials.
  • The client depends on the still-open server endpoint in feat: add one-step gateway setup pairing #98263, so landing it independently creates version-skew failure.
  • The head has a failing iOS dead-code check, conflicts with the current onboarding surface, and the branch does not allow maintainer edits.

The supported replacement is a current-main client/server change that routes redemption through the canonical Gateway trust owner, lands atomically with the server contract, and proves stored-pin success, pin-mismatch rejection, self-signed Gateway behavior, code TTL/single-use, and bootstrap-token scope. A replacement with that evidence would change this decision.

Thanks @Solvely-Colin for the implementation and proof work. For future PRs, enabling Allow edits by maintainers lets us repair a strong contributor branch directly.

@steipete steipete closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios maintainer Maintainer-authored PR 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants