Skip to content

fix(server): keep a held pane held when herdr answers late, and stop taking a shell's startup for OmO - #243

Merged
devswha merged 2 commits into
mainfrom
fix/flaky-contract-tests
Oct 1, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/flaky-contract-tests

Conversation

@devswha

@devswha devswha commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Closes #239, closes #240.

Two contract tests failed now and then on a Linux workstation. Both turned out to be product bugs that the tests caught by chance, so the assertions stay as they are.

1. A held pane was resumed and held again (#240)

server/attach-held.contract.test.ts got attach_held one time too many (2 instead of 1 at line 130, or 3 instead of 2 at line 148).

The bridge holds an attach's first bytes for 100 ms and, if herdr's refusal is not there by then, decides the attach took. The timer started at the first byte, but the first bytes are terminal mode changes (ESC[?1006l ..., ESC[?1049h) that the herdr terminal attach CLI writes itself before herdr has answered. On 400 refused attaches in a row on a busy machine, the refusal came more than 100 ms after the first byte 4 times (up to 218 ms). Each time the pane was resumed, and held again when the refusal arrived; in between, keys and input from the waiting bridge could reach a pane the other bridge holds.

Fix: mode changes alone no longer start the hold. Counting from the first byte that is not a mode change, the refusal was at most 1 ms away in the same 400 attaches, because herdr writes it together with that byte.

New test: a scripted herdr prints the mode changes, waits 0.4 s, then refuses. On main the client gets ["attach_held", "attach_held"]; with the fix it gets one.

2. A new shell was taken for OmO while its startup files ran (#239)

server/omo.contract.test.ts failed in different tests on different runs.

isOmoProcess matched any argv word containing /omo-ai/. A zsh startup file on this machine runs printf %s\n "$PATH", and that PATH contains omo-ai's node_modules/.bin. Polling pane.process_info on 12 fresh shells with nothing typed into them, 9 matched isOmoProcess during startup, each time on that printf. The test helper returned on that match, before the stand-in omo was running. In the product the same match could mark a new shell as OmO for a moment and let New session report omo started too early.

Fix: an argv word with a : in it is a path list, not a program, and no longer counts (0 of 12 fresh shells match now). The test helper also waits for the stand-in by its own path. A unit test covers the PATH argument.

Failure rates

Each file alone, in a loop, on the same machine (32 cores, herdr 0.9.3, Bun 1.4.2, other work running):

File main this branch
server/attach-held.contract.test.ts 1 of 20 failed 0 of 40 failed
server/omo.contract.test.ts 2 of 20 failed 0 of 40 failed
for i in $(seq 1 40); do HERDR_TEST_MODE=integration bun test --timeout 15000 ./server/attach-held.contract.test.ts || echo FAIL; done
for i in $(seq 1 40); do HERDR_TEST_MODE=integration bun test --timeout 15000 ./server/omo.contract.test.ts || echo FAIL; done

Checks

  • bun run typecheck: clean
  • bun run test:unit: 654 pass, 0 fail (before the added unit assertions were the only change to that suite)
  • bun run test:integration: 153 pass, 1 fail. The failure is web push > reports a Codex unknown after work as done over WS and HTTP and delivers its completion push in server/api.contract.test.ts ("not received within 5000ms"), a test this PR does not touch; see the comment below for how it behaves alone on main and on this branch.

Not covered

isOmoProcess still matches a single path into omo-ai given as an argument to another program (grep -q /.../omo-ai/x). I have not seen a shell startup do that.

devswha added a commit that referenced this pull request Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 02522bfc-ba34-4cb2-b6c4-ec0dd51e929a

📥 Commits

Reviewing files that changed from the base of the PR and between f8a74c4 and 9387486.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • server/attach-held.contract.test.ts
  • server/conversation.test.ts
  • server/index.ts
  • server/omo.contract.test.ts
  • server/omo.ts
 ___________________________________________________________________
< Your commit message says 'quick fix'. That's how folklore starts. >
 -------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

…taking a shell's startup for OmO

Closes #239, closes #240.
@devswha
devswha force-pushed the fix/flaky-contract-tests branch from 9387486 to f46ff44 Compare October 1, 2026 08:37
@devswha
devswha merged commit d672035 into main Oct 1, 2026
10 checks passed
@devswha
devswha deleted the fix/flaky-contract-tests branch October 1, 2026 08:43
devswha added a commit that referenced this pull request Oct 1, 2026
Release v0.3.39: moves the Unreleased notes under 0.3.39 and bumps
`package.json` and `herdr-plugin.toml`.

In this release, all fixes: a password sent right after a reconnect
(#244), typing and keys outliving their connection (#235), panning a
terminal whose grid is not the browser's own on a phone (#241), omo's
question form in the chat (#237 by @nahwan-kim), and a held pane resumed
by a late herdr answer plus a new shell taken for OmO (#243). No remote
bundle change: `REMOTE_BUNDLE_VERSION` stays 9.

Changelog housekeeping that was waiting for a release:
- Compare links at the bottom now cover 0.3.31 to 0.3.39 (they stopped
at 0.3.30), and `[Unreleased]` compares from v0.3.39.
- Five references that were a bare `#N` are full PR links with their
author: #164 is the issue PR #199 fixed, #154 the issue PR #155 closed,
and #45 and #6 are PRs. No other wording of released entries changed.

`bun scripts/release-notes.ts 0.3.39` prints the notes and exits 0.
devswha added a commit that referenced this pull request Oct 1, 2026
…ent that names it (#249)

## Change

`isOmoProcess` took a foreground process for omo when any word of its
argv was an omo path, so `grep -q …/omo-ai/x`, `cat …/bin/omo` or `node
watch.js …/omo-ai/plugin` counted as omo. The sidebar then named the
pane `omo`, the transcript lookup counted it as a second omo in the cwd,
and `startShellAgent` could report a start.

Now only the program counts: `argv[0]`, or, when `argv[0]` is
`node`/`nodejs`/`bun`, the script it runs (the first word after it that
is not a flag). The word must still be one path (no `:`), as #243
required.

Shapes kept, the first two exactly as herdr 0.9.0's `pane.process_info`
reported them for omo 5.1.7 in a test pane:
- `/home/u/.bun/bin/bun
…/omo-ai/node_modules/@code-yeongyu/senpi/dist/bundle/cli.js --extension
…/omo-ai/plugin`
- `/home/u/.bun/bin/bun …/omo-ai/plugin/runtime/ast-grep-mcp/cli.js mcp`
(omo's MCP child, same process group)
- `node …/bin/omo`, `node --flag …/omo-ai/bin/omo.js`, a native `omo`,
and the SDK child `…/omo-ai/…/claude`

The change is confined to `isOmoProcess` and one regex above it in
`server/omo.ts`; Windows paths (#234) are untouched.

Closes #248

## Also checked: the omo question cards against real omo 5.1.7 (no
defect found, no code change)

In the isolated `herdr-web-ui-test` session (herdr 0.9.0), a server from
this branch, and a real omo asked for a two-question `ask_user_question`
form:
- The card appeared with the form's title, options and step chips
(`Question 1 of 2`, Red/Green/Blue, chips Color/Fruits), identical at
120, 60 and 40 columns.
- Single choice, multiple choice, a typed answer, reopening an answer
from the review, and Submit each moved omo on; omo reported `2 answered;
0 unanswered` with the answers sent. A stale answer got 409
`prompt_changed`.
- The footer was 2 lines under exactly one rule at all three widths.
- Backspace cleared an earlier multiple choice (Apple, Cherry -> Banana)
and an earlier typed answer (Purple -> Teal).
- Options 10 and above cannot occur in omo 5.1.7: its tool refuses with
`options must contain 2 to 4 items when present`.
- herdr reported the pane as `pi` before the first turn and `claude`
with status `idle` (not `blocked`) while the form showed; the card still
came from the session's pending call.

## Validation

- `bun run typecheck` passes.
- `bun run test:unit`: 673 pass, 0 fail (two new tests in
`server/omo.test.ts`, one per direction).
- `bun test ./server/omo.contract.test.ts
./server/omo-prompt.contract.test.ts ./server/prompt.contract.test.ts`:
10 pass.
devswha added a commit that referenced this pull request Oct 1, 2026
Fixes #256.

Raises `REMOTE_BUNDLE_VERSION` from 9 to 10, so that remote PCs (Windows
PCs included) get the bridge-side fixes merged since `remote-v9`: #235,
#243, #249, #251, #264, #265, #267, #278, #281 and the rest of `git log
remote-v9..main -- server shared`.

`server/machines.test.ts` named the `remote-v9` directory literally and
failed on the new number; it now reads the constant.

## Order, from docs/remote-pcs.md
1. Merge this.
2. Push the `remote-v10` tag on `main`: the Remote PC bundles workflow
builds, smoke-tests and publishes the five archives and `manifest.json`.
3. Only then release the app: an app that carries the new number finds
no `remote-v10` manifest before step 2, and every connected PC's bridge
counts as incompatible until it is updated.

## Checked
`bun run typecheck`, `bun run test:unit` (734 pass). The bundle build
and smoke run in this PR's Remote PC bundles checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant