You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(terminal): read herdr-core's attach paint as a frame - #4491
On a herdr-core server the page never read an agent's input row after attaching until the agent drew again.
herdr-core's attach paint opens with CAN, DECSTR (CSI ! p) and CSI ? 2026 l, to reset the viewer, and then
paints the screen outside any synchronized update. FrameGate (src/lib/inputRow.ts) marked the stream as one drawn
in synchronized blocks at any ?2026, so it then waited for a whole block opened after the reset: the paint never
settled, and inputRowNow() stayed unknown until the program drew a synchronized frame of its own.
What it showed: Codex at rest draws nothing after an attach, so the composer's effort button's /model went with its
row unread, and Back to Chat over the list left no "/model is still open in the terminal" note (the server's agent_blocked refusal still kept the message). A shell, which draws no blocks, was never read at all.
The fix: only CSI ? 2026 h marks the stream as drawn in blocks; an end that closes no block frames nothing, as for a
terminal (xterm.js's reset of mode 2026 only clears synchronizedOutput, already off, and refreshes). herdr's own
frames, each h … l, settle as before; the existing FrameGate cases pass unchanged. No UI of its own: the note and
the peek's return are the existing ones, now reached on herdr-core as on herdr.
Validation
In the CI runner image (scripts/self-hosted-runner/Dockerfile built locally on 2026-11-20, before #4419 changed it for the
Rust PTY host's slots, which these checks do not use; Bun 1.4.4), on a fresh clone of the branch:
bun run check run bun test src/lib/inputRow.test.ts on the branch rebased onto main 4640b69d: 238 pass. Control, the old
line put back with the new tests kept: the two new FrameGate cases fail.
bun run check fast: workflow syntax, generated files, typecheck and build ok; unit 22191 pass, 21 fail, 65 skip. The
21 are the same as on main 119b36e2 in the same image (22189 pass, 21 fail): scripts/plugin.test.ts (18), scripts/relay-ios-sim.test.ts (2) and server/account/step2-upgrade-matrix.test.ts (1).
The browser regressions that read through the gate, in the lane (BROWSER_SCRIPTS=… bun run check run -- bun scripts/ci-browser-parallel.ts): command-outcome-demo-regression.ts and terminal-autoswitch-demo-regression.ts, 2/2
pass.
On a real herdr-core 0.1.21 server, from a downstream build with the same change (a Codex stand-in at rest that draws each
screen in a synchronized update, as Codex does): the effort button's /model, then Back to Chat over the list, shows
"/model is still open in the terminal" at 860×954 and 412×915 touch, and the message stays unsent; with the old line
built, the same run times out waiting for the note.
Not run: Windows, macOS, a real Codex or provider.
herdr-core's attach paint opens with CAN, DECSTR and CSI ? 2026 l to reset the
viewer, then paints the screen outside any synchronized update. FrameGate took
that lone end for the mark of a stream drawn in synchronized blocks and from
then on settled only whole blocks, so the paint was never read and the page
knew no input row until the program drew again. Codex at rest draws nothing:
the effort button's /model went with its row unread, and Back to Chat over the
list left no "still open in the terminal" note (the server's agent_blocked
refusal still kept the message). A shell, which draws no blocks, was never
read at all.
An end that closes no block now frames nothing: a stream counts as drawn in
blocks once a block opens. herdr's own frames, each in a block of its own,
settle as before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
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
Fixed a delay in displaying terminal input on herdr-core servers, so the page updates before the agent draws again.
Restored chat’s indication that a command screen, such as a model-selection menu, is still open in the terminal.
FrameGate now treats a synchronized-update terminator without an open block as unsynchronized input. Regression tests cover herdr-core attach-paint handling, and a changelog entry describes the reported behavior.
enqueue sets synced when it processes an opening marker. Tests cover attach paint on its own and after a blocked stream, split terminator reads, subsequent blocked frames, and resize behavior. The changelog describes the herdr-core attach-paint case.
This change fixes how input rows are read when an agent attaches on herdr-core servers, so idle sessions no longer wait for a redraw. It carries little merge risk. Real-environment testing outside the author's reported checks was not done.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the terminal fix that makes FrameGate read herdr-core's attach paint as a frame. It is specific and matches the changeset, which only adds the FrameGate rule change, i…
Description check
The description follows the template. It has a Change section that describes the problem, the cause in FrameGate, the resulting behavior, and the fix. It has a Validation section that lists the checks…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the terminal fix that makes FrameGate read herdr-core's attach paint as a frame. It is specific and matches the changeset, which only adds the FrameGate rule change, its tests, and a changelog entry.
Full details: Description check
Explanation
The description follows the template. It has a Change section that describes the problem, the cause in FrameGate, the resulting behavior, and the fix. It has a Validation section that lists the checks run with results, the checks not run (Windows, macOS, real Codex or provider), and the 21 pre-existing failures. The template asks for an issue link only for features, and this is a fix, so no link is needed. The description does not mention the changelog entry in changelog.d/, which CONTRIBUTING.md requires, and it does not mention contract-test coverage. These are minor gaps.
Finishing Touches
Generate unit tests (beta)
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.
Reviewing files that changed from the base of the PR and between 667f86f and 776c98c.
Files selected for processing: 3
changelog.d/herdr-core-attach-paint-frame.md
src/lib/inputRow.test.ts
src/lib/inputRow.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Blocked from merging after an adversarial review (codex exec, gpt-6.2-sol-fast, xhigh) reproduced a HIGH regression and three MEDIUM issues on current main (c50894a0c):
HIGH — Truncated 128 KiB replay can bypass Claude manual hold
When a pane's replay buffer truncates (server/output-window.ts:163-189, server/core/terminals.ts:375-391), OutputWindow.text() prepends saved private modes including an unmatched CSI ? 2026 l before the truncated tail (which may have dropped an unchanged esc to interrupt row while keeping the empty composer and background-agent notice).
On main, that leading ?2026l marks FrameGate as synchronized and keeps the truncated replay from settling until the requested repaint arrives, so useComposerSends.ts:123 keeps a working Claude pane on hold when autoSendQueued is off.
With this patch, the unmatched ?2026l no longer marks synced, so the truncated replay settles as a complete screen and useComposerSends.ts:123 upgrades delivery to immediate on a working Claude pane with manual hold enabled.
MEDIUM — Multi-chunk (<= 16 KiB) herdr-core attach paint can prematurely close a watched Codex peek
When herdr-core splits an attach paint across chunks (server/herdr-core/core.fake.ts:28), settling each non-synchronized chunk lets the history-only chunk read as gone (arming usePeekReturn, src/lib/usePeekReturn.ts:63) and the next chunk read the unchanged composer as ready, auto-closing a watched /permissions peek before the command screen opens.
MEDIUM — Combined private-mode sequence CSI ?25;2026h is missed
SYNC = /\u001b\[\?2026([hl])/g (src/lib/inputRow.ts:50) misses combined parameters like CSI ?25;2026h that xterm honors for synchronized output, allowing an unfinished frame to settle while xterm still has synchronized output active.
MEDIUM — Same-channel recovery after resize still leaves the input row unknown
When herdr-core repaints on an existing channel after an upstream reconnect following a resize (server/herdr-core/adapter.test.ts:363, src/lib/useTerminalMount.ts:1322), FrameGate is not reset, so a stream that previously saw ?2026h stays unknown through the non-synchronized recovery paint.
To address the attach-paint bug safely without regressing truncated replays or multi-chunk attach paints, the gate needs to distinguish a complete attach paint from a truncated replay tail (and handle combined ?2026 mode parameters).
Merged main (55859eeb1) and pushed follow-up df10eeda5 addressing the Codex adversarial review (gpt-6.2-sol-fast, xhigh) findings directly on the PR branch:
Truncated 128 KiB replay guard (src/lib/inputRow.ts, server/output-window.ts): Keep unmatched CSI ? 2026 l outside a herdr-core paint marking the stream as synchronized so a truncated replay cannot settle as a complete screen and bypass Claude's manual hold. In ReplayBuffer, never restore ?2026h across a truncation boundary (restoring ?2026l instead when ?2026h was cut) and ignore unmatched ?2026l from a plain herdr-core stream that never opened a synchronized block.
Multi-chunk 16 KiB herdr-core attach paint framing (src/lib/inputRow.ts, server/herdr-core/attach-session.ts): Track herdr-core paints from CAN + DECSTR (\x18\x1b[!p) through CSI ? 9001 [hl] so intermediate history chunks stay unboundary and cannot transiently read gone and arm/close a watched peek. Insert FOCUS_ON (\x1b[?1004h) inline right after FOCUS_OFF (\x1b[?1004l) rather than appending at the end of a chunk, so a \x1b[?9001l terminator split across a 16 KiB chunk boundary is never broken.
Same-channel recovery paints & resize guard (src/lib/inputRow.ts): Clear prior synchronized state only when a CAN + DECSTR … CSI ? 9001 [hl] paint both starts and finishes on the current epoch and matching grid geometry, so same-channel recovery paints settle without an external gate.reset() while stale recovery paints crossing a resize cannot consume reflowing.
Combined private modes & terminal resets (src/lib/inputRow.ts): Replace the exact \x1b[?2026[hl] regex with a streaming CSI private-mode scanner that handles combined mode lists (e.g. CSI ?25;2026h / l, zero-padded params, subparameters, xterm 6's 32-parameter cap) across arbitrary chunk splits, and clears synchronized state on RIS (ESC c) and standalone DECSTR (CSI ! p) like xterm 6.
Verification: Verified new regression tests failed on original PR code (776c98cbe) before the fix; after the fix, all 343 targeted tests (inputRow.test.ts, attach-session.test.ts, output-window.test.ts, usePeekReturn.hook.test.ts, usePaneAttach.hook.test.ts, src/conventions.test.ts, server/conventions.test.ts) and bun run typecheck pass.
Merged through pr-merge at head 26a284af3. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit said it did not review (a limit or a skip) since this head.
outside contributor; maintainer fixed review findings; reviews: CodeRabbit + Codex adversarial review (gpt-6.2-sol-fast, xhigh, all HIGH/MEDIUM/LOW findings fixed and verified); on owner/Dori word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
On a herdr-core server the page never read an agent's input row after attaching until the agent drew again.
herdr-core's attach paint opens with
CAN,DECSTR(CSI ! p) andCSI ? 2026 l, to reset the viewer, and thenpaints the screen outside any synchronized update.
FrameGate(src/lib/inputRow.ts) marked the stream as one drawnin synchronized blocks at any
?2026, so it then waited for a whole block opened after the reset: the paint neversettled, and
inputRowNow()stayedunknownuntil the program drew a synchronized frame of its own.What it showed: Codex at rest draws nothing after an attach, so the composer's effort button's
/modelwent with itsrow unread, and Back to Chat over the list left no "/model is still open in the terminal" note (the server's
agent_blockedrefusal still kept the message). A shell, which draws no blocks, was never read at all.The fix: only
CSI ? 2026 hmarks the stream as drawn in blocks; an end that closes no block frames nothing, as for aterminal (xterm.js's reset of mode 2026 only clears
synchronizedOutput, already off, and refreshes). herdr's ownframes, each
h … l, settle as before; the existingFrameGatecases pass unchanged. No UI of its own: the note andthe peek's return are the existing ones, now reached on herdr-core as on herdr.
Validation
In the CI runner image (
scripts/self-hosted-runner/Dockerfilebuilt locally on 2026-11-20, before #4419 changed it for theRust PTY host's slots, which these checks do not use; Bun 1.4.4), on a fresh clone of the branch:
bun run check run bun test src/lib/inputRow.test.tson the branch rebased onto main4640b69d: 238 pass. Control, the oldline put back with the new tests kept: the two new
FrameGatecases fail.bun run check fast: workflow syntax, generated files, typecheck and build ok; unit 22191 pass, 21 fail, 65 skip. The21 are the same as on main
119b36e2in the same image (22189 pass, 21 fail):scripts/plugin.test.ts(18),scripts/relay-ios-sim.test.ts(2) andserver/account/step2-upgrade-matrix.test.ts(1).BROWSER_SCRIPTS=… bun run check run -- bun scripts/ci-browser-parallel.ts):command-outcome-demo-regression.tsandterminal-autoswitch-demo-regression.ts, 2/2pass.
On a real herdr-core 0.1.21 server, from a downstream build with the same change (a Codex stand-in at rest that draws each
screen in a synchronized update, as Codex does): the effort button's
/model, then Back to Chat over the list, shows"/model is still open in the terminal" at 860×954 and 412×915 touch, and the message stays unsent; with the old line
built, the same run times out waiting for the note.
Not run: Windows, macOS, a real Codex or provider.
🤖 Generated with Claude Code