Skip to content

refactor(ui): derive native device settings types from schemas - #144705

Merged
jesse-merhi merged 3 commits into
mainfrom
refactor/native-device-settings-schema
Sep 11, 2026
Merged

jesse-merhi merged 3 commits into
mainfrom
refactor/native-device-settings-schema

Conversation

@jesse-merhi

@jesse-merhi jesse-merhi commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Native device settings define the same snapshot shape twice: once as a TypeScript type and again in a long runtime validator. Adding a native setting requires keeping both definitions aligned.

Why This Change Was Made

Use the UI's existing Zod dependency to define the consumed snapshot and Chrome setup result shapes, then infer their types. All three snapshot boundaries consume the parsed schema output directly. Unknown host fields are stripped and snapshots are parsed copies; consumers use declared fields and subscriptions, with no observed dependency on raw host object identity. No native host, command, or contract-version changes.

User Impact

No intended user-visible change. macOS and iOS retain their optional settings families, permission order and uniqueness checks, required nullable values, authoritative edit replies, and Chrome setup errors.

Change breakdown

Part Files +LOC -LOC
Implementation 1 +145 -289
Total 1 +145 -289

Evidence

A before/after probe exercised both implementations through the bridge with the existing macOS/iOS fixtures:

Input or action Before After
iOS snapshot omits browser and updates Accepted Accepted
Snapshot contains additional host fields Original object retained Declared fields parsed; unknown fields stripped
Duplicate permission IDs Ignored; previous snapshot retained Ignored; previous snapshot retained
Native edit returns authoritative snapshot Draft settles before subscribers receive native state Same
Chrome setup returns a negative/fractional/unsafe count Invalid-result error Same

At the earlier 5db7566 revision, 2,582 snapshot comparisons passed, plus event/edit identity and Chrome setup projection/error checks. These identity results do not describe the current parsed-copy implementation. The temporary probe files are no longer available; this is recorded execution evidence, not a retained reproducer.

Validation of the committed source bytes:

  • 34 existing native device settings tests passed on Blacksmith Testbox (tbx_01m27d9zzqnhprzb3qkv97bem9).
  • Production UI build and bundle budget passed: 352,874 B startup gzip versus a 353,107 B limit. This is not a matched native-startup performance comparison.
  • UI typecheck and targeted type-aware lint passed with zero warnings/errors on Blacksmith Testbox (tbx_01m27dcsdmcha00287h68hwerc).
  • Formatting and git diff --check passed.

Test/build environment, type/lint environment.

All four existing native settings browser scenarios passed on Blacksmith Testbox (tbx_01m27fj8pgarv3tyhv9kdb8drr): iPhone light/dark settings, Mac settings and permission requests, browser-only absence, and canceled/newer edits across navigation. Browser proof environment.

The following captures were inspected from that completed Chromium run at head 5db756653b13c03e85ab13dd94452e151237f0e5. They use mocked native-host and Gateway state; no live OS settings or signed native-app proof is claimed. No visual redesign was made.

Confirmed iPhone appearance setting (375 × 812)

The Appearance field reflects the native reply's Dark selection.

iPhone appearance field after the native reply

Mac settings after authoritative replies (1440 × 1800)

The Dock icon is Origami and Show Dock icon is off after the host confirms both edits.

Mac settings after confirmed native edits

To repeat the browser check:

OPENCLAW_CAPTURE_UI_PROOF=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/native-device-settings.e2e.test.ts

Review status at 5db756653b13c03e85ab13dd94452e151237f0e5: two native review passes and one independent cold review pass found no actionable regressions; no review fixes were needed. ClawSweeper acknowledged the re-review request but has not supplied a verdict, so the complete code-review gate remains unfinished.

This PR remains draft because exact-head CI has failed:

  • Control UI shard 3: the unchanged session-link-presentation.browser.test.ts:69 expects inline-grid but receives grid. This CSS-only test does not import the changed native settings module. No separate base-run reproduction is claimed.
  • Control-plane runtime job: dependency installation failed when the Matrix crypto binary download hit ECONNRESET, followed by its installer throwing ReferenceError: err is not defined. Tests did not run.

Neither failure has been changed or rerun as part of this one-file refactor. Required CI and ClawSweeper review must complete before readiness; no merge is authorized.

Current-head follow-up

At 32fe150e9ad212bd132fd05fa792841641ef78d3, removed isSnapshot and used safeParse plus typed data at startup, change events, and authoritative edit replies. Invalid-input handling is preserved. This deliberately replaces raw snapshot identity/unknown-field retention with schema-owned output.

The exact committed source passed all 34 focused native settings tests, UI typecheck, targeted type-aware lint (zero warnings/errors), formatting, and diff checks. Current validation run, Blacksmith Testbox tbx_01m27gnyevcm21fbh2vp7n9gdb (stopped). Earlier browser captures and native/cold review remain evidence for the earlier revision; they have not been rerun for this follow-up. ClawSweeper review of the current head is requested separately. The PR remains draft.

Merge checkpoint

Fresh final-head review completed: two native passes and independent general, TypeScript, and test reviews found no actionable regressions. ClawSweeper reviewed this head with no findings and a platinum rating; its additional confirmation request is pending.

Current-head CI run34597691317 passed all three UI test shards, all13 UI E2E shards, and UI performance. Merge remains blocked by android-test-play:1 of3189 Kotlin tests failed when SettingsScreensContrastTest.chatHeaderDoesNotAnnounceOfflineForConnectedHealthFailure could not display New chat, Ready after reconnect (SettingsScreensContrastTest.kt:364). The changed file is a TS WebKit bridge and does not modify Android; no base reproduction or rerun is claimed. Required CI has not passed. No merge or cleanup has been performed.

Android failure attribution and base refresh

Confirmed unrelated to this change: merged PR144682 records the identical New chat, Ready failure on main and fixes the race between ViewModel state and Compose rendering. Its commit 1bd25b2471c7f56289ad20e7ee6085d2b9615bb7 was absent from the failing head. The entire Android tree was identical between our original base and head (006eb01c04e5427c329cee936ea1b05b80681032), and the Gradle task does not consume the changed TS module.

Merged current main 66c7fad06385986bc426a64d87a020f9b24b5fbb normally into the feature branch, producing b5ca7aa7bb7d7303bd62fc794f74507c3153803b. No force push. The PR remains a one-file diff (+145/-289), with unchanged patch fingerprint eda479502d6f5a4d01a3486962b9ab806c949c01. Current-head CI must run against this refreshed base before merge.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Sep 11, 2026
@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 11, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 11, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 8:54 AM ET / 12:54 UTC (Revision 4).

ClawSweeper review

What this changes

Replace duplicated native settings types and handwritten validators with Zod schemas that infer types and return validated copies of host settings.

Merge readiness

✅ Ready for maintainer review

No actionable regression found. This remains a useful, bounded refactor absent from current main; member authorship and the protected maintainer label also preclude automatic closure.

Priority: P3
Reviewed head: b5ca7aa7bb7d7303bd62fc794f74507c3153803b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused simplification with useful existing coverage and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored refactor is exempt from external-contributor proof requirements and introduces no material authority change. Inspected earlier mock-host captures cover settings presentation; reported focused checks cover parsed-copy consumption, without claiming live OS behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored refactor is exempt from external-contributor proof requirements and introduces no material authority change. Inspected earlier mock-host captures cover settings presentation; reported focused checks cover parsed-copy consumption, without claiming live OS behavior.
Evidence reviewed 8 items Schema conversion and boundary preservation: Read the complete changed module and main version. Required nullable fields, optional settings families, permission order and uniqueness, invalid-input handling, and edit settlement remain intact. Parsed copies and unknown-field stripping are explicitly documented in the supplied PR body.
Re-review continuity: The changed module has no differences from the previously reviewed head. The supplied completed-review projection contains no findings or published rank-up moves.
Still distinct from main and latest release: Current main and v2026.9.4 both contain blob 5aff0547b74813a55c72862e2c389384c20a6c09, the handwritten implementation; the PR contains blob 1bded6c1dc32212df628fb44a341007341739b3b. The supplied merged Android test repair is unrelated to this refactor.
Findings None None.
Security None None.

How this fits together

The Control UI receives device settings from the macOS or iOS app through a WebKit bridge. Validated snapshots populate device settings pages, while edits return to the native app for authoritative handling.

flowchart LR
  A[Native app settings] --> B[WebKit bridge]
  B --> C[Snapshot validation]
  C --> D[Settings cache and subscribers]
  D --> E[Device settings pages]
  E --> F[Typed edit commands]
  F --> B
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -144. Total -144 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 145 289 -144
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 145 289 -144

Review metrics

None.

Technical review

Best possible solution:

Keep one schema-owned UI snapshot contract while native apps retain ownership of settings changes and permission decisions.

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

Not applicable: this is a refactor, and source inspection found no introduced failure requiring reproduction.

Is this the best way to solve the issue?

Yes: inferring types from the existing validation owner removes duplication, and inspected consumers do not depend on retained unknown fields or raw host-object identity.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 66c7fad06385.

Labels

Label justifications:

  • P3: This removes duplicated validation definitions without adding settings or changing intended user behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 member-authored refactor is exempt from external-contributor proof requirements and introduces no material authority change. Inspected earlier mock-host captures cover settings presentation; reported focused checks cover parsed-copy consumption, without claiming live OS behavior.

Evidence

What I checked:

  • Schema conversion and boundary preservation: Read the complete changed module and main version. Required nullable fields, optional settings families, permission order and uniqueness, invalid-input handling, and edit settlement remain intact. Parsed copies and unknown-field stripping are explicitly documented in the supplied PR body. (ui/src/app/native-device-settings.ts:233, b5ca7aa7bb7d)
  • Re-review continuity: The changed module has no differences from the previously reviewed head. The supplied completed-review projection contains no findings or published rank-up moves. (ui/src/app/native-device-settings.ts, b5ca7aa7bb7d)
  • Still distinct from main and latest release: Current main and v2026.9.4 both contain blob 5aff0547b74813a55c72862e2c389384c20a6c09, the handwritten implementation; the PR contains blob 1bded6c1dc32212df628fb44a341007341739b3b. The supplied merged Android test repair is unrelated to this refactor. (ui/src/app/native-device-settings.ts, 3a9d69db306c)
  • Native producer and consumer contracts: The Swift contract publishes JSON snapshots and change events, including explicitly encoded nullable fields. Device pages subscribe to the capability and retain pending edits by capability identity, not snapshot identity. The documented macOS/iOS optional settings remain represented. (apps/shared/OpenClawKit/Sources/OpenClawKit/DeviceSettingsContract.swift:543, b5ca7aa7bb7d)
  • Existing behavioral coverage: The unchanged bridge tests exercise optional iOS fields, malformed snapshots, duplicate permissions, authoritative replies, disposal, and exact outgoing commands. The body reports 34 focused tests plus type and lint checks passing for the parsed-copy implementation. No tests or target code were executed during this read-only review. (ui/src/app/native-device-settings.test.ts:31, b5ca7aa7bb7d)
  • Dependency integer contract: The patch directly imports Zod, already pinned to 4.4.3 by the UI. Its integer validator rejects unsafe integers, preserving the prior Chrome profile-count guard: Zod integer implementation. (packages/zod/src/v4/core/checks.ts:290)

Likely related people:

  • Peter Steinberger: 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 (3 earlier review cycles)
  • reviewed 2026-09-11T07:23:38.443Z sha 32fe150 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-11T12:26:40.428Z sha 32fe150 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-11T12:38:58.617Z sha 32fe150 :: needs maintainer review before merge. :: none

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 11, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@jesse-merhi
jesse-merhi marked this pull request as ready for review September 11, 2026 14:13
Copilot AI lite review requested due to automatic review settings September 11, 2026 14:13

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jesse-merhi
jesse-merhi merged commit 90e44fe into main Sep 11, 2026
264 of 268 checks passed
@jesse-merhi
jesse-merhi deleted the refactor/native-device-settings-schema branch September 11, 2026 14:13
vincentkoc added a commit that referenced this pull request Sep 11, 2026
* commit 'f2ce199238e974b1d4caff8f11112aa51eb00d9e': (310 commits)
  refactor(copilot): deduplicate transcript user text (#144888)
  refactor(sessions): await discovery and config readiness (#144854)
  refactor(e2e): deduplicate release file assertions (#144904)
  ci: keep growing hosted test plans within the job cap (#144965)
  fix(macos): avoid stale dashboard command assertions (#144710)
  refactor(memory): await standing intent operations (#144832)
  refactor(ui): derive native device settings types from schemas (#144705)
  refactor(memory): await journal operations and allocate sequences atomically (#144824)
  refactor(tests): share command field assertions (#144955)
  refactor(matrix): share bounded context cache insertion (#144939)
  refactor(i18n): share Apple catalog reader (#144848)
  fix(doctor): preserve legacy registry files when quarantine fails (#144787)
  refactor(tests): reuse PixVerse auth fixtures (#144926)
  fix(bonjour): silence transient ENODEV socket warnings (#144870)
  fix(matrix): preserve unrelated files when migration fails (#144883)
  feat(sqlite): run Team Reports storage in owned workers (#144871)
  fix(update): install explicit same-version artifacts (#144894)
  refactor(ui): share cached message extraction (#144244)
  refactor: normalize Claude usage responses at one boundary (#144707)
  refactor: simplify CLI child listener registration (#144929)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
…law#144705)

Consolidate native device settings validation and inferred types with the existing Zod dependency. Consume parsed snapshots directly while preserving invalid-input handling and authoritative edit settlement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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