Skip to content

feat(cli): highlight fenced code in live and detailed transcripts - #6307

Open
HuYellow wants to merge 3 commits into
apache:mainfrom
HuYellow:codex/feat-5083-tui-code-highlighting
Open

HuYellow wants to merge 3 commits into
apache:mainfrom
HuYellow:codex/feat-5083-tui-code-highlighting

Conversation

@HuYellow

Copy link
Copy Markdown
Contributor

Summary

Enable syntax highlighting for tagged Markdown code blocks in both the live TUI conversation and the detailed transcript reader. The shared Markdown hook supports 18 languages and explicit aliases, uses Maka's terminal color policy, and preserves stored message text. Unknown languages, formatter failures, and blocks over 4,096 UTF-16 code units render as plain code.

Continue the implementation from the stale-closed #5126, retaining @yuzhiyang1's original two commits and attribution. This revision adds documented language/fallback behavior, bounds synchronous work for streaming fences, and fixes ANSI whitespace classification and extra blank rows in the existing pi-tui patch so narrow wrapping matches the plain-code baseline.

Fixes #5083

Verification

  • Full npm run build, npm run typecheck, npm run lint, npm run format:check, and Desktop/UI Knip checks passed on Node 24.22.1, rebased onto d41baadba.
  • Affected transcript, detailed-reader, highlighting, and ANSI suites: 144 passed, 2 platform skips, 0 failed. Coverage includes all languages/aliases, source preservation, color capabilities, open/closed fences, and complete before/after rows at widths 8/24/40/100. Removing the shared hook causes the regression suite to fail.
  • Release file-policy and TUI-copy tests: 23 passed. TUI copy, CLI third-party notices, ASF headers, and whitespace checks passed.
  • The filtered highlight.js runtime closure imports independently of the checkout and loads all 18 grammars. The complete pi-tui patch applies to a pristine official npm tarball; 40 independent ANSI/plain wrapping comparisons passed.
  • Full npm test and installed-package/platform smoke tests were not run. The general dependency-patch fixture suite encounters Windows EPERM while creating a symlink; the clean-tarball patch verification above passed.

The images below are generated terminal renders from the actual production ANSI output, with the same Markdown and both transcript surfaces. They are not shell screenshots. Captured source, visible text, and hashes confirm unchanged source and identical visible rows.

Before

Plain code in live and detailed transcripts

After

Highlighted code in live and detailed transcripts

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex assisted with the original implementation and this continuation, including code, regression tests, validation, terminal evidence, and PR preparation. This PR is submitted at @HuYellow's direction. The original implementation by @yuzhiyang1 is retained with its commit authorship. All contribution commits carry Generated-by: OpenAI Codex; please retain that trailer when squash-merging. Automated review does not replace independent human review.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

yuzhiyang1 and others added 3 commits October 26, 2026 15:51
Generated-by: OpenAI Codex
(cherry picked from commit 394021d)
Generated-by: OpenAI Codex
(cherry picked from commit 4ce9d18)
Limit synchronous syntax work, retain code text and rows across terminal widths, and document the supported language policy.

Generated-by: OpenAI Codex
@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Oct 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tui): add syntax highlighting to Markdown code blocks

2 participants