@@ -12,6 +12,100 @@ import type {
1212 ThemeName ,
1313} from '../types/theme-system'
1414
15+ /**
16+ * Check if the terminal supports truecolor (24-bit color).
17+ * Terminals like macOS Terminal.app only support 256 colors and cannot
18+ * render hex colors properly - they need ANSI color name fallbacks.
19+ */
20+ // Cache the truecolor support result since it won't change during runtime
21+ let _truecolorSupport : boolean | null = null
22+
23+ export function supportsTruecolor ( env : CliEnv = getCliEnv ( ) ) : boolean {
24+ if ( _truecolorSupport !== null ) {
25+ return _truecolorSupport
26+ }
27+
28+ const termProgram = env . TERM_PROGRAM ?. toLowerCase ( ) ?? ''
29+
30+ // Terminal.app (Apple_Terminal) does NOT support truecolor - only 256 colors
31+ if ( termProgram === 'apple_terminal' ) {
32+ _truecolorSupport = false
33+ return false
34+ }
35+
36+ const colorterm = env . COLORTERM ?. toLowerCase ( )
37+ if ( colorterm === 'truecolor' || colorterm === '24bit' ) {
38+ _truecolorSupport = true
39+ return true
40+ }
41+
42+ // Some terminals that are known to support truecolor
43+ const truecolorTerminals = [
44+ 'iterm.app' ,
45+ 'hyper' ,
46+ 'wezterm' ,
47+ 'alacritty' ,
48+ 'kitty' ,
49+ 'ghostty' ,
50+ 'vscode' ,
51+ ]
52+
53+ if ( truecolorTerminals . some ( t => termProgram . includes ( t ) ) ) {
54+ _truecolorSupport = true
55+ return true
56+ }
57+
58+ // Check TERM for known truecolor-capable values
59+ const term = env . TERM ?. toLowerCase ( ) ?? ''
60+ if ( term . includes ( 'truecolor' ) || term . includes ( '24bit' ) ) {
61+ _truecolorSupport = true
62+ return true
63+ }
64+
65+ // xterm-kitty, alacritty, etc.
66+ if ( term === 'xterm-kitty' || term === 'alacritty' || term . includes ( 'ghostty' ) ) {
67+ _truecolorSupport = true
68+ return true
69+ }
70+
71+ _truecolorSupport = false
72+ return false
73+ }
74+
75+
76+
77+ /**
78+ * Get the block color for the logo based on theme and terminal capabilities.
79+ * In dark mode: white (#ffffff or 'white')
80+ * In light mode: black (#000000 or 'black')
81+ */
82+ export function getLogoBlockColor (
83+ themeName : ThemeName ,
84+ env : CliEnv = getCliEnv ( ) ,
85+ ) : string {
86+ const isTruecolor = supportsTruecolor ( env )
87+ if ( themeName === 'dark' ) {
88+ return isTruecolor ? '#ffffff' : 'white'
89+ }
90+ return isTruecolor ? '#000000' : 'black'
91+ }
92+
93+ /**
94+ * Get the accent color for the logo based on theme and terminal capabilities.
95+ * Returns the primary green color with appropriate fallback.
96+ */
97+ export function getLogoAccentColor (
98+ themeName : ThemeName ,
99+ env : CliEnv = getCliEnv ( ) ,
100+ ) : string {
101+ const isTruecolor = supportsTruecolor ( env )
102+ // The primary green color - 'lime' is CSS bright green
103+ if ( themeName === 'dark' ) {
104+ return isTruecolor ? '#9EFC62' : 'lime'
105+ }
106+ return isTruecolor ? '#65A83E' : 'green'
107+ }
108+
15109const IDE_THEME_INFERENCE = {
16110 dark : [
17111 'dark' ,
0 commit comments