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

Function detectZedTheme

cli/src/utils/theme-system.ts:576–612  ·  view source on GitHub ↗
(
  env: CliEnv = getCliEnv(),
)

Source from the content-addressed store, hash-verified

574}
575
576const detectZedTheme = (
577 env: CliEnv = getCliEnv(),
578): ThemeName | null => {
579 if (!isZedTerminal(env)) {
580 return null
581 }
582
583 const settingsPaths = collectExistingPaths(resolveZedSettingsPaths(env))
584 for (const settingsPath of settingsPaths) {
585 const content = safeReadFile(settingsPath)
586 if (!content) continue
587
588 const theme = extractZedTheme(content)
589 if (theme) {
590 return theme
591 }
592
593 // If extractZedTheme returned null, check if theme mode is 'system'
594 // and fall back to platform detection
595 try {
596 const sanitized = stripJsonStyleComments(content)
597 const parsed = JSON.parse(sanitized) as Record<string, unknown>
598 const themeSetting = parsed.theme
599 if (themeSetting && typeof themeSetting === 'object') {
600 const themeConfig = themeSetting as Record<string, unknown>
601 const modeRaw = themeConfig.mode
602 if (typeof modeRaw === 'string' && modeRaw.toLowerCase() === 'system') {
603 return detectPlatformTheme()
604 }
605 }
606 } catch {
607 // Ignore parsing errors
608 }
609 }
610
611 return null
612}
613
614export const detectIDETheme = (
615 env: CliEnv = getCliEnv(),

Callers 1

detectIDEThemeFunction · 0.85

Calls 9

getCliEnvFunction · 0.90
isZedTerminalFunction · 0.85
collectExistingPathsFunction · 0.85
resolveZedSettingsPathsFunction · 0.85
safeReadFileFunction · 0.85
extractZedThemeFunction · 0.85
stripJsonStyleCommentsFunction · 0.85
detectPlatformThemeFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected