Skip to content

feat(tui): highlight fenced code with terminal theme colors - #261

Merged
danielkov merged 1 commit into
mainfrom
feat/tui-syntax-highlighting
Oct 4, 2026
Merged

danielkov merged 1 commit into
mainfrom
feat/tui-syntax-highlighting

Conversation

@danielkov

Copy link
Copy Markdown
Contributor

Summary

Add syntax highlighting to TUI code fences, including TypeScript and TSX, using Syntect and Two-face. Syntax scopes map to Kit鈥檚 existing terminal palette rather than a bundled RGB theme; wrapping and source-copy ranges are preserved.

Impact

Unknown or explicitly plain-text languages retain the existing code style. Highlighting falls back to plain text for the remainder of a fence after a parser error or input limit: 4 KiB per line and 128 KiB of parsed code per document render. These are input limits, not a regex execution-time guarantee.

Technical details

Minimal TUI-only dependencies

Pin Syntect 5.3.0 and Two-face 0.5.2 with the pure-Rust fancy-regex backend. Do not enable Syntect鈥檚 bundled syntaxes/themes, HTML, YAML/plist loaders, or Oniguruma; only Two-face鈥檚 newline-aware syntax bundle is used. Headless builds exclude the added dependency versions.

The lockfile adds four package versions without upgrades, including fancy-regex 0.16.2 alongside the existing version and bincode 1.3.3. Bincode has an unmaintained advisory (RUSTSEC-2025-0141), not a reported vulnerability; this integration uses it only for compiled-in grammar data. Published archives and packaged sources were reconciled against registry checksums and upstream commits, with Two-face鈥檚 embedded payloads matched to upstream LFS hashes.

Fence-local parsing

Load the grammar set lazily and retain multiline parsing state within each fence. Streaming suffix rerenders reconstruct that state through the existing transcript cache path. Once parsing is skipped or fails, do not resume that fence with stale state.

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. The changes look good to merge.

@danielkov
danielkov merged commit dc3f3b8 into main Oct 4, 2026
6 checks passed
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