Skip to content

test(ui): await activity cache imports before teardown - #142282

Merged
steipete merged 1 commit into
mainfrom
codex/test-activity-import-teardown
Sep 8, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-activity-import-teardown

Conversation

@steipete

@steipete steipete commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where Activity page tests pass their assertions but fail the Node CI job when lazy cache imports continue after the jsdom environment is torn down. Main run 34241634465 reported four EnvironmentTeardownError rejections after 5,650 passing tests.

Why This Change Was Made

Gateway changes start asynchronous warm-boot cache invalidation. Stopping the test's Gateway does not join those lazy imports. The fixture now waits for Vitest's native recursive import drain after disposing its owners and before clearing browser state, matching the existing authentication and boot-record fixtures.

User Impact

More reliable CI, with all 21 Activity page cases and their assertions retained. No application behavior changes, new waits with fixed durations, extended deadlines, mocks, or production seams. Production delta: 0; test delta: +3/-1. The remaining import work is accounted for in teardown rather than leaking into the next environment.

Evidence

  • The original 21-case file passed locally; the exact intermittent CI error was not reproduced locally.
  • A temporary counter around the real lazy import promise showed pending work at the end of the complete original teardown. The same 21-case order passed with the native drain. The diagnostic added no delayed imports, fake timers or mocks and was removed before final verification.
  • Final diagnostics-free run: 21/21 passed. Required changed checks passed, including UI types, formatting, lint and repository guards. Independent P2 review found no actionable issue.
  • Installed Vitest 5.0.0 implementation was checked directly: dynamicImportSettled() waits for resolving modules and their nested imports. Existing gateway-store.auth.test.ts and gateway-store.boot-record.test.ts use the same cleanup boundary.

Local timings had different cache/load states, so no controlled speedup is claimed. This repair prevents a passing test shard from failing during teardown and needing another run. Exact-head Linux CI will verify the final source before landing.

@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Sep 8, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 11:39 AM ET / 15:39 UTC.

ClawSweeper review

What this changes

The Activity page tests wait for pending lazy imports after disposing their owners and before clearing browser state.

Merge readiness

✅ Ready for maintainer review

Keep open: the teardown repair remains useful on current main, follows existing fixture practice, and introduces no actionable correctness finding. This maintainer-labeled PR is also protected from automated closure.

Priority: P3
Reviewed head: a7142693e17165752856f38fe5e38ba3689baaa7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair supported by source, the Vitest contract, neighboring fixtures, and clearly qualified validation claims.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a member-authored test repair, so external-contributor runtime proof is not required; the body reports pending imports through the real cleanup owner and 21/21 after-fix fixture results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a member-authored test repair, so external-contributor runtime proof is not required; the body reports pending imports through the real cleanup owner and 21/21 after-fix fixture results.
Evidence reviewed 7 items Verified introduced change: The pinned merge-base-to-head diff only makes teardown asynchronous and adds the native import drain after owner disposal; test assertions and production code are unchanged.
Concrete asynchronous cleanup path: Gateway credential changes call clearWarmBootState, which starts lazy snapshot and roster cleanup without awaiting it. Gateway stop is synchronous and does not join those imports.
Existing fixture precedent: Authentication teardown waits for dynamic imports after stopping the Gateway and before removing globals; boot-record teardown uses the same native drain.
Findings None None.
Security None None.

How this fits together

Control UI Activity tests exercise Gateway connection changes that start asynchronous cache cleanup. Their teardown must finish module loading before Vitest destroys the simulated browser environment.

flowchart LR
  A[Activity lifecycle tests] --> B[Gateway connection changes]
  B --> C[Lazy cache imports]
  A --> D[Dispose test owners]
  D --> E[Wait for imports]
  C --> E
  E --> F[Clear browser state]
  F --> G[Destroy test environment]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +2. Total +2 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 3 1 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 3 1 +2

Review metrics

None.

Technical review

Best possible solution:

Keep asynchronous import cleanup inside the fixture lifecycle, preserving every existing assertion and the production lazy-loading boundary.

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

No deterministic reproduction of the intermittent CI failure is established. Source confirms unjoined lazy imports during the exercised Gateway-change cases, and the PR reports observing pending work after original teardown.

Is this the best way to solve the issue?

Yes: Vitest's recursive import drain matches the demonstrated lifecycle gap and existing neighboring fixtures without adding fixed delays, weakening assertions, or changing production behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 37dbd0aac655.

Labels

Label changes:

  • add P3: This is a bounded test-fixture reliability repair with no application 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: The supplied repository state identifies a member-authored test repair, so external-contributor runtime proof is not required; the body reports pending imports through the real cleanup owner and 21/21 after-fix fixture results.

Label justifications:

  • P3: This is a bounded test-fixture reliability repair with no application 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: The supplied repository state identifies a member-authored test repair, so external-contributor runtime proof is not required; the body reports pending imports through the real cleanup owner and 21/21 after-fix fixture results.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff only makes teardown asynchronous and adds the native import drain after owner disposal; test assertions and production code are unchanged. (ui/src/pages/activity/activity-page.test.ts:151, a7142693e171)
  • Concrete asynchronous cleanup path: Gateway credential changes call clearWarmBootState, which starts lazy snapshot and roster cleanup without awaiting it. Gateway stop is synchronous and does not join those imports. (ui/src/app/bootstrap-warm-boot.ts:8, a7142693e171)
  • Existing fixture precedent: Authentication teardown waits for dynamic imports after stopping the Gateway and before removing globals; boot-record teardown uses the same native drain. (ui/src/app/gateway-store.auth.test.ts:40, a7142693e171)
  • Dependency contract inspected: The introduced vi.dynamicImportSettled call and PR's Vitest 5 claim establish the dependency signal. Vitest v5.0.0 resolves to this commit; its implementation waits a tick, collects unevaluated module promises, checks resolving modules, and recursively drains further imports. (packages/vitest/src/integrations/vi.ts:891, f441c6fab25e)
  • Current main and release still lack the drain: The fetched main revision retains synchronous Activity teardown without dynamicImportSettled. Inspection of v2026.9.3 also finds synchronous teardown. No merged replacement was established. (ui/src/pages/activity/activity-page.test.ts:151, 37dbd0aac655)
  • Area history and routing: Available history identifies Peter Steinberger's warm-boot work and Shakker's Activity lifecycle work. Bootstrap blame points to the warm-boot commit, but parent-content inspection failed, so introduction attribution remains unverified. (ui/src/app/bootstrap-warm-boot.ts:14, 24ae0fc1984c)

Likely related people:

  • Peter Steinberger: Raw commit 24ae0fc adds ui/src/app/bootstrap-warm-boot.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 24ae0fc1984c; files: ui/src/app/bootstrap-warm-boot.ts)
  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit cb3e534 into main Sep 8, 2026
87 checks passed
@steipete
steipete deleted the codex/test-activity-import-teardown branch September 8, 2026 15:50
@steipete

steipete commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 8, 2026
* commit '04869ae4899ad0524c3287759798362b0d62fef8': (677 commits)
  fix(release): pin Kova census refresh (#142104)
  fix: doctor read-only database inspections time out on large agent databases (#142179)
  docs: align v2026.9.3 framing with release announcement (#142307)
  fix(ui): discover models when default-model pickers open (#142105)
  fix(ci): keep Docker upgrade seed baseline older than target (#142273)
  refactor(tests): reuse named OAuth credential fixtures (#142272)
  fix(ci): keep mobile release helpers out of source checks (#142115)
  chore(ui): refresh control ui locales (#142147)
  fix(active-memory): explain why recall was skipped (#138658)
  fix(media): preserve converted images with HEIC filenames (#142263)
  docs: add v2026.9.3 release notes (#142277)
  fix(ui): retire picker focus listeners together (#142258)
  fix(ui): keep menu hover colors consistent across themes (#142243)
  fix(release): keep changelog credits within verified history (#142261)
  fix: keep tool-finalizer placeholders private in message-only groups (#138645)
  perf(tui): carry prepared URL membership through rendering (#142262)
  test(ui): await activity cache imports before teardown (#142282)
  fix(qa): align auth and Workshop proofs with runtime contracts (#142280)
  feat(xai): use one curated catalog and concrete setup default (#142136)
  refactor(outbound): reuse prepared sendability facts (#142252)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
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: XS 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