Skip to content

fix(ui): reject nondecimal strings in config form number coercion - #109675

Closed
wangmiao0668000666 wants to merge 4 commits into
openclaw:mainfrom
wangmiao0668000666:fix/ui-config-nondecimal-coercion
Closed

wangmiao0668000666 wants to merge 4 commits into
openclaw:mainfrom
wangmiao0668000666:fix/ui-config-nondecimal-coercion

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI config form coerces string input back to schema-typed numbers before submitting config.set/config.apply, but the coercion used a bare Number(trimmed). Number() accepts radix and JS-only spellings, so typing 0x10 into a numeric field or a string|number union field silently persisted 16 — the stored config value differs from what the user typed, with no error surfaced. Same for 0b1010 → 10, 0o17 → 15, 1_000 → 1000, Infinity, and leading + spellings.

Entry paths are real: mixed string|number unions render as plain text inputs, array items arrive as strings, and HTML number inputs always emit string .values — all flow through patchForm → serializeFormForSubmit → coerceFormValues → coerceConfigFormNumberString.

Why This Change Was Made

Gate coercion on a decimal regex (/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/, ui/src/components/config-form.shared.ts) before calling Number(). The grammar mirrors the HTML valid floating-point number grammar exactly: radix and JS-only spellings (0x10, 0b1010, 0o17, 1_000, Infinity, NaN, leading +, dangling exponents like 1e/e5) fall through to the keep-as-string path, so the typed text is submitted verbatim and the gateway's schema validation rejects it with a visible error instead of silently storing a reinterpreted number.

Scientific notation (1e5, -2.5E-3, .5e2) is deliberately accepted: it is part of the HTML number input grammar and the standard Number() spelling, so rejecting it would be a compatibility break, and Number("1e5") → 100000 is not a reinterpretation — the persisted value means exactly what the user typed. Anything a real <input type="number"> can hold coerces exactly as Number() reads it; spellings the browser itself sanitizes away (0x10, 1_000, +5) are rejected at the patchForm boundary for the text-input entry paths (union fields, array items).

This mirrors the merged nondecimal-reject pattern: #107480 (parseCronEveryMs rejects 0x10/+1 in cron repeat amounts) and #105158 (parseStrictFiniteNumber rejects hex --cpus 0x10 in fleet). Negative decimals, floats, and .5/5. spellings coerce exactly as before, and the existing finite/integer guards are untouched.

No new config/env/options; the production change is one module-level regex in ui/src/components/config-form.shared.ts.

User Impact

  • Typing 0x10/0b1010/1_000/Infinity into a numeric config field no longer silently writes a different number into openclaw.json; the typed text is preserved and rejected by schema validation where the user can see it.
  • Scientific notation typed into a number field (1e5) saves as the number it spells (100000), matching the HTML number grammar and Number() contract.
  • Valid decimal input (42.5, -7, .5) behaves exactly as before.

Evidence

Production-entry proof — real createRuntimeConfigCapability save flow

A standalone script (not committed) drives the real capability — ensureLoaded + ensureSchemaLoaded + patchForm + save() against a plain fake gateway client object — and inspects the exact raw bytes submitted to config.set. No test mocks anywhere in the path.

Before fix (origin/main @ 19b5e564d7):

{
  "hex-into-number-field": { "typed": "0x10", "submittedValue": 16, "submittedType": "number" },
  "binary-into-integer-field": { "typed": "0b1010", "submittedValue": 10, "submittedType": "number" },
  "exponent-into-number-field": { "typed": "1e3", "submittedValue": 1000, "submittedType": "number" },
  "hex-into-string|number-union": { "typed": "0x10", "submittedValue": 16, "submittedType": "number" },
  "valid-decimal-still-coerces": { "typed": "42.5", "submittedValue": 42.5, "submittedType": "number" },
  "valid-negative-still-coerces": { "typed": "-7", "submittedValue": -7, "submittedType": "number" }
}

After fix (this PR, regex + guard in config-form.shared.ts):

