Skip to content

fix(runner): the build cache keeps each build under the run that built it (needs owner OK) - #3585

Merged
devswha merged 2 commits into
mainfrom
fix/build-cache-per-run
Nov 10, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/build-cache-per-run

Conversation

@devswha

@devswha devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Why

Follow-up to #3567, from the merge pass's review of it (its third note).

On the self-hosted runner the jobs of one CI run share the client build: the first job to build hands dist/ to the launcher under a key, and the launcher takes it into the cache when GitHub confirms that the slot runs a job of a trusted run (a push to main, or a pull request the writer login opened, at its head). It never checked that the key was that run's. The key is a hash the job computes itself; it is only the job's word for what it built.

So a trusted pull request's run (agents open PRs as the maintainer account, and CI runs before review) could hand in a build under the key of a new commit of main before main's own run builds it. Main's Integration and Browser jobs would then restore and test that dist/. Since #3567 a release can be validated by main's run, so that build could stand behind a release too.

What

An entry belongs to the run that wrote it.

  • The launcher's promoter (scripts/self-hosted-runner/build-cache-promote.sh) files an admitted build as entries/<run id>/<key>, under the run GitHub confirmed for the slot. The run's directory is made by the promoter, must be a real directory of its own user, and is never followed through a link.
  • A job (scripts/build-cache.ts) reads, waits and checks "stored" only under <cache>/<GITHUB_RUN_ID>/. With no usable run id it builds without the cache.
  • The lock carries the run too (.lock-<key>-<run id>): another run of the same commit reads other entries, so waiting for its build gains nothing. A waiting job waits for one job's build, not for a chain of them.
  • Eviction walks the runs' directories, keeps the most recently used entries of all runs within the limit, and removes a run's directory once it is empty.
  • What a launcher from before filed by the key alone (entries/<key>) is removed in the new launcher's first pass: a job of a commit from before would still read it there, whichever run had filed it.
  • A cache of one's own (no outbox) is unchanged.

Sharing between runs was never the purpose: the jobs of one run are. A rerun keeps its run id.

The launcher is an installed copy

build-cache.ts comes with the commit a run checks out; the promoter is the copy installed on each runner host, updated by hand. While the two differ, both directions end in "no hit, every job builds", measured with the real scripts of each side (4 jobs of one run, a 2 s build, 0.3 s per GitHub answer):

Jobs Launcher Seconds per job Builds
new new 3.3 / 3.3 / 3.3 / 3.2 1 the cache hits
new old 3.3 / 6.5 / 6.5 / 6.5 4 from this merge until the installed copy is updated
old new 3.4 / 6.6 / 9.8 / 12.7 4 reruns of runs from before, runs in flight at the update

No wait runs out, nothing fails, and nothing wrong is restored. Main's runs are safe from the merge on, whichever launcher is installed: a job of the new code never reads where the old launcher files.

After the merge the owner updates the installed launcher on every host whose launcher runs with --build-cache: copy scripts/self-hosted-runner/ over ~/.local/share/ovis-ci-runner by rename (rsync -a does; the promoter is started from that directory every second) and restart the unit, as the README says. Merge first, then update: the other order makes the jobs of every run in flight build one after another. Until then every job builds (about one build later than with no cache) and the job log says was not filed under this run but by its key alone; this PR's own CI run will show that line. I did not touch the installed copy or the running runners.

Proof

  • The attack is a test (scripts/build-cache.test.ts, "never restores, in main's run, a build that a pull request's run handed in under the key of main's commit"): run 200, a trusted pull request's, hands in a build under the key main's run 100 then looks for; main's job does not restore it and builds its own. Against main's two scripts that test fails: main's job restores the pull request's build without building (13 of the 48 tests fail there).
  • An independent review agent tried to break it: 16 spellings of main's run id in a claim from a pull request's slot (0100, +100, 0x64, 1e2, 100/../100, twenty digits, ...) against a stand-in GitHub that reads run ids leniently filed nothing under main's run; FIFOs, links and directories as claim, tar and marker wrote nothing outside entries/. Its verdict was ready, with three notes, all in this head: the removal of the old flat entries, the log line that blamed an old launcher (true only with one now), and "every runner host" in the docs.
  • 19 mutations, each caught: the reader looking by the key alone again; the promoter filing by the key alone; a run directory trusted through a link; eviction following a linked run directory or leaving empty ones; any string accepted as a run; the lock without the run; "already there" or "stored" tested by the key alone; the old flat entries left in place; and others.

Validation

  • bun run check fast: pass on this head (14784 unit tests pass, 0 fail).
  • bun test scripts/build-cache.test.ts scripts/self-hosted-runner.test.ts: 48 and 53 pass. bash -n on both shell scripts; shellcheck is not installed here.
  • Both transition directions run end to end with main's scripts against these.
  • Not run: real GitHub answers, Docker mounts, the installed launcher and live runners (not to be touched). The first CI run after the launcher is updated is that proof: its jobs log hit <key> after the first one's stored.
  • Skipped: integration and browser suites.

Not in this PR

🤖 Generated with Claude Code

…t it

On the self-hosted runner a job handed its client build to the launcher under a key, and the
launcher took it in when GitHub confirmed a trusted run on that slot. It never checked that the
key was that run's: the key is only the job's word for what it built. So a trusted pull request's
run could file a build under the key of a new commit of main before main's own run built it, and
main's Integration and Browser jobs would test that dist/. Since a release can be validated by
main's run, that build could stand behind a release too.

An entry now belongs to the run that wrote it. The launcher files an admitted build as
entries/<run id>/<key>, under the run GitHub confirmed, and a job reads only under its own
GITHUB_RUN_ID. The lock carries the run too, and a waiting job waits for one job's build, not for
a chain of them. A cache of one's own (no outbox) is unchanged.

The launcher on a runner host is an installed copy. While it and the repository differ, nothing
is restored and every job builds; no wait runs out. The new launcher removes what the earlier one
filed by the key alone in its first pass.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Build-cache entries are now isolated by CI run, preventing jobs from restoring builds created by a different run. Cache restores verify file integrity.
    • Jobs wait only for builds from their own run. Older runner installations may build locally until their launcher is updated and the service restarted.
  • Documentation
    • Updated release, development, and runner guidance to explain run-scoped caching, compatibility behavior, and runner update steps.

Runner build-cache entries, restores, and locks are now scoped to a GitHub run. The launcher promotes entries into run-specific directories and manages eviction across those directories. Tests and documentation cover run isolation and compatibility with older launcher layouts.

Changes: Run-scoped build cache

Layer / File(s) Summary
Select and restore run-scoped entries
scripts/build-cache.ts, scripts/build-cache.test.ts, scripts/self-hosted-runner/README.md, scripts/self-hosted-runner/run.sh
Runner builds select entries and locks using the run ID. If the run ID is missing or invalid, the runner bypasses the cache. Lock waits now detect when a different holder takes over. Tests cover run-specific restores and locks.
Promote and manage run-scoped entries
scripts/self-hosted-runner/build-cache-promote.sh, scripts/build-cache.test.ts, scripts/self-hosted-runner.test.ts
The launcher validates run IDs and stores entries beneath entries/<run>/<key>. Cache lookup, usage tracking, and eviction operate across run directories. Tests cover promotion, eviction, and symlink handling.
Verify run isolation and layout compatibility
scripts/build-cache.test.ts, scripts/release-ci-reuse.test.ts, docs/development.md, scripts/self-hosted-runner/README.md, scripts/self-hosted-runner/run.sh, changelog.d/build-cache-per-run.md
Tests cover cross-run isolation and legacy key-only entries. Documentation describes release-job reuse, launcher compatibility, and host update requirements.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Possibly related PRs

  • devswha/ovis#2825: Introduced the client-build cache that this change updates to use run-scoped entries.
Merge Risk: Minimal · previous review e16d1

The change scopes runner build-cache entries to the GitHub run that produced them, so a pull-request run cannot supply a build that a main run restores. Hosts need a manual launcher update, and until then jobs build without cache hits. No concrete merge-blocking defect was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly identifies the main change: build-cache entries are scoped to the run that produced them. The owner-approval note is extra, but does not obscure the change.
Description check Passed The description explains the problem and resulting behavior, and its Validation section lists checks, results, and skipped tests. The “Why” and “What” headings replace the template’s “Change” heading,…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Description check

Explanation

