Skip to content

fix(terminal): herdr-core default pictures draw from the first output; switch follows the terminal - #3195

Merged
devswha merged 3 commits into
mainfrom
fix/terminal-pictures-default
Nov 6, 2026
Merged

devswha merged 3 commits into
mainfrom
fix/terminal-pictures-default

Conversation

@devswha

@devswha devswha commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Fixes #3184. Also covers the CodeRabbit note on #3171 (src/components/SettingsDialog.tsx, Pictures switch).

Problem

With no Pictures choice stored on the device, herdr-core turns pictures on by default (settings.terminalImages ?? terminalHistory). terminalHistory is React state set once the server lists terminal-history, and the image addon is a lazy chunk imported from an effect after that. The attach replay arrives in the meantime, so xterm parsed a sixel/iTerm2 picture in a pane's first output before the addon existed and dropped it.

Settings showed the switch from the health read (shownHerdr.runtime === "herdr-core"). When that read fails, or names herdr while the terminal connection lists terminal-history, the switch showed off while the terminal drew pictures.

Fix

  • src/lib/terminalImages.ts: holdForPictures(terminal, data, resume). When pictures are wanted and the addon is not on yet, output that may hold a picture waits until useTerminalImages turns pictures on or off for that terminal. That covers a DCS, an OSC 1337, or a frame ending in a split OSC 1337 introducer (ESC ], ESC ]1, ESC ]13, ESC ]133). The import failing, the effect cleaning up, or 1 s passing releases it. While output is held, every queued frame, and every frame that arrives meanwhile, is acknowledged (pty-ack) at once, as xterm's own write buffer would take it. The server's output-stall stop (OUTPUT_STALL_MS, 2 s) therefore never sees the wait. After a timeout that terminal never waits again, so a stalled chunk fetch cannot stop a pane's output.
  • src/lib/useTerminalMount.ts: the output queue calls it before each write. "Wanted" is computed synchronously as the stored choice, else socket.hasTerminalHistory(), so there is no state-to-effect gap. A pane switch while output is held still drops the queued frames as before. The OSC 52 replay guard reads the parser state, because nothing is parsing while output is held.
  • src/App.tsx: when no choice is stored, the switch shows on whenever the terminal connection has terminal-history (the same fact PaneTerminal uses). It falls back to the health read only until the connection has listed its features.

Output from herdr, output with no picture sequence, and terminals with pictures turned off are never held.

Tests

scripts/terminal-images-demo-regression.ts gets two new cases with nothing stored on the device:

  • herdr-core (terminal-history listed): a picture in the attach's first replayed output is drawn, a later one is drawn, and the switch shows on even though the demo's health names herdr.
  • herdr: no picture is drawn and the switch shows off.

Failing first on main c46dd12: the first-output picture assertion failed (pixel null). With only the App change reverted, the switch assertion failed.

Validation

  • bun run check fast: pass (12797 unit tests, typecheck, build).
  • In herdr-ci-runner:local: terminal-images, terminal-ghostty, core-history-scroll, replay-clipboard, terminal-view-replay, terminal-early-keys, terminal-release-no-watch, terminal-paste-insert, terminal-autoswitch and terminal-keyboard demo regressions all PASS. After the review round, check fast and the first five were re-run, and they still pass.
  • Skipped: the full integration suite and the full browser suite (left to CI).

No new controls. The composer UI is unchanged.

Review rounds

  • omo: CLEAR at b85bffd, 3298b1d and cc9ebe4.
  • Codex (gpt-6.1-terra xhigh), round 1:
    • HIGH: the hold kept frames unacknowledged long enough to reach the server's stall stop.
    • MEDIUM: an introducer split across frames bypassed the hold.
    • LOW: the switch fell back to health while terminal-history was already set.
  • Fixes: held frames are now acknowledged at once (3rd commit), split ESC ]1337 introducers are held, and hasTerminalHistory() wins.
  • Codex round 2 flagged a bare trailing ESC delaying ordinary output. The bare ESC match was removed.
  • Final Codex check at cc9ebe4: the HIGH is closed, the ack order and lifecycle are sound, and there is no new HIGH.

…ut, and show the switch from the terminal

Output that may hold a picture waits (bounded) for the image addon when pictures are wanted, and the Settings switch follows the terminal connection's terminal-history instead of the health read. Fixes #3184.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c46dd12 and cc9ebe4.

Files selected for processing: 6

  • changelog.d/terminal-pictures-default-first-output.md
  • scripts/terminal-images-demo-regression.ts
  • src/App.tsx
  • src/components/PaneTerminal.tsx
  • src/lib/terminalImages.ts
  • src/lib/useTerminalMount.ts
  • 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

@devswha

devswha commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Review notes at cc9ebe4 (omo CLEAR; final Codex check found no HIGH). Left as is, with no follow-up issue because neither was reproduced:

  • MEDIUM (Codex, simulated only): while output waits for the picture addon, frames are acknowledged and queued with no byte cap. The wait lasts at most 1 s, and only once per terminal before the addon's first load. A program writing very fast for that whole second leaves a backlog. If xterm then took longer than the 2 s stall deadline to parse it, new unacknowledged output could still reach the server's stop. This was not reproduced in a browser: Codex ran an OutputWindow simulation only.
  • LOW: a sixel DCS split between ESC and P across two frames is not held. A frame ending in a bare ESC is usually a key sequence, and holding it delayed ordinary output.

scripts/output-browser-qa.ts fails the same way on main's src (strict-mode match on "Terminal output stopped..."), so that failure predates this PR.

@devswha

devswha commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit did not review this PR: its review limit was reached. The omo review (CLEAR at cc9ebe4) and three Codex passes stand in; their findings and how each was resolved are in the PR body and the comment above.

@devswha

devswha commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Merge note (merge pass) at head cc9ebe4:

  • Merged on GitHub's required checks, all green on this head (Fast checks, Integration and browser, Native Windows install).
  • omo review receipt: CLEAR at this exact head. Unresolved review threads: 0 (GraphQL). CodeRabbit: neutral; no CodeRabbit review ran on this head.
  • Fixes Terminal pictures default on herdr-core: add a no-stored-choice regression and check the first output #3184: on herdr-core a picture in a pane's first output is drawn with no stored choice (it waits up to 1 s for the image addon; frames are pty-acked), and the Pictures switch follows the terminal connection. Failing-first regression; terminal path, so merged on GitHub's required checks. Codex HIGH/MEDIUM/LOW fixed, final check no HIGH.

@devswha
devswha merged commit 6dfcc17 into main Nov 6, 2026
18 checks passed
@devswha
devswha deleted the fix/terminal-pictures-default branch November 6, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal pictures default on herdr-core: add a no-stored-choice regression and check the first output

1 participant