Skip to content

Strip all ANSI control sequences in bounded terminal output buffer - #1266

Open
nordicnode wants to merge 1 commit into
CodebuffAI:mainfrom
nordicnode:fix-strip-all-ansi-control-sequences
Open

Strip all ANSI control sequences in bounded terminal output buffer#1266
nordicnode wants to merge 1 commit into
CodebuffAI:mainfrom
nordicnode:fix-strip-all-ansi-control-sequences

Conversation

@nordicnode

Copy link
Copy Markdown

Summary

  • Switch BoundedOutputBuffer.append from stripColors to stripAnsi in sdk/src/tools/run-terminal-command.ts.
  • Update INCOMPLETE_ESCAPE_SEQUENCE_REGEX to match split ECMA-48 CSI (\x1b[...) and OSC (\x1b]...) sequences across chunk boundaries.
  • Rename internal tracker pendingColorSequence to pendingEscapeSequence.
  • Add unit tests in sdk/src/__tests__/run-terminal-command.test.ts verifying 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

- 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.
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.

1 participant