Repository navigation
test(keybar): prove the shell took the bar's Enter by a command's output, not a prompt count - #2395
Conversation
…put, not a prompt count The check counted the "$" on screen before the key-bar taps and waited for more after Enter. The grid keeps no scrollback and one shell serves three contexts, so a new prompt can push an old one off the top and leave the count flat: the wait timed out (keybar-focus-regression.ts:72, flaky 9 times and failed twice once in 417 CI runs). Type a command without running it that prints a marker its echo does not hold, and wait for the marker after the bar's Enter. The command starts with C-g and C-u: each context ends with an Escape tap to the same shell, and readline can still hold that Esc as a Meta prefix when the next context types, turning the command's first letter into M-p (a history search) so the Enter runs nothing. A timeout names the context and shows the screen's tail. Fail-first with the screen filled with prompts first (scratch): the old check failed 3/3, the marker check passed 3/3. With a lone Esc left pending before the command (scratch): without C-g/C-u it failed 2/2, with them it passed 3/3. Plain runs passed 5/5; bun run check fast ok.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 26 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Merging 48e1449. Test-only (browser script): keybar-focus-regression proves the shell took the key bar's Enter by a typed command's unique output marker appearing, instead of counting prompts (with no scrollback a new prompt can push an old one off the screen), and clears readline first (C-g, C-u) so a leftover Escape cannot eat the command's first letter. Diff read by the merge pass; no CodeRabbit review needed. |
…s instead of racing 2 s (#2402) Found by the flake-hunt lane, with a Dori pin. The Pi listing tests added by #2377 raced the two-second production deadline on busy runners: - **`server/pi-session-metadata.test.ts`** "lists the newest 50 long sessions within the deadline and reads zero bytes on repeat": - #2391's Fast checks (run 40955829630): 6.6 s, "Pi sessions could not be read right now". - #2397's Fast checks (run 40960224000): 8.96 s. - Both passed on rerun. - **`server/api.contract.test.ts`** "lists a 202-session Pi store with 50 long transcripts through the real API without timing out": #2395's Integration run (job 123744721790), a 503 for the same reason. ## Cause (test flake) Both tests list about 200 MiB of Pi transcripts and check what is listed: - the newest 50 rows, with their titles and first prompts; - zero bytes read on a repeat listing; - chunk-sized reads, and an empty queue; - a later rename (API test). They did this under the listing's real deadline, `PI_READ_DEADLINE_MS` (2 s of wall clock, queue time included). On a loaded runner, reading 200 MiB takes longer than that. ## Change The deadline is injected rather than raced: - **Reader:** `PiSessionReader` takes an optional `deadlineMs` beside its existing `read` test seam and exposes it as `listingDeadlineMs`. `piSessions` uses that for the listing's deadline. Unset, it is still `PI_READ_DEADLINE_MS`. - **Server:** `createServer` gets a test option, `piSessionDeadlineMs`, passed to its reader. It is next to the other `*Ms` test options, such as `attachHoldMs`. - **The two tests:** each passes 120 s, past its own timeout. The unit test's timeout is 30 s; the API case's goes from 20 s to 60 s. The "zero bytes on repeat" and chunk assertions stay. - **Docs and changelog:** `docs/development.md` and the changelog fragment say this. The shared two-second deadline is still covered, with a fake clock: aggregate expiry, independent deadlines, queued expiry and FIFO admission, in `pi-session-metadata.test.ts:484-505`, `:585` and `:627`. Those tests also assert that the default is `PI_READ_DEADLINE_MS`. The API's 503 shape is still checked by its own case. ## Proof - **Fail-first (unit test):** with every 64 KiB read delayed 1 ms (scratch), the old test failed 2/2 with the CI error ("could not be read right now"), and the new one passed 3/3. - **Wiring (API test):** with `piSessionDeadlineMs: 1` (scratch), the API case fails with CI's 503, so the option reaches the listing. - **Runs:** the API case passed 3/3 (`bun run check run bun test ./server/api.contract.test.ts -t lists.a.202-session`). The unit file passed 5/5, then 39/39 again after the wording edits. - **Local checks:** `bun run check fast` ok. ## Reviews The PR changes product code (the reader and server test seams, with no production behaviour change), so both reviewers ran. - **omo-native-code-reviewer:** APPROVE (CLEAR) on both rounds. It confirmed that no production caller sets the option: `server/index.ts:738`, `server/remote-entry.ts:88`, the default reader, and the QA script. - LOWs fixed: the test name had claimed the shared-budget proof, and the comment said "a bound no slow runner reaches". Both now describe what the test checks. - LOW, follow-up only: the neighbouring API case "streams ..." reads about 17 MiB under the real 2 s deadline. That is about 0.7 s at CI's worst rate, and it has never failed. If it ever does, it can pass the same option. - LOW, style: the docs paragraph's wording, and the fixture helper's argument order. - **Codex Sol 6.1 Fast xhigh:** APPROVE on both rounds. - Round 1's LOW: the docs still said "under the ordinary deadline". Fixed. - Round 2: no findings.
Found by the flake-hunt lane:
scripts/keybar-focus-regression.ts:72(run byscripts/ui-contexts-regression.ts) timed out (waitForFunction: Timeout 10000ms exceeded) waiting for the shell to take the key bar's Enter. Over the 417 CI runs from 2026-10-28 03:26Z to 2026-10-29 18:22Z it passed only on its in-job second run 9 times and failed both runs once (latest 40864267912). In the failing log every key's input frame had already passed its check.Cause (test flake)
The check counted the
$on screen before the key-bar taps and waited for the count to grow after Enter. The grid keeps no scrollback (scrollback: 0) and one shell serves the three contexts in turn, so a new prompt can push an old one off the top and leave the count flat.Change
printf 'KB_%s\n' <nonce>, waits for its echo, and after the bar's Enter waits forKB_<nonce>. The echo cannot hold the joined marker, so the marker drawn proves the shell ran the command.Esc C-gis abort), and C-u clears the line. The test shell is alwaysbash --noprofile --norcin emacs mode (scripts/test-shell.ts).Proof
bun run check run bun scripts/keybar-focus-regression.tspassed 5/5.bun run check fastok.Test-only.
Reviews