import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Switch } from "@/components/ui/switch"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; import { usePreferencesStore } from "@/modules/settings/preferences"; import type { ThemePref } from "@/modules/settings/store"; import { EDITOR_THEME_LABELS, EDITOR_THEMES, TERMINAL_FONT_SIZES, setAutostart, setEditorTheme, setRestoreWindowState, setShowHidden, setTerminalFontSize, setTerminalWebglEnabled, setVimMode, type EditorThemeId, } from "@/modules/settings/store"; import { useTheme } from "@/modules/theme"; import { ArrowDown01Icon, ComputerIcon, Moon02Icon, Sun03Icon, } from "@hugeicons/core-free-icons"; import { HugeiconsIcon } from "@hugeicons/react"; import { disable, enable, isEnabled } from "@tauri-apps/plugin-autostart"; import { useEffect } from "react"; import { SectionHeader } from "../components/SectionHeader"; import { SettingRow } from "../components/SettingRow"; const APPEARANCE: { id: ThemePref; label: string; icon: typeof ComputerIcon; }[] = [ { id: "system", label: "System", icon: ComputerIcon }, { id: "light", label: "Light", icon: Sun03Icon }, { id: "dark", label: "Dark", icon: Moon02Icon }, ]; export function GeneralSection() { const { theme, setTheme } = useTheme(); const editorTheme = usePreferencesStore((s) => s.editorTheme); const autostart = usePreferencesStore((s) => s.autostart); const restoreWindowState = usePreferencesStore((s) => s.restoreWindowState); const vimMode = usePreferencesStore((s) => s.vimMode); const showHidden = usePreferencesStore((s) => s.showHidden); const terminalWebglEnabled = usePreferencesStore( (s) => s.terminalWebglEnabled, ); const terminalFontSize = usePreferencesStore((s) => s.terminalFontSize); // Reconcile autostart pref with the actual OS state on mount — the user may // have toggled it from System Settings. useEffect(() => { let alive = true; void isEnabled() .then((on) => { if (!alive) return; if (on !== usePreferencesStore.getState().autostart) { void setAutostart(on); } }) .catch(() => undefined); return () => { alive = false; }; }, []); const onToggleAutostart = async (next: boolean) => { try { if (next) await enable(); else await disable(); await setAutostart(next); } catch (e) { console.error("autostart toggle failed", e); } }; const onPickEditor = (id: EditorThemeId) => void setEditorTheme(id); const onToggleTerminalWebgl = (next: boolean) => { void setTerminalWebglEnabled(next).catch((e) => console.error("terminal WebGL preference update failed", e), ); }; const onPickTerminalFontSize = (size: number) => void setTerminalFontSize(size); return (
{APPEARANCE.map((o) => ( ))}
{EDITOR_THEMES.map((t) => ( onPickEditor(t)} className={cn( "text-[12px]", t === editorTheme && "bg-accent/50", )} > {EDITOR_THEME_LABELS[t]} ))} void setVimMode(v)} />
void setShowHidden(v)} />
Use WebGL renderer xterm's WebGL renderer caches glyphs in a GPU texture atlas. On some macOS setups (especially with Nerd Fonts), the atlas corrupts and terminal text becomes unreadable. Turn this off as a fallback — performance dips slightly, but text renders correctly via the DOM renderer. } description="Hardware-accelerated rendering. Turn off if text shows corruption or blank tiles." > {TERMINAL_FONT_SIZES.map((size) => ( onPickTerminalFontSize(size)} className={cn( "rounded-none px-3 py-1.5 text-[12px]", size === terminalFontSize && "bg-accent/50", )} > {size} px ))}
void onToggleAutostart(v)} /> void setRestoreWindowState(v)} />
); } function Label({ children }: { children: React.ReactNode }) { return ( {children} ); }