Fix #1452: Piped sync child leaves colorizeStderr mid-line after the send confirm, so the next diagnostic line loses its severity colour - #1461
Open
philcunliffe wants to merge 3 commits into
Open
Conversation
…rizer can trust The wizard pipes `hyp sync` so it can read the child's words, which turns off the child's own painting; the parent's colorized stderr is then the only painter left. The send confirm ends without a newline and its answer is echoed by the tty, not by that stream, so `paintChunk`'s line-start gate left the next diagnostic plain. `colorizeStderr` gains `resyncLineStart`, and the echo calls it on the chunk that follows an unterminated one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Feature or issue
Since PR #1448 the wizard's sync step spawns
hyp syncwith a piped stderr, which turns off the child's own painting (useColoris false on a pipe), leaving the parent'scolorizeStderras the only painter. That wrap infers the cursor from its own writes, but the child's send confirm ends without a newline and the answer, plus the newline the tty echoes beside it, never passes through the wrap. The wrap therefore still believes it is mid-question when the child's next diagnostic arrives, andpaintChunk's line-start gate leaves it plain:hyp sync: nothing was sent - the sink driver is holding every tickreached the terminal red understdio: 'inherit'and unpainted afterwards. Reverting only thesrc/half of this branch reproduces it exactly, with the new wizard test asserting the redhyp sync:prefix and receiving the bare text.Solution
colorizeStderrgains a symbol-keyed hook andstyle.jsexportsresyncLineStart(stream), which tells a wrap the terminal is back at a line start. It is a no-op on an unwrapped stream, which is every stream that was not painting anyway.runSyncChildecho loop tracks whether the chunk it last relayed ended without a newline and resyncs before writing the next one, so the diagnostic that follows an answered confirm is classified again.src/files reverted to their pre-fix content the new wizard test fails on the missing SGR prefix and the style test file fails to load; with the fix restored all 42 tests in the two files pass. Fullnpm testandnpm run typecheckshow no new failures (the two hyparquet-pin test failures and thesquirrelingtype error are present on master without this branch).Code: +37 / -5 lines
Fixes #1452