Surface unknown ANSI escape sequences inline - #408
Merged
Conversation
Add an opt-in RX "Show Unknown Escape Codes" setting that renders unsupported/malformed CSI sequences (e.g. ESC[K, ESC[6n, unsupported SGR codes) inline as a highlighted `unknown-escape` marker instead of silently dropping them, via SingleTerminal._surfaceUnknownEscapeCode. The setting is folded into the unreleased v20->v21 AppData migration and defaults to false, so existing behaviour is unchanged until enabled. Also document in CLAUDE.md that the app data version should only be bumped once per release (fold changes into the latest unreleased migration).
✅ Deploy Preview for ninjaterm-docs canceled.
|
✅ Deploy Preview for ninjaterm-app canceled.
|
Add a "unsupported escape codes" fake port that streams a rotating set of CSI sequences NinjaTerm doesn't support and auto-enables the new "Show Unknown Escape Codes" setting, for testing the surfacing feature in dev. Add a search box to the fake port selection dialog that filters the list by name/description. The filter preserves each port's original index so selection and openPort() keep working against the full array.
Each terminal char is its own span, so border-radius rounded every character's box — clipping glyph edges and splitting the marker into separate blocks. Square corners keep it a clean contiguous bar.
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
Adds support for troubleshooting ANSI escape sequences by making unknown sequences visible instead of silently dropping them.
A new opt-in RX setting, "Show Unknown Escape Codes", renders unsupported or malformed CSI sequences (e.g.
ESC[K,ESC[6n,ESC[?25h, unsupported SGR codes) inline in the terminal as a highlightedunknown-escapemarker. Previously these were discarded silently (or logged only to DevTools).Details
showUnknownEscapeCodes(default OFF — behaviour unchanged until enabled), wired throughRxSettings,RxSettingsData, and the settings UI (disabled unless ASCII + ANSI parsing on).SingleTerminal): new_surfaceUnknownEscapeCodehelper renders the raw sequence bytes (ESC shown as its control glyph) taggedunknown-escape, gated by the setting. Wired into unrecognized CSI final bytes, unsupported SGR codes, and unsupported/NaN ED + cursor-move params. The hot path stays allocation-free.span.unknown-escapemagenta highlight.v20→v21migration (no extra version bump).Scope note
Non-CSI escapes (OSC
ESC], charsetESC() already surface as raw glyphs via the existing max-length path and were left unchanged.Testing
npx tsccleannpm run test:unit— functional suite passes (253 tests), including 4 new surfacing tests and the migration round-trip. The oneansi-heavyperf-threshold miss is an environmental/loaded-machine artifact (all scenarios, including the untouched plain-ASCII path, came in uniformly slow), not a regression.