Skip to content

fix(test): run the shared Control UI lane on the cross-file cleanup runner - #126071

Merged
steipete merged 2 commits into
mainfrom
steipete/ui-lane-leak-sweep
Aug 19, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/ui-lane-leak-sweep

Conversation

@steipete

@steipete steipete commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI unit lane fails at random on pull requests that never touched the failing file, and the blamed file moves whenever any UI file changes size. Measured on this machine before the fix: 4 of 4 full pnpm --dir ui test --maxWorkers 3 runs failed, each blaming a different unrelated file (board-view, chat-pane-sidebar-layout.lazy, app-host.panel-toggles, widget-theme). Restricting to src/app and shuffling file order, 8 of 20 seeds failed across four files (app-host.test.ts, app-host.chat-metadata.test.ts, overlays.test.ts, gateway-store.test.ts), typically as expected 0 to be 1 where a vi.mock factory never reached production code.

Why This Change Was Made

ui/vitest.config.ts is what CI's checks-ui job runs (pnpm --dir ui test). Its unit project sets isolate: false but never wired runner: nonIsolatedRunnerPath, so the whole per-file cleanup stack in test/non-isolated-runner.ts — module-graph reset, repo-owned custom-element dropping, DOM body reset, timer/spy restoration, mocker serialization — never ran in the lane CI actually uses. Only the repo-root lane behind scripts/run-vitest.mjs loaded it.

Without that cleanup, files sharing a worker keep the previous file's evaluated modules. Whichever file imports a component first pins it to the real dependency, and a later file's vi.mock factory never reaches production code. Because Vitest orders files by size, adding or resizing any UI file reshuffles worker packing and moves the failure to a different innocent file.

This is exactly the class PR #123512 diagnosed and fixed at the runner. That fix never reached this lane, so the repo kept absorbing the same class one uiIsolatedTestFiles entry at a time — the reactive workaround #123512 explicitly called out. Fixing the wiring removes the need for new entries rather than adding another.

Two projects stay exempt, for reasons stated at the code site:

  • browser runs in browser mode, where the runner's node:fs and server-module imports cannot load.
  • unit-node carries the Playwright-driven layout tests (chat-responsive.browser.test.ts, view.browser.test.ts) whose browser lives in module scope; wiring the runner there churned it and failed 5 layout assertions in 1 of 3 runs, so it is deliberately left alone.

test/vitest-ui-package-config.test.ts asserted runner was undefined for every ui project, which pinned the broken wiring in place. It now asserts the invariant instead and fails on the pre-fix config.

User Impact

No runtime behavior change. CI stops failing on unrelated PRs, and a mock that does not reach production now fails deterministically in the file that owns it instead of at random in a sibling.

Evidence

