Skip to content

test(browser): what the scripts start is awaited, and a diagnostic cannot end a run - #3974

Merged
devswha merged 4 commits into
mainfrom
test/newtab-typeahead-counter-installed-first
Nov 16, 2026
Merged

devswha merged 4 commits into
mainfrom
test/newtab-typeahead-counter-installed-first

Conversation

@devswha

@devswha devswha commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Test-only. In five browser scripts, a script started something without awaiting it, read a state before it was there, or let a diagnostic end the run:

  • scripts/newtab-typeahead-regression.ts: watch() installed the page's sent-frame counter with an un-awaited page.addInitScript (line 54) and its callers went on to page.goto. When the navigation won the race, the page had no window.sentByPage, so the wait "the page's frames for the new tab are all heard" compared heard.count >= undefined for 15 s and timed out, though every key had arrived. Measured on main bcc55ef in the runner image pinned to 2 cores: 2 failures in 36 runs, both with sentByPage undefined. Now watch() is async and awaits the installation, and all three callers (typeAhead, composingAcrossHandOver, ownedPage) await it before their goto. If the counter is missing, the wait fails at once with <case>: the page has no frame counter (window.sentByPage is undefined): watch() must install it before the page loads instead of a 15 s comparison that can never be true.
  • scripts/secret-input-regression.ts: accepted() read the fixture's file as soon as it existed. writeFileSync creates or empties the file before it writes the count, so a read in between saw '' (seen once: '' !== '17' at line 110). It now waits, bounded at 5 s, for the file to hold the expected count, and on timeout says what it last held. Forcing the race also showed a second site: the desktop "grid takes the typed secret" step polled for "13" while the file still held below-secret's "13" (same length), so it could pass on the old count, and the later control read (line 260) then landed in the new write's empty window. That step now clears the file first, as the other rounds do, and waits through accepted() with its own regression message.
  • scripts/terminal-attach-regression.ts: same shape, a void page.route(...) (inside a Promise executor) before the click that uploads. It is awaited now. It was not forced: losing that race would hang on await reached until the script timeout, and the call is ordered ahead of a multi-round-trip click, so it is fixed for its shape, not for a seen failure.

scripts/omo-question-wheel-regression.ts: a diagnostic could end the run

The page's response log read every POST /pane/scroll body with void response.json().then(...) (line 94), and nothing caught a rejection. If the next fixture's page.goto came first, Chrome no longer had the body, and the rejection (json: Protocol error (Network.getResponseBody): No resource with given identifier found) ended the run after every check had passed. The CI supervisor measured this as 1 failure in 34 runs of main 1a16970. The three page.waitForResponse predicates (lines 153-155, 169-170, 207) read the body the same way. Forced, a predicate whose body is gone makes Playwright reject the whole wait with that protocol error; it does not keep waiting.

The new scripts/response-gone.ts has one helper, unlessGone(response, read). It skips only the errors that mean the browser no longer has the body: No resource with given identifier found (seen in a forced real case, below), No data found for resource with given identifier, and Target page, context or browser has been closed (also seen, below). It logs response body gone: <method> <url> <error> and gives undefined. Every other error is rethrown, so a body that is not JSON still fails. In the wheel script:

  • the response log passes over a gone body. A body that is not JSON still ends the run, as on main.
  • the POST wheel wait reads body.scroll.offset_from_bottom strictly, as main did, so an error's answer with no scroll fails the wait (TypeError). It only passes over a body that is gone.
  • the two size waits (GET /pane/scroll?) keep ?.scroll?., as main did, because a metrics read can answer { scroll: null }. A comment there says so.

(The first push of this PR caught every error and used ?.scroll?. on the POST wait, so a bad answer in the middle of the wheel sequence was skipped. The merge pass found it, and this push takes it back; see the forced cases.)

scripts/terminal-attach-regression.ts pick() and scripts/theme-first-paint-demo-regression.ts: the same kind of handler

  • pick() read each upload's answer (assert.equal(status, 200), await response.json()) in an async page.on("response") handler that had no catch and was never removed. A wrong answer ended the run from the handler while the pick waited forever. Every earlier pick's listener also read later answers, up to the page's close. Now a wrong answer rejects the pick where it is awaited, and the listener leaves once every file is stored. Here a gone body is not skipped: within its pick the path is needed, so it fails the pick. The pick's promise is marked handled when it is made, so an early rejection is reported at await responses.
  • Correction (found by the merge pass at d73874e): removing that listener also removed the only thing that checked the held upload's answer. On main and at 67d1d11, the earlier picks' leftover listeners read it and asserted status 200, so a refused held upload failed the run. At d73874e nothing read it, so a held upload answered 500 passed (forced: exit 0). The held-upload step now awaits that answer explicitly. It subscribes before the hold is released and asserts status 200 and a string path before it checks that nothing was typed. Forced: exit 1, the held upload is stored.
  • theme-first-paint's response handler (line 265) awaits allHeaders() and body() with no catch, the same shape. A read that the page's close overtakes is now passed over through unlessGone. The checks then report the missing boot response or CSP as they would on main (no boot script response, the page was served with null). Any other failure still ends the run. Not forced; run 5 times through CI's command (below).

Can a wrong product answer now pass where it failed on main?

  • newtab-typeahead: no. Awaiting the counter's installation and the new typeof sentByPage === "number" check only add a failure. The comparison textOf(sent, second) === expected, "no key goes to the old tab" and "opens no other tab" are unchanged. Forced: an extra key typed after the command reaches the new tab, and the run fails with plus: every key reaches the new tab, in order ('echo ahead-plus\rz' vs 'echo ahead-plus\r').
  • secret-input: no. accepted() waits for the expected count, and a different count still fails when the 5 s bound ends. Forced: a fixture that takes one character more fails with Masked input never reached fixture: it took "16", not 15 characters. Clearing the file before the grid's typed secret removes a stale count of the same length that could have passed for it.
  • terminal-attach: no, at this head; yes at d73874e, for the held upload (above). The route is awaited before the click, a wrong pick answer fails the pick where it is awaited, and the held upload's answer is checked explicitly. Each forced case is in the table below.
  • question-wheel: no, after this push. Forced below: invalid JSON and a 500 without scroll fail as on main.

Every listener this PR removed or narrowed, and what it no longer reads

Each of these is answered by a forced run in the table below, not by reading the code.

  • terminal-attach pick() listener: removed once its files are stored. It no longer reads:
    • the later picks' uploads. Each later pick's own listener reads them. Forced: a refused first-pick upload and a refused input-line upload both fail.
    • the late pick's upload. There is none: forced, the late pick makes 0 uploads.
    • the held upload. This was the hole, now closed by the explicit check.
    • the line-break pane's pick. That pick is on its own page and has its own listener.
  • question-wheel response log: passes over a gone body only. A body that is not JSON still ends the run.
  • question-wheel POST wheel wait: passes over a gone body only, and reads scroll strictly.
  • question-wheel GET size waits: pass over a gone body only. A metrics answer that is not JSON fails the wait. 67d1d11 had a hole here, closed at d73874e.
  • theme-first-paint response handler: passes over a gone header or body read only. A refused boot script or a missing CSP header still fails.

Same shape elsewhere