{
  "hex-into-number-field": { "typed": "0x10", "submittedValue": "0x10", "submittedType": "string" },
  "binary-into-integer-field": { "typed": "0b1010", "submittedValue": "0b1010", "submittedType": "string" },
  "exponent-into-number-field": { "typed": "1e3", "submittedValue": 1000, "submittedType": "number" },
  "hex-into-string|number-union": { "typed": "0x10", "submittedValue": "0x10", "submittedType": "string" },
  "valid-decimal-still-coerces": { "typed": "42.5", "submittedValue": 42.5, "submittedType": "number" },
  "valid-negative-still-coerces": { "typed": "-7", "submittedValue": -7, "submittedType": "number" }
}

Note the round-3 behavior change: 1e3 now coerces to 1000 (standard scientific spelling, not a reinterpretation), while radix/JS-only spellings still stay strings.

Control-red

Reverse-verified both directions: reverting the regex to the strict decimal-only form turns the 6 new scientific-notation assertions red (1e5/1e3/.5e2/-2.5E-3 coercion in number fields, integer fields, and the union field); restoring it returns the suite to green. Reverting the whole guard to a bare Number(trimmed) reproduces the silent 16/10 rewrites.

Regression tests — ui/src/lib/config/index.test.ts + ui/src/components/config-form.browser.test.ts

  • it.each(["0x10", "0b1010", "0o17", "+5", "1_000", "Infinity", "NaN", "1e", "e5"]): number AND integer fields keep radix/JS-only spellings as strings in the submitted config.set payload.
  • it.each([["42.5", 42.5], ["-7", -7], [".5", 0.5], ["1e3", 1000], ["1e5", 100000], [".5e2", 50], ["-2.5E-3", -0.0025]]): decimal and scientific spellings coerce to numbers.
  • Union field: 1e5 → 100000 (number), 0x10 stays a string, 42 → 42.
  • Browser renderer test: real input events on rendered number inputs — 1e5 patches 100000, -2.5E-3 patches -0.0025, 42.5 into an integer field is held back as a string for schema validation.

Test suite

$ node scripts/run-vitest.mjs ui/src/lib/config/index.test.ts ui/src/components/config-form.browser.test.ts
 Test Files  2 passed (2)
      Tests  97 passed (97)

Lint / format

$ oxlint ui/src/components/config-form.shared.ts ui/src/components/config-form.browser.test.ts ui/src/lib/config/index.test.ts
(exit 0, no findings)
$ oxfmt --check <same files>   # clean
$ git diff --check             # clean

Real Control UI browser proof (round 3, refreshed 2026-07-18)

Real gateway from this branch's dist/ + real Chromium driving the served Control UI (no mocks), agents.defaults.compaction.reserveTokens (integer field):

  • Typing 1e5 autosaves and persists "reserveTokens": 100000 in openclaw.json (new behavior — scientific notation preserved).
  • Typing 42.5 into the same integer field still fails schema validation: "Save failed" pill, typed text retained, file keeps 100000.
  • Reloading shows the persisted 100000 in the field; typing a plain decimal (150000) saves as a number, exactly as before.
  • Radix spellings (0x10, 1_000, +5) cannot even be entered into a real <input type="number"> — Chromium sanitizes them to the empty string — so their rejection is proven at the patchForm boundary in the tests above.

Screenshots + transcript: #109675 (comment)

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 2:50 AM ET / 06:50 UTC.

Summary
The PR centralizes Control UI numeric-string coercion and preserves nondecimal JavaScript-only spellings as strings for gateway schema validation.

PR surface: Source +23, Tests +177. Total +200 across 5 files.

Reproducibility: yes. the supplied before/after real Control UI and gateway transcript identifies the affected save path, and the focused regression cases exercise the same renderer and serialization boundaries.

Review metrics: 1 noteworthy metric.

  • Numeric coercion contract: 1 shared normalization helper changed. Both renderer-time and submit-time paths now share one accepted-number grammar, so the compatibility decision applies across the Control UI rather than one field type.

Stored data model
Persistent data-model change detected: serialized state: ui/src/lib/config/index.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • [P2] Confirm the intended accepted-number grammar and refresh the branch against current main before merge.

