Skip to content

test(ui): split settings node suite by concern - #128788

Merged
steipete merged 2 commits into
mainfrom
steipete/angry-hertz-318ed2
Aug 24, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/angry-hertz-318ed2

Conversation

@steipete

@steipete steipete commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

ui/src/app/settings.node.test.ts sat at 999 oxlint-counted lines against its
1000-line max-lines cap. Any contributor adding a single counted line to it
failed the check-lint-core-* CI shard — and because the cap is evaluated on
the merge ref, two branches that each add a few lines can both pass locally and
fail only after merge. #128474 hit exactly that failure mode on
ui/src/app/bootstrap.test.ts; this file was the next one queued up to do it.

Why This Change Was Made

The file had one 42-test describe still titled "loadSettings default gateway
URL derivation" that had long since grown past gateway URLs into every
preference and layout key the settings module persists. Rather than cut it at
an arbitrary line number, it is split along the surfaces under test:

  • settings.node.test.ts keeps gateway URL derivation, tab-local token
    handling, and per-gateway/per-base-path session scoping (16 tests).
  • settings.preferences.node.test.ts takes browser-local preference
    persistence: chat shortcut/follow-up/catalog target, sidebar live activity,
    advanced toggle, message width, realtime Talk devices, theme, text scale,
    pinned agents, and local user identity (21 tests).
  • settings.layout.node.test.ts takes chat split, workspace dock, board
    session views, and sidebar session layouts (7 tests).

Keeping the base filename follows the precedent set by the earlier
settings.sidebar-prefs.node.test.ts split rather than renaming every sibling.
The location/base-path/settings-fixture helpers and the storage lifecycle hooks
are genuinely shared by four files now, so they move into
ui/src/test-helpers/settings-node.ts in the style of the existing
installBrowserHistoryIsolation; settings.sidebar-prefs.node.test.ts drops
its copy-pasted duplicates of the same helpers (-56/+14).

Tests were moved, never duplicated or rewritten, and no max-lines suppression
or config/max-lines-baseline.txt entry was added.

User Impact

No runtime or user-visible change — test-file organization only. For
contributors, the settings suites now have 557 to 890 counted lines of headroom
instead of 1, so ordinary test additions stop tripping the core lint shard.

Evidence

Test names and counts are identical before and after — verified by diffing the
sorted it() titles from HEAD against the new files (44 titles, byte-identical),
plus the 3 in settings.sidebar-prefs.node.test.ts:

before: Test Files 2 passed (2) | Tests 47 passed (47)
after:  Test Files 4 passed (4) | Tests 47 passed (47)

Counted lines vs the 1000-line test cap, measured with the rule's own counter
(a throwaway max-lines: 1 oxlint config), not an approximation:

File Before After
settings.node.test.ts 999 409
settings.preferences.node.test.ts — 443
settings.layout.node.test.ts — 110
settings.sidebar-prefs.node.test.ts 111 73

Validation run locally on this branch:

  • node --import tsx scripts/run-oxlint-shards.mts --only=core --split-core --core-stripe=5/5 --threads=1 — clean
  • node scripts/check-changed.mjs — exit 0 (format, package patch guard, knip, i18n catalog, tsgo core tests + UI, full core lint)
  • node_modules/.bin/oxfmt over all touched files
  • autoreview (Codex, gpt-5.6-sol, high) — clean, no accepted findings

Also in this PR: a CI flake fixed rather than waited out