The search for the same shape across scripts/ and src/ (void page|context .addInitScript|route|exposeFunction|exposeBinding, and any of these calls not awaited or returned) found only the two fixed above (newtab-typeahead, terminal-attach). relay-shell-browser-qa.ts:1568 returns the addInitScript promise, and its callers await it. The CI supervisor's measurement found the question-wheel diagnostic. The merge pass found the two async response handlers (terminal-attach pick(), theme-first-paint), and both are fixed above. Per the merge pass's grep, the other void ….then( calls in scripts/ have a rejection handler, or are page code over a promise that cannot reject.

No fixed sleep was added. The existing 25 ms polls remain, inside bounded waits. No changelog fragment, because this is test-only.

Validation

Ran:

  • Forced cases, at four versions. Each is a scratch copy (not committed) of that version's script with one fault, run through bun run check run -- bun <copy> in the herdr-ci-runner:local image, pinned to one 2-core slot, with no network and no artificial load. Terminal-attach ran through a scratch runner (test herdr, createServer on port 0, its own workspace). Each cell says what happened: exit 1 after N s and the assertion or error that ended it; exit 0 when the script passed (in bold where it should have failed: the hole); or hangs: the run never ended by itself and was killed at the harness's limit (240 s, exit 124; main's first-pick case by hand after 349 s), which on CI would cost the job its whole timeout. No forced case hangs at this head: every cell in its column ended in 18 s or less, except theme-first-paint, which runs all 62 cases (about 72 s).
forced case main (1a16970) 67d1d11 d73874e 3de6a63 (this head)
newtab: the frame counter installed only after the page loaded exit 1 after 19 s: the 15 s wait on undefined times out, plus: the page's frames for the new tab are all heard exit 1 after 4 s: plus: the page has no frame counter (window.sentByPage is undefined)… exit 1 after 4 s: same exit 1 after 4 s: same
newtab: an extra key reaches the new tab after the command exit 1 after 3 s: plus: every key reaches the new tab, in order exit 1 after 3 s: same exit 1 after 4 s: same exit 1 after 3 s: same
secret-input: the fixture's file is empty 1.5 s before its count exit 1 after 4 s: '' !== '15' exit 0 after 18 s (passes: waits for the count, as intended) exit 0 after 18 s (same) exit 0 after 18 s (same)
secret-input: the fixture takes one character more exit 1 after 4 s: '16' !== '15' exit 1 after 9 s: Masked input never reached fixture: it took "16", not 15 characters exit 1 after 9 s: same exit 1 after 10 s: same
question-wheel: real body gone (the log reads each body after the next navigation) exit 1 after 7 s: all five PASS lines, then error: json: Protocol error (Network.getResponseBody): No resource with given identifier found ends the run exit 0 after 6 s (passes, as intended: the gone bodies are logged) exit 0 after 8 s (same) exit 0 after 7 s (same)
question-wheel: one POST /pane/scroll in the wheel sequence answers 200 "{not json" exit 1 after 4 s: SyntaxError: waitForResponse: JSON Parse error exit 0 after 7 s (passes: the hole) exit 1 after 4 s: SyntaxError: waitForResponse: JSON Parse error exit 1 after 4 s: same
question-wheel: that answer is 500 {"error":…} (no scroll) exit 1 after 4 s: TypeError … (await response.json()).scroll.offset_from_bottom exit 0 after 7 s (passes: the hole) exit 1 after 4 s: TypeError … body.scroll.offset_from_bottom exit 1 after 5 s: same
question-wheel: the first metrics read after the resize answers 200 "{not json" exit 1 after 5 s: SyntaxError: waitForResponse: JSON Parse error exit 0 after 8 s (passes: the hole) exit 1 after 5 s: same exit 1 after 4 s: same
terminal-attach: the key-bar pick's first upload answers 500 hangs: the handler's 500 !== 200 is reported as unhandled, then the pick waits forever; killed at the harness's hand stop after 349 s (does not pass) hangs: same, then the pick waits forever; killed at the harness's 240 s limit after 246 s (does not pass) exit 1 after 4 s: 500 !== 200 at the pick's await exit 1 after 4 s: same
terminal-attach: the input-line pick's upload answers 500 hangs: two leftover listeners report 500 !== 200 as unhandled, then the pick waits forever; killed at the harness's 240 s limit after 245 s (does not pass) hangs: same, then the pick waits forever; killed at the harness's 240 s limit after 245 s (does not pass) exit 1 after 5 s: 500 !== 200 at the pick's await exit 1 after 4 s: same
terminal-attach: the held upload answers 500 exit 1 after 5 s: 500 !== 200 twice, from leftover pick listeners exit 1 after 5 s: same exit 0 after 5 s (passes: the hole) exit 1 after 5 s: the held upload is stored
terminal-attach: uploads the late pick makes (counted, no fault) exit 0 after 6 s, 0 uploads exit 0 after 6 s, 0 uploads exit 0 after 6 s, 0 uploads exit 0 after 5 s, 0 uploads
theme-first-paint: the boot script answers 500 exit 1 after 70 s: per case boot response {…"status":500…} and boot request failed, then a frame showed another theme than the saved one exit 1 after 71 s: same exit 1 after 72 s: same exit 1 after 72 s: same
theme-first-paint: the page is served without its CSP header exit 1 after 70 s: per case the page was served with null, then a frame showed another theme than the saved one exit 1 after 72 s: same exit 1 after 81 s: same exit 1 after 74 s: same

In bold, where a version passed a fault or hung: 67d1d11's question-wheel holes (fixed at d73874e), d73874e's held upload (fixed at this head), and the picks that hang on main and 67d1d11 (fixed at d73874e, when a pick's wrong answer began to reject the pick).

  • The first push's forced runs (3 times each, same image and slot): the counter installed late or 3 s slow and not awaited fails with CI's message timed out: plus: the page's frames for the new tab are all heard and sentByPage=undefined; the awaited 3 s install passes. A stand-alone harness (Bun.serve and the same Chromium) shows that a waitForResponse predicate whose body is gone rejects the whole wait: main's shape gives REJECTED: waitForResponse: json: Protocol error (Network.getResponseBody): No resource with given identifier found, and bodyOf passes over it and resolves on the next answer.
  • CI's own command on this head, BROWSER_SCRIPTS=scripts/ui-contexts-regression.ts BROWSER_WORKERS=2 BROWSER_RETRY=0 bun run check run -- bun scripts/ci-browser-parallel.ts. It ran 21 times (20 valid), each in the runner image pinned to one 2-core heavy slot with four yes hogs on the slot's CPUs, as in the measurement. Runs 1-19 were on the first commit (its newtab and secret-input files are identical at this head); run 20 passed the script, but check voided it because I edited the question-wheel file while it ran, so run 21 replaces it on this head.
    • The two steps this PR fixes: 0 failures in 20 valid runs. The "frames for the new tab are all heard" wait and the secret fixture's count passed in every run where they were reached. Secret-input passed in all 20.
    • 17 of the 20 runs passed the whole script. Runs 14, 15 and 18 failed at a different step, the touch case's the new tab ran the command typed ahead (sent to it: "", held for review: false). That case comes before its frame wait. Here the page sent the new tab nothing. This is the timeout test(newtab-typeahead): compare the page's frames once all are heard, and say why a run timed out #3691 already describes ("CI has seen this time out without saying why"). All three came within six minutes (11:06-11:11), while this PC's CPU pressure was at its limit, with four of these runs side by side. The other runs were one or four at a time at lower pressure, and all passed. This PR does not touch that step, and I found no way for awaiting the counter's installation to affect it. It is left to a separate look.
  • The same command for scripts/ui-terminal-regression.ts (the part that runs terminal-attach-regression.ts), once with four yes hogs: passed, including PASS the input line's Attach button puts picked files' paths at the caret and sends nothing, and a stale pick or upload types nothing.
  • The same command for scripts/omo-question-wheel-regression.ts on this head: 5 runs, one at a time, no hogs. 5 of 5 passed, and no answer's body was gone.
  • bun run check fast: passed on each of the four commits (workflow syntax, generated types/themes, typecheck, build, unit tests), the last time on this head.
  • Second follow-up (this head, 3de6a63). Each touched script ran through CI's own command 5 times in a row, one container at a time, unloaded:
    • question-wheel: 5 of 5 passed.
    • theme-first-paint: 5 of 5 passed.
    • ui-terminal-regression.ts (terminal-attach, with the new held-upload check): 5 of 5 passed, each with the Attach button's PASS line.
    • ui-contexts-regression.ts (newtab-typeahead and secret-input): 5 of 5 passed, each with both PASS lines.
  • First follow-up (head d73874e). Each touched script ran through CI's own command (BROWSER_SCRIPTS=<script> BROWSER_WORKERS=2 BROWSER_RETRY=0 bun run check run -- bun scripts/ci-browser-parallel.ts) 5 times in a row, one container at a time. These runs were unloaded (no yes hogs), except the first four terminal-part runs, which were started before the CI supervisor asked for no load. The 20 loaded runs above stand as they were.
    • scripts/omo-question-wheel-regression.ts: 5 of 5 passed.
    • scripts/theme-first-paint-demo-regression.ts: 5 of 5 passed, no response body gone line.
    • scripts/ui-terminal-regression.ts (terminal-attach): 5 of 5 passed, each with the Attach button's PASS line.
    • scripts/ui-contexts-regression.ts (newtab-typeahead and secret-input): 5 of 5 passed, each with both PASS lines.

Skipped: bun run check full, and loaded runs for the follow-up (correctness, not load, was the question there), and the integration lane (no server, src or shared change); the Windows and macOS jobs (they run none of these scripts).

…e loads, and wait for the secret fixture's count, not its file

newtab-typeahead-regression.ts installed its sent-frame counter with an un-awaited
page.addInitScript and went straight to page.goto: when the navigation won, the page had no
window.sentByPage and the wait "the page's frames for the new tab are all heard" compared
against undefined for 15 s. watch() now awaits the installation and its three callers await
watch() before any goto; a missing counter fails at once and says so.

terminal-attach-regression.ts registered its upload-holding route with an un-awaited
page.route before the click that uploads; it is awaited now.

secret-input-regression.ts read the fixture's file as soon as it existed, though writeFileSync
makes it empty before it writes the count; it now waits for the count itself. The grid's typed
secret clears the file first, as the other rounds do, so below-secret's count of the same
length cannot pass for it.
…as neither ends the run nor fails a wait

The page's response log read every POST /pane/scroll body with an un-caught
void response.json(): when the next fixture's goto came first, Chrome no longer had
the body, and the rejection ended the run after every check had passed (measured:
1 in 34 runs of main 1a16970). Three waitForResponse predicates read the body the
same way, and a predicate that throws rejects the whole wait with that protocol
error. bodyOf() reads it, or logs that it is gone and gives undefined: the log
skips it and the waits pass over that answer.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated regression checks for type-ahead input, scrolling, direct text entry, and terminal attachment to handle browser timing and unavailable response data more reliably.
    • Added checks that confirm input results match expected content and that setup is complete before interactions begin.

Four regression scripts update their setup and verification steps. The changes cover init-script installation before navigation, unavailable response bodies, result-file content polling, and image-route arrival signaling.

Changes: New-tab type-ahead

Layer / File(s) Summary
Init script and frame check
scripts/newtab-typeahead-regression.ts
watch awaits init-script installation before navigation. The frame-count check reports when the counter is absent.

Question-wheel response handling

Layer / File(s) Summary
Response-body handling
scripts/omo-question-wheel-regression.ts
bodyOf parses response data or logs the request and returns undefined. Scroll logging and response predicates use the helper and skip unavailable bodies.

Secret-input result validation

Layer / File(s) Summary
Result-file validation
scripts/secret-input-regression.ts
accepted polls for the expected file content and reports observed and expected values on timeout. The desktop direct-input check deletes its prior result before typing.

Terminal attachment upload race

Layer / File(s) Summary
Route setup and arrival signal
scripts/terminal-attach-regression.ts
The test installs the image route before clicking Attach. The route handler resolves a separate arrival signal when it is entered.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Other

Possibly related PRs

  • devswha/ovis#3713: Adds the page-side sent-frame counter used by the new-tab type-ahead check.
  • devswha/ovis#3788: Updates the sent-frame counter contract used by the new-tab type-ahead check.
Merge Risk: Minimal · up to 67d1d

These changes only make browser regression scripts more reliable and cause no production behavior change. No concrete merge-blocking issue was established.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test-only change: awaiting script startup, and a diagnostic no longer ending a run. It matches the four browser-script fixes, though it does not name each file. It is a single sent…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template. It has a Change section that explains the problem and the resulting behavior for each of the five browser scripts. It has a Validation section that lis…
Full details: Title check

Explanation

The title names the test-only change: awaiting script startup, and a diagnostic no longer ending a run. It matches the four browser-script fixes, though it does not name each file. It is a single sentence, specific, and not vague.

Full details: Description check

Explanation

The description follows the repository template. It has a Change section that explains the problem and the resulting behavior for each of the five browser scripts. It has a Validation section that lists the forced-failure cases, the CI commands run, and the checks skipped (bun run check full, the integration lane, and the Windows and macOS jobs). The Change section does not link an issue, but the template asks for one only for features, and this PR is test-only, so that is not a gap.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2f95460 and 67d1d11.

Files selected for processing: 4

  • scripts/newtab-typeahead-regression.ts
  • scripts/omo-question-wheel-regression.ts
  • scripts/secret-input-regression.ts
  • scripts/terminal-attach-regression.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

…as; a bad answer fails again

The merge pass found that question-wheel's bodyOf() caught every failure of a scroll
answer's JSON, and with ?.scroll?. the wheel waits skipped a bad product answer (invalid
JSON, a 500 without scroll) instead of failing. scripts/response-gone.ts's unlessGone()
now skips only the body-gone errors (No resource with given identifier found, No data
found for resource with given identifier, the page or context closed) and rethrows
the rest; the POST wheel wait reads body.scroll strictly again, and the two size waits
keep ?. for a { scroll: null } answer.

terminal-attach's pick() read each upload's answer in a response handler that was never
removed and had no catch: a wrong answer now rejects the pick where it is awaited, and
the listener leaves once every file is stored. theme-first-paint's response handler
passes over a header or body read that the page's close overtakes, through the same
unlessGone().
… now that no pick listener reads it

Removing pick()'s listener once its files are stored also removed what had checked
the held upload's answer: on main the earlier picks' listeners asserted its status
200, so a refused held upload failed the run; at d73874e it passed. The step now
awaits that answer (subscribed before the hold is released) and asserts status 200
and a string path before checking that it types nothing. pick()'s promise is marked
handled when made, so a rejection is reported at its await. unlessGone() matches the
two Chromium texts only behind their Protocol error (Network.getResponseBody):
prefix.
@devswha
devswha merged commit 7e778e3 into main Nov 16, 2026
14 of 15 checks passed
@devswha

devswha commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 3de6a63b45d7 as 7e778e3a34d0 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

@devswha
devswha deleted the test/newtab-typeahead-counter-installed-first branch November 16, 2026 15:00
devswha added a commit that referenced this pull request Nov 17, 2026
… dropped; ui-contexts checks wait for the exact state (#4031)

## Why

`ui-contexts-regression` and `ui-contexts-layout-regression` were the
browser lane's least stable scripts over the last week of CI: 13
failures and 37 hidden second-run passes for the first, 2 and 12 for the
second, 5 of each on main. This finds the cause of each failure site
from the CI logs (the `browser-main` artifacts' `*.attempt-1.log`),
reproduces it in the CI runner image, and fixes the test races and the
one product bug at their cause. No sleep, timeout, retry or skip is
added.

What the product fix changes for a user, plainly: a key typed while a
pane taken back from another app's hold is drawing (after its attach
takes input, before its screen is drawn) now reaches the pane; on main
it was dropped silently. A key typed before the attach takes input,
including the one that takes the pane back, is still not delivered: it
is now refused with a notice instead of being dropped silently.

## Failure sites (7 days of CI)

| Site | Hits | Class | Cause | Fix |
|---|---|---|---|---|
| `newtab-typeahead-regression.ts:142-145` touch | 15 of 16 newtab hits
| (a) test race | When herdr answers before the first key, the
type-ahead field is gone; on a touch screen the new tab's terminal
deliberately takes no focus (no on-screen keyboard unasked), so every
key lands on `BODY` and is lost (`sent to it: ""`). | The case holds
herdr's answer until its keys are typed (`holdCreate`), as the other
held cases do; `touch-midway` stays the case of a tab that comes while
keys are typed. |
| `chat-size-regression.ts` `held` (old line 734) | 6 | (b) product bug
| After `attach_held`, `resume()` cleared the held state but left
xterm's `disableStdin` on until the new attach's first output was
parsed, so a key typed in that window was dropped by xterm before the
app saw it, without a word. | `resume()` reopens what the hold closed
(`src/lib/useTerminalMount.ts`). Until the taken-back pane's own screen
has been read for a masked prompt, a key goes as a password does:
**delivered** when typed after the new attach says `input-ready` (the
window the `held` check and CI's failure cover), **refused with a
notice** when typed before it, the key that takes the pane back included
(it might be a password, so it is never drafted). The `held` case types
with the page clock still paused, before the new attach's output can be
drawn: it fails on main every time. |
| `chat-size-regression.ts:1249` reclaim | 1 | (a) test race | A window
takes the pane back only once the server's `pane-geometry` has told it
another device took it; the test acted as soon as the shell reported the
new size. | Each size the pty takes is waited for in both windows
(`pane-geometry` frames) before either acts. |
| `mobile-tabs-regression.ts:334` | 6 | (a) test race | `.tab-strip`
also matches the phone's tab row in the header, so the wait after
resizing to a tablet returned before the new width was drawn. | Waits
for the row under the header (`.pane-slot .tab-strip`), as the file
already does above. |
| `terminal-copy-regression.ts:343` edge drag | 2 | (a) test race | A
press counts lines from herdr's own scroll position; the test read the
start line off a drawn screen that can still be one wheel step behind
herdr. CI's miss was exactly one wheel step (10 lines: ended at 259,
expected 229 + 42 - 2 = 269). Not reproduced locally (8 throttled runs
on main green); herdr's `pane.read` "visible" was checked to follow its
scroll position (S261 to S211 after a 50-line scroll). | Line numbers
are read once the drawn screen's top line is herdr's. |
| `secret-input-regression.ts:110` | 2 | (a) | Already fixed on main by
#3974. | - |
| `Timed out after 600s` | 7 jobs | (c) host | Self-hosted runners under
load: every check 2-5x its usual time, `ui-regression` timing out in the
same jobs (73341eb among them). | Not this PR's. |
| wake-lock:100, terminal-pinch:139, telemetry:118, hidden-mount | 1-3
each | not flaky | Failed twice on one PR branch each: that PR's own
breakage. | - |

## Not reproduced, not changed

Each got at least two honest attempts in the runner image; none failed,
so nothing was patched blind:

- `chat-size-regression.ts` `idle-secret` "the masked prompt is on the
watched screen" (3 hits, the newest today): 0 of 22 on main (10 alone,
12 in the whole lifecycle sequence under 2x CPU throttle, with screen
and frame diagnostics on failure).
- `usage-regression.ts:215/467` "the popover stays inside the phone's
screen" (3 hits): 0 of 8 under 2x throttle. The hypothesis that the
first roster closes a drawer opened before it was disproved (drawer
stayed open 5 of 5 with the roster held until it was open).
- `tab-menu-regression.ts:625` phone "Pane and tab…" sheet (1 hit): 0 of
8 under 2x throttle, 0 of 40 in a loop of the same steps.
- `newtab-typeahead-regression.ts:153` and `chat-size-regression.ts:62`
(1 hit each, 11-12/11-15).

## Follow-up (not this PR)

- Codex review, MEDIUM, not reproduced: after a pane let go of while its
view was not drawn (a hidden page), keys typed before the new attach
takes input are retained with the masked-prompt state of the last screen
seen, so a password typed at a prompt that appeared meanwhile could
reach a draft. That path exists on main for every pane let go of that
was never held. For a held pane this PR does not open it: keys typed as
a held pane is taken back count as a password until the new attach's
screen is read (raised by the omo review of 916689b and Codex's of
aa87bfc, answered in 745dac3).

- Codex re-review, MEDIUM, not reproduced: a held pane whose connection
drops while it is away comes back with stdin still closed
(`onDisconnect` clears the held state but not what the hold closed), so
its first keys are still dropped. Same on main; this PR reopens stdin
only on the resume of a pane still held.
- Both reviewers, MEDIUM, declined: on a touch screen, keys typed after
the new tab already exists (none typed ahead) are not caught: the app
does not focus a terminal unasked there, so they reach no field. That is
the touch focus policy (`takeKeyboard`), not the type-ahead contract,
which covers keys typed before the tab exists (`touch` now) and across
its arrival (`touch-midway`). Changing it would put the on-screen
keyboard up unasked; a product decision, not this PR's.
- omo review, LOW, declined: no browser step checks that an observer
stays read-only after a resume; `onData` refuses an observer's keys on
its own as well.
- Earlier review findings answered in later commits: the reopening is
limited to a pane that was held (a `terminal_unsupported` or ended pane
stays closed, 916689b); keys typed before the taken-back pane's own
current screen is read go as a password (sent once it takes input,
otherwise refused with a notice, never drafted), scoped to that pane and
not ended by a recovering attachment's replay (745dac3, cb6c734);
the `held` case asserts that its key went without a receipt, so it fails
if that rule goes (aa78006).
- Codex, MEDIUM, declined: a key sent under that password rule keeps no
unconfirmed copy, so it can be lost if the connection ends before the
bridge takes it. That is how every key typed at a masked prompt already
goes; on main these keys were dropped outright.
- Codex, LOW, declined: the `held` check does not record the input
frame's pane. That page shows the held pane only, so an input frame on
it is that pane's.
- Codex, MEDIUM, declined: the password rule ends at the first whole
frame of the taken-back pane's screen (`FrameGate`'s boundary), which a
synchronized-update marker split across chunks could fool. That boundary
is the product's existing proof for every masked-prompt read; the rule
ends exactly where that detection already trusts the screen.
- omo review of aa78006, LOW, follow-up: when a second client of the
bridge keeps a held attachment alive, the replay a returning tab gets
first is the screen from before the hold, and it ends the password rule;
on `attach-resumed` the keyboard then reopens with that screen's
masked-prompt state. Main has the same exposure on `attach-resumed`. A
fix would start the rule on `attach_held` too and end it only on a
screen of an attach that is not held.
- omo review of aa78006, LOW, follow-up: a program with focus
reporting on makes xterm send `ESC [ I` on the click that takes a held
pane back; refused as typed in the password window, it shows the "a
password is never held" notice although nothing was typed. `retainTyped`
could leave xterm's own replies silent before that notice.
- omo review of aa78006, LOW, declined: no check fails if the password
rule never ends. The `held` case stops at the window it covers; a later
key's receipt would need the new screen's parse awaited under the page
clock, more harness than the risk.
- Both reviews, MEDIUM/LOW, declined: while the rule holds, keys go as a
password does, so with no receipt and no unconfirmed copy: a connection
that ends before the bridge takes one loses it untold, as for any key
typed at a masked prompt. On main they were dropped untold every time.
- Merge pass, follow-up: a key sent after `input-ready` but before the
screen is drawn goes as a password, without a receipt, so it is lost
untold if the connection drops in that gap (in one narrow case main kept
such a key in a draft).
- Merge pass, follow-up: `syncedTop` in terminal-copy polls herdr with a
25 ms wait inside its 10 s bound.
- CodeRabbit (terminal-copy:316), follow-up: the drag's scroll writes go
one at a time and the last can still be queued after release, so
`syncedTop` can match an intermediate position. The exact wait is for
the page's in-flight scroll writes to reach zero (the script already
wraps `fetch`), not two equal reads.

