MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / detectSystemTheme

Function detectSystemTheme

cli/src/hooks/use-theme.tsx:61–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59]
60
61export const detectSystemTheme = (): ThemeName => {
62 const env = getCliEnv()
63 const envPreference = env.OPEN_TUI_THEME ?? env.OPENTUI_THEME
64 const normalizedEnv = envPreference?.toLowerCase()
65
66 if (normalizedEnv === 'dark' || normalizedEnv === 'light') {
67 return normalizedEnv
68 }
69
70 const preferredTheme = (): ThemeName => {
71 for (const detector of THEME_PRIORITY) {
72 const result = detector.detect()
73 if (result) {
74 return result
75 }
76 }
77 return 'dark'
78 }
79
80 const resolved = preferredTheme()
81
82 if (normalizedEnv === 'opposite') {
83 return resolved === 'dark' ? 'light' : 'dark'
84 }
85
86 return resolved
87}
88
89export function initializeThemeStore() {
90 if (themeStoreInitialized) {

Callers 1

initializeThemeStoreFunction · 0.85

Calls 2

getCliEnvFunction · 0.90
preferredThemeFunction · 0.85

Tested by

no test coverage detected