Repository navigation
fix(tui): stop settled strip redraw timers - #220
Conversation
d0b12af to
c88d8be
Compare
tt-a1i
left a comment
There was a problem hiding this comment.
Changes requested. The status-dependent timer lifecycle itself is sound and the targeted tests pass, but the real extension event path still bypasses the new repaint key: every Subagent event reaches updateStatus(), which calls ui.setStatus() even in TUI mode, and Pi setStatus() unconditionally requests a global render. Therefore the PR body claim that streaming, tool, and usage updates no longer cause global strip redraws is not yet true. Please gate or avoid unchanged TUI status writes and cover the complete event path. Issue #189 also explicitly requests a 60-second idle requestRender/CPU benchmark; advancing a fake clock proves timer behavior but supplies no CPU evidence.
agnitum2009
left a comment
There was a problem hiding this comment.
Independent second review — local verification plus source-level corroboration of @tt-a1i's blocking points.
Local verification against c88d8be (fetched the branch and ran the stated test plan):
node --test --experimental-strip-types tests/extensions/workflows/navigation.test.ts tests/extensions/subagents/navigation.test.ts-> 17/17 passbun run check-> clean (only pre-existing effect lint warnings inextensions/file-search/src/binaries.ts, unrelated to this PR)bun run test-> 934/934 pass
So the widget-level timer lifecycle and its fake-timer tests are sound, matching the owner's read.
Bypass independently confirmed in source: both extensions subscribe updateStatus/updateIndicator to every manager event (extensions/subagents/index.ts:409), and each calls ui.setStatus(...) unconditionally; on the Pi side, setExtensionStatus() in pi-coding-agent/dist/modes/interactive/interactive-mode.js always calls this.ui.requestRender() without diffing the text. So streaming/tool/usage events still force a global render even when the strip is settled — the new entryKey gate stops the widget's own interval but not the event path.
+1 to the outstanding requests: gate unchanged status writes before calling Pi, add an extension-level UI spy test covering manager.notify -> setStatus -> requestRender, and the real 60-second idle requestRender/CPU benchmark from #189.
There was a problem hiding this comment.
Re-reviewed exact head 91ebe4e1bdd2dbb83dc823a4b5bea862a471a3b7.
The follow-up commit resolves both blockers from the earlier review:
- unchanged Subagent/Workflow status writes are collapsed before Pi's unconditional global render path, with extension-level coverage for the full manager -> setStatus flow;
- the requested real-time idle benchmark is present, while focused tests cover settlement, idle zero-render behavior, and timer restart.
Independent verification:
- focused repaint/navigation tests: 24 passed
bun run check: passedbun run test: 937 passed- benchmark smoke: settled idle render requests 9 -> 0 over 1 second; running control remained active
- local merge with current
main@bf6b439: clean; focused tests andbun run checkpassed on the merge result
No blocking code findings remain on this head. Approval is code-review evidence only: the branch is currently behind main and GitHub reports no checks for this head, so required checks still need to run before merge.
91ebe4e to
6531b30
Compare
|
Rebased onto the latest main; all required checks are green, and the previously requested review threads are resolved. This PR should now be ready to merge. Thank you for the review. |
Pi's setStatus() requests a global render without diffing the text, and the subagent manager notifies on every child event, so streaming deltas, tool cycles, and usage ramps each repainted the whole TUI to rewrite a footer line that never changed. The strip's own repaint key could not help: setStatus had already asked for the render before the widget gate ran. Route both extensions' footer writes through a shared writer that remembers the last value per UI and forwards only real changes. Cover the complete manager -> setStatus path with an extension-level UI spy driving a real spawn against a stub backend, and add the 60-second idle requestRender/CPU benchmark openpi-dev#189 asked for. Co-Authored-By: Claude Fable 5 <[email protected]>
7a6dea0 to
cc398e9
Compare
tt-a1i
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 59d9a7e against current main efd804d. The prior blockers remain resolved: settled strips stop their timers, lifecycle changes receive one final repaint and restart correctly, and unchanged status writes are collapsed before Pi setStatus triggers a global render. The post-approval changes only update the benchmark SubagentSnapshot fixture contract and merge current main. Independent verification: 24 focused repaint/navigation tests passed; bun run check passed; bun run test passed (1009 passed, 1 skipped); the 1-second benchmark smoke measured settled idle render requests 9 -> 0 while the running control remained active. No blocking findings.
* fix(tui): stop settled strip redraw timers * perf(tui): collapse unchanged extension status writes Pi's setStatus() requests a global render without diffing the text, and the subagent manager notifies on every child event, so streaming deltas, tool cycles, and usage ramps each repainted the whole TUI to rewrite a footer line that never changed. The strip's own repaint key could not help: setStatus had already asked for the render before the widget gate ran. Route both extensions' footer writes through a shared writer that remembers the last value per UI and forwards only real changes. Cover the complete manager -> setStatus path with an extension-level UI spy driving a real spawn against a stub backend, and add the 60-second idle requestRender/CPU benchmark openpi-dev#189 asked for. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(bench): update subagent fixture contract --------- Co-authored-by: Claude Fable 5 <[email protected]> (cherry picked from commit 6286bd8)
Problem
Fixes #189. Workflow and Subagent below-editor strips continued calling
requestRender()while a settled unread result remained visible, so a finished run kept the terminal repainting a line that never changed.Reviewing the first pass surfaced a second, larger source of the same idle cost: Pi's
setStatus()requests a global render unconditionally, without diffing the text (interactive-mode.jssetExtensionStatus). The subagent manager notifies on every child event (foldEvent->notify), and each notify reachedui.setStatus. In the TUI that value is alwaysundefined— the strip carries the activity instead — so streaming deltas, tool cycles, and usage ramps each repainted the whole terminal to rewrite nothing. The widget-level repaint key could not prevent this:setStatushad already requested the render before the widget gate ran.Value
Preserves the final result notice and all live feedback without keeping the terminal UI active. Idle
requestRendercalls from a settled strip drop to zero, and a streaming subagent now writes the footer once instead of once per event.Approach
running; retain the existing 120 ms Workflow and 500 ms Subagent cadences.createStatusWriterinextensions/shared/activity-status.ts: it remembers the last value written per UI object and forwards only real changes. Both Subagent and Workflow footer writes route through it, and both reset it onsession_shutdown(a new session's footer starts empty, so the UI identity is part of the comparison).__setSubagentTestBackends, a test-only backend seam matching the existing__setWorkflowTestAgentSessionFactoryconvention, so extension-level tests can drive a real spawn without a child pi session.Validation
node --test --experimental-strip-types tests/extensions/workflows/navigation.test.ts tests/extensions/subagents/navigation.test.ts tests/extensions/subagents/status-repaint.test.ts tests/extensions/shared/activity-status.test.ts— 24 passed, 0 failed.bun run check— passed; reports the 12 pre-existing Effect warnings inextensions/file-search/src/binaries.ts.bun run test— 937 passed, 0 failed.New
tests/extensions/subagents/status-repaint.test.tsboots the extension with a UI spy and drives a real spawn through the stub backend, coveringmanager.notify -> updateStatus -> setStatus -> requestRender. Verified as a regression guard: reverting the writer makes it fail with 25 status writes instead of 3.undefined) across the whole streaming run, and no further widget renders for 900 ms after settlement.1 running,1 done— so the gate does not swallow genuine changes.New
benchmarks/strip-idle-render.ts, the 60-second idle measurement perf(tui): settled Workflow/Subagent strip 仍持续定时请求全局重绘 #189 asked for (node --experimental-strip-types benchmarks/strip-idle-render.ts --seconds 60, Darwin arm64, Node 24):process-floorsettled-idle-beforesettled-idle-afterrunning-afterIdle repaints go 610 -> 0 over 60 s, with CPU landing on the bare-process floor; the
running-aftercontrol confirms the spinner still animates at its old ~10.2/s combined cadence. Scope note: the benchmark measures the strips' own timers and render work, not the rest of the frame a realrequestRender()repaints, so the true idle saving is larger than the delta shown, never smaller.Manual Pi TUI
/reloadsmoke — run against a locally linked checkout of this branch, covering both strips:% ctxfields advance, and refreshing them on the spinner tick instead of per event is not perceptible.✓ <title>and stays on screen — the unread result notice is preserved.Manual CPU sampling (
ps -o time=deltas over 60 s idle, Darwin arm64): with this branch loaded, the process burned 0.28 s, 0.28 s, and 0.12 s of CPU across three idle windows (settled subagent strip visible, settled workflow strip visible, and after a restart cycle). No real-hardware pre-fix baseline or strip-absent floor was collected, so these are absolute observations only — they do not by themselves quantify the saving. The CPU-delta claim rests onbenchmarks/strip-idle-render.tsabove, which is an isolated measurement with both a process floor and a pre-fix arm.Impact
% ctxand counts now refresh on the 500 ms spinner tick rather than on every event — the same cadence the glyph already used.session_shutdown.