Repository navigation
test(copilot): wait through a switch's 409 and scrollback answers, not read every answer as a transcript - #2385
Conversation
|
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 37 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 |
…t read every answer as a transcript A conversation read checks ownership before and after reading the page: one whose checks straddle the stand-in's Unregistering/Registering lines answers 409 history_changed, which has no turns, and the switch polls read turns[0] off it (TypeError, three times in 417 CI runs, also after #2224). Poll for an HTTP 200 copilot-transcript answer with the expected first turn, keeping the last answer for the timeout message; poll both panes to scrollback after the peer starts; and have the read-retry test wait for a cursor before arming each injected failure, printing every answer it waits past (that test's CI failures had no logged cause). Fail-first with a scratch spy forcing the straddle: old 3/3 TypeError, new 3/3 pass. Plain runs on CI's herdr 0.9.3 and Node 22: 4/5 at this head (the fifth is the read-retry test's open finding); bun run check fast ok.
a00f156 to
28ea384
Compare
…ease the session the test reported
"binds only the reported UUID ..." quit its stand-in and then waited for
herdr's agent label on the pane to stop saying copilot, with 10 s to do it.
The label is not the exit: the test itself reported the Copilot session for
that pane (report_agent_session, source herdr:copilot), and on the CI runner
the label outlasted the 10 s ("isolated fixture did not exit", every main
push since c5851e7 and several PRs), while startFixture then waited on the
same label for the next stand-in.
Wait for the stand-in's own pid to leave the pane's foreground, release the
session the test reported (pane.release_agent, as Copilot's hook does at its
exit), wait for the label to go, and start the next stand-in by its own
process. A timeout now prints the pid's state, the foreground, the label and
its session, so CI says which signal never came.
Local, on CI's herdr 0.9.3 and Node 22: the case passed 4/4 (two pairs side
by side in two checkouts) and the whole file 5/5; bun run check fast ok. The
stuck label itself did not reproduce here (herdr cleared it 150-320 ms after
the exit), so there is no local fail-first for that part.
Review of 8a44db5 (omo-native-code-reviewer): APPROVE (WATCH)CI on this head: Integration tests pass. The line-320 case took 2389 ms (job 123739245177); it failed at 12.6 s before. The whole copilot file took 7.8 s. The reviewer confirmed:
How each finding was resolved:
|
|
Merging 8a44db5. Test-only: server/copilot.contract.test.ts waits, with deadlines, through a switch's transient answers (a 409 while ownership changes, or scrollback) instead of reading each answer as the transcript, and fixes the case that failed main twice ('isolated fixture did not exit'): it now waits for the quit stand-in's own process to leave the pane rather than herdr's agent label (which can outlast it), releases the session the test reported as Copilot's hook would, and every timeout prints what it saw. Diff read by the merge pass; no CodeRabbit review needed. |
Found by the flake-hunt lane:
server/copilot.contract.test.ts"reads a resumed CLI without marker or report and follows foreground switches rather than stale reports" failed withTypeError: undefined is not an object (evaluating '(await read()).turns[0]')in its switch polls three times in the 417 CI runs from 2026-10-28 03:26Z to 2026-10-29 18:22Z (jobs 122685036108, 122847698843, 123297359877), including after #2224. Each passed on a rerun.Cause (test flake)
The Copilot stand-in logs a switch as two lines:
Unregistering, thenRegistering. A conversation read resolves ownership, reads the page, and checks ownership again (server/conversation.ts, about lines 1682-1686). A read whose two checks straddle the switch rightly answers HTTP 409{"error":{"code":"history_changed"}}, which has noturns. A read between the two lines rightly answers scrollback. The test's polls treated every answer as a conversation and readturns[0]off the 409 body.Reproduced: a scratch spy appended a real
Registeringline during a read, forcing the straddle. The old test failed 3/3 with CI's TypeError, and the new one passed 3/3 while it saw the real 409s. A 400 ms gap between the two lines alone did not reproduce it (3/3 passed).Change
read()returns nothing for a non-200 answer and keeps the last answer for the timeout message.waitForTranscript(text, previousHistory?)waits for HTTP 200, sourcecopilot-transcriptand the expected first turn (and a newhistory_idwhen asked). Every switch poll uses it.Registeringline.Proof
These runs used CI's herdr 0.9.3 and Node 22, with checksum-verified binaries under the run's own tools directory. As #2224 notes, this file cannot run on herdr 0.9.5 with Node 24.
bun run check fastok.Test-only.
Not fixed here: the sibling test's cursor wait (reproduced, cause unknown)
The sibling test's last loop failed on CI twice (jobs 122661979002, 122801012396;
before.cursorundefined, then line 448). Locally it failed once in five runs with the new wait. The server answered200 {"source":"scrollback","turns":[]}for the whole 5 s after the transcript file was replaced and the session registered again.A read-only analysis ruled out the timestamp cache and the generation map: a registration with identical timestamps is picked up at once. It could not name the cause, because
ConnectionDiagnosticssuppresses repeat failures for 30 s and the underlyingConversationUnavailablereason is never logged. The wait added here prints each answer it skips, so the next CI failure says what it saw. Because the wait only retries until a cursor shows, a real regression there still fails, now as a timeout with its answers printed.Reviews
waitForTranscriptrepeat what it guarantees.Second commit: the quit wait at line 320 (red on main)
"binds only the reported UUID to the foreground process's home and rejects old cursors after a switch" failed at
:320("isolated fixture did not exit") on every main push since c5851e7 and on several PRs, #2385 itself included.Cause: after
:quitthe test waited 10 s for herdr's agent label on the pane to stop sayingcopilot. The label is not the exit: the test itself reported the Copilot session for that pane (pane.report_agent_session, sourceherdr:copilot), and on the CI runner the label outlasted the 10 s.startFixturethen waited on the same label for the next stand-in.Change:
pane.release_agent, as Copilot's own hook would at its exit), waits for the label to go, and starts the next stand-in by its own process.Proof:
bun run check fastok.:quitdid not hold it. So there is no local fail-first for that part, and this PR's CI run is the first real test of it.