All runs are pnpm --dir ui test --maxWorkers 3 (CI's exact command) on the same machine, interleaved to control for load.

Scope Before After
src/app, 20 shuffled seeds 8/20 seeds failed 0/20
Full suite, 5 previously-failing seeds failed 5/5 pass (699 files)
Full suite, repeated runs 4/4 runs failed 3/4 runs fully green
  • Guard test fails on the pre-fix config and passes after (verified by reverting the wiring line and re-running test/vitest-ui-package-config.test.ts).
  • Root lane unaffected: node scripts/run-vitest.mjs ui/src/app ui/src/pages/new-session → 92 files, 1082 tests pass.
  • node scripts/check-changed.mjs → exit 0. Autoreview (Codex gpt-5.6-sol, high): clean, "patch is correct (0.99)".
  • Sibling audit: every other config setting isolate: false already wires the runner — createScopedVitestConfig defaults it on, the fake-timer and shared configs set it explicitly, and test/vitest-projects-config.test.ts already asserts it for the root ui, contract, unit-fast and bundled lanes. The ui package configs were the only drift.

Production LOC delta: 0 (test infrastructure only).

Known residual

This is a large improvement, not a total elimination. One run in four still failed a single cross-file test (channels-page, and sessions-hub-tabs in an earlier round); both pass 3/3 alone and with their own directory, and the baseline arm failed more often and across more files. That tail is a separate root cause in the same class and is left as a named follow-up rather than absorbed into uiIsolatedTestFiles.

Follow-up worth considering: with the runner active, much of uiIsolatedTestFiles may no longer need isolation — that list can likely shrink, but shrinking it is its own change with its own proof.

Related work

PR #126037 (open) hardens late mock-registration draining inside test/non-isolated-runner.ts. The two changes are complementary and independent: that one makes the runner more correct, this one makes CI's Control UI lane actually load it. Neither depends on the other.

Second commit: unblocking red main

check-prod-types was red on main (broken by #126062, reproduced locally), which blocks this PR's gate. Per repo policy I fixed it here rather than waiting it out; no fix was in flight.

#126062 threaded resolveGatewayContext into the announce dispatch call, but that call goes through dispatchGatewayLifecycleMethod, whose options type does not carry the field. The type checker is correct: dispatchGatewayLifecycleMethod hands work to runtime.dispatchAgent, which resolves context from the Gateway instance it is bound to and forwards a fixed option allowlist — so the caller-supplied resolver was already being ignored at runtime. Removing it is behavior-preserving.

subagent-announce-delivery.test.ts asserted the resolver was forwarded. Production now binds to the instance dispatcher while that test injects a mock, so the assertion only proved the mock; it now asserts the resolver is deliberately not forwarded.

For the owner of #126062: sendSubagentAnnounceDirectly and its callers still accept and thread resolveGatewayContext, which is vestigial on this path now. Deleting that chain, or teaching the instance runtime to honor the resolver, is a design call on a just-landed change, so I left it alone rather than guessing.

CI note

checks-node-compact-small-4 failed once here on src/gateway/server.chat.gateway-server-chat.test.ts ("restart drain overlaps dispatch rejection"). That is a pre-existing intermittent main-side flake, not related to this diff (which touches only ui/vitest.config.ts and a config test): main itself failed the same shard on run 32197140213 while the preceding main run passed it. Re-run to confirm; the flake is reported separately rather than silently absorbed.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 18, 2026 23:15
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 8:21 PM ET / August 19, 2026, 00:21 UTC.

ClawSweeper review

What this changes

The branch assigns the existing cross-file cleanup runner to Control UI’s shared Vitest unit project, tests that configuration, and removes an ignored context resolver from instance-bound subagent announcement dispatch.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for protected maintainer handling: the branch fixes a real missing Control UI runner wiring with no blocking code finding, but exact-head CI is still running and the PR documents a residual flake requiring maintainer judgment.

Priority: P2
Reviewed head: 6ec5962bbfd7e820a173d1a533b5d1cc5e1980c3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch follows existing owner boundaries and has credible lane evidence; refreshed exact-head CI remains the material merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is not subject to the external-contributor proof gate; its body nevertheless includes after-fix terminal evidence from the actual Control UI lane.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is not subject to the external-contributor proof gate; its body nevertheless includes after-fix terminal evidence from the actual Control UI lane.
Evidence reviewed 6 items Missing current-main UI wiring: Current main’s unit project is non-isolated but has no cleanup-runner setting; the branch adds the existing runner at that project boundary.
Runner owner behavior: The shared runner performs per-file mock draining, DOM cleanup, module reset, and mock reset only when isolation is disabled.
CI entry point: The ordinary checks-ui job runs the package UI suite with three workers, so this project configuration controls the reported lane.
Findings None None.
Security None None.

Live Verification

Command: pnpm test test/vitest-ui-package-config.test.ts

Result: FAIL (partial) — step 2 expect_output runs the shared jsdom ui project on the cross-file cleanup runner: expected terminal output was not visible within 30 seconds: "runs the shared jsdom ui project on the cross-file cleanup runner"

pnpm test test/vitest-ui-package-config.test.ts
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126071-pgZODr/target$ pnpm test test/vitest-ui-package-config.test.ts
$ node --import tsx scripts/test-projects.mts test/vitest-ui-package-config.test.ts
pnpm test test/vitest-ui-package-config.test.ts
[test] starting test/vitest/vitest.tooling.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-126071-pgZODr/target

 ✓  tooling  test/vitest-ui-package-config.test.ts (4 tests) 6ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  00:22:00
   Duration  1.27s (transform 411ms, setup 58ms, import 871ms, tests 6ms, environment 0ms)

[test] passed 1 Vitest shard in 6.76s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126071-pgZODr/target$ pnpm test test/vitest-ui-package-config.test.ts
$ node --import tsx scripts/test-projects.mts test/vitest-ui-package-config.test.ts
[test] starting test/vitest/vitest.tooling.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-126071-pgZODr/target

 ✓  tooling  test/vitest-ui-package-config.test.ts (4 tests) 5ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  00:22:07
   Duration  851ms (transform 119ms, setup 27ms, import 587ms, tests 5ms, environment 0ms)

[test] passed 1 Vitest shard in 6.28s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126071-pgZODr/target$




















Assertions:

  • FAIL expect_output: runs the shared jsdom ui project on the cross-file cleanup runner

How this fits together

Control UI unit tests share non-isolated Vitest workers, so project configuration determines whether repository cleanup resets modules, DOM state, timers, and mocks between files. Subagent completion delivery separately invokes an agent through a Gateway instance runtime that owns the request context.

flowchart LR
  A[Control UI test files] --> B[Shared Vitest worker]
  B --> C[UI unit project configuration]
  C --> D[Cross-file cleanup runner]
  D --> E[Reset modules DOM and mocks]
  F[Subagent completion] --> G[Gateway lifecycle dispatcher]
  G --> H[Instance-bound agent runtime]
Loading

Decision needed

Question Recommendation
After integration is refreshed and the exact-head Control UI checks are green, should this partial CI-reliability repair land while the separately observed residual flake remains under investigation? Land after green refreshed checks: Accept the existing runner-boundary repair once the current integration passes, while keeping the residual cross-file failure as separate work.

Why: The protected maintainer label and the PR’s own residual-failure evidence require an explicit maintainer decision about accepting the bounded improvement versus waiting for the remaining cause.

Before merge

  • Resolve merge risk (P1) - The PR reports one remaining intermittent cross-file failure after this improvement; require green exact-head Control UI checks and retain that tail as separately tracked root-cause work.
  • Resolve merge risk (P1) - The branch is behind current main, although GitHub reports it mergeable; refresh the integration before landing rather than treating branch-only results as merge results.
  • Complete next step (P2) - The protected maintainer label, pending exact-head checks, and documented residual flake require maintainer review rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source +12, Tests +31. Total +43 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 15 3 +12
Tests 2 33 2 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 48 5 +43

Review metrics

Metric Value Why it matters
Production versus test LOC production 0 net (3 added, 3 removed); test/test-support +45, -2 The production adjustment removes an ignored argument without growth; all net growth is configuration guard and test-infrastructure coverage.
Runner scope 1 shared unit project wired; 2 non-isolated project classes remain exempt The change targets the one package project that needs cross-file cleanup without applying a Node-capable runner to browser or Playwright-module-scope projects.

Merge-risk options

Maintainer options:

  1. Refresh and validate the integration (recommended)
    Use the current merge result or a rebase, then require the exact-head Control UI lane to finish green before landing.
  2. Pause for the residual flake
    Defer the change if maintainers require a complete deterministic fix before accepting an incremental CI-stability improvement.

Technical review

Best possible solution:

Retain the single shared-runner wiring and its focused configuration guard, then land only after refreshed integration checks are green while investigating any residual flake separately.

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

Yes for the wiring defect: current main has an isolate: false UI unit project without the existing cleanup runner, and the PR body supplies before/after executions of the exact CI command. The stochastic failure rate was not rerun by this read-only review.

Is this the best way to solve the issue?

Yes: using the existing cleanup runner at the shared-worker owner boundary is preferable to growing per-file isolation exceptions, and the resolver removal matches the instance dispatcher’s typed option contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded repair for intermittent shared test-lane failures, with limited blast radius outside CI reliability.
  • merge-risk: 🚨 automation: The PR changes the runner used by the shared Control UI CI lane, so incorrect integration could affect test execution reliability.
  • 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 member-authored PR is not subject to the external-contributor proof gate; its body nevertheless includes after-fix terminal evidence from the actual Control UI lane.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the UI project configuration to Peter Steinberger, and merged commits for the cleanup runner and instance lifecycle dispatcher are also authored by him. (role: recent Control UI and Gateway lifecycle contributor; confidence: high; commits: f59392fdf5e6, e7a2d1758afe, 2cd87d3d27c1; files: ui/vitest.config.ts, test/non-isolated-runner.ts, src/gateway/server-recovery-runtime-context.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the current integration and wait for the exact-head Control UI checks to complete green.

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 (2 earlier review cycles)
  • reviewed 2026-08-18T23:21:49.013Z sha effebe61e3e5a56355117c518792e46168eaa0a9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-18T23:51:31.479Z sha a6ec2f53b0410544282633dcfb070fc3aa69ed7d :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/ui-lane-leak-sweep branch from effebe6 to a6ec2f5 Compare August 18, 2026 23:46
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S and removed size: XS labels Aug 19, 2026
…unner

ui/vitest.config.ts drives CI's checks-ui job (pnpm --dir ui test). Its
unit project sets isolate:false but never wired
runner: nonIsolatedRunnerPath, so the per-file cleanup in
test/non-isolated-runner.ts — module-graph reset, repo-owned custom
element dropping, DOM body reset, timer and spy restoration — never ran
in the lane CI actually uses. Only the repo-root lane behind
scripts/run-vitest.mjs loaded it.

Files sharing a worker therefore kept the previous file's evaluated
modules, so whichever file imported a component first pinned it to the
real dependency and a later file's vi.mock factory never reached
production code, surfacing as "expected 0 to be 1" in whichever sibling
the size sequencer happened to pack alongside it. This is the class
PR #123512 diagnosed and fixed at the runner; the fix never reached this
lane, so the repo kept absorbing it one uiIsolatedTestFiles entry at a
time.

browser stays exempt (the runner imports node:fs and server modules that
cannot load in browser mode) and unit-node stays exempt (it carries the
Playwright-driven layout tests whose browser lives in module scope, which
per-file module resets churn). The config test asserted runner was
undefined for every project, pinning the broken wiring; it now asserts
the invariant and fails on the pre-fix config.
…nce dispatch

check-prod-types is red on main: #126062 threaded resolveGatewayContext
into the announce dispatch call, but that call now goes through
dispatchGatewayLifecycleMethod, whose options type does not carry the
field.

The type checker is right that it does not belong there. That dispatcher
hands work to runtime.dispatchAgent, which resolves context from the
Gateway instance it is bound to and forwards a fixed option allowlist, so
a caller-supplied resolver was already being ignored. Dropping it is
behavior-preserving.

The delivery test asserted the resolver was forwarded, but production now
binds to the instance dispatcher while the test injects a mock, so that
assertion only proved the mock. It now asserts the resolver is
deliberately not forwarded.

Left for the owner of #126062: sendSubagentAnnounceDirectly and its
callers still accept and thread resolveGatewayContext, which is now
vestigial on this path. Deleting that chain or teaching the instance
runtime to honor the resolver is a design call on a just-landed change.
@steipete
steipete force-pushed the steipete/ui-lane-leak-sweep branch from 6ec5962 to 5f9ec34 Compare August 19, 2026 00:30
@steipete
steipete merged commit 4fac990 into main Aug 19, 2026
233 checks passed
@steipete
steipete deleted the steipete/ui-lane-leak-sweep branch August 19, 2026 00:42
@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 20, 2026
…unner (openclaw#126071)

* fix(test): run the shared Control UI lane on the cross-file cleanup runner

ui/vitest.config.ts drives CI's checks-ui job (pnpm --dir ui test). Its
unit project sets isolate:false but never wired
runner: nonIsolatedRunnerPath, so the per-file cleanup in
test/non-isolated-runner.ts — module-graph reset, repo-owned custom
element dropping, DOM body reset, timer and spy restoration — never ran
in the lane CI actually uses. Only the repo-root lane behind
scripts/run-vitest.mjs loaded it.

Files sharing a worker therefore kept the previous file's evaluated
modules, so whichever file imported a component first pinned it to the
real dependency and a later file's vi.mock factory never reached
production code, surfacing as "expected 0 to be 1" in whichever sibling
the size sequencer happened to pack alongside it. This is the class
PR openclaw#123512 diagnosed and fixed at the runner; the fix never reached this
lane, so the repo kept absorbing it one uiIsolatedTestFiles entry at a
time.

browser stays exempt (the runner imports node:fs and server modules that
cannot load in browser mode) and unit-node stays exempt (it carries the
Playwright-driven layout tests whose browser lives in module scope, which
per-file module resets churn). The config test asserted runner was
undefined for every project, pinning the broken wiring; it now asserts
the invariant and fails on the pre-fix config.

* fix(agents): stop passing an ignored resolver to instance-bound announce dispatch

check-prod-types is red on main: openclaw#126062 threaded resolveGatewayContext
into the announce dispatch call, but that call now goes through
dispatchGatewayLifecycleMethod, whose options type does not carry the
field.

The type checker is right that it does not belong there. That dispatcher
hands work to runtime.dispatchAgent, which resolves context from the
Gateway instance it is bound to and forwards a fixed option allowlist, so
a caller-supplied resolver was already being ignored. Dropping it is
behavior-preserving.

The delivery test asserted the resolver was forwarded, but production now
binds to the instance dispatcher while the test injects a mock, so that
assertion only proved the mock. It now asserts the resolver is
deliberately not forwarded.

Left for the owner of openclaw#126062: sendSubagentAnnounceDirectly and its
callers still accept and thread resolveGatewayContext, which is now
vestigial on this path. Deleting that chain or teaching the instance
runtime to honor the resolver is a design call on a just-landed change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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