Skip to content

VS Code extension: webview renders in light theme under dark high-contrast color themes #2158

Description

@Tolik-Trek

What version of Kimi Code is running?

moonshot-ai.kimi-code 0.6.4

Which open platform/subscription were you using?

Allegretto

Which model were you using?

No response

What platform is your computer?

No response

What issue are you seeing?

Summary

When VS Code is set to a dark high-contrast color theme (e.g. the built-in "Dark High Contrast"), the Kimi Code panel renders with a light (white) UI instead of a dark one.

Environment

  • Extension: moonshot-ai.kimi-code v0.6.3 / v0.6.4 (win32-x64, but platform-independent)
  • VS Code: 1.100+
  • OS: Windows (likely affects all platforms)

Root cause

The theme-detection code in the webview bundle only recognizes the vscode-dark body class:

function mU() {
  const e = document.body.classList.contains("vscode-dark");
  document.documentElement.classList.toggle("dark", e);
}
mU(),
new MutationObserver(mU).observe(document.body, { attributes: !0, attributeFilter: ["class"] });

VS Code sets one of these classes on the webview <body>:

VS Code theme kind Body class
Light vscode-light
Dark vscode-dark
Dark High Contrast vscode-high-contrast
Light High Contrast vscode-high-contrast-light

Under a dark high-contrast theme the body gets vscode-high-contrast, which contains("vscode-dark") does not match, so the dark class is removed from <html> and the app falls back to its light palette.

Proposed fix

Treat vscode-high-contrast as a dark theme (light high-contrast already falls through correctly):

const isDark =
  document.body.classList.contains("vscode-dark") ||
  document.body.classList.contains("vscode-high-contrast");
document.documentElement.classList.toggle("dark", isDark);

I verified this locally by patching the bundled dist/webview.js — the panel then renders dark under Dark High Contrast, and light/high-contrast-light themes still render light. The existing MutationObserver keeps live theme switching working.

A possible follow-up (out of scope for this fix): a dedicated high-contrast palette for the webview instead of reusing the regular dark palette, e.g. by honoring vscode-high-contrast / vscode-high-contrast-light classes with higher-contrast tokens.

What steps can reproduce the bug?

Steps to reproduce

  1. In VS Code: Ctrl+K Ctrl+T → select Dark High Contrast (or any dark high-contrast theme).
  2. Open the Kimi Code panel.

Expected: the webview renders its dark theme.
Actual: the webview renders its light theme (all white).

What is the expected behavior?

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions