Skip to content

fix(tui): remove red coloring from code syntax highlighting - #1995

Merged
liruifengv merged 1 commit into
mainfrom
fix/tui-code-highlight-no-red
Jul 21, 2026
Merged

fix(tui): remove red coloring from code syntax highlighting#1995
liruifengv merged 1 commit into
mainfrom
fix/tui-code-highlight-no-red

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

Code syntax highlighting in the TUI (Write/Edit tool previews, approval panels, and assistant markdown code blocks) renders strings, regular expressions, and diff-block deletions in red. This comes from cli-highlight's default theme, which maps those tokens to chalk.red. The result is alarm-red noise all over ordinary code output, and red should not appear in code highlighting at all.

What changed

  • Add a shared cli-highlight theme that resets exactly the three red tokens (string, regexp, deletion) to plain; every other token keeps the library default, so the rest of the highlighting is untouched.
  • Route both highlight paths — tool-call file previews and the pi-tui markdown highlightCode — through this theme so behavior is consistent.
  • Add tests asserting the three tokens are identity-styled and that, with colors forced on, highlighted JS strings/regexps and diff deletions emit no red SGR while keywords (blue) and diff additions (green) remain colored.

This approach fits Kimi Code because it keeps the change inside the theme layer (src/tui/theme/) as the single source of truth for color, without forking the highlight library or touching renderers.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2320152

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@2320152
npx https://pkg.pr.new/@moonshot-ai/kimi-code@2320152

commit: 2320152

@liruifengv
liruifengv merged commit 73eb5f8 into main Jul 21, 2026
15 checks passed
@liruifengv
liruifengv deleted the fix/tui-code-highlight-no-red branch July 21, 2026 04:54
@github-actions github-actions Bot mentioned this pull request Jul 21, 2026
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