Skip to content

perf(planning): wait on page state, not fixed pauses, in the surface journey suite - #11523

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-8757-41194408560-1
Oct 31, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-8757-41194408560-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Refs: #8757

Summary

Opened by the work-resolve-issue lane. The run's own summary:

surface-journey.test.sh's page script (tests/ui_journey.js) paused for a fixed time about 90 times, including inside its tap helper. Each pause is now settle(ms), which returns as soon as the page has caught up: two frames painted, its own fetches answered (with a 150 ms gap, so a chain like Confirm all counts as one), and the server's current /api/state applied from an SSE state frame. The old pause stays as the upper bound. I chose the frame comparison over a DOM-quiet heuristic because session_bridge.py sends state frames from a loop that polls every 0.3 s, so a quiet DOM does not prove the push has landed. Frames and /api/state both come from Hub.read_state, so a signature over the fields the server's frame signature follows (dropping the clock-driven listener.idleFor) matches between the two. When there is no state to compare (server stopped, page offline), settle waits the full old time, so a wait is never cut short without proof. The phase 11 1500 ms pause, which keeps a time window open on purpose, is unchanged. No check was added or dropped, and the journey's count of 235 checks is unchanged. The re-measure the issue asked for has already landed on main: scripts/suite-seconds.txt has surface-journey at 164 s.

Remaining work

  • Re-measure surface-journey.test.sh on main after this merges. If its median is under 120 s, update scripts/suite-seconds.txt, and drop its scripts/suite-budget-exceptions.txt row once the median is under 150 s.

Not verified

  • surface-journey.test.sh and the other planning surface suites were not run: this lane cannot run playwright-cli or the test runner. The PR's CI test-bash leg runs them and prints the TIME: and per-phase seconds that show the cut.
  • Whether surface-journey.test.sh now finishes under 120 s is unmeasured. The fixed pauses add up to about 50 s (per #11409), against a 164 s median; how much settle saves shows only in CI.
  • Tidy pass 4 (ai-slop fix) was skipped: its detector script is not among the commands this lane may run. I read the one-line fragment by hand for AI tells and found none. The other three tidy passes ran.
  • Review nit left as is: phases 8 and 10 call setHidden(true) then settle(200), which can now return in about 50 ms. Hiding the tab starts no fetch and no frame, so the negative check's meaning holds.
  • The checkout has untracked files I did not create (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc), probably from the runner's sandbox setup. They are not part of this change.

Fix

  • plugins/planning/surface/tests/ui_journey.js: new settle(ms) helper; a phase 1 init script that wraps fetch (counts requests in flight until the body is read) and EventSource (records the signature of the last applied state frame); every fixed waitForTimeout and the tap pause replaced by settle, exc
  • .changes/planning/perf-8757-journey-waits-on-page-state-c41e7a90.md: bump: none fragment, because the change is test-only

Verification

The runner ran each check from the base copy against a6b5e16:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • check-changelog-fragments: all 14 fragments valid (run after tidy and after the review fixes)
  • check-affected: 11 passed, 7 skipped, 0 failed over 2 changed files (run after tidy and after the review fixes); the first run failed on the missing planning fragment, which I then added
  • read scripts/suite-seconds.txt and scripts/suite-budget-exceptions.txt on main: surface-journey.test.sh median 164 s, exception row at 480 s, the other five surface suites at 104/85/72/64/24 s
  • read server.py signature()/read_state()/route_get and session_bridge.py's SSE loop: frames and /api/state share read_state; frames are sent when signature() changes, polled every 0.3 s; route_get routes on the parsed path, so /api/state?probe=1 is served
  • fresh-context review subagent over the diff: found no JavaScript errors and confirmed the signature matches; raised 2 risks and 2 nits; I fixed both risks and nit 3
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41194408560

Left out: the items under Not verified.

Related

#8757

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed a6b5e1620a14610658c6f1d781b6f1fafa5edc24: 0 finding(s), 0 as inline comments.

No security issues found. Skip gate item 2 applies: the change has no security-relevant surface.

What changed. The PR touches two files:

  • plugins/planning/surface/tests/ui_journey.js is a Playwright journey script for the planning interview surface. It replaces the fixed waitForTimeout pauses with a settle(ms) helper.
  • .changes/planning/perf-8757-journey-waits-on-page-state-c41e7a90.md is a bump: none changelog fragment.

Why nothing is exposed.

  • Where the code runs. The new code is a phase-1 addInitScript that wraps window.fetch and EventSource inside the test browser. It runs only in the test harness, against the suite's own local server. It ships to no installed user, because the fragment declares the change test-only and the interview surface is unchanged.
  • Secrets and network. It sends nothing outside the page and handles no tokens or secrets. The /api/state?probe=1 read uses the page's own origin, and the existing token() header handling is untouched.
  • Output. settle only gates how long the test waits, and every wait still has a time cap. The pass/fail checks are not weakened or removed. The PR text says the count of 235 checks is unchanged, and the diff shows only waits swapped.

Other items checked.

  • No file matches the trusted-path globs. No trust control, merge hold, token scope, kill switch or manifest field is touched, so there are no manifest <field> lines.
  • The diff deletes no standing instruction, so the instruction-surface lens does not apply.
  • The PR context contains no embedded directives aimed at the review lane.
  • The change spends no billable resources. It makes CI test runs shorter.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed a6b5e1620a14610658c6f1d781b6f1fafa5edc24: 0 finding(s), 0 as inline comments.

No findings. I read the whole diff and the PR context, and checked the new settle helper against server.py and index.html. I did not run the journey suite, so none of this is verified by execution.

Scope. The change is test-only. It adds a settle(ms) helper to plugins/planning/surface/tests/ui_journey.js and replaces the fixed waitForTimeout pauses with it. A bump: none changelog fragment goes with it. There is no closing issue with acceptance criteria (the PR only refs #8757). No plugin manifest is touched, so there are no manifest <field> lines. No trusted-path file is changed.

What I checked

  • Signature fields. Hub.signature() (server.py:1099-1116) follows the mtimes of the questions, responses, theme, settings and watch-seq files. It also follows the listener's state, waiters > 0 and lease is not None. The client-side sig covers the same data, drops listener.idleFor, and adds listener.lastDeliverAt. That extra field would only cause a full-length wait, never an early return. I did not confirm that lastDeliverAt moves only when watchSeq does.
  • Frame application. index.html:2428 handles state frames by calling apply(JSON.parse(e.data)) inside the event handler. The wrapper's own listener records applied in a setTimeout(0) that runs after the page's handler. That ordering holds.
  • Probe request. GET /api/state needs no token; the page's own refresh() calls it without one (index.html:2404). The probe URL /api/state?probe=1 does not match phase 5's /\/api\/state$/ request counter.
  • Fetch counting. The probe goes through the original io.fetch, so it does not count as a pending request. The page only uses fetch for short request/response calls and EventSource for the stream, so the clone-and-read-body wrapper cannot hang on a long-lived fetch.
  • Fallback. When the server is stopped or the page is offline, the probe resolves to null and settle waits the full original time. The old pause stays as the upper bound.

Unverified. The PR says surface-journey.test.sh was not run by the lane and that the saving is unmeasured. I did not run it either; the author's claims about the 235-check count and the time saved are author-claimed and unverified. One small point, not worth a comment: the probe fetch inside settle has no timeout of its own, so a server that accepts the connection but never answers would stall page.evaluate past ms. The PR's stated cases (server stopped, page offline) fail fast.

Cost. None. This only changes CI test runtime; no hold.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head a6b5e1620a14610658c6f1d781b6f1fafa5edc24. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head a6b5e1620a14610658c6f1d781b6f1fafa5edc24.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 64b5f5a Oct 31, 2026
47 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-8757-41194408560-1 branch October 31, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants