Repository navigation
fix(test): run the shared Control UI lane on the cross-file cleanup runner - #126071
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 8:21 PM ET / August 19, 2026, 00:21 UTC. ClawSweeper reviewWhat this changesThe 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 readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherControl 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]
Decision needed
Why: The protected Before merge
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +31. Total +43 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
effebe6 to
a6ec2f5
Compare
…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.
6ec5962 to
5f9ec34
Compare
|
Merged via squash.
|
…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.
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 3runs failed, each blaming a different unrelated file (board-view,chat-pane-sidebar-layout.lazy,app-host.panel-toggles,widget-theme). Restricting tosrc/appand 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 asexpected 0 to be 1where avi.mockfactory never reached production code.Why This Change Was Made
ui/vitest.config.tsis what CI'schecks-uijob runs (pnpm --dir ui test). Itsunitproject setsisolate: falsebut never wiredrunner: nonIsolatedRunnerPath, so the whole per-file cleanup stack intest/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 behindscripts/run-vitest.mjsloaded 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.mockfactory 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
uiIsolatedTestFilesentry 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:
browserruns in browser mode, where the runner'snode:fsand server-module imports cannot load.unit-nodecarries 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.tsassertedrunnerwasundefinedfor 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.src/app, 20 shuffled seedstest/vitest-ui-package-config.test.ts).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 (Codexgpt-5.6-sol, high): clean, "patch is correct (0.99)".isolate: falsealready wires the runner —createScopedVitestConfigdefaults it on, the fake-timer and shared configs set it explicitly, andtest/vitest-projects-config.test.tsalready 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, andsessions-hub-tabsin 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 intouiIsolatedTestFiles.Follow-up worth considering: with the runner active, much of
uiIsolatedTestFilesmay 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
maincheck-prod-typeswas red onmain(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.#126062threadedresolveGatewayContextinto the announce dispatch call, but that call goes throughdispatchGatewayLifecycleMethod, whose options type does not carry the field. The type checker is correct:dispatchGatewayLifecycleMethodhands work toruntime.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.tsasserted 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:
sendSubagentAnnounceDirectlyand its callers still accept and threadresolveGatewayContext, 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-4failed once here onsrc/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 onlyui/vitest.config.tsand a config test):mainitself 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.