Skip to content

fix: replace chalk.yellow with theme-aware hex in session-directory warning#229

Open
LifeJiggy wants to merge 2 commits into
MoonshotAI:mainfrom
LifeJiggy:fix/named-color-violation-tui
Open

fix: replace chalk.yellow with theme-aware hex in session-directory warning#229
LifeJiggy wants to merge 2 commits into
MoonshotAI:mainfrom
LifeJiggy:fix/named-color-violation-tui

Conversation

@LifeJiggy
Copy link
Copy Markdown

Related Issue

Resolve #177

Problem

kimi-tui.ts used chalk.yellow (a named chalk color) to render a session-directory mismatch warning. Named chalk colors bypass the theme system, so the warning does not respond to theme switches and may have poor contrast in light mode.

The same pattern existed in run-prompt.ts.

What changed

  1. kimi-tui.ts — replaced chalk.yellow(...) with chalk.hex(this.state.theme.colors.warning)(...), making the warning respect the active theme's color palette.
  2. run-prompt.ts — replaced chalk.yellow(...) with chalk.hex('#E8A838')(...) for the same warning message (CLI code has no theme access).
  3. Chalk named-color guard test — added a CI-enforceable guard that scans all production source files under apps/kimi-code/src/ for chalk.<named_color>( patterns and rejects them, preventing regressions.
  4. Theme color tests — added tests verifying ColorPalette.warning exists in both themes, and ThemeStyles.warning() correctly wraps text.

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
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: a3db91c

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: e4120b6f0e

ℹ️ 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".

@@ -0,0 +1,39 @@
import { describe, expect, it } from 'vitest';
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 Move the theme assertions into an existing suite

The local apps/kimi-code/AGENTS.md test placement rule says not to create a generic feature test just to land a small change; this new top-level theme-colors.test.ts only checks existing theme exports/helpers and duplicates coverage that can live with the existing TUI/theme-related tests. Keeping it as a separate generic file makes the test tree noisier and violates that directory's documented maintenance rule, so please fold these assertions into the corresponding existing theme/TUI state suite instead.

Useful? React with 👍 / 👎.

… guard test bugs

- Move theme-colors.test.ts assertions into existing terminal-theme.test.ts to
  avoid a generic feature test file (Codex P2)
- Fix chalk-named-color-guard.test.ts:
  - Replace require('fs') with ESM import (readdirSync) (P1)
  - Fix over-broad comment-skip logic — use proper inBlockComment state
    tracker instead of line.includes('*') which silently skipped valid
    code lines containing asterisks (P1)
  - Remove dead code (const entries = [['dir', '']]) (P2)
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: a3db91c748

ℹ️ 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".

if (target.workDir !== workDir) {
stderr.write(
`${chalk.yellow(
`${chalk.hex('#E8A838')(
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 Use a light-safe warning color for print mode

When kimi -p -r <session> hits the wrong-directory path on a light/white terminal, this hard-coded dark-theme warning color has only about 2.1:1 contrast against white; the palette already uses lightColors.warning (#92660A, about 5.1:1) for this case. Because print mode has no theme detection here, replacing ANSI yellow with the dark palette hex makes this warning difficult to read for light-terminal users instead of fixing the contrast problem.

Useful? React with 👍 / 👎.

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.

color issues

1 participant