Skip to content

Surface unknown ANSI escape sequences inline - #408

Merged
gbmhunter merged 3 commits into
mainfrom
feature/surface-unknown-escape-codes
Jun 28, 2026
Merged

Surface unknown ANSI escape sequences inline#408
gbmhunter merged 3 commits into
mainfrom
feature/surface-unknown-escape-codes

Conversation

@gbmhunter

Copy link
Copy Markdown
Owner

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 highlighted unknown-escape marker. Previously these were discarded silently (or logged only to DevTools).

Details

  • Setting showUnknownEscapeCodes (default OFF — behaviour unchanged until enabled), wired through RxSettings, RxSettingsData, and the settings UI (disabled unless ASCII + ANSI parsing on).
  • Parser (SingleTerminal): new _surfaceUnknownEscapeCode helper renders the raw sequence bytes (ESC shown as its control glyph) tagged unknown-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.
  • Styling: span.unknown-escape magenta highlight.
  • Migration: folded into the existing unreleased v20→v21 migration (no extra version bump).
  • Added 4 unit tests, a CHANGELOG entry, and a CLAUDE.md note about bumping the app data version only once per release.

Scope note

Non-CSI escapes (OSC ESC], charset ESC() already surface as raw glyphs via the existing max-length path and were left unchanged.

Testing

  • npx tsc clean
  • npm run test:unit — functional suite passes (253 tests), including 4 new surfacing tests and the migration round-trip. The one ansi-heavy perf-threshold miss is an environmental/loaded-machine artifact (all scenarios, including the untouched plain-ASCII path, came in uniformly slow), not a regression.

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).
@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

Deploy Preview for ninjaterm-docs canceled.

Name Link
🔨 Latest commit 055157d
🔍 Latest deploy log https://app.netlify.com/projects/ninjaterm-docs/deploys/6a40c63c53199b0008db3e4e

@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

Deploy Preview for ninjaterm-app canceled.

Name Link
🔨 Latest commit 055157d
🔍 Latest deploy log https://app.netlify.com/projects/ninjaterm-app/deploys/6a40c63c540e2d000892d0e8

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.
@gbmhunter gbmhunter self-assigned this Jun 28, 2026
@gbmhunter
gbmhunter merged commit 11850c3 into main Jun 28, 2026
16 checks passed
@gbmhunter
gbmhunter deleted the feature/surface-unknown-escape-codes branch June 28, 2026 07:58
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