Risk before merge

  • [P1] This intentionally stops the UI from accepting JavaScript-only numeric spellings that previous Number() coercion converted; maintainers should explicitly accept that compatibility boundary and refresh the branch against current main before landing.

Maintainer options:

  1. Confirm the narrowed grammar before merge (recommended)
    Accept the patch after a maintainer confirms that rejecting radix and JavaScript-only numeric spellings in configuration forms is the intended upgrade behavior.
  2. Preserve broader legacy parsing
    Do not merge this change if configuration forms must continue accepting JavaScript-only numeric spellings; document the required legacy contract before selecting an alternative implementation.

Next step before merge

  • [P2] A maintainer must confirm the intentional accepted-number grammar; there is no narrow mechanical repair to dispatch.

Maintainer decision needed

  • Question: Should Control UI configuration forms retain JavaScript-only numeric coercion, or adopt this PR's standard decimal/scientific grammar and surface the remaining spellings through existing schema validation?
  • Rationale: The implementation is coherent, but choosing which previously accepted numeric spellings remain valid in a user-facing configuration editor is an intentional compatibility policy decision.
  • Likely owner: steipete — The remaining question is product compatibility rather than a mechanical defect.
  • Options:
    • Adopt standard numeric grammar (recommended): Accept decimal and scientific notation while preserving radix and JavaScript-only text for schema validation, as implemented by this PR.
    • Retain permissive coercion: Keep the existing broad Number() acceptance if compatibility with JavaScript-only numeric spellings is more important than preventing silent reinterpretation.

Security
Cleared: The patch only changes local UI value normalization and focused tests; it adds no dependency, workflow, permission, secret, download, or supply-chain surface.

Review details

Best possible solution:

Land the shared boundary only after confirming that config forms should accept standard decimal/scientific notation but leave radix and other JavaScript-only spellings to schema validation.

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

Yes: the supplied before/after real Control UI and gateway transcript identifies the affected save path, and the focused regression cases exercise the same renderer and serialization boundaries.

Is this the best way to solve the issue?

Unclear until maintainer intent is confirmed: the shared helper is the narrowest maintainable implementation, but the accepted numeric grammar is a user-facing compatibility choice.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded user-facing configuration correctness and compatibility change without evidence of an urgent outage or data-loss event.
  • merge-risk: 🚨 compatibility: Merging changes which numeric spellings existing Control UI form paths accept and coerce during configuration saves.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The PR provides refreshed real gateway plus Chromium before/after screenshots and transcript evidence for the changed save behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides refreshed real gateway plus Chromium before/after screenshots and transcript evidence for the changed save behavior.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR provides refreshed real gateway plus Chromium before/after screenshots and transcript evidence for the changed save behavior.
Evidence reviewed

PR surface:

Source +23, Tests +177. Total +200 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 49 26 +23
Tests 2 177 0 +177
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 226 26 +200

What I checked:

  • Shared coercion boundary: The branch adds one shared numeric-input normalizer that returns empty input as undefined, decimal/scientific finite values as numbers, and unsupported spellings as their original text for schema validation. (ui/src/components/config-form.shared.ts:67, 39df5c3f5c3a)
  • Both UI entry paths use the helper: Plain number controls call the shared normalizer at input time, and configuration serialization calls the same helper for number and integer schema values; this avoids the earlier split behavior between renderer and save paths. (ui/src/components/config-form.node.ts:507, 39df5c3f5c3a)
  • Regression coverage: The branch adds focused renderer and runtime-config cases for rejected radix/JavaScript-only spellings, accepted decimal/scientific spellings, integer rejection, and union behavior. (ui/src/lib/config/index.test.ts:201, 39df5c3f5c3a)
  • After-fix behavior proof: The supplied PR discussion includes refreshed real-gateway and Chromium evidence showing scientific notation persists as its numeric value while an invalid fractional value for an integer field remains visible and fails schema validation. (39df5c3f5c3a)
  • Prior review continuity: The earlier scientific-notation blocker was addressed in the current head: the shared grammar explicitly accepts exponent forms and the new tests cover them, so no previous finding remains actionable. (ui/src/components/config-form.shared.ts:67, 39df5c3f5c3a)

