Repository navigation
fix(herdr-core): read the screen's colors so Claude's grey suggestion is no draft - #2674
Conversation
|
Warning Review limit reachedYou'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 16 minutes. View limit details
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. CodeRabbit Verify
|
…lored trailing spaces
|
Review round 1 (omo and Codex adversarial, head 8139387). Here is what changed and why. Fixed
Not changed
Re-verified at the new head: |
|
CodeRabbit hit its review limit on this PR ("Review limit reached" at 8139387), so no CodeRabbit review ran. The omo review and a Codex adversarial review stand in; their findings and resolutions are in the comment above. |
|
omo re-review at cc77304: CLEAR. LOW and non-blocking items, left as follow-ups:
|
…echeck (#2693) ## Summary origin/main (12a7c63) fails `bun run typecheck` with four errors in `server/herdr-core/adapter.ts`. #2671 typed `HcConnection.call` and `open` by hc method name, generated from hc's own schema. #2674, merged right after it, added a `hc.open<{ channel: number; terminal?: HcTerminal }>("terminal.attach", ...)` and a `hc.call<{ text: string }>("terminal.read", ...)` written for the old untyped signature, where the type argument was the result type. This drops those two type arguments. The method name now types both calls: `terminal.attach` gives `AttachResult` (whose `terminal.rows` the code reads) and `terminal.read` gives `ReadResult` (whose `text` it reads). Nothing changes at runtime. No changelog fragment: users notice nothing. ## Validation - `bun run typecheck`: clean (four errors on main before). - `HERDR_TEST_MODE=unit bun test server/herdr-core`: 90 pass, 0 fail. - `bun run check fast`: not run locally. The heavy-run slots were all held by other lanes, so the lead chose to let CI's Fast checks gate this PR. - Not run: Integration and browser lanes, and Windows. CI runs them.
Fixes #2609
Problem
With
OVIS_RUNTIME=herdr-core, every Chat send to a Claude Code pane that showed a grey suggested prompt was held with "Not sent: Claude Code's input box in the terminal already holds …" and needed Clear it and send.The chat's box check tells Claude's grey (dim) suggestion apart from typed text by the colors of herdr's
visibleANSI read. The herdr-core adapter answered that read with hc'sterminal.read, which is plain text only, so every non-empty box counted as a draft.Fix
server/herdr-core/adapter.ts: apane.readwithformat: "ansi"andsource: "visible"now takes the screen's colors from the first paint of anobserve: trueattach. Such an attach never types or resizes, and it is closed as soon as the screen has arrived.paintedScreenturns that paint into the same window hc's own text read gives:rowslines of history for this.This matters because the server only uses the colors once their text equals the live screen (
viewportShowsLive, since herdr-core reports no scroll). Claude leaves a blank row under its footer once the chat has scrolled, and without the trimming and history alignment the colors were rejected in exactly that common case. A paint of an unexpected shape falls back to the plain text, which keeps the current behavior: the box counts as a draft.One limit remains: while a soft-wrapped line is on screen, hc's text read joins it with the next line but the paint does not. The texts then differ and the send waits for confirmation, as before. The guide now states that limit instead of "screen reads carry no colors".
Reproduction (origin/main 4bc043d)
This used a real hc 0.1.17 in an isolated core (mkdtemp
XDG_*/HOME, ownHC_SESSION/HC_SOCKET) with the herdr-core adapter on a temp socket. A terminal reportsapp=claude-codeand draws the recorded Claude Code 2.1.311 suggestion fixture (server/fixtures/claude-suggestion-2.1.311-119.ansi), and the script calls the chat send's box check,freeClaudeBox:refused: input_draft … | draft: "do it". The visible ANSI read carries no SGR.box check passed. This holds with no scrollback, 118 filler lines and 300 filler lines (blank cursor row under a scrolled screen).do itand Claude's cursor after it: stillrefused: input_draft | draft: "do it", so Clear it and send is offered as before.Validation
bun test server/herdr-core/: 84 pass, 5 skip, 0 fail. The new chat (herdr-core): Claude Code's grey prompt suggestion is read as typed text, so every send needs "Clear it and send" #2609 adapter test fails on main (the read is plain text) and passes here; others cover the plain-text fallback (no paint, stream ended) and colored trailing spaces.OVIS_TEST_HC_BIN=<hc 0.1.17> bun test server/herdr-core/live.test.ts: 3 pass against a real, isolated hc.bun run check fast: green (workflow syntax, generated types/themes, typecheck, build, unit tests).bun run check full, and a real Claude Code session (the recorded fixture stands in). Hermes' hint goes through the same verified-colors path (italic and background SGR survive in the paint), but it was not exercised.