Skip to content

perf(test): speed up Agents page observation polling - #127063

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-agents-page-polling
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-agents-page-polling

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Agents-page test suite spends about one second waiting for Vitest's default 50 ms observation-polling interval, even though the model catalog, reconnect fencing, scoped cron, file, identity, and effective-tools transitions are driven by already-pending promises.

Why This Change Was Made

Classified each of the 24 waits in ui/src/pages/agents/agents-page.test.ts: all observe actual promise/state completion; none enforces a product debounce, timer, deadline, or lifecycle duration. Reuse the existing waitForFast helper, which preserves Vitest's assertion, timeout, and async semantics while using a 1 ms observation interval. Keep every assertion, reconnect, deferred resolution, stale-result check, and real state transition unchanged. Compact an existing equivalent fixture constructor so the test stays below the repository's 1,000-line lint limit.

User Impact

No runtime or production behavior changes. Production LOC: +0/-0. Test LOC: +26/-27 (net -1).

Four retained runs per side on the same Blacksmith Testbox, with one worker, distinct filesystem caches, import diagnostics, /usr/bin/time -v, and an excluded warmup:

Measurement Before After Improvement
Scoped wall samples 2.86, 2.84, 2.92, 3.20 s 2.05, 1.90, 1.89, 1.82 s
Median scoped wall 2.89 s 1.895 s 0.995 s / 34.4%
Test body 1.04 s 44-46 ms approximately 95.7%
Vitest import 0.916-1.11 s 0.871-1.00 s unchanged within normal noise
Tests 27 passed 27 passed all existing coverage retained

Median RSS is approximately 682 MB before and 686 MB after; user/system CPU remains approximately 2.2-2.3 s / 0.28-0.30 s. The gain removes waiting, not product work.

Evidence

  • Same-host benchmark: OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_IMPORT_DURATIONS=1 OPENCLAW_VITEST_PRINT_IMPORT_BREAKDOWN=1 OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/tmp/agents-page-SAMPLE /usr/bin/time -v node scripts/run-vitest.mjs ui/src/pages/agents/agents-page.test.ts --maxWorkers=1 --reporter=verbose.
  • Focused owner/controller/cache proof: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs ui/src/pages/agents/agents-page.test.ts ui/src/pages/agents/agent-file-lifecycle.test.ts ui/src/pages/agents/github-identity-controller.test.ts ui/src/pages/agents/skills.test.ts ui/src/lib/agents/index.test.ts ui/src/lib/chat/chat-metadata-store.test.ts ui/src/lit/gateway-page-controller.test.ts ui/src/lit/subscriptions-controller.test.ts — 8 files, 104 passing tests.
  • Real Chromium, mocked Gateway only: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/model-alias-display.e2e.test.ts ui/src/e2e/agents-set-default-persistence.e2e.test.ts ui/src/e2e/agent-config-save.e2e.test.ts ui/src/e2e/agent-page-scope.e2e.test.ts — 4 files, 9 passing scenarios.
  • Production-owner fault proof: temporarily prevent model-catalog publication and the optimized catalog test fails; temporarily weaken the reconnect generation equality and the existing stale-file test fails because the obsolete workspace becomes visible. Both production mutations were restored before validation.
  • Full changed gate: OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 pnpm check:changed.
  • node_modules/.bin/oxfmt --check ui/src/pages/agents/agents-page.test.ts; node_modules/.bin/oxlint --config .oxlintrc.json ui/src/pages/agents/agents-page.test.ts; git diff --check; clean independent autoreview.
  • Follow-up, intentionally outside this one-performance-PR scope: the selected-agent stale-model-catalog regression can miss a removed ownership guard because its final assertion runs before the owner's layered promise continuation; strengthen that existing assertion in a separate focused change.

@clawsweeper

clawsweeper Bot commented Aug 21, 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: S maintainer Maintainer-authored PR labels Aug 21, 2026
@steipete
steipete marked this pull request as ready for review August 21, 2026 06:37
@steipete

Copy link
Copy Markdown
Contributor Author

Ready to land exact head 916e684ac5c934fff061d3e105ea4650a641eb88.

  • Same-machine median scoped wall: 2.89 s -> 1.895 s (-0.995 s, -34.4%) across four retained measurements per side; test body 1.04 s -> 44-46 ms; all 27 original tests and assertions retained.
  • Production LOC +0/-0; test LOC +26/-27. All 24 waits were classified as incidental state-observation polling; no product timer, debounce, deadline, reconnect order, or deferred resolution changed.
  • Owner/controller/cache proof: 104 passing tests across 8 files. Mock-Gateway Chromium proof: 9 passing browser scenarios across 4 files. The complete changed gate, format/lint/diff checks, and fresh independent review all passed.
  • Two temporary production-owner faults were caught: lost selected-agent catalog publication and stale reconnect-generation workspace acceptance; both faults were fully reverted.
  • Exact-head hosted CI: https://github.com/openclaw/openclaw/actions/runs/32455170337 (attempt 2, successful). Attempt 1 hit an unrelated flaky new-session draft-restoration browser assertion; that exact case passed independently, and the failed-shard-only rerun passed without code changes.
  • Native scripts/pr review-validate-artifacts 127063 and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 127063 completed successfully.
  • The latest ClawSweeper comment is only its in-progress placeholder, with no actionable findings or rank-up moves. The separately identified stale-catalog assertion-strengthening opportunity remains a follow-up outside this one test-performance PR.

@steipete
steipete merged commit 46d09d1 into main Aug 21, 2026
211 of 213 checks passed
@steipete
steipete deleted the steipete/perf-agents-page-polling branch August 21, 2026 06:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 21, 2026
* origin/main: (107 commits)
  perf(test): speed up Agents page observation polling (#127063)
  fix(android): explicitly target notification intents (#127055)
  fix(agents): preserve literal Unicode-space paths (#126797)
  fix(agents): distinguish review routing from enforcement (#126216)
  fix(ui): associate steering work by target run (#126997)
  fix(ui): collapse completed pre-steer work
  fix(codex): preserve steering transcript order
  fix(gateway): retain Bonjour cleanup on startup failure (#127062)
  fix(release): require concrete validation retry groups (#127012)
  fix(file-transfer): expose directory page tokens (#127051)
  perf: trim setup detection worker imports (#127053)
  fix(onboard): make --auth-choice help match the accepted set (#127030)
  fix(gateway): await cron exit watcher drain (#126963)
  fix(telegram): preserve direct-topic self-history (#127050)
  fix: dismiss sidebar session menu tooltip (#127044)
  perf(test): speed up pairing access polling (#127047)
  perf(cli): remove ineffective dynamic imports (#127046)
  fix(gateway): recover credential-file accounts after secrets reload (#126999)
  fix(gateway): restore scheduler-owned Gateway context (#126640)
  fix(macos): keep first-run onboarding visible after Gateway changes (#127038)
  ...

# Conflicts:
#	.github/workflows/full-release-validation.yml
#	test/scripts/full-release-validation-at-sha.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 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 size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant