Strip all ANSI control sequences in bounded terminal output buffer - #1266
Open
nordicnode wants to merge 1 commit into
Open
Strip all ANSI control sequences in bounded terminal output buffer#1266nordicnode wants to merge 1 commit into
nordicnode wants to merge 1 commit into
Conversation
- Switch BoundedOutputBuffer.append from stripColors to stripAnsi in sdk/src/tools/run-terminal-command.ts. - Update INCOMPLETE_ESCAPE_SEQUENCE_REGEX to correctly match split ECMA-48 CSI and OSC sequences across chunk boundaries. - Rename internal tracker pendingColorSequence to pendingEscapeSequence. - Add unit tests in sdk/src/__tests__/run-terminal-command.test.ts verifying stripping of line erases, cursor movement, cursor visibility, and chunk-split sequences.
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.
Summary
BoundedOutputBuffer.appendfromstripColorstostripAnsiinsdk/src/tools/run-terminal-command.ts.INCOMPLETE_ESCAPE_SEQUENCE_REGEXto match split ECMA-48 CSI (\x1b[...) and OSC (\x1b]...) sequences across chunk boundaries.pendingColorSequencetopendingEscapeSequence.sdk/src/__tests__/run-terminal-command.test.tsverifying that line clears (\x1b[2K), cursor movement (\x1b[1A), and cursor visibility (\x1b[?25h/\x1b[?25l) are cleanly stripped, including across chunk boundaries.Test plan
[✓]
bun test --config=/dev/null --preload test/setup-env.ts src/__tests__/run-terminal-command.test.ts[✓]
bun run build:sdk[✓]
bun run --cwd cli typecheck[✓]
bun freebuff/cli/build.ts 0.0.0-ci[✓]
bun cli/scripts/smoke-binary.ts cli/bin/freebuff[✓] PR hygiene check passed