Likely related people:

  • steipete: A maintainer should confirm the intended user-facing compatibility boundary for configuration-form numeric input before merge; provided review context does not include sufficient local file-history provenance to identify a more specific recent code owner. (role: likely product-direction reviewer; confidence: low; files: ui/src/components/config-form.shared.ts, ui/src/components/config-form.node.ts, ui/src/lib/config/index.ts)
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.
Review history (8 earlier review cycles)
  • reviewed 2026-07-17T05:37:07.585Z sha 17f11f49d6b0af1d2b11a468a6651ba909e4b0c9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T18:39:57.119Z sha 17f11f49d6b0af1d2b11a468a6651ba909e4b0c9 :: needs changes before merge. :: [P1] Validate nondecimal input before patching number fields
  • reviewed 2026-07-17T19:53:51.181Z sha 068e147f5c42779c13fa39dc8038a6c378938236 :: found issues before merge. :: [P1] Preserve scientific notation in number fields
  • reviewed 2026-07-17T20:35:40.706Z sha 068e147f5c42779c13fa39dc8038a6c378938236 :: found issues before merge. :: [P1] Preserve scientific notation in generic number fields
  • reviewed 2026-07-17T20:53:06.111Z sha 95ffcaeb791a16cc6ea870509e6ee06da0bc60db :: found issues before merge. :: [P1] Preserve scientific notation in generic number fields
  • reviewed 2026-07-18T01:50:10.203Z sha 95ffcaeb791a16cc6ea870509e6ee06da0bc60db :: found issues before merge. :: [P1] Preserve scientific notation in generic number fields
  • reviewed 2026-07-18T03:25:18.831Z sha 4c671dc82dec80e720ce758357f4692ee115262d :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T04:07:52.174Z sha 4c671dc82dec80e720ce758357f4692ee115262d :: needs maintainer review before merge. :: none

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Real Control UI + real gateway proof for the 🦪 needs-proof gate (head 17f11f49d6b0af1d2b11a468a6651ba909e4b0c9).

Setup: built the PR worktree (pnpm build, Node 24), started a real gateway from dist/ with an isolated OPENCLAW_STATE_DIR and token auth, then drove the Control UI it serves in real Chromium (Playwright) via the tokenized dashboard URL — the same URL openclaw dashboard hands a user. No mocks anywhere: the browser's autosave fired real config.set requests against the real gateway and its Zod validation. (Crabbox/Testbox backends were unreachable from this environment — no broker auth, no blacksmith CLI — so this trusted-source proof ran locally per the AGENTS.md remote-fallback rule.)

Field: Settings → AI & Agents → Agents → Agent Defaults → Compaction → "Compaction Active Transcript Size Threshold" (agents.defaults.compaction.maxActiveTranscriptBytes, schema union(integer, byte-size string)), rendered as a text input — a real field whose typed text flows through coerceFormValues at submit.

Before (same build, only ui/src/lib/config/index.ts swapped to origin/main): typing 1e5 autosaves successfully; after the save round-trip the form itself redisplays the silently reinterpreted 100000, and openclaw.json persists "maxActiveTranscriptBytes": 100000. The typed spelling is rewritten without any sign to the user.

before: 1e5 silently saved as 100000

After (this PR): typing 1e5 surfaces "Save failed" + Retry in the config toolbar; the field keeps the typed 1e5; the gateway's schema validation rejects the string and nothing is persisted (maxActiveTranscriptBytes stays absent from openclaw.json).

after: 1e5 rejected with visible Save failed

Decimal control (this PR): typing 100000 saves cleanly — "Saved" pill plus the usual "Saved to openclaw.json — restart the gateway to apply" banner — and the file gets "maxActiveTranscriptBytes": 100000 as a number.

after: 100000 saves successfully