checks-node-compact-large-3 failed twice on this branch, in two different
tests of src/node-host/node-worker-supervisor.container.test.ts — unrelated to
the UI split, which touches no src/** code. The second failure named the cause
outright: SyntaxError: Unexpected end of JSON input from the fake engine's
load() while the supervisor ran docker rm --force.

The test shim saved container state with a truncating fs.writeFileSync while
sibling shim invocations (rm, inspect, wait, ps) read the same path, so a
reader could hit the zero-length window and exit 1. It now writes a .pending
sibling and renames over the target; rename is atomic, so readers always observe
a complete previous or next state. The ps handler filters on the
.container.json suffix, so pending files are ignored.

A concurrent write/read probe over the old pattern produced 2014 partial reads
in 212900
; the same probe over write-then-rename produced 0 in 203468. The
end-to-end failure does not reproduce on macOS even under 96-way CPU contention
— the truncation window is far narrower there than on the loaded Linux shard —
so the CI stack trace plus the mechanism probe are the evidence, not a local red
test.

Nearby, not touched

These are the next merge-ref landmines of the same kind: ui/src/components/app-sidebar-session-navigation.ts is at 695/700
and ui/src/app/app-shell-view.ts at 681/700. Both are production files, so
splitting them is an ownership decision rather than a mechanical move; not
touched here.

ui/src/app/settings.node.test.ts sat at 999 oxlint-counted lines against
the 1000-line max-lines cap, so any added assertion failed the core lint
shard — and, as in #128474, could pass locally while only the merge ref
tripped the cap.

Split the 42-test monolith along the surfaces it actually covers: the
base file keeps gateway URL derivation, tab-local token handling, and
per-gateway session scoping; preference persistence and layout
persistence move to dotted siblings, matching the existing
settings.sidebar-prefs.node.test.ts precedent. Test names and count are
unchanged (47 across the settings node suites, before and after).

The location/base-path/settings-fixture helpers and the storage
lifecycle hooks are now shared from ui/src/test-helpers/settings-node.ts
instead of being copy-pasted per file; sidebar-prefs drops its duplicate
copies too.
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 16:06
checks-node-compact-large-3 failed twice on this branch in different
tests of node-worker-supervisor.container.test.ts, most recently with
"SyntaxError: Unexpected end of JSON input" raised from the fake engine's
load() while the supervisor ran `docker rm --force`.

The shim saved container state with a truncating fs.writeFileSync while
sibling shim invocations (rm, inspect, wait, ps) read the same path, so a
reader could observe the zero-length window and exit 1. Write to a
".pending" sibling and rename over the target instead; rename is atomic,
so readers always see a complete previous or next state. The ps handler
filters on the ".container.json" suffix, so pending files are ignored.

A concurrent write/read probe over the old pattern produced 2014 partial
reads in 212900; the same probe over write-then-rename produced 0 in
203468. Not reproducible end-to-end on macOS, where the truncation
window is far narrower than on the loaded Linux shard.
@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 Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 12:40 PM ET / 16:40 UTC.

ClawSweeper review

What this changes

The PR splits Control UI settings persistence tests into focused suites with shared test setup and replaces truncating fake-container state writes with write-then-rename.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main has not absorbed this work, and source review found no actionable defect. The maintainer-authored, maintainer-labeled PR needs the normal human merge decision after exact-head CI finishes.

Priority: P3
Reviewed head: 8e8ca92a1ef2cc15e2a2487f73172fb95bf4c796
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-verified test maintenance patch with preserved coverage and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR is exempt from the external contributor real-behavior-proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only PR is exempt from the external contributor real-behavior-proof gate.
Evidence reviewed 5 items Shared test lifecycle: The extracted lifecycle owns storage/global setup and drains the settings module's in-memory fallback after each test; all four settings suites consume it.
Coverage preservation: The complete before/after multiset of settings-suite test titles is identical at 47 tests.
Fake-engine race repair: The test shim writes a PID-scoped pending file then renames it over the state file; the process listing only reads .container.json files, leaving pending files out of discovery.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs ui/src/app/settings.node.test.ts ui/src/app/settings.preferences.node.test.ts ui/src/app/settings.layout.node.test.ts ui/src/app/settings.sidebar-prefs.node.test.ts src/node-host/node-worker-supervisor.container.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs ui/src/app/settings.node.test.ts ui/src/app/settings.preferences.node.test.ts ui/src/app/settings.layout.node.test.ts ui/src/app/set
tings.sidebar-prefs.node.test.ts src/node-host/node-worker-supervisor.container.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128788-2uoeE8/target$ node scripts/run-vitest.mjs ui/src/app/settings.node.test.ts ui/src/app/settings.preferen
ces.node.test.ts ui/src/app/settings.layout.node.test.ts ui/src/app/settings.sidebar-prefs.node.test.ts src/node-host/node-worker-supervisor.container.test.ts
node scripts/run-vitest.mjs ui/src/app/settings.node.test.ts ui/src/app/settings.preferences.node.test.ts ui/src/app/settings.layout.node.test.ts ui/src/app/set
tings.sidebar-prefs.node.test.ts src/node-host/node-worker-supervisor.container.test.ts
[test] starting test/vitest/vitest.unit.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128788-2uoeE8/target

 ✓  unit  src/node-host/node-worker-supervisor.container.test.ts (13 tests) 4496ms
     ✓ mounts only the admitted bundle and workspace and round-trips the stdio result  649ms
     ✓ uses the documented Node 22 image when no override is configured  412ms
     ✓ keeps a pending cancelled container slot occupied until the fake engine confirms removal  445ms
     ✓ cancel kills and removes the container before terminal persistence  402ms
     ✓ close kills and removes the container before terminal persistence  393ms
     ✓ interrupts a stale running journal after verifying its dead container identity  300ms
     ✓ keeps the launch and capacity occupied when removal fails until cancellation can retry  543ms
     ✓ never executes a container worker when its durable identity cannot be recorded  486ms

 Test Files  1 passed (1)
      Tests  13 passed (13)
   Start at  16:41:47
   Duration  6.91s (transform 1.77s, setup 769ms, import 1.36s, tests 4.50s, environment 0ms)

[test] starting test/vitest/vitest.ui.config.ts

























Assertions:

  • PASS expect_output: Test Files

How this fits together

Control UI settings are loaded from browser storage and exercised by node-environment test suites that share module-level state. Separately, node-worker supervisor tests use a fake container engine whose commands read and update per-container state files.

flowchart LR
  A[Control UI settings] --> B[Node settings test suites]
  B --> C[Shared storage lifecycle]
  C --> D[Settings persistence module]
  E[Worker supervisor tests] --> F[Fake container engine]
  F --> G[Container state files]
  G --> H[Concurrent shim commands]
Loading

Decision needed

Question Recommendation
Should this maintainer-authored, maintainer-labeled test-maintenance PR merge once its exact-head CI is green? Merge after CI: Accept the focused test refactor and race repair when required checks pass on the current head.

Why: The protected maintainer label requires explicit maintainer handling even though the reviewed patch has no actionable finding.

Before merge

  • Resolve merge risk (P1) - Exact-head CI was still in progress at review time, so merge should wait for its terminal result.
Agent review details

Security

None.

PR surface

Source +87, Tests -63. Total +24 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 1 87 0 +87
Tests 5 692 755 -63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 779 755 +24

Review metrics

Metric Value Why it matters
Production versus test LOC production 0; tests and test support +779/-755 (net +24) All six touched paths are test or test-support surfaces; the small net growth is the shared fixture and explanatory race-safety code.

Stored data model

Persistent data-model change detected: serialized state: src/node-host/node-worker-supervisor.container.test.ts, serialized state: ui/src/app/settings.layout.node.test.ts, serialized state: ui/src/app/settings.preferences.node.test.ts, serialized state: ui/src/app/settings.sidebar-prefs.node.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge this focused test-only maintenance once exact-head CI is green, retaining the shared lifecycle and fake-engine atomic replacement.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge this focused test-only maintenance once exact-head CI is green, retaining the shared lifecycle and fake-engine atomic replacement.

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

Unclear for live execution: source establishes the fake-engine reader/writer boundary, but this read-only review did not run the race or test suites.

Is this the best way to solve the issue?

Yes: behavior-based test splitting with one shared lifecycle is preferable to a lint suppression, and atomic replacement belongs in the fake engine that owns the state file.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is low-risk test organization and CI-harness reliability maintenance without a user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR is exempt from the external contributor real-behavior-proof gate.

Label justifications:

  • P3: This is low-risk test organization and CI-harness reliability maintenance without a user-visible behavior change.
  • 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: This maintainer-authored, test-only PR is exempt from the external contributor real-behavior-proof gate.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame and history show sustained work on the settings suites; the same contributor also authored the preceding node-worker container repair. (role: recent area contributor; confidence: high; commits: e31de4a6c0ca, 9f5803079e4e; files: ui/src/app/settings.node.test.ts, ui/src/app/settings.sidebar-prefs.node.test.ts, src/node-host/node-worker-supervisor.container.test.ts)
  • Vincent Koc: History shows prior settings-suite contributions, though the current PR surface is primarily associated with steipete. (role: historical settings contributor; confidence: medium; commits: cd2c9a2ed473, 0606c0a96426; files: ui/src/app/settings.node.test.ts)

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.

@steipete
steipete merged commit d2d58a5 into main Aug 24, 2026
305 of 307 checks passed
@steipete
steipete deleted the steipete/angry-hertz-318ed2 branch August 24, 2026 17:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
* test(ui): split settings node suite by concern

ui/src/app/settings.node.test.ts sat at 999 oxlint-counted lines against
the 1000-line max-lines cap, so any added assertion failed the core lint
shard — and, as in openclaw#128474, could pass locally while only the merge ref
tripped the cap.

Split the 42-test monolith along the surfaces it actually covers: the
base file keeps gateway URL derivation, tab-local token handling, and
per-gateway session scoping; preference persistence and layout
persistence move to dotted siblings, matching the existing
settings.sidebar-prefs.node.test.ts precedent. Test names and count are
unchanged (47 across the settings node suites, before and after).

The location/base-path/settings-fixture helpers and the storage
lifecycle hooks are now shared from ui/src/test-helpers/settings-node.ts
instead of being copy-pasted per file; sidebar-prefs drops its duplicate
copies too.

* test(node-host): write fake container-engine state atomically

checks-node-compact-large-3 failed twice on this branch in different
tests of node-worker-supervisor.container.test.ts, most recently with
"SyntaxError: Unexpected end of JSON input" raised from the fake engine's
load() while the supervisor ran `docker rm --force`.

The shim saved container state with a truncating fs.writeFileSync while
sibling shim invocations (rm, inspect, wait, ps) read the same path, so a
reader could observe the zero-length window and exit 1. Write to a
".pending" sibling and rename over the target instead; rename is atomic,
so readers always see a complete previous or next state. The ps handler
filters on the ".container.json" suffix, so pending files are ignored.

A concurrent write/read probe over the old pattern produced 2014 partial
reads in 212900; the same probe over write-then-rename produced 0 in
203468. Not reproducible end-to-end on macOS, where the truncation
window is far narrower than on the loaded Linux shard.
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: XL 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.

1 participant