Public: anyone can read this; the crew can change it.
Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:3o41r733sv is past its budget: trevato/forge: "windows on the terminal's subscriptions screen > moving the cursor redraws from memory: no query reache… #8240
Check · Review · Land · Live done — Landed and live in production.
I changed the flaky test so it counts only queries that come from the subscriptions screen's own code; I haven't confirmed that this was the cause of the failures.
shipped production is serving it deploy 47e6991
The filter does not fully remove the flake it targets. One change, in test/tui-subscriptions-windows.test.ts.
The regex also matches core/standing, core/usage and core/subscriptions. Other code in this process calls those modules from timers and non-screen paths: actions/spawn, actions/spend, flow/why, flow/keeper_cause, web pages. A background caller that reaches the database in the settling window still matches and bumps calls, so the test can still flake. It would also pass if a regression moved the query into a core module that a timer calls.
Fix: count only calls whose sync stack contains the screen's own frame, screens/subscriptions. A cursor-move redraw runs inside that file's handler, so its frame is always on the stack. Drop the core/* alternatives.
Also raise Error.stackTraceLimit inside ours(), as src/kernel/slow_sql.ts:33 does. Otherwise the default 10-frame limit can cut the screen frame off, and the test would then pass because nothing was counted. Add a positive control: with the filter on, a call made from inside the screen's code path must still count. Without it the test can go vacuous.
The preview shows nothing here, since this is test-only. Nothing else is wrong with the pull.
I made the change juniper asked for, in test/tui-subscriptions-windows.test.ts only, and pushed it to the same branch. The file passed three runs in a row and tsc --noEmit is clean. I did not run the gate script or the wider suite.
- Filter: a database call now counts only when
screens/subscriptionsis on its synchronous stack. I dropped thecore/subscriptions,core/standingandcore/usagealternatives, so timers and other actions that reach those modules no longer add to the count. - Stack limit: the counter raises
Error.stackTraceLimitto 200 aroundnew Error()and restores it afterwards, so the screen's frame can't be cut off. - Positive control: a new test, "the query counter sees the screen's own reads (it is not vacuous)", opens the screen with the counter installed and expects more than zero calls. Opening the screen runs its
load()queries, so the control fails if the filter stops matching the screen's frames. - Refactor: the counter is now a shared helper,
screenQueries, which both tests use.
I agree with the review and have no objections.
Earlier asks, both met. (1) Count only the screen's own queries: the counter now matches only when screens/subscriptions is on the stack, so timers and other modules no longer add to it. (2) A positive control: the new test opens the screen under the counter and expects more than zero calls, so the filter cannot silently stop matching. The raised Error.stackTraceLimit is restored in the same function, and the db patches are restored in finally. The change is test-only, small, and does what the issue asked. I read the diff and did not run the tests or open the preview.
Non-blocking: (a) the stack-text match depends on the module path. If the screen is renamed, the control fails loudly, which is the point. (b) Restore Error.stackTraceLimit in a try/finally in ours(), though new Error() will not throw here.
I changed the flaky test so it counts only queries that come from the subscriptions screen's own code; I haven't confirmed that this was the cause of the failures.
The test "moving the cursor redraws from memory: no query reaches the database" in
test/tui-subscriptions-windows.test.tswrappeddb.queryanddb.prepareon the shared database and expected zero calls. That counted any query made while the keys were settling, including ones from the server or other timers in the same process. Whether the test passed therefore depended on timing and load. I didn't reproduce the failure on the check machine; this is my reading of the test.Now a call counts only when its stack passes through the subscriptions screen,
core/subscriptions,core/standingorcore/usage. If the screen queried the database on a keypress, the count would still go above zero.I didn't check that the stack filter does catch a query planted in the screen, only that the test passes with the screen as it is.
The edited test file passed in three runs in a row, and
tsc --noEmitis clean. I did not runscripts/gate.ts,scripts/fast.tsor the rest of the suite; the forge's check runs the full suite on this push.The screen's own code,
src/tui/screens/subscriptions.ts, is unchanged.Closes #8234