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.
scout/forge:scout/8234-sentinel-shared-01m23vygyffx5hg2f5vm8r74 → main 2 commits fork 1 thread · 1 unresolved
1 file
changed +32
−6
test/tui-subscriptions-windows.test.ts +32 −6
| @@ -144,25 +144,51 @@ describe("windows on the terminal's subscriptions screen", () => { | ||
| 144 | 144 | expect(rest).toContain(`resets ${first.slice(first.indexOf("resets ") + "resets ".length)}`); |
| 145 | 145 | }); |
| 146 | 146 | |
| 147 | test("moving the cursor redraws from memory: no query reaches the database", async () => { | |
| 148 | const h = await open(); | |
| 147 | /** Database calls made while `run` goes, counting only those with the screen's own frame on the stack. */ | |
| 148 | async function screenQueries(run: () => Promise<void>): Promise<number> { | |
| 149 | 149 | const db = forge.db as unknown as { query: (...a: unknown[]) => unknown; prepare: (...a: unknown[]) => unknown }; |
| 150 | 150 | const { query, prepare } = db; |
| 151 | 151 | let calls = 0; |
| 152 | db.query = (...a) => (calls++, query.apply(forge.db, a)); | |
| 153 | db.prepare = (...a) => (calls++, prepare.apply(forge.db, a)); | |
| 152 | // Other timers in this process share the database, so a call counts only when | |
| 153 | // screens/subscriptions is on its stack; the limit is raised so that frame is never cut off. | |
| 154 | const ours = () => { | |
| 155 | const limit = Error.stackTraceLimit; | |
| 156 | Error.stackTraceLimit = 200; | |
| 157 | const stack = new Error().stack ?? ""; | |
| 158 | Error.stackTraceLimit = limit; | |
| 159 | return stack.includes("screens/subscriptions"); | |
| 160 | }; | |
| 161 | db.query = (...a) => (ours() && calls++, query.apply(forge.db, a)); | |
| 162 | db.prepare = (...a) => (ours() && calls++, prepare.apply(forge.db, a)); | |
| 154 | 163 | try { |
| 155 | await h.press("j"); | |
| 156 | await h.press("k"); | |
| 164 | await run(); | |
| 157 | 165 | } finally { |
| 158 | 166 | db.query = query; |
| 159 | 167 | db.prepare = prepare; |
| 160 | 168 | } |
| 169 | return calls; | |
| 170 | } | |
| 171 | ||
| 172 | test("moving the cursor redraws from memory: no query reaches the database", async () => { | |
| 173 | const h = await open(); | |
| 174 | const calls = await screenQueries(async () => { | |
| 175 | await h.press("j"); | |
| 176 | await h.press("k"); | |
| 177 | }); | |
| 161 | 178 | expect(calls).toBe(0); |
| 162 | 179 | expect(h.text()).toContain("windows not seen yet"); |
| 163 | 180 | h.stop(); |
| 164 | 181 | }); |
| 165 | 182 | |
| 183 | test("the query counter sees the screen's own reads (it is not vacuous)", async () => { | |
| 184 | let h: Awaited<ReturnType<typeof open>> | undefined; | |
| 185 | const calls = await screenQueries(async () => { | |
| 186 | h = await open(); | |
| 187 | }); | |
| 188 | expect(calls).toBeGreaterThan(0); | |
| 189 | h?.stop(); | |
| 190 | }); | |
| 191 | ||
| 166 | 192 | test("an account with no window seen says so, whichever row the cursor is on", async () => { |
| 167 | 193 | const h = await open(); |
| 168 | 194 | await h.press("g"); |
new above
offline
Drop core/subscriptions|core/standing|core/usage from the regex. Timers and other actions call those modules too, so they leak into
calls. Match onlyscreens/subscriptions, and raise Error.stackTraceLimit aroundnew Error()so the frame is not truncated.