The description explains the problem and resulting behavior, and its Validation section lists checks, results, and skipped tests. The “Why” and “What” headings replace the template’s “Change” heading, but the required change information is present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 6 files. (3 skipped: 3 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
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 68f1fa9 and e16d168.

Files selected for processing: 9

  • changelog.d/build-cache-per-run.md
  • docs/development.md
  • scripts/build-cache.test.ts
  • scripts/build-cache.ts
  • scripts/release-ci-reuse.test.ts
  • scripts/self-hosted-runner.test.ts
  • scripts/self-hosted-runner/README.md
  • scripts/self-hosted-runner/build-cache-promote.sh
  • scripts/self-hosted-runner/run.sh

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

…ds its pass

A build's directories keep the modes its job gave them, so an entry can hold a directory without
the owner's write bit. Removing what an earlier launcher filed by the key alone, or evicting, then
failed, and under set -e that ended the pass before any slot's build was judged: on every pass,
since the entry stayed.

Entries are admitted with the owner's write bit on everything, an entry is given it before it is
removed, and a removal that still fails says so and goes on.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

One more commit, 550ac1a, for a fault I found in my own change after opening this.

The new loop that removes what an earlier launcher filed by the key alone ran rm -rf under set -e. A build's directories keep the modes its job gave them, so an entry can hold a directory without the owner's write bit; rm -rf then fails, and the pass ended there, before any slot's build was judged, on every pass, since the entry stayed. Eviction had the same exposure before this PR, at the end of a pass.

  • Entries are admitted with the owner's write bit on everything (chmod -R u+rwX,a+rX,go-w).
  • An entry is given that bit before it is removed, and a removal that still fails is logged and ends nothing (discard), for the old flat entries and for eviction alike.
  • New test: an old flat entry holding a directory at mode 555 is removed, and the slot's build after it is judged and filed. It fails on the commit before (the pass exits before the outbox loop).

bun run check fast passes on the new head (14785 unit tests, 0 fail); build-cache.test.ts 49 pass, self-hosted-runner.test.ts 53 pass.

@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate: FAIL

Local merge gate: FAIL #3585 merge=f414f6024746 head=550ac1a647f3 main=e0dee8be0935 on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 in 546s, reruns=1

The Linux suites of the required checks (Fast checks, Integration and browser), run on main e0dee8b with this PR's head 550ac1a merged in (local merge f414f6024746, not pushed), as groups side by side in the self-hosted CI runner image on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 (22% busy before the start, host load 40.73; shards=4 unit_workers=8 browser_main_workers=2 browser_other_workers=16). Scope: full. Native Windows install and the macOS checks are not part of this gate.

Step Command Result Seconds Counts
fast-install bun install --frozen-lockfile pass 0 -
release-guards bun scripts/release-guards.ts --base e0dee8be0935 pass 0 -
fast bun run check fast pass 193 tests 15177 pass / 0 fail; check steps 6 ok / 0 failed
integration-install bun install --frozen-lockfile pass 0 -
integration bun run check integration fail (exit 1) 219 tests 1388 pass / 1 fail; check steps 1 ok / 2 failed
integration-rerun bun run check run -- bun test --timeout 15000 <each failed file> fail (exit 1) 0 -
browser-main-install bun install --frozen-lockfile pass 0 -
browser-main-build bun run build pass 12 -
browser-main BROWSER_SCRIPTS=ui-regression,ui-contexts-regression bun run check run -- bun scripts/ci-browser-parallel.ts pass 349 browser scripts 2/2 passed
browser-other-install bun install --frozen-lockfile pass 0 -
browser-other-build bun run build && bun run build:shell pass 17 -
browser-other BROWSER_EXCLUDE=<those two> bun run check run -- bun scripts/ci-browser-parallel.ts pass 519 browser scripts 203/203 passed

Reruns:

  • integration not rerun: server/pending-input.contract.test.ts: not a timeout: error: expect(received).toBe(expected) "�[200~/model sonnet�[201~ - �[200after the switch�[201 - " + �[200after the switch�[201" - Exp

Total 546s.

@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate: FAIL

Local merge gate: FAIL #3585 merge=36b01ea78a3b head=550ac1a647f3 main=6821c55b7937 on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 in 574s, reruns=1

The Linux suites of the required checks (Fast checks, Integration and browser), run on main 6821c55 with this PR's head 550ac1a merged in (local merge 36b01ea78a3b, not pushed), as groups side by side in the self-hosted CI runner image on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 (20% busy before the start, host load 59.58; shards=4 unit_workers=8 browser_main_workers=2 browser_other_workers=16). Scope: full. Native Windows install and the macOS checks are not part of this gate.

Step Command Result Seconds Counts
fast-install bun install --frozen-lockfile pass 0 -
release-guards bun scripts/release-guards.ts --base 6821c55b7937 pass 0 -
fast bun run check fast pass 223 tests 15178 pass / 0 fail; check steps 6 ok / 0 failed
integration-install bun install --frozen-lockfile pass 0 -
integration bun run check integration fail (exit 1) 241 tests 1387 pass / 2 fail; check steps 1 ok / 2 failed
integration-rerun bun run check run -- bun test --timeout 15000 <each failed file> fail (exit 1) 0 -
browser-main-install bun install --frozen-lockfile pass 0 -
browser-main-build bun run build pass 15 -
browser-main BROWSER_SCRIPTS=ui-regression,ui-contexts-regression bun run check run -- bun scripts/ci-browser-parallel.ts pass 399 browser scripts 2/2 passed
browser-other-install bun install --frozen-lockfile pass 0 -
browser-other-build bun run build && bun run build:shell pass 21 -
browser-other BROWSER_EXCLUDE=<those two> bun run check run -- bun scripts/ci-browser-parallel.ts pass 540 browser scripts 203/203 passed

Reruns:

  • integration not rerun: server/opencode.contract.test.ts: not a timeout: error: expect(received).toBeLessThan(expected) Expected: < 2000 Received: 2047.0931299999975

Total 574s.

@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate: PASS

Local merge gate: PASS #3585 merge=c2cb8ad52d68 head=550ac1a647f3 main=6821c55b7937 on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 in 550s, reruns=0

The Linux suites of the required checks (Fast checks, Integration and browser), run on main 6821c55 with this PR's head 550ac1a merged in (local merge c2cb8ad52d68, not pushed), as groups side by side in the self-hosted CI runner image on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 (11% busy before the start, host load 45.36; shards=4 unit_workers=8 browser_main_workers=2 browser_other_workers=16). Scope: full. Native Windows install and the macOS checks are not part of this gate.

Step Command Result Seconds Counts
fast-install bun install --frozen-lockfile pass 0 -
release-guards bun scripts/release-guards.ts --base 6821c55b7937 pass 0 -
fast bun run check fast pass 182 tests 15178 pass / 0 fail; check steps 6 ok / 0 failed
integration-install bun install --frozen-lockfile pass 0 -
integration bun run check integration pass 204 tests 1389 pass / 0 fail; check steps 3 ok / 0 failed
browser-main-install bun install --frozen-lockfile pass 0 -
browser-main-build bun run build pass 10 -
browser-main BROWSER_SCRIPTS=ui-regression,ui-contexts-regression bun run check run -- bun scripts/ci-browser-parallel.ts pass 364 browser scripts 2/2 passed
browser-other-install bun install --frozen-lockfile pass 0 -
browser-other-build bun run build && bun run build:shell pass 14 -
browser-other BROWSER_EXCLUDE=<those two> bun run check run -- bun scripts/ci-browser-parallel.ts pass 526 browser scripts 203/203 passed

Total 550s.

@devswha
devswha merged commit d7332df into main Nov 10, 2026
27 of 33 checks passed
@devswha
devswha deleted the fix/build-cache-per-run branch November 10, 2026 19:13
@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 550ac1a647f3 as d7332df1b892 on the local merge gate, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

Both reviewers CLEAR (Claude Opus 5.5, Codex Terra), also on the added commit. A runner change merged on the merge pass's recommendation (owner, 2026-11-10). After this merge each runner host needs: rsync -a scripts/self-hosted-runner/ ~/.local/share/ovis-ci-runner/ (no restart: the promoter is re-read each pass; a restart would cancel jobs in flight). Until then no build is restored and every job builds. Follow-up by the CI session: tie a claim to the slot's container generation; rename an un-removable entry out of the key namespace and log once; discard() in admit's cleanup and the .new-* sweep; docs.

devswha added a commit that referenced this pull request Nov 10, 2026
…whose job handed it in (#3606)

## Why

Follow-up to #3585, from its reviews. #3585 files a build under the run
GitHub confirmed for the slot that handed it in. What was left is how
that run is confirmed.

**1. A claim was matched to the job the slot runs when GitHub answers,
not to the job that wrote it.** A slot runs one job per container, under
the same runner name every time. The promoter asked GitHub whether "the
slot" runs a job of the run a claim names:

- A trusted pull request's job writes `<main's key>.tar` and a claim
naming main's run Y, whose jobs are queued, and ends. If GitHub answers
only after the slot has started its next container and that one has
picked up a job of Y, the build is filed as `entries/Y/<key>` and Y's
other jobs restore it. With the per-run layout this was the one path
left from a pull request's run to the `dist/` main's Integration and
Browser jobs test, and so to a release validated by main's run.
- GitHub goes on listing the job of a container that was killed as
running, for minutes (about 13.5 after the 2026-11-09 reboot) and
sometimes for days (two jobs of 2026-11-05 are still listed on this
repository's slots 14 and 18). A job in the slot's next container could
name that run and be vouched for by the dead job.

**2. An old entry that could not be removed was walked and logged every
second.** The flat `entries/<key>` an earlier launcher filed is removed
at the start of every pass. One that stayed (a file of another user in
it, an immutable file) was `chmod -R`'d and logged once a second, about
86,400 lines a day, and stayed readable by jobs of commits from before
#3585.

**3. A refused build could leave a staging directory nothing removed.**
`admit`'s own cleanup and the sweep of old `.new-*` leftovers used a
bare `rm -rf`, which cannot empty a directory extracted without the
owner's write bit.

**4. The docs said "restart the unit"**, which stops every slot's
container and cancels the jobs in flight, and which a promoter change
does not need.

## What

- **The claim is its container's.** The promoter reads the slot's
container from docker (`docker container inspect -f '{{.Id}}' <slot>`)
before it takes a claim and again after GitHub has answered, and takes
the build in only when both are the same container. `run.sh` already
empties a slot's outbox before it starts the slot's next container, so
what is in the outbox while a container is the slot's, that container's
job wrote. A slot with no container is refused without asking GitHub.
- **The job started once that container had.** Docker also says when the
container started, and the promoter takes only a job whose `started_at`
is not earlier, to the second, with nothing allowed for the two clocks:
`run.sh` waits two seconds before a slot's next container, so a killed
container's job started at least that long before the next one, and any
allowance would let in a job that started just before the kill (the
second head of this PR allowed five seconds). A container's own job
starts ten seconds or more after it, once the runner has registered.
- **The job is on the runner registered under the name now.** A runner
that ended its job is gone from GitHub, and the next container registers
a new one (ids 24001, 24092, 24098, 24103 for one slot's four last
jobs), so a job of an earlier registration is on another id. This does
not tell a killed container's job apart, as the first head of this PR
claimed: a container that registers over a dead one's runner (`config.sh
--replace`) keeps the id (runner 22406 across the 2026-11-09 reboot).
The start time does. One more GitHub call per judged claim, about one
per CI run.
- A refusal because the container changed, or because no runner is
registered any more, is innocent, a job that ended while GitHub was
asked, and holds nothing off. A job that started before the container,
or on another runner, means the claim named a run that is not its own:
the slot is held off for ten minutes, as for any claim at fault.
- **Old flat entries are renamed first**, to `.new-gone-<random>`, a
name no job reads. The rename needs only `entries/` itself, whoever owns
what is inside, so an entry that cannot be removed is out of reach at
once and is not walked again each second; an eviction tries it again
once it is over an hour old. One that cannot even be renamed (`entries/`
not writable) is emptied where it is, so no job restores it, and logged
once a day while its empty directory stays.
- A slot whose container is not running (never started, or stopped) gets
nothing taken in.
- **The claim was written once that container had started.** All of the
above rests on the outbox being empty when a container starts. Were
`run.sh` unable to empty it, the earlier job's claim and build would be
read while the next container is the slot's. So the promoter refuses a
claim or a build last changed before the container started: the system's
own time of the last change (`stat %Z`), which a job cannot set back, to
the millisecond, read before the file is taken (taking it changes that
time). Removing another name of a file (a hard link) sets that time to
now, so the restore markers, which the promoter removes and which could
be such names, are now removed after the claims are judged, and a claim
or a build with a second name is not taken at all. And `run.sh` starts a
runner whose outbox still holds a file without the build cache (its job
builds).
- **`discard()`** (owner's write bit first, then remove, a failure
logged and ending no pass) in `admit`'s cleanup and in the sweep.
- **README and changelog:** a change to `build-cache-promote.sh` needs
only the copy (`rsync -a`): the launcher starts the promoter from the
installed directory every second. A change to `run.sh` takes a restart,
which cancels the jobs in flight, so it waits for idle slots.

**The copy alone applies what closes the paths.** Everything the
promoter does is in force from its next pass. `run.sh` changes in one
place, the runner that starts without the cache when its outbox could
not be emptied: that takes effect at the launcher's next restart, and
until then the promoter's refusal of anything older than the container
covers the same case.

## Why runner slots starting before the old flat entries are removed
open no new window

Codex's finding on #3585 (e16d168): after an update the first promoter
pass removes the old `entries/<key>`, and a slot's job could start
before that pass.

- Only a job of a commit from before #3585 reads `entries/<key>`, and
such a job read it, whichever run had filed it, on every day before the
update. The moment between the copy and the next pass (at most a second)
is the last of that exposure, not a new one.
- With a restart, the promoter is started before the slots, and its
first act, before any GitHub call, is this removal; a slot needs a
registration token, a container, a runner registration and a job's
checkout and install before anything reads the cache.
- A job of a commit that has #3585 never reads there: it takes only
`^[0-9]{1,20}$` as its run's directory.

## Proof

`scripts/self-hosted-runner.test.ts` and `scripts/build-cache.test.ts`
run the promoter against stand-ins for `gh` and `docker`. New cases:

| Case | Result |
|---|---|
| the slot has another container by the time GitHub has answered about
the jobs | refused, logged; the next container's own claim is taken in
(slot not held off) |
| the slot has no container, one that never started, or one that has
stopped | refused, GitHub not asked |
| the job GitHub lists started 13.5 minutes before the slot's container,
on the same runner id (a killed container's job, the runner taken over)
| refused; the slot is held off (the next claim costs no call) |
| the job started 2 s or 1 s before the container / in the container's
own second | refused / taken in |
| the job GitHub lists is on another runner than the one registered
under the name now | refused; the slot is held off |
| a build left in the outbox before the slot's container started |
refused, GitHub not asked; the container's own build after it is taken
in |
| the claim alone, or the build alone, last changed 1 ms before the
container started | refused |
| a leftover claim and build with second names that are restore markers,
the container started 20 ms after they were written | refused, GitHub
not asked (before: the markers' removal made both look new) |
| the claim alone, or the build alone, has a second name | not taken,
GitHub not asked |
| `run.sh`: an outbox it cannot empty still holds a claim | that runner
starts with no build cache mount or variable, and says so |
| no runner is registered under the name any more | refused; the slot is
not held off |
| a refused build with a `0555` directory and a file nobody may read |
nothing left in `entries/` |
| an old flat entry that cannot be removed | renamed out of the key's
name; one log line in three passes |
| an old flat entry in an `entries/` that cannot be written | emptied;
one log line in three passes, every pass exits 0 |
| an old `.new-*` leftover with a `0555` directory | gone at the next
eviction |

Twenty-four single-line mutations, twenty-three of the promoter and one
of `run.sh` (the second container read dropped; the empty-container
refusal dropped; the runner id not compared; a gone runner counted as a
claim at fault; `rm -rf` back in `admit`'s cleanup; in the sweep; the
rename dropped; the once-a-day mark dropped; the start time not
compared; the container's start not passed on; a stopped container
accepted; a one-second allowance; the older-than-the-container refusal
dropped; the claim's time not read; the build's time not read; the
container's start cut to the second; the markers removed before the
claims again; the second-name refusal dropped, for the claim alone, for
the build alone; the entry not emptied; its log not held to once; the
quiet removal logging; `run.sh` going on with the cache): each fails at
least one of these tests, and no other test.

## Validation

- `bun run check fast`: pass on this head (15258 unit tests pass, 0
fail).
- `bun test ./scripts/self-hosted-runner.test.ts
./scripts/build-cache.test.ts`: 59 and 52 pass.
- **Not run:** the launcher itself, or the promoter against real GitHub
and a real docker. No launcher may be started from a session, and the
installed one and its runners were not touched. Read only: the runner
ids of this repository's last jobs; that `GET
/repos/{owner}/{repo}/actions/runners?name=<slot>` returns the one
runner of that name; and `docker container inspect` of this PC's running
slots beside the jobs GitHub lists on them: five live jobs started 10 s
to 21 min after their containers (a slot waits for a job), and the two
jobs of 2026-11-05 still listed on slots 14 and 18 started five days
before theirs.
- **Not shown:** that GitHub hands a new job to a runner registered over
a dead one while the dead job is still listed. If it does not, the
killed-container case cannot arise; the start time refuses it either
way.
- Skipped: the integration and browser suites (no product code).

## For the owner

After the merge, on each runner host: `rsync -a
scripts/self-hosted-runner/ ~/.local/share/ovis-ci-runner/`. No restart.
Until then the hosts run #3585's promoter, which is safe as it is.

## Not in this PR

- `run.sh` does not wait until the outbox can be emptied, as the review
thread suggested: a slot that never starts takes a runner away for good,
where one without the cache only builds. It does not record a slot's
container for the promoter either; docker is asked instead, so no
restart is needed. Should docker not answer within 10 s, the build is
refused and the run's jobs build themselves.
- A host whose clock runs more than about ten seconds ahead of GitHub's
(the least a job starts after its container) has its builds refused (the
job then looks older than its container) and its slots held off: its
jobs build without the cache, and the promoter's log says why.
- A build is refused when its job ended before the promoter got to it
(the job waits up to 60 s for its verdict, so this takes a GitHub that
slow, or a cancelled job): its run's other jobs build.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>
devswha added a commit that referenced this pull request Nov 10, 2026
…s stay usable when the pane draws again (#3618)

## Why

On a device that only watches, the rows of the composer's background
tasks list stop answering as soon as the pane draws again with the list
open: a running task's detail and the fold of ended tasks cannot be
opened any more, nor a row of an OMP pane's side conversations list. In
v0.5.2.

`PaneTerminal` had a layout effect with no dependency list that, on
every draw of a watching pane, set `disabled = true` on every button in
the composer's control rows except the chips, and never set it back. The
lists' rows are such buttons and carry no `disabled` prop, so React
never enables them again. The effect is a leftover of #3431: its branch
locked the watching composer twice within six minutes, once with this
effect and once in the composer's own render (`viewOnly = role ===
"observe"`), and the squash kept both.

This is also the browser lane's
`background-agent-states-{desktop,phone,korean}-demo-regression` failure
(`background-agent-detail-demo-run.ts:201`, `click: Timeout 20000ms`,
`<button disabled … class="bg-task-open">`): 12 jobs on 11 branches on
2026-11-09 and 2026-11-10, #3578, #3583 and
#3585 among them, all on the System-Product-Name runners. In the
script's watching state the
demo sends the pane's first terminal output 60 ms of wall clock after
the attach. A machine that gets to the list before that output has the
rows disabled by the draw the output causes. #3562 split the script and
moved that state to a quieter, faster minute of the lane, which took the
rate from 6 of 38 script attempts to 23 of 59 on those runners.

## What

- `src/components/PaneTerminal.tsx`: the effect is gone. The composer's
own render already locks what writes (the message box, attach, the
microphone, the quick replies, Send, Stop; Paste and send is not drawn)
from the `role` it is given. Nothing outside React writes `disabled`
now, so nothing can stay locked after view-only ends.
- `scripts/background-agent-detail-demo-run.ts`: both watching states
assert which composer controls are disabled once the pane has read the
role. A new state, `observe-late`, lets the pane learn the role while
the list is open (the page patch holds the pane's read until the script
releases it): the draw that makes the pane view-only then runs with the
rows mounted.
- `src/components/ComposerCrossTab.test.tsx`: the watch-only composer
locks the message box, attach and Stop, keeps the chip, and unlocks them
when the role takes input again.
- `DESIGN.md`: a watching device keeps the chip, the fold and the rows.
No new design: this restores #1842's read-only list and sheet for
watching devices, which #3431's leftover effect had taken away, so there
is no other app's design to compare with.
- `changelog.d/watching-background-task-rows.md`.

## Proof

CI runner image, one worker, no second run of a failed script
(`RETRY=0`).

| What | origin/main | With this PR |
|---|---|---|
| The pane's first output held until the list is up (scratch patch),
three states scripts | 0 of 3: the lane's exact error | 3 of 3 |
| Only the demo's first screen 40 ms later, script untouched, three
states scripts | 4 of 6: two fail with the lane's error at its lines | 9
of 9 |
| The same shift, loops of the watching state | 71 of 75 dead (0 of 75
on the parent of #3431) | not run as loops |
| The new `observe-late` state, three states scripts | 0 of 3:
`.bg-task-open` and `.bg-ended-toggle` disabled | 9 of 9 (the runs
below), and 9 of 9 under the shift above |
| The four background-agent entries, three times | not needed: green on
this PC before too | 12 of 12 |

The locks of a watching composer with the list open, before and after
the pane draws again, are the same with this PR (message box, attach,
microphone, Send disabled; chip, rows, fold usable); on `origin/main`
the rows and the fold turn disabled at that draw.

## Validation

Ran, on the PR's diff:

- `bun run typecheck`
- `bun test src/conventions.test.ts scripts/conventions.test.ts
server/conventions.test.ts scripts/changelog-fold.test.ts`
- `bun test src/components/ComposerCrossTab.test.tsx
src/components/ComposerPasteSend.test.tsx
src/components/ComposerRestored.test.tsx src/components/OmpBtw.test.tsx`
- In the CI runner image, `BROWSER_WORKERS=1 BROWSER_RETRY=0 bun run
check run -- bun scripts/ci-browser-parallel.ts` with
`BROWSER_SCRIPTS=`:
-
`scripts/background-agent-detail-demo-regression.ts,scripts/background-agent-states-desktop-demo-regression.ts,scripts/background-agent-states-phone-demo-regression.ts,scripts/background-agent-states-korean-demo-regression.ts`,
three times: 12 of 12
-
`scripts/terminal-keyboard-demo-regression.ts,scripts/terminal-paste-insert-demo-regression.ts,scripts/terminal-paste-insert-variants-demo-regression.ts,scripts/composer-send-demo-regression.ts,scripts/composer-fit-demo-regression.ts,scripts/composer-draft-demo-regression.ts,scripts/terminal-autoswitch-demo-regression.ts,scripts/plan-chip-demo-regression.ts,scripts/held-rows-demo-regression.ts,scripts/sidebar-activity-demo-regression.ts,scripts/narrow-pane-demo-regression.ts,scripts/device-security-demo-regression.ts,scripts/ui-contexts-regression.ts,scripts/ui-contexts-layout-regression.ts,scripts/artifacts-browser-regression.ts`,
once: 15 of 15
  - `scripts/ui-regression.ts`, once: 1 of 1

`bun run check fast`: pass on this head (15464 unit tests pass, 0 fail),
which is that diff rebased onto `origin/main` `636920ecf`. On this head,
in the CI runner image: the four background-agent entries, 4 of 4. The
other browser runs above were made on `00284cd48` and `9cc353031` with
the diff as a patch, and were not repeated on it.

An independent review agent went through the diff, the CI numbers and
every log before this PR was opened, and rebuilt the forcing on a later
`origin/main` (`06836a7e6`): the script change alone 0 of 3
(`observe-late`: rows and fold disabled); the whole diff 8 of 8; main
with the pane's first output held until the list is up 0 of 2 with the
lane's exact error; the whole diff under the same hold 3 of 3. Its
verdict was clear. Of its three notes, the fragment now names the side
conversations list, the design line is above, and the third is under
"Not in this PR".

Skipped: the rest of the browser lane, the integration suite, Windows
and macOS jobs, `scripts/design-gate-qa.ts`, Firefox, WebKit, a real
watching device against a real server (the demo transport only), and the
System-Product-Name runners themselves.

## Not in this PR

- `PaneTerminal` reads the device's role with a health read of its own,
although the app already knows it. Each pane learns it late and never
unlearns it (`authWatching` is only set to true).
- The rows of an OMP pane's Side conversations list were locked by the
same effect and are free now (measured by the reviewer on `main` and
with the fix); no browser script covers that chip.
- The unit test added here passes on `main` too: it pins the composer's
own lock, the only one left, for the message box, attach, Stop and the
chip. Send with text in the box, the microphone and the absent Paste and
send have no role check of their own yet.
- A file dropped on a watching composer still reaches the client's
upload path (the server refuses the write); the removed effect did not
cover that either.
- `scripts/ci-browser-timings.json`: the three states scripts walk one
more state (about 5 s).
- The System-Product-Name runners were not used for the proof: the
lane's failure is reproduced on the other runner machine by forcing the
order.



This changes what a device that only watches can press, so it wants a
real review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.2 <[email protected]>
devswha added a commit that referenced this pull request Nov 11, 2026
…ring the blocked state up as the settling gap ends (#3623)

## Why

Three tests of `server/pending-input.contract.test.ts` fail on a busy
runner while the product is right.

- "confirms a receipt queued behind a Pi command …" failed four times
since 2026-11-05 (three CI runs and the local merge gate of #3585), and
"checks active Pi receipt capacity per connection before typing" four
times since 2026-11-01. Both read the pane recorder's log right after a
receipt frame. The bridge sends that frame after herdr answered the
Enter, but the recorder is another process: on a loaded host it had not
logged the Enter yet.
- "checks a new blocked state after the … settling gap, before pasting"
failed seven times since 2026-10-21 (both variants; last in run
42891660450 of #3610). The test reported the blocked state after it saw
the `sending` frame. The gap is 300 ms from the ESC, not from the claim,
so on a loaded host it was over first: the bridge pasted, saw the
blocked state before Enter, and answered `submit_changed`.

## What

- The first two tests wait for the Enter in the pane's log (`waitBytes`)
before they read it.
- In the third, the blocked state comes up as the gap ends. The test
tells herdr at the first status read that starts after the bridge
claimed the message (a spy on `PendingInputs.prototype.claim`) and no
sooner than the gap after the ESC, and that read waits for herdr's
answer (a spy on `herdrClient.sessionSnapshot`). Every earlier read says
the agent works. No timer is raced any more.
- The third test still fails on a bridge that checks before the gap,
that waits out no gap, or whose Stop starts none (the state of #1106's
head). It can only tell such a bridge while its first status read comes
sooner than 299 ms after the ESC: at +8 ms and about +105 ms on an idle
runner. Load can make it pass, never fail.
- Test only. No assertion dropped or weakened. No timeout, sleep or
retry added.

## Proof

In the CI runner image, one container, 8 CPUs, on `f372ef12b`:

- origin/main with the recorder logging a lone Enter 300 ms late and
Send now's own check 350 ms slower: the first test and both variants of
the third fail with CI's exact errors (2 of 2 runs). With this change:
they pass (2 of 2).
- origin/main with the Enter of "other owner" logged 300 ms late and the
test's last read made 400 ms later: the second test fails with CI's
exact error (2 of 2). With this change: it passes (2 of 2).
- This change on three wrong bridges: the check made before the gap
(both variants fail, `submit_changed`), no gap (both fail, the message
is sent), the Stop starting no gap (the Stop variant fails).
- The four changed tests with this change: 4 pass, twenty times. The
whole file: 123 pass, 0 fail, three times.

## Validation

- Ran: `bun run typecheck`; `bun test ./scripts/conventions.test.ts
./server/catalog.conventions.test.ts ./server/conventions.test.ts
./src/conventions.test.ts` (63 pass).
- Ran in the CI runner image: `bun run check run -- env
HERDR_TEST_MODE=integration bun test --timeout 15000
./server/pending-input.contract.test.ts` three times, and the same with
`-t` filters for the changed tests, plain (twenty times) and under the
forcings and mutations above.
- `bun run check fast`: pass on this head (15742 unit tests pass, 0
fail), which is that diff rebased onto `origin/main` `ce11b34af`.
- Checked again on the final diff, in the CI runner image: the whole
file twice (123 pass, 0 fail each), and the two settling-gap tests on a
bridge with no gap (both fail, twice).
- An independent review agent found the first version of the third
test's change too weak (it passed on a bridge with no gap); it was
redone as described above, and the review's other two notes are in this
head (the second log read, and one of the eight CI hits first counted
was a real failure of #1106's head, not the race).
- Skipped: `bun run check full`, the rest of the integration suite, the
browser scripts (no UI change), macOS and Windows. No changelog
fragment: nothing a user notices.

## Not in this PR

- Ten cases of the file do a test step inside a `submitDelayMs` window
of 500 to 3000 ms. Same kind of race as the third test, wider margin, no
CI hit.
- Other flakes of the file seen in the CI history (the launcher cases of
"a create request's first message", "delivers queued /model as …").

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.2 <[email protected]>
devswha added a commit that referenced this pull request Nov 11, 2026
…prove a FIFO unread by who gets its text (#3630)

## Why

Two tests fail on a busy machine with their code untouched.

- `server/pty/host.test.ts`, "PtySession on the node PTY host > ends a
plain exit without waiting out the hold for a closed terminal": 151.99
and 213.5 ms against 150 in two local merge gates (#3585, #3354), 233.6
and 166.7 ms in two Integration jobs on GitHub (run 42827626297 attempt
1 of #3542, run 42831916527 attempt 1).
- `server/opencode.contract.test.ts`, "answers the catalog and a cold @
send within budget while opencode.json is a FIFO": 2047 ms against 2000
in the local gate of #3585.

Each measured mostly something else than what it guards.

- The PTY test's 150 ms ran from before the host's spawn. The Node
host's start is 37 of the 55 ms an idle run takes; the behaviour, an
exited command not being held for the host's 200 ms wait, is the last
17.
- The FIFO test's 2 s is the 1.5 s attach budget plus delivery. The
server never opens the FIFO, so none of it is the FIFO. On one CPU the
test fails every time (2009, 2023 ms).

## What

- PTY: the command leaves a file as it exits (`: > "$1"; exit 7`), and
the 150 ms run from that file's own time (its mtime, the system's word
for when the command wrote it) to the reported exit. What the test
process does late only makes the span longer, so a host that holds the
exit cannot pass on a busy machine. (The first head of this PR started
the clock when the test saw the file; the review showed that could hide
a hold.) Same number, same exit code. From there the exit is 18 to 23 ms
away on the Node host (the Rust host's whole test takes 4 to 5 ms); a
waited hold adds 200 ms. The marker is a file and not output because the
Node host ends a pty whose last byte comes with the hangup another way
(see "Not in this PR").
- FIFO: a writer waits at the FIFO from the start, and the test goes on
only once the writer has said it is about to open the FIFO and sleeps in
that open, so no read can come before it waits. Its open returns only
when something opens the FIFO to read, and that reader gets its text. At
the end the test opens the FIFO itself, without waiting, and must get
the text. No time is counted, and a server that reads the FIFO is not
held by it, so a regression fails in about 4 s instead of 7. The test is
renamed "answers the catalog and a cold @ send without opening an
opencode.json that is a FIFO".
- No product code changes.

Two things change in what the FIFO test catches:

- It now also fails when the server opens the FIFO without waiting on it
(`O_NONBLOCK`, refused by its descriptor). The old test passed there.
`openRegular` checks the path before any open, and the test now holds it
to that.
- It no longer bounds the catalog at 4 s or the first key at 2 s. A cold
send slowed past 2 s by something other than the FIFO failed before and
passes now. The attach budget has its own test, checked at its boundary
(#1741).

## Proof

In the CI runner image, one container at a time, commit ce11b34 plus
patch files.

| Product | Old tests | New tests |
|---|---|---|
| as is, 8 CPUs, whole files ×3 | pass | pass (41 pass / 26 pass, 0
fail) |
| as is, with a Rust host built from main, `host.test.ts` ×3 | pass |
pass on both hosts (64 pass, 0 fail) |
| Node host waits out the hold for an exited command | fail ×3 (322 to
371 ms) | fail ×3 (206 to 207 ms) |
| Rust host waits out the hold for an exited command | fail ×3 (404 ms)
| fail ×3 (200.4 ms) |
| the scan reads `opencode.json` with a plain open | fail ×3 (catalog
5.0 to 5.2 s) | fail ×3 (the text is gone) |
| the cold send reads `opencode.json` with a plain open | fail ×3 (first
key 6.2 to 6.4 s) | fail ×3 (the text is gone) |
| forced: the host starts 120 ms later, delivery is 600 ms slower | fail
×3 both (198 to 208 ms; 2115 to 2217 ms) | pass ×3 both |
| forced: one CPU, whole files ×2 | PTY pass, FIFO fail ×2 (2009, 2023
ms) | pass ×2 both |
| the server opens the FIFO without waiting and refuses it | pass ×2 |
fail ×2 (by design) |

## Validation

Ran:

- In the CI runner image (`herdr-ci-runner:local`), three times each, on
8 CPUs: `bun run check run -- env HERDR_TEST_MODE=integration bun test
--timeout 15000 ./server/pty/host.test.ts` (41 pass, 29 skip, 0 fail)
and `bun run check run -- env HERDR_TEST_MODE=integration bun test
--timeout 15000 ./server/opencode.contract.test.ts` (26 pass, 0 fail).
The same two commands twice on one CPU: pass.
- The first command three more times with `crates/pty-sidecar` built
from main (Rust 1.85, musl) in place: 64 pass, 4 skip, 0 fail.
- The mutation and forcing runs of the table above, each test alone
(`-t`).
- On the host: `bun run typecheck`; `bun test --timeout 15000
./scripts/conventions.test.ts ./server/conventions.test.ts
./server/catalog.conventions.test.ts ./src/conventions.test.ts` (63
pass).

- `bun run check fast`: pass on this head (15742 unit tests pass, 0
fail).
- On this head, in the CI runner image: both files three times (67 pass,
0 fail each), and the two changed tests with the Node host made to wait
out the hold and the scan made to read `opencode.json`: both fail, twice
(211.7 and 212.2 ms against 150; the text handed is `""`).
- Checked again on the final diff by the session that opens this PR, in
the CI runner image: both files twice (67 pass, 0 fail each), and the
two changed tests with the Node host made to wait out the hold and the
scan made to read `opencode.json` (both fail, twice: 208.4 and 206.9 ms;
the text handed is `""`). The independent review agent meant for this
change ended on the account's rate limit before it reported, so this
check and a reading of the diff stand in for it.

Skipped:

- `bun run check full`, the rest of the integration suite, the browser
lanes (no UI change).
- Native Windows and macOS: neither file is in those jobs.
- GitHub's "Rust PTY host" job, which runs `host.test.ts` on its own
build: it runs on the PR.

No changelog fragment: tests only, nothing a user notices, as in #3617,
#3604 and #3605.

## Not in this PR

- The Node PTY host holds a command 200 ms, or kills it, when its last
output is read together with the hangup: `printf X; exit 7` is reported
after 242 ms where `exit 7` takes 51 and the Rust host 2, and `printf X;
exec 0<&- 1>&- 2>&-; sleep 0.05; exit 3` is reported as 137 where the
Rust host says 3. The host takes the socket's end of stream for
node-pty's destroy after an exit. It needs its own fix and parity tests.
- The other tests that assert elapsed time under a fixed number. The
tightest are `server/prompt.test.ts:6651` (`< 1_790` over a 1.5 s wait),
the first-key gaps in `server/opencode.contract.test.ts:1102` (`<
1_000`, seen up to 774 ms) and `server/prompt.contract.test.ts:564` (`<
600`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>
hallelshohat added a commit to hallelshohat/ovis that referenced this pull request Nov 15, 2026
* fix(ipad): hardware-keyboard flash, landscape shell fit, field sizes and window controls on an iPad (supersedes #3338-#3341) (#3583)

Supersedes #3338, #3339, #3340 and #3341, four iPad fixes by @Noobear
that all change `src/lib/viewport.ts` and
`scripts/keyboard-viewport-regression.ts` and conflict pairwise. This
branch carries their commits unchanged (same author), in the order
#3341, #3340, #3339, #3338, resolves the conflicts, and fixes what
review found on each. The four PRs name no issue to close; this one
closes #3483, which #3339 and #3561 together fix.

Thank you, @Noobear: the four fixes, their regression cases and the
measurements from your own iPad are all here, and nothing more is needed
from you.

Closes #3483

## What changes for a user

- **Hardware keyboard on an iPad home-screen app (#3341):** a visual
viewport that shrinks for one frame on each key is no longer taken for
an on-screen keyboard, so the page does not flash.
- **iPad home-screen app in landscape (#3340):** the shell fits the area
under the status bar, so a tap into a field no longer slides the screen
up and back.
- **Fields (#3339):** text fields and selects follow the interface font
size like the labels beside them. On an iPhone or iPad a field that is
pressed or takes the focus is at least 16px while it has the focus, so
Safari does not zoom the page into it. Find in diff does the same on an
iPad (#3483).
- **Windowed iPad home-screen app, iPadOS 26 and later (#3338):** the
header's first button stays clear of the window's close, minimize and
full-screen controls.

## Commits

Author's commits, cherry-picked in order (the only conflict resolution:
one `PASS` line holding every suffix, and one `const ios` instead of
two):

| From | Commit |
|---|---|
| #3341 | fix(mobile): apply a shrinking visual viewport only once it
lasted a moment |
| #3340 | fix(mobile): fit an iPad home-screen app's landscape shell to
the visual viewport |
| #3339 | fix(settings): fields follow the interface font size; iOS arms
a pressed field to 16px |
| #3339 | fix(settings): arm a field from its label's press; disarm on a
cancelled press |
| #3339 | fix(settings): an armed field keeps an interface size over
16px instead of shrinking to it (maintainer, already on the PR) |
| #3339 | fix(settings): arm a field a handler focuses, not only a
pressed one (maintainer, already on the PR) |
| #3338 | fix(ipad): keep the header's first button clear of a windowed
app's controls (iPadOS 26) |

Then seven commits of this PR: the four fixes below (each
`Co-authored-by` the author, whose code they rework), the #3483
regression case, the changelog credit, and one for the review of this PR
itself (second table below).

## Findings and how each was resolved

Each MEDIUM was reproduced first as a failing case in
`scripts/keyboard-viewport-regression.ts` on the unfixed code, then
fixed; the case stays as the regression.

| # | Finding | Reproduced | Resolution |
|---|---|---|---|
| 1 | **#3341 MEDIUM** Every viewport event restarted the 40 ms wait, so
a keyboard opening under a stream of events was applied only 40 ms after
the last one. | Yes: twelve frames with an event each, `a keyboard
opening under a stream of viewport events counts while it opens` failed
(`data-keyboard` still off at 192 ms). | The first shrinking event
starts the wait; later ones leave it running. |
| 2 | **#3340 × #3341** timing contradiction: "shrinking" meant shorter
than `100lvh`, which is the steady state of an iPad home-screen app
under its status bar (and of a Safari tab with its toolbars), so every
sync waited there and #3340's own check read no height after the load. |
Yes: with both PRs in, `iPad landscape: the shell fits the visual
viewport` failed (`published: ''`, 820 instead of 796). | Shrinking is
measured against the state applied last, so a steady state and the first
sync of a page never wait. (The first version of this fix also said
Chrome shrinks all three viewports together; that was wrong, see finding
12.) |
| 3 | The one-frame check raced a real clock: an installed Playwright
clock keeps running, so a slow runner could let the 40 ms run out
between two steps. | Yes (probe: a 40 ms timer fired by itself after
`clock.install()`). | The scenario pauses the page clock; only `runFor`
moves it. |
| 4 | **#3340 MEDIUM** The iPad test read the layout (744px on its short
side); an enlarged page zoom (125% lays an 820-point side out at 656px)
or a narrow window turned the fit off. | Yes: `iPad landscape at 125%
page zoom: the shell fits the visual viewport` failed (656 instead of
637). | The screen's own short side is read. The cases now use the
layout a page zoom really produces (85%: 1388×965; 125%: 944×656) and
add a 600px window. |
| 5 | **#3339 LOW** An iOS press could leave the agent picker (a button
drawn as a select) at 16px for good; so could a field whose press ended
without the focus, and a disabled field pressed through its label. |
Yes: `a pressed picker button keeps the interface size` failed, and with
that one skipped `a picker button keeps the interface size after its
press` (16px instead of 14px). | Only a text field, a textarea or a
native select that can take the focus is armed. A press that ends in a
click without the focus is disarmed once the click's default is done; a
press that never ends in a click is cleared by the next press. |
| 6 | **#3338 MEDIUM** Every home-screen app narrower than its screen
got the 68px room, also iPadOS 16-18 Split View, Slide Over and Stage
Manager, which draw nothing in that corner. | Yes: `Split View on iPadOS
18: the window's controls are not there` failed. | A probe for iPadOS 26
and later: `CSS.supports("anchor-name: --a")` (CSS anchor positioning
arrived with Safari 26; a home-screen app's user agent on an iPad names
no system version). Where the controls are not drawn, nothing is marked,
measured or listened for. |
| 7 | **#3338 LOW** The one-point margin was smaller than what page zoom
rounds away (iPad mini at 300%: 377px × 3 = 1131 of 1133; at 115% in
portrait: 742.9 of 744). | Yes, with the whole-number widths of the
review: `full screen at 300% page zoom: the window's controls are not
there` failed. Whether WebKit reports whole numbers there was not
checked on a device. | The margin is the scale plus one point. |
| 8 | **#3338 LOW** No test of the default wide layout, where the room
goes on `.header-side`, nor of a window going full screen. | n/a
(coverage) | The cases build the app's zoned header with the sidebar's
top row: from 769px the room is on that row and the header adds none,
with the sidebar collapsed or under 769px it is on the header, never
both; a resize to full screen clears the mark and back sets it. |
| 9 | **#3338 LOW** No reference design named. | n/a | See "Reference
design". |
| 10 | Maintainer note on #3338: the mark only follows `resize`. | Not a
defect: every way in or out of a window changes its width. | Left as is,
said in a comment. An `orientationchange` listener would read the new
orientation against the old width for a moment. |
| 11 | Known limit from #3338, unchanged: a window as wide as the screen
but shorter is not detected. | n/a | Not in this PR. |

### Second round: the review of this PR (head `3cb28a6ed`)

Both reviewers and CodeRabbit found the shrink wait reaching further
than the bug it is for. Each row was reproduced first as a failing check
of `scripts/keyboard-viewport-regression.ts` on `3cb28a6ed`, with the
script reading each state in the event that set it.

| # | Finding | Reproduced | Resolution |
|---|---|---|---|
| 12 | **MEDIUM** The 40 ms wait had no platform gate and also held a
shrink while a keyboard was up: an iPhone's and Android's keyboard were
counted 40 ms late, a keyboard that grew kept a stale taller shell, and
so did a rotation. The comment and this body claimed Chrome shrinks all
three viewports together; `src/lib/viewport.test.ts` records 477 / 477 /
lvh 533. | Yes: the phone's keyboard (472px), a keyboard that grows
(400px), Chrome's measured numbers (477, 477, 533), a rotation with the
keyboard up, split view, the virtual keyboard and both home-screen phone
scenarios all failed `keyboard flag follows occlusion, not focus alone`
when read in their event. | The wait is for the reported case only: an
iPad (the platform an iPad reports and an iPad's screen, at least 744
points on its short side), no keyboard counted yet, and a visual
viewport shorter than the one applied last. Everything else is applied
in its event, in `main`'s order. |
| 13 | **LOW** The regression ran the clock 50 ms before every read and
its resizes-content case set lvh equal to the visual viewport, so no
case could see a delay. | Yes: with the read moved into the event, the
existing keyboard-up checks of every phone scenario failed on
`3cb28a6ed`. | The clock is paused and a state is read in its event;
only a case that must wait runs the clock. The one-frame and stream
cases moved to an iPad home-screen scenario; the phone gained a keyboard
that grows and `geometry(page, 477, 477, 533)`. |
| 14 | **MEDIUM** (Codex) A field that lost the focus while the shrink
waited was gone when the wait ended, so the keyboard was not counted and
covered the shell. | Yes: on the iPad scenario, blur during the wait:
`keyboard flag follows occlusion, not focus alone` failed after the
wait. | The focus a dip began with is kept until its wait ends. |
| 15 | **Minor** (CodeRabbit) An iPad window made smaller kept its old
shell height for 40 ms. | Yes: a smaller window (676 under 700) and a
rotation back to landscape both failed `height override follows keyboard
or measured standalone inset` in their event. | A dip leaves the window
as it was: the wait needs the same width and the same large viewport, so
a resized window and a rotation are applied in their event. |
| 16 | **LOW** A field disabled while it had the focus kept `data-armed`
(16px at rest) after the focus left. | Yes: `the blur of a field
disabled while focused disarms it` and `the next press disarms a field
that lost the focus without a blur` failed. | The blur disarms whatever
it leaves, and a press or a focus elsewhere clears anything left armed
without the focus. |
| 17 | **LOW** A pressed Settings select widened before the tap ended,
which can wrap its row's label and move the select from under the
finger. | Yes for the cause: `.select: a press leaves the size` failed
(16px at `pointerdown`), and an armed select is wider than at rest
(asserted). The tap missing on a device was not reproduced. | A native
select is armed only as it takes the focus; a text field, whose box does
not follow its text, is still armed by the press. |

### #3339's three review threads

All three are settled on this branch (they were raised on the PR's first
commit and answered by the author's second):

- *Changelog wording*: the fragment says the field "grows to at least
16px and keeps it while it has the focus".
- *Arm the field when its label is pressed*: done in the author's second
commit, with a regression case (`16px from a press on its label`).
- *Clear the armed state after an unsuccessful press*: a cancelled press
was handled in the author's second commit; finding 5 adds the press that
ends without the focus and the one that never ends in a click, each with
a case.

## #3483: Find in diff on an iPad

`scripts/diff-find-demo-regression.ts` gains the case #3561 left for
after #3339: on the demo, with the platform and touch points iPadOS
reports, at 1180 and at 820, the query a tap on Find focuses and the
query a tap focuses read 16px, 14px again once the focus leaves; a 20px
interface keeps 20px.

## Reference design

- **Window controls (#3338):** the answer of desktop apps that draw
their own title bar, the Claude and Codex desktop apps and Zed on macOS
among them: the top bar's first control starts to the right of the
window's controls, the bar keeps its height and nothing else moves. Ovis
already does this for Chrome's `window-controls-overlay` mode from
`titlebar-area-x`; iPadOS reports no such value, so the room is a
measured constant (68pt) converted through the page zoom.
- **Fields (#3339):** a field's text at the size of the labels around
it, as those apps draw their settings. The 16px while focused differs
from them on purpose: Safari zooms a web page into a field under 16px on
an iPhone, which an app with its own window does not face.
- **#3340 and #3341** change no design: they keep the shell where it
already was.
- These are named from how the apps are known to behave; none was opened
for this PR.

## Screenshots

Not uploaded here. Before/after shots were taken on the static demo and
handed to the maintainer: Settings → Appearance (selects and text
fields) and the New workspace dialog (Directory, the agent picker), as
an iPhone at 390px and an iPad at 1180px, at the default and a 20px
interface size, at rest and with a text field focused by a tap (32
shots, 16 side-by-side pairs). The computed sizes they show:

| | before: rest / focused | after: rest / focused |
|---|---|---|
| iPhone 390px, default (14px body) | 16px / 16px | 14px / 16px |
| iPhone 390px, 20px interface | 16px / 16px | 20px / 20px |
| iPad 1180px, default | 13px / 13px | 13px / 16px |
| iPad 1180px, 20px interface | 18.6px / 18.6px | 18.6px / 18.6px |

The agent picker (a button) follows the same resting sizes and is never
enlarged. A native select follows them too and is enlarged only once it
has the focus, not by the press. The shots were taken on the first head;
the second round changed none of the sizes in this table.

## Validation

All on head `1171f74d9` (the branch rebased onto `main` 68f1fa9fb, plus
the second round's commit) unless said otherwise.

- `bun run check fast`: passed (workflow syntax, generated types and
themes, typecheck, build; unit tests 14770 pass, 0 fail, 51 skip).
- In the CI runner image (`herdr-ci-runner:local`, as its own user, in a
checkout of its own at this head, through
`scripts/ci-browser-parallel.ts`), no retries:
- `scripts/ui-regression.ts`, `scripts/ui-contexts-regression.ts`,
`scripts/ui-contexts-layout-regression.ts`: 3/3 passed. They also run
the checks they import, among them `mobile-viewport`, `keybar-focus`,
`mobile-tabs`, `terminal-pinch`, `terminal-input-spacing`, `pane-find`,
`settings-tabs`, `header-lens-switch`, `split-view`, `tab-menu` and
`secret-input`.
- 54 scripts that name the header, the sidebar, fields, the composer or
the viewport: 54/54 passed, `keyboard-viewport-regression` and
`diff-find-demo-regression` among them.

    <details><summary>The 54 scripts</summary>

`agent-helpers-fold-demo-regression`, `chat-greeting-demo-regression`,
`cliproxy-settings-regression`, `composer-draft-demo-regression`,
`composer-fit-demo-regression`, `composer-send-demo-regression`,
`context-menu-inputs-demo-regression`, `deep-link-demo-regression`,
`diff-find-demo-regression`, `drawer-modal-regression`,
`droplet-demo-regression`, `file-text-size-demo-regression`,
`file-viewer-mobile-regression`, `files-prompt-regression`,
`header-context-demo-regression`, `interface-font-demo-regression`,
`keyboard-viewport-regression`, `machine-dialog-regression`,
`mirror-fold-demo-regression`, `new-session-skills-browser-qa`,
`pane-input-focus-demo-regression`,
`phone-glass-header-demo-regression`, `phone-safe-area-demo-regression`,
`prompt-dock-demo-regression`, `push-health-demo-regression`,
`pwa-update-browser-qa`, `recent-folders-regression`,
`reconnect-header-demo-regression`, `repo-diff-browser-qa`,
`settings-pages-demo-regression`,
`settings-palette-search-demo-regression`,
`settings-rows-demo-regression`, `sidebar-activity-demo-regression`,
`sidebar-agent-tree-demo-regression`,
`sidebar-background-workspaces-demo-regression`,
`sidebar-branch-line-demo-regression`,
`sidebar-context-ring-demo-regression`,
`sidebar-declutter-demo-regression`, `sidebar-filter-demo-regression`,
`sidebar-heads-demo-regression`,
`sidebar-machine-layout-demo-regression`,
`sidebar-machine-removal-demo-regression`,
`sidebar-peek-demo-regression`,
`sidebar-selection-contrast-demo-regression`,
`sidebar-spacing-demo-regression`,
`sidebar-split-access-demo-regression`, `sidebar-split-demo-regression`,
`sidebar-tokens-demo-regression`, `tap-targets-demo-regression`,
`terminal-keyboard-demo-regression`, `terminal-served-font-regression`,
`terminal-viewport-regression`, `unconfirmed-input-demo-regression`,
`workspace-rows-regression`

    </details>
- Each reproduction above: `scripts/keyboard-viewport-regression.ts` on
the host's Chromium, failing before its fix and passing after. For the
second round the script was also run once with its assertions collecting
instead of stopping, on `3cb28a6ed`'s code, to list every check that
fails there.
- The first head (`3cb28a6ed`) passed the same checks before the rebase
(fast checks, 3/3 and 50/50 in the image). Its GitHub run failed one
script this PR does not touch,
`background-agent-states-desktop-demo-regression` (a disabled row
button, `background-agent-detail-demo-run.ts:201`); its sibling failed
the same way on another PR's run (42808284998), and it passes here on
the rebased branch.
- Skipped: `bun run check full`, the integration suite, the Windows and
macOS jobs, and every script not listed above.

### iOS Simulator (the test Mac; iPhone 18 Pro and iPad Air 11-inch,
iOS/iPadOS 27.0, Safari 27.0)

Static demo only. Real touches; a probe logged sizes, `visualViewport`
and the marks. First round: `main` f88576037 against the branch at
`484e67f3e`. Second round, after the review: `main` 68f1fa9fb against
this head, with the probe timing each mark against its viewport event.

- **Safari's zoom (#3339), iPhone:** a control page proves this Safari
zooms: a 12px field goes to scale 1.33 when tapped and when a button's
handler focuses it; a 16px one stays at 1. On this branch, at the
default and at a 12px interface, the sidebar filter, a Settings select,
Find in diff (through its button and tapped) and Rename tab rest at the
interface size, read 16px while focused, return on blur, and the page
stays at scale 1 at the focus and 300 ms and 1200 ms after it. A field
focused by a handler is armed inside the focus event, and no zoom
followed. This was the open question on #3339.
- **Safari's zoom, iPad:** Safari on the iPad never zoomed into a field,
on `main` either: the 12px control stays at scale 1 in landscape and
portrait, and with the mobile site in landscape. So the zoom #3483
describes did not reproduce on an iPad. The sizes are as intended
(filter and select 13px → 16px → 13px, Find in diff 14px → 16px → 14px,
at 1180 and 820), but on this iPad they only change how a focused field
looks: it grows by 3px, and a select that keeps the focus after its menu
closes stays that size until the focus moves. See "A decision left to
the maintainer".
- **Window controls (#3338):** the home-screen app could be installed
and put in a window (641×583). On this branch it is marked, the room is
68px and the header's first button starts at x=68, clear of the
controls, which end about 61pt from the window's left edge. On `main`
the button sits at x=12, under them. In a Safari tab and in the
full-screen app nothing is marked. `CSS.supports("anchor-name: --a")` is
true on iPadOS 27.
- **Page zoom (#3338, #3340):** at 85%, 100%, 115% and 125% in a Safari
tab, `screen` stays 820×1180 while the layout and `visualViewport.scale`
follow the zoom (125% in landscape lays out 944px wide at scale 1.25),
which is what both fixes assume.
- **Landscape shell (#3340):** in the full-screen home-screen app the
visual viewport is 788 under a 820 `100lvh`, and this branch publishes
`--app-height: 788px`. iPadOS 27 already draws `100dvh` at 788 there, so
at rest nothing differs from `main` and the slide on focus did not show
on `main`. A difference did show with a hardware key pressed and the
keyboard reduced to its floating bar (viewport 719.5): this branch fits
the shell to 720px and the composer stays clear of the bar; on `main`
the shell stays 788 and the bar covers the composer's bottom row.
- **Shrink wait (#3341):** keys sent as HID events caused no one-frame
shrink on either build, so the flash was neither reproduced nor refuted.
- **The phone's keyboard (second round):** on the iPhone, this head sets
and clears `data-keyboard` and `--app-height` in the same task as the
viewport event, as `main` does: 0 to 7 ms on both builds over four opens
and four closes each, and no 40 ms gap in 16 more keyboard changes. A
rotation with the keyboard up is the same on both.
- **The iPad's keyboard (second round):** only the iPad waits, and only
on a shrink: the keyboard counts 41 to 43 ms after the viewport event
(Safari tab and the windowed home-screen app), where `main` counts it in
the event; it is cleared in the event on both. One case beyond a plain
open waits too: rotating back to landscape with the keyboard up, where
the window's resize first un-counts the keyboard and the viewport's
shrink 0.8 s later is then held 41 ms.
- **A pressed select (second round, iPhone):** at `pointerdown` and in
the next frame a Settings select keeps its size, has no `data-armed` and
the same box (115×44 at 14px, 106×44 at 12px); with the focus it is 16px
and 125×44; the picker opened on 8 of 8 taps. Text fields: no zoom, as
in the first round.

### Could not be checked

- A real iPad, and a Magic Keyboard: the two home-screen bugs as
reported (#3340's slide, #3341's flash) were not reproduced on `main`
here.
- iPadOS 16 to 18 and iPadOS 26: only the 27.0 runtime is installed, so
the probe's false side (Split View, Slide Over on iPadOS 18) ran in the
regression only, with the probe faked.
- A windowed app 769px or wider on a device (the `.header-side` rule):
the Simulator's window would not resize further. The regression covers
the rule.
- Page zoom inside the home-screen app, a pinch, and an iPhone
home-screen app.
- Whether WebKit reports whole-number widths under page zoom (finding
7).
- On a device: a field losing the focus during the iPad's wait (finding
14), a keyboard that changes height while up on the iPad (the emoji
views did not change the viewport), and the tap that finding 17 says
could miss (the press no longer changes the select, so it was not
provoked).

## A decision left to the maintainer

Arming on an iPad follows #3483 and #3561, and the new regression pins
16px there. The Simulator says Safari on an iPad does not zoom into a
small field at all, so on an iPad the arming is only a visible 3px
growth while a field has the focus. Limiting the arming to the iPhone
would be a small change (and #3483 would close as not reproducing); it
is not made here because iPadOS 16 to 26 could not be checked.

## Not in this PR

- A field with a size of its own (Rename tab uses `--fs-sm`) grows to
the generic field size when armed at a large interface size (noted on
#3339).
- The native iPad app (Capacitor, `app/ios`): not covered,
`display-mode: standalone` was not checked there.
- A window as wide as the screen but shorter (finding 11).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Noobear <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: sisyphus-dev-ai <[email protected]>

* fix(terminal): a key-bar tap no longer hides the soft keyboard that is up (#3597)

<!-- See CONTRIBUTING.md for checks, translations, contract tests and
the changelog (a file in changelog.d/, never CHANGELOG.md). -->

## Change

**Problem.** On Android (seen on a Galaxy S26 Ultra), with the soft
keyboard up in a terminal pane,
tapping any key-bar key (Esc, Ctrl, Tab, an arrow, More keys) hides the
keyboard. The tap's focus is
already kept (`keepFocus` cancels pointerdown and mousedown), so focus
is not what moves.

The cause is `holdKeyboardForTap()` from #3297. For every touch press of
a key it sets
`inputmode="none"` on the focused field until the click is handled. That
is right for the case #3297
fixed (#3274: Back put the keyboard away but left the field focused, and
the next key tap raised it
again). But with the keyboard **up**, switching a focused field to
`inputmode="none"` makes Blink send
the new input type to the IME, and the IME hides the keyboard that is
showing. The comment there said
it "also leaves a keyboard that is up where it is"; on this device it
does not.

**Behavior after this PR.** `holdKeyboardForTap()` returns early when
`keyboardUp()` is true (the
`data-keyboard` attribute `lib/viewport.ts` sets). With the keyboard up,
a key tap leaves `inputmode`
alone and the keyboard stays up. With the keyboard down (Back put it
away), the hold works exactly as
in #3297, so #3274 stays fixed.

This follows T3 Code's mobile terminal, whose key row over the keyboard
(arrows, esc, sticky
ctrl/alt, tab) leaves the keyboard up on every key and puts it away only
through its own explicit
dismiss button
(`apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx`).

- `src/components/KeyBar.tsx`: the early return and the corrected
comment.
- `scripts/keybar-focus-regression.ts`: a keyboard-up case. It sets
`data-keyboard`, taps Escape and
More keys, and asserts the field keeps focus and a `MutationObserver`
sees no `inputmode` change
  during the taps. The keyboard-down case is unchanged.
- `changelog.d/keybar-tap-keeps-keyboard-up.md`.

Risk: the fix relies on `data-keyboard` being current at the moment of
the tap. If it lagged behind a
keyboard that was just put away, the tap would skip the hold and #3274's
re-raise could come back for
that one tap.

Note on coverage: `scripts/keybar-focus-regression.ts` is not listed in
`scripts/ci-browser.sh` and
has no line in docs/development.md. Its check still runs in CI through
`ui-contexts-checks.ts` (`checkKeyBarKeepsKeyboardDown`, run by
`ui-contexts-regression`), and the new
keyboard-up case is inside that exported check, so CI covers it. Only
the standalone script is
unlisted. `scripts/android-ime-regression.ts`, the one test that asks a
real IME whether the keyboard
is shown, needs `ANDROID_IME_SERIAL` (an emulator) and did not run here.

## Validation

- `bun run check fast` on this branch: typecheck, build and unit tests
ok (14795 pass; the one
failure, `server/copilot.test.ts` "keeps a logged binding when only the
log's timestamps change",
  fails the same way on main and passed on later runs).
- After the doc-comment commit (084ad83b, comments only), `bun run check
fast` again: typecheck and build
ok; unit tests failed on the same copilot test (fails on main too), two
`pi-questionnaire-route`
timeouts and `scripts/plugin.test.ts` "stop > returns only once the
server's process group is gone".
Rerun by file, the questionnaire tests pass, and the plugin test passes
2 of 2 on this branch and on main.
- In the self-hosted runner image built from
`scripts/self-hosted-runner/Dockerfile`, as its own
  user, through `bun run check run`:
- pass: `keybar-focus-regression`, `ui-contexts-regression`,
`key-bar-hold-repeat-regression`,
`key-bar-customization-demo-regression`,
`terminal-keyboard-demo-regression`,
`sticky-modifiers-regression`, `keyboard-viewport-regression`,
`terminal-input-regression`.
- skipped: `android-ime-regression` (needs an emulator; refuses physical
devices).
- On a device, by hand: Galaxy S26 Ultra, Chrome. On the 0.5.2 release
(which has #3297), a key-bar
tap with the keyboard up hid the keyboard; on this branch the keyboard
stays up through key,
modifier and arrow taps. #3274's case still holds: after Back puts the
keyboard away, a key-bar tap
  leaves it down.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(agents): grok lookups by session, Agy locks read last, and 503 for a Letta scan cut short (#3598)

Follow-ups to the low-severity findings the merge pass left on #3572,
#3573 and #3575, as one PR, plus what the review of this branch found on
the way. Cut from `925872654`; it merges cleanly into `origin/main` at
`c94f52572`.

## The five findings

### 1. A grok pane herdr names no session for keeps what it holds
(#3572)

`server/agent-tasks.ts`. A grok pane reported with no `agent_session`
for one snapshot lost its background count, and the hold of a turn that
ended on a task, for about ten seconds. The missing id was read as
another session, so the pane was looked up as reported. A grok session
is found by its id, so that lookup could only fail, and a failed lookup
of "another session" lets the state go at once.

herdr naming no session is not another session. A grok pane reported
without one is now asked for by the session known for it:

- Nothing is looked up while that lookup is recent.
- Once it is old, the lookup is a real one of the known id. One that
fails is a first miss as any: the count stands, the poll asks again ten
seconds on by that id, and two in a row let the pane go.
- A pane nothing is known of is asked for as herdr reports it.
- The session known is used only when it is grok's own: another agent's
id is never what a grok pane is asked for by, nor the key its miss is
remembered under.

### 2. A failed lookup is remembered with the session it was of (#3572)

`server/agent-tasks.ts`. The memory of a failed lookup was kept per pane
and agent. For grok, a miss of one session id held off the snapshot
lookup of a newly named other session for the retry interval, and could
count as the first of its two misses.

The pane's misses are now kept by session, for the agent they were of
(grok only: an agy session is found by the pane's process, so its miss
still holds whichever id herdr names). Both gates read the same entry:
the retry spacing, and the "second miss in a row" that lets a pane go.
Each session's miss stays beside the others', so herdr naming a session,
then none or another, then the first again asks for each only every ten
seconds while none of them is found.

**Known limit, left as it is.** A lookup that finds a session drops
every miss of the pane. Where herdr names in turn a session that is
found and one that is not, every snapshot looks one up and the count is
told and let go in turn: ten lookups in ten seconds, where main makes
two (and leaves the count at 0). Nothing shows herdr naming two ids in
turn for one pane; the observed case (an id, then none) is covered by
item 1. The comment on `failed` states the limit and a test pins it.
Spacing it would mean keeping the other sessions' misses through a
lookup that finds one and reading them for a pane whose session is
known, which would also hold a snapshot's lookup of a session the pane
really went back to.

### 3. Agy: herdr is asked the second time before the locks are read
(#3573)

`server/agy-store.ts`, `resolveAgyStore` and `agyFreshSession`. The
order was identity, locks, second ask, identity. It is now identity,
second ask, locks, identity, so the lock read is the last evidence
gathered and still lies inside the start-identity bracket. A second
answer that names another process ends the lookup before any lock is
read.

**What the new order costs.** The second ask is made before it is known
what the locks show:

| Case | Asks before | Asks now |
|---|---|---|
| A lookup that answers | 2 | 2 |
| A lookup that finds no single conversation lock | 1 | 2 |
| A greeting refused because a lock is held | 1 | 2 |
| A pane herdr names no single Agy for | 1 | 1 |
| An Agy whose start identity cannot be read | 1 | 1 |
| A greeting refused by its start arguments | 1 | 1 |

`docs/agy-chat.md` describes the new order and these costs, and the
unreleased fragment of #3573 (`changelog.d/agy-pane-process-recheck.md`)
is reworded to it.

### 4. Letta: no output when the pane moved during the last resolution
(#3575)

`server/conversation.ts`, the Letta branch of `toolOutput`. After the
awaited scan the pane is resolved once more, and that resolution was
only compared by its own answer. One begun before a `/new` in the pane
still names the conversation the output was read from, so when another
read saw the pane on the new conversation meanwhile, the old
conversation's output was answered. The final check now also refuses
when the binding moved since the lookup resolved it (`|| rebound(paneId,
transcript)`).

### 5. Letta: a scan cut by its time limit answers "try again" (#3575)

`server/letta.ts`, `server/file-tasks.ts`. A transcript scan stopped by
its own 10 s limit answered as "no such call" (404 `output_not_found`),
though the call may lie past where it stopped.

- `lettaToolOutput` throws `LettaScanCut` when it runs out of time with
some of what the transcript held as the scan began still unread. It
answers null as before at the end of the file, when all of that was
read, and at its 256 MiB cap.
- The file thread answers a cut scan as `{ cut: true }` (an error
crosses a thread as its message alone), and `lettaToolOutputOffThread`
rejects with `FileBusyError` for it.
- The route gains no new answer: it is the 503 `file_busy` with
`Retry-After` it already gives when no file thread is free. Only which
cases get it changes.
- The `letta-output` file task takes an optional `budgetMs`, as the
documents task does, so a test can run a scan with no time on a real
file thread.

## Beyond the five findings

**OmO has the window item 4 closes for Letta.** The OmO branch of
`toolOutput` resolved the pane a last time and compared only that answer
(older code, #3359). The review of this branch reproduced it: the held
last resolution answered the old session's output after another read had
seen the pane on a new session. The same `|| rebound(paneId,
transcript)` is added there, with a test and a changelog fragment of its
own. Please treat it as an addition to the five; it is one commit
(`7fcbbe6a2`) and can be dropped on its own.

## Tests

- `server/agent-tasks.test.ts`: a session-less grok pane keeps its count
and is asked for by the session known; a pane known as another agent's,
or let go meanwhile, is asked for as reported; a miss holds no lookup of
another session off; each session's miss is kept beside the others'; the
known limit above.
- `server/agy-store.test.ts`: the ask counts of the table above; a
stand-in Agy that moves its lock while herdr answers the second time; on
Linux the order of the reads (ask, identity, ask, locks, identity), and
that the start identity read after the locks is what refuses a pid taken
between the second answer and the lock read; a greeting with an
unreadable start identity asks once. The order test is Linux only:
elsewhere the identity is read through `ps` or a Windows handle.
- `server/letta.test.ts`: the pane moved during the last resolution; a
scan with no time answers `{ cut: true }` on the file thread and
`FileBusyError` on the pane's route, for a call the transcript holds and
for one it does not; read to the end, the answers are the output and
"not found".
- `server/conversation.test.ts`: the OmO pane moved during the last
resolution ("old session" before the fix, no output now).

## Changelog

`changelog.d/grok-unnamed-session-keeps-count.md`,
`letta-tool-output-try-again.md` and `omo-tool-output-pane-moved.md` are
new; `agy-pane-process-recheck.md` (#3573, unreleased) is reworded to
the new order.

## Validation

Run at head `aa59268f9`, with `HERDR_TEST_MODE=unit` and a `TMPDIR` of
its own:

- `bun test server/agent-tasks.test.ts`: 23 pass
- `bun test server/agy-store.test.ts`: 24 pass
- `bun test server/conversation.test.ts`: 253 pass
- `bun test server/letta.test.ts`: 81 pass
- `bun test server/file-pool.test.ts`: 21 pass
- `bun test server/core/status.test.ts`: 82 pass
- `bun test server/conventions.test.ts`: 14 pass
- `bun test scripts/changelog-fold.test.ts`: 12 pass
- `bun run typecheck`: clean

`bun run check fast` at `aa59268f9`: green (unit 14797 pass, 0 fail;
typecheck, build, generated files).

Reviewed before opening by an independent agent reviewer in three rounds
(one medium and several low findings, all fixed or listed above; the
last round: ship).

Not run: `bun run check full` and the browser regressions (no `src/`
change). Nothing was run on macOS or Windows; the Agy path on macOS is
untested natively, as `docs/agy-chat.md` already says.
`server/agy-store.ts` is imported by `server/windows-native.test.ts`, so
this waits for GitHub's Native Windows job.

## Notes for the merge pass

- Item 5 changes which cases of `GET /api/pane/conversation/tool-output`
answer 503 instead of 404, so this PR touches an HTTP answer and waits
for a real review.
- The message of `8c44a2908` gives a wrong reason for the `known?.agent
=== agent` clause (a saved herdr call). `resolveGrokStore` refuses a
session that is not grok's before it asks herdr anything; the clause
only keeps another agent's id out of what a grok pane is asked for by
and remembered under. `aa59268f9`'s message corrects it; a squash
message should not carry the old line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>

* fix(connect): no socket row for a named session beside an older Ovis; a refusal notice reads the global relay's own refusal (#3599)

## Change

Follow-ups to the low findings the merge pass listed on #3576 and #3579,
one commit each. No HTTP/WS contract change and no new strings.

**1. Adding a PC over SSH: herdr's own socket is offered beside an older
Ovis only when no session is named (#3576)** — `server/machines.ts`

Adding a PC over SSH that runs an older Ovis, with no runtime of this
app there, offers herdr's own socket as a session row built from the
socket file. With a session typed in the dialog, that row was the named
session's socket. Chosen, the PC was saved with the socket (only the
default session's socket is saved as herdr to start), so after that PC
restarted its bridge said the session was no longer running instead of
starting it by its name.

The row is now built only when the dialog names no session (`!session &&
answered && !listedHere`). A named session connects as it did before the
card existed: the approval of what the setup installs, then a bridge
started for the session by its name.

`server/machine-core-choice.test.ts` ("older peer, no bundle") adds the
named session: it reaches the approval with no card, and the bridge is
started with the session and no chosen socket. The unreleased changelog
entry of #3576 (`changelog.d/ssh-add-pc-default-session-restart.md`) now
says the offer is for a dialog that names no session.

**2. Before the announced date, a refusal notice needs the global link's
own pass refusal (#3579)** — `src/lib/relayNotice.ts`

Before the date, the notice over the pane read a refusal from the
refused flag beside the global link in error. A regional relay's refusal
sets that flag too, and a global link that dropped for the network is in
error as well (`relay_unreachable`), so a regional refusal plus a
network error showed "add this PC", "PC limit" or "needs an account" for
as long as the global link was down.

Before the date a refusal is now the global link's own: the flag, the
link in error, and an error code that names the pass (`pass_*`). A
server from before the codes names none and is read as before. Past the
date, and with no date, nothing changes: the flag beside any error still
reads as a refusal there.

**3. A dismissed not-listed or PC-limit notice stays dismissed while the
PC asks the relay again (#3579)** — `src/lib/relayNotice.ts`

Before the date, a PC the relay closed for its pass looks again every 30
minutes and whenever a pass comes, and each attempt reads `connecting`.
The not-listed and PC-limit notices read "no notice needed" for that
window, which `useRelayNotice` takes as the state being over: it removed
the stored dismissal, and the notice the user had dismissed showed again
after the next refusal.

While the refused flag stands and the global link has neither let the PC
in nor refused it for its pass (it is connecting, or in error for
another reason such as `relay_unreachable` between attempts), the
reading is now "not known" (`undefined`) where nothing else shows: no
notice, and stored dismissals are kept, as before a first answer. No
refusal is read from it, so a regional relay's refusal during a global
reconnect still shows none. The link online, with the flag set or
cleared, still ends the dismissal, and the sign-in reminder that names
the date still shows meanwhile.

`src/components/RelayNotice.test.tsx` covers 2 and 3: the flag beside
`relay_unreachable`, `server_key_refused` and `start_failed` before the
date; every `pass_*` code; the flag beside a network error past the
date; and `useRelayNotice` driven through a refusal, its retry and the
next refusal for both notices, including a page load that lands in the
retry.

No changelog fragment for 2 and 3: they correct the before-the-date
reading that #3579 added, which is not released, and its fragment
(`changelog.d/relay-notice-open-visitor-refusal.md`) still reads true.
Nothing visible is designed anew (the notice, its wording and its
dismissal are as #3579 left them), so no reference app is named.

### Not in this PR

Two low findings from the review of this b