Skip to content

fix(ui): improve Markdown text color, code block dimming, and border visibility#233

Draft
LifeJiggy wants to merge 1 commit into
MoonshotAI:mainfrom
LifeJiggy:fix/markdown-heading-levels-theme
Draft

fix(ui): improve Markdown text color, code block dimming, and border visibility#233
LifeJiggy wants to merge 1 commit into
MoonshotAI:mainfrom
LifeJiggy:fix/markdown-heading-levels-theme

Conversation

@LifeJiggy
Copy link
Copy Markdown

Problem

Issue #209 reports incomplete Markdown rendering in the TUI: headings, bold, lists, and code blocks displayed as raw source instead of styled output.

Root Cause

  1. Missing default text style: AssistantMessageComponent passed no defaultTextStyle to pi-tui's Markdown component, so plain paragraph text used the terminal's default foreground color instead of the theme's text color.
  2. Unstyled code blocks: highlightCode fallback for unknown fence languages returned raw text without any styling.
  3. Subtle code block borders: codeBlockBorder used the textMuted color, making code block fences hard to distinguish.

Changes

1. Default text style (assistant-message.ts)

Pass a DefaultTextStyle with color: chalk.hex(colors.text) to the Markdown component so all plain text inherits the correct theme foreground color.

2. Dimmed code block fallback (pi-tui-theme.ts)

When highlightCode encounters an unknown or missing fence language, apply textDim styling to the lines instead of returning raw unstyled text. Known languages continue to be syntax-highlighted via cli-highlight.

3. Visible code block borders (pi-tui-theme.ts)

Changed codeBlockBorder from textMuted to textDim for better visibility against surrounding content.

Tests

Added tests verifying:

  • Unknown fence languages produce no stderr noise
  • Headings render without raw # prefix
  • Bold text renders without raw ** markers
  • Lists render without raw - markers

Closes #209

…visibility

Apply default text color to plain paragraph content via defaultTextStyle,
improve highlightCode fallback to dim unknown-language code blocks,
and use textDim for code block borders instead of textMuted.

Adds tests for headings, bold, lists to verify no raw markdown syntax
leaks into rendered output.

Closes MoonshotAI#209.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: 0b9849e

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b9849eaef

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

this.contentContainer.clear();
if (displayText.trim().length > 0) {
this.contentContainer.addChild(new Markdown(displayText.trim(), 0, 0, this.markdownTheme));
this.contentContainer.addChild(new Markdown(displayText.trim(), 0, 0, this.markdownTheme, this.defaultTextStyle));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Invalidate assistant markdown on theme changes

When an assistant message has already rendered, this Markdown instance keeps its cached output and pi-tui also caches the default style prefix derived from this new defaultTextStyle; checked applyTheme in apps/kimi-code/src/tui/kimi-tui.ts, and it only mutates state.theme.colors plus requests a redraw, without invalidating/recreating transcript children. In the theme-switch path, existing assistant messages with plain or inline-formatted text therefore keep the old ANSI foreground color until their content changes or the component is rebuilt. Please ensure theme changes invalidate/recreate these Markdown instances (and their default style prefix) for existing assistant transcript entries.

Useful? React with 👍 / 👎.

@LifeJiggy LifeJiggy marked this pull request as draft May 29, 2026 16:56
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.

[Bug] TUI Markdown rendering incomplete: only tables rendered, other elements shown as raw source

1 participant