## Validation

All browser runs are in the self-hosted CI runner image
(`herdr-ci-runner:local`, herdr 0.9.3, bun 1.4.2) on a heavy slot of two
cores (`~/.ovis-toolchain/heavy-run.sh`), each started only while
`/proc/pressure/cpu` avg60 was under 20, one at a time. "Throttled"
means Chromium's CPU slowed 2x through CDP
(`Emulation.setCPUThrottlingRate`), which reproduces CI's slow-runner
timing without loading the host.

**How large N is, and why it is per site.** CI's old rate on main for
these two scripts is about 10 first-attempt failures in 298 runs (3.4%).
Catching that rate whole-script at 95% confidence takes
ln(0.05)/ln(1-0.034) = 87 runs a side (about 9 hours of slot time each),
and an idle slot does not reproduce it (main whole-script: 4 of 4 green
before this work). So each site is proven where it can be made to fail,
with the N its own failure rate needs, and the whole scripts are run on
head as a check that nothing else broke.

| What | main (116252f) | head (aa78006) |
|---|---|---|
| `held` (product bug), the new check, `CHAT_SIZE_CASE=held` | 5/5 fail:
the wait for the typed `z` to go out times out (the CI symptom) | 5/5
pass |
| chat-size lifecycle under 2x throttle (CI's `held` symptom) | 4/12
fail (all the CI symptom: no `input` after `input-ready`, then the idle
release) | 8/8 pass; at 916689b 12/12. With p = 4/12, (2/3)^8 = 3.9%
and (2/3)^12 = 0.8% for an unfixed head to pass them all |
| newtab touch mechanism (keys typed after the new tab arrives on a
touch screen) | lost 5/5 (land on BODY) | the `touch` case now types
before herdr answers (holdCreate) |
| newtab-typeahead check, 2x throttle | 10/10 pass | 10/10 pass |
| mobile-tabs check, 2x throttle | 10/10 pass | 10/10 pass |
| terminal-copy check, 2x throttle | 8/8 pass | 10/10 pass |
| chat-size `reclaim` (`CHAT_SIZE_CASE=reclaim`) | - | 5/5 pass |
| both scripts whole, as CI's job runs them (`ci-browser-parallel`, 2
workers, `BROWSER_RETRY=0`) | 8/8 pass (an idle slot does not reach CI's
rate: no comparison, see N above) | 8/8 pass (303-381 s each) |