Driver transcripts (Playwright log lines, incl. persisted-file reads after each autosave)
# after (PR head)
field initial value: ""
after typing 1e5: SAVE FAILED pill visible
after 1e5: field="1e5" persistedInFile=false fileValue=<absent>
after 100000: fileValue="maxActiveTranscriptBytes": 100000

# before (origin/main coercion)
field initial value: ""
after typing 1e5: Saved pill visible
after 1e5: field="100000" persistedInFile=true fileValue="maxActiveTranscriptBytes": 100000
after 100000: fileValue="maxActiveTranscriptBytes": 100000

Note on scope: plain type: "number" fields use <input type="number">, whose @input handler already parses through Number(...) before patching form state, so this PR's guard changes behavior at the submit-time coercion boundary exercised by union-typed text fields (like the one above) and any string values already present in form state — exactly the paths the new unit tests cover.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 17, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

P1 fix pushed: head 068e147f5c42779c13fa39dc8038a6c378938236.

What changed: the strict decimal gate now runs at the earliest input-normalization boundary, before any Number(...) conversion. The regex + coercion moved into coerceConfigFormNumberString in ui/src/components/config-form.shared.ts and are used by both plain number-input handlers in ui/src/components/config-form.node.ts (plain number/integer fields and number-only unions) as well as the existing serialize-time path in ui/src/lib/config/index.ts — one canonical implementation. Plain type="number" controls no longer pre-convert: typing 1e5 keeps the typed text in form state as a string, so the gateway's schema validation — not a silent Number() reinterpretation — decides. That is the same "typed text preserved until schema arbitrates" behavior the union text-field path already had: on a plain integer field the string is rejected with a visible error; on a string|number union the string variant accepts it verbatim.

Regression coverage for both field classes:

  • ui/src/components/config-form.browser.test.ts: plain number input — 1e5 patches as the string "1e5" (not 100000), 42 → 42, 42.5 into an integer field stays "42.5", empty → undefined. Control-red verified: stashing the component change turns this test red (1e5 again becomes 100000).
  • ui/src/lib/config/index.test.ts: new string|number union cases (1e5/0x10 stay strings, 42 → 42) alongside the existing plain number/integer spelling tests.

node scripts/run-vitest.mjs ui/src/lib/config/index.test.ts ui/src/components/config-form.browser.test.ts → 2 files, 89 tests, all green. oxlint clean on all 5 files; tsgo UI + UI-test lanes 0 errors.

