()
| 829 | } |
| 830 | |
| 831 | export function detectPlatformTheme(): ThemeName { |
| 832 | if (typeof Bun !== 'undefined') { |
| 833 | if (process.platform === 'darwin') { |
| 834 | const value = runSystemCommand([ |
| 835 | 'defaults', |
| 836 | 'read', |
| 837 | '-g', |
| 838 | 'AppleInterfaceStyle', |
| 839 | ]) |
| 840 | if (value?.toLowerCase() === 'dark') return 'dark' |
| 841 | return 'light' |
| 842 | } |
| 843 | |
| 844 | if (process.platform === 'win32') { |
| 845 | // Try PowerShell background color detection first |
| 846 | const powershellTheme = detectWindowsPowerShellTheme() |
| 847 | if (powershellTheme) return powershellTheme |
| 848 | |
| 849 | // Fallback to Windows system theme |
| 850 | const value = runSystemCommand([ |
| 851 | 'powershell', |
| 852 | '-NoProfile', |
| 853 | '-Command', |
| 854 | '(Get-ItemProperty -Path HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize).AppsUseLightTheme', |
| 855 | ]) |
| 856 | if (value === '0') return 'dark' |
| 857 | if (value === '1') return 'light' |
| 858 | } |
| 859 | |
| 860 | if (process.platform === 'linux') { |
| 861 | const value = runSystemCommand([ |
| 862 | 'gsettings', |
| 863 | 'get', |
| 864 | 'org.gnome.desktop.interface', |
| 865 | 'color-scheme', |
| 866 | ]) |
| 867 | if (value?.toLowerCase().includes('dark')) return 'dark' |
| 868 | if (value?.toLowerCase().includes('light')) return 'light' |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | return 'dark' |
| 873 | } |
| 874 | |
| 875 | const DEFAULT_CHAT_THEMES: Record<ThemeName, ChatTheme> = { |
| 876 | dark: { |
no test coverage detected