Not reproduced on main despite trying (see above): `idle-secret` 0/22,
usage popover 0/8, tab-menu 0/48, terminal-copy 0/8 (its fix rests on
CI's exact one-wheel-step miss).

Checks:
- `bun run check fast` once at aa78006, on the rented heavy server
(the default for heavy runs since today): workflow syntax, generated
types and themes, typecheck and build ok; unit tests failed only in the
three job-started hook tests of `scripts/self-hosted-runner.test.ts`
that fail on that server for a known test bug (its stderr is a socket
there), a file this PR does not touch. Every other unit file passed.
- `bun run typecheck` on this PC after each commit: ok.
- Not run: `bun run check full`, the integration suite, the other
browser scripts (only the two ui-contexts scripts and the five changed
checks were run).

- GitHub at aa78006: all 18 checks pass, including Fast checks (whose
unit tests include `scripts/self-hosted-runner.test.ts`) and Browser
regression (ui-regression), which runs both ui-contexts scripts.

Reviews before the handover, at aa78006: a fresh
omo-native-code-reviewer (claude-opus-5-5, high) CLEAR with four LOW,
and Codex (gpt-6.1-terra, xhigh, read-only) CLEAR; five rounds in all,
each round's findings fixed in the next commit or declined above with a
reason. `dori review #4031`: CLEAR at aa78006.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant