Просмотр исходного кода

fix(tui): remove execSync theme detection, match main branch exactly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fanghanjun 7 месяцев назад
Родитель
Сommit
9f700b7e74
1 измененных файлов с 12 добавлено и 44 удалено
  1. 12 44
      packages/cli/src/tui/theme.ts

+ 12 - 44
packages/cli/src/tui/theme.ts

@@ -1,49 +1,17 @@
 /** Whether the terminal is macOS Terminal.app. */
 export const isAppleTerminal = process.env.TERM_PROGRAM === "Apple_Terminal";
 
-import { execSync } from "node:child_process";
+export const WARM_ACCENT = "#c88a56";
+export const WARM_MUTED = "#8f8374";
+export const WARM_REPLY = "#f0e6d8";
+export const WARM_BORDER = "#6b6156";
 
-type TerminalTheme = "dark" | "light";
+// Semantic status colors
+export const STATUS_SUCCESS = "#7ec87e";
+export const STATUS_ERROR = "#e06060";
+export const STATUS_ACTIVE = "#d4a76a";
+export const STATUS_IDLE = "#7a7268";
 
-/**
- * 1. $COLORFGBG (iTerm2, rxvt)
- * 2. macOS AppleInterfaceStyle (Terminal.app doesn't set COLORFGBG)
- * 3. Default: dark
- */
-function detectTerminalTheme(): TerminalTheme {
-  const raw = process.env.COLORFGBG;
-  if (raw) {
-    const parts = raw.split(";");
-    const bg = Number(parts[parts.length - 1]);
-    if (!Number.isNaN(bg)) {
-      return bg <= 6 || bg === 8 ? "dark" : "light";
-    }
-  }
-  // Only Terminal.app follows macOS system appearance; other terminals
-  // (Ghostty, kitty, etc.) have their own theme independent of the OS.
-  if (isAppleTerminal && process.platform === "darwin") {
-    try {
-      const result = execSync("defaults read -g AppleInterfaceStyle", {
-        encoding: "utf8", timeout: 500, stdio: ["pipe", "pipe", "pipe"],
-      }).trim();
-      return result === "Dark" ? "dark" : "light";
-    } catch {
-      return "light";
-    }
-  }
-  return "dark";
-}
-
-const isDark = detectTerminalTheme() === "dark";
-
-// Dark theme (original main-branch values)
-export const WARM_ACCENT = isDark ? "#c88a56" : "#8b5e3c";
-export const WARM_MUTED = isDark ? "#8f8374" : "#7a6e62";
-export const WARM_REPLY = isDark ? "#f0e6d8" : "#2a4a6a";
-export const WARM_BORDER = isDark ? "#6b6156" : "#b0a898";
-export const STATUS_SUCCESS = isDark ? "#7ec87e" : "#2e7d32";
-export const STATUS_ERROR = isDark ? "#e06060" : "#c62828";
-export const STATUS_ACTIVE = isDark ? "#d4a76a" : "#a06020";
-export const STATUS_IDLE = isDark ? "#7a7268" : "#908478";
-export const ROLE_USER = isDark ? "#a8c4d4" : "#3a6a8a";
-export const ROLE_SYSTEM = isDark ? "#b8a8d0" : "#5c4a80";
+// Role colors
+export const ROLE_USER = "#a8c4d4";
+export const ROLE_SYSTEM = "#b8a8d0";