fix(ui): improve Markdown text color, code block dimming, and border visibility#233
fix(ui): improve Markdown text color, code block dimming, and border visibility#233LifeJiggy wants to merge 1 commit into
Conversation
…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 detectedLatest commit: 0b9849e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
💡 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)); |
There was a problem hiding this comment.
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 👍 / 👎.
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
AssistantMessageComponentpassed nodefaultTextStyleto pi-tui'sMarkdowncomponent, so plain paragraph text used the terminal's default foreground color instead of the theme's text color.highlightCodefallback for unknown fence languages returned raw text without any styling.codeBlockBorderused thetextMutedcolor, making code block fences hard to distinguish.Changes
1. Default text style (
assistant-message.ts)Pass a
DefaultTextStylewithcolor: chalk.hex(colors.text)to theMarkdowncomponent so all plain text inherits the correct theme foreground color.2. Dimmed code block fallback (
pi-tui-theme.ts)When
highlightCodeencounters an unknown or missing fence language, applytextDimstyling to the lines instead of returning raw unstyled text. Known languages continue to be syntax-highlighted viacli-highlight.3. Visible code block borders (
pi-tui-theme.ts)Changed
codeBlockBorderfromtextMutedtotextDimfor better visibility against surrounding content.Tests
Added tests verifying:
#prefix**markers-markersCloses #209