Skip to content

Commit 06fad42

Browse files
jimgqyuDeepSeek
andcommitted
fix: wire settings.theme to TUI via CODET_TUI_THEME env var
DEFAULT_THEME was determined solely by detectLightMode() which checks terminal env vars (COLORFGBG, TERM_PROGRAM) but never reads the user's explicit `theme` preference from settings.json. As a result, the TUI always used auto-detection regardless of what the user configured. Fix: set process.env.CODET_TUI_THEME from settings.theme before app.js loads (which triggers theme.ts module init). During `coder setup`, set it immediately after the user picks a theme so the post-setup TUI session uses the right theme. Co-Authored-By: DeepSeek <noreply@deepseek.com>
1 parent 9a5ab38 commit 06fad42

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

packages/cli/src/entry.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ if (cliArgs.setup || process.argv.includes('setup')) {
635635
});
636636
});
637637
settings.theme = theme;
638+
// Apply immediately for the current TUI session
639+
process.env.CODER_TUI_THEME = theme;
638640
console.log(` Theme: ${theme}\n`);
639641
rl.close();
640642
}
@@ -766,6 +768,23 @@ if (process.env.CODER_HEAPDUMP_ON_START === '1') {
766768

767769
process.on('beforeExit', () => stopMemoryMonitor())
768770

771+
// Apply user's theme preference from settings.json before TUI initializes.
772+
// This overrides terminal auto-detection (detectLightMode) when the user
773+
// has explicitly chosen a theme via `coder setup` or `coder --model`.
774+
if (!process.env.CODER_TUI_THEME) {
775+
try {
776+
const settingsTheme = JSON.parse(
777+
(await import('node:fs')).readFileSync(
778+
(await import('node:path')).join((await import('node:os')).homedir(), '.coder', 'settings.json'),
779+
'utf-8',
780+
)
781+
)?.theme
782+
if (settingsTheme === 'light' || settingsTheme === 'dark') {
783+
process.env.CODER_TUI_THEME = settingsTheme
784+
}
785+
} catch {}
786+
}
787+
769788
const [ink, { App }, { logFrameEvent }, { trackFrame }] = await Promise.all([
770789
import('@coder/tui'),
771790
import('./app.js'),

0 commit comments

Comments
 (0)