Refreshed real-browser proof for the plain number field (real gateway from this branch's dist/ + real Chromium, no mocks; field: agents.defaults.compaction.reserveTokens, schema integer):

PR body Evidence section updated with the same before/after pairs.

@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/ui-config-nondecimal-coercion branch from 068e147 to 95ffcae Compare July 17, 2026 20:49
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 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.

Re-review progress:

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Round 3 — P1 addressed: scientific notation preserved, radix spellings still rejected @ 4c671dc82d

The grammar is narrowed to "reject radix/JS-only spellings, keep the standard decimal + scientific spellings":

CONFIG_FORM_DECIMAL_NUMBER_RE = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/

This mirrors the HTML valid floating-point number grammar exactly, so anything a real <input type="number"> can hold coerces exactly as Number() reads it. 1e5 → 100000 is not a reinterpretation — it is the standard spelling both in the HTML number grammar and in Number(), so rejecting it was the compatibility break flagged in review. What still stays a string for the gateway's schema validation to reject: 0x10, 0b1010, 0o17, 1_000, Infinity, NaN, leading +5, dangling exponents 1e/e5, and empty text.

Tests (ui/src/lib/config/index.test.ts, ui/src/components/config-form.browser.test.ts)

  • New coercion cases: 1e3 → 1000, 1e5 → 100000, .5e2 → 50, -2.5E-3 → -0.0025 (number fields); union field 1e5 → 100000 (was: kept as string).
  • Still rejected (kept as strings in the submitted config.set payload): 0x10, 0b1010, 0o17, +5, 1_000, Infinity, NaN, 1e, e5.
  • Renderer-level: real input events on rendered number inputs — 1e5 patches 100000, -2.5E-3 patches -0.0025, 42.5 into an integer field is still held back as a string for schema validation.
  • Reverse-verified: reverting the regex to the strict decimal-only form turns the 6 new scientific-notation assertions red; restoring it returns the suite to green.
$ node scripts/run-vitest.mjs ui/src/lib/config/index.test.ts ui/src/components/config-form.browser.test.ts
 Test Files  2 passed (2)
      Tests  97 passed (97)

oxlint / oxfmt / git diff --check clean on the 3 touched files.

Real Control UI browser proof (round 3, refreshed)

Real gateway from this branch's dist/ build + real Chromium driving the served Control UI (no mocks), field agents.defaults.compaction.reserveTokens (integer). Transcript:

field initial value: ""
after typing 1e5: Saved pill visible fileValue="reserveTokens": 100000
after typing 42.5 into integer field: SAVE FAILED pill visible field="42.5" fileValue="reserveTokens": 100000
after reload: field="100000" (persisted from 1e5)
after typing 150000: Saved pill visible fileValue="reserveTokens": 150000

Gateway log confirms both sides of the boundary:

⇄ res ✓ config.set — persisted agents.defaults.compaction.reserveTokens: 100000  (typed: 1e5)
⇄ res ✗ config.set INVALID_REQUEST — invalid config: agents.defaults.compaction.reserveTokens: Invalid input: expected number, received string  (typed: 42.5, held back verbatim)

Note: radix spellings like 0x10 cannot even be entered into a real <input type="number"> — Chromium sanitizes them to the empty string on input — so their rejection is exercised at the patchForm boundary in the unit tests above (union text fields, array items, and preloaded values are the real entry paths for such spellings).

@clawsweeper clawsweeper Bot added 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. and removed 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. labels Jul 18, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Note on the red CI: the two failing checks (checks-node-compact-small-5, openclaw/ci-gate) fail on test/scripts/apple-app-i18n.test.ts with "Apple catalog apps/ios/Resources/Localizable.xcstrings is stale". This is unrelated to this PR's diff (which touches only ui/src/components/config-form.shared.ts and its colocated test) — main itself is currently failing the same shard with the identical error on runs 29629024764 and 29629284704. Will rebase onto a green main once the catalog is resynced upstream.

wangmiao0668000666 and others added 4 commits July 18, 2026 14:45
The decimal grammar now mirrors the HTML valid floating-point number
grammar: scientific spellings (1e5, -2.5E-3, .5e2) coerce exactly as
Number() reads them, while radix and JS-only spellings (0x10, 0b1010,
0o17, 1_000, Infinity, NaN, leading +, 1e, e5) still stay strings for
schema validation to reject. Rejecting 1e5 was a compatibility break
with the HTML number input grammar and standard Number() spelling.

Co-Authored-By: Claude <[email protected]>
@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/ui-config-nondecimal-coercion branch from 4c671dc to 39df5c3 Compare July 18, 2026 06:46
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (723f5ba4fc) now that the upstream apple-app-i18n catalog is resynced and main CI is green again (runs 29633866092/29633896259). Focused tests re-verified post-rebase: run-vitest.mjs ui/src/components/config-form.browser.test.ts ui/src/lib/config/index.test.ts — 97/97 green. No code changes; diff is patch-identical to the round-3 head.

@vincentkoc

Copy link
Copy Markdown
Member

Thanks @wangmiao0668000666. The broader config-form integrity fix incorporated this PR's numeric grammar and regression coverage, with contributor credit preserved, and has now merged in #116282 at 183db47e97f5960df46f8accbcb2ad2d0cc0613a.

Closing this PR as superseded by the landed canonical fix.

@vincentkoc vincentkoc closed this Jul 30, 2026
@wangmiao0668000666
wangmiao0668000666 deleted the fix/ui-config-nondecimal-coercion branch July 30, 2026 16:39
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks @vincentkoc for carrying the numeric grammar and regression coverage into the broader fix — verified the landed grammar in config-form.constraints.ts on main matches the round-3 decimal/scientific behavior. Happy to see it shipped.

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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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