"use client"; import { useState } from "react"; import Link from "@/components/routing/app-link"; import { useTheme } from "@/components/theme/app-theme"; import { IconActivity, IconCommand, IconPalette, IconKeyboard, IconGitBranch, } from "@tabler/icons-react"; import { Card, CardContent, CardHeader, CardTitle } from "@kandev/ui/card"; import { Label } from "@kandev/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@kandev/ui/select"; import { Separator } from "@kandev/ui/separator"; import { SettingsSection } from "@/components/settings/settings-section"; import { KeyboardShortcutsCard } from "@/components/settings/keyboard-shortcuts-card"; import { SystemMetricsSettingsCard } from "@/components/settings/system-metrics-settings-card"; import { GENERAL_NAV_ITEMS } from "@/components/settings/general-nav"; import { useAppStore, useAppStoreApi } from "@/components/state-provider"; import { updateUserSettings } from "@/lib/api"; import type { Theme } from "@/lib/settings/types"; function ThemeSettingsCard() { const { theme: currentTheme, setTheme } = useTheme(); const themeValue = currentTheme ?? "system"; return ( Color Theme
); } function ChatSubmitKeyCard() { const userSettings = useAppStore((state) => state.userSettings); const setUserSettings = useAppStore((state) => state.setUserSettings); const [isSavingSubmitKey, setIsSavingSubmitKey] = useState(false); const handleChatSubmitKeyChange = async (value: "enter" | "cmd_enter") => { if (isSavingSubmitKey) return; setIsSavingSubmitKey(true); const previousValue = userSettings.chatSubmitKey; try { setUserSettings({ ...userSettings, chatSubmitKey: value }); await updateUserSettings({ workspace_id: userSettings.workspaceId || "", repository_ids: userSettings.repositoryIds || [], chat_submit_key: value, }); } catch { setUserSettings({ ...userSettings, chatSubmitKey: previousValue }); } finally { setIsSavingSubmitKey(false); } }; return ( Submit Shortcut

{userSettings.chatSubmitKey === "cmd_enter" ? "Press Cmd/Ctrl+Enter to send messages. Press Enter for newlines." : "Press Enter to send messages. Press Shift+Enter for newlines."}

); } function ChangesPanelLayoutCard() { const userSettings = useAppStore((state) => state.userSettings); const setUserSettings = useAppStore((state) => state.setUserSettings); const storeApi = useAppStoreApi(); const [isSaving, setIsSaving] = useState(false); const handleChange = async (value: "flat" | "tree") => { if (isSaving) return; setIsSaving(true); const current = storeApi.getState().userSettings; const previous = current.changesPanelLayout; try { setUserSettings({ ...current, changesPanelLayout: value }); await updateUserSettings({ workspace_id: current.workspaceId || "", repository_ids: current.repositoryIds || [], changes_panel_layout: value, }); } catch { setUserSettings({ ...storeApi.getState().userSettings, changesPanelLayout: previous }); } finally { setIsSaving(false); } }; return ( Changes Panel Layout

Display changed files as a flat list with full paths, or as a folder tree.

); } export function GeneralSettings() { return (
{GENERAL_NAV_ITEMS.map(({ href, label, description, icon: Icon }) => ( {label}

{description}

))}
); } export function AppearanceSettings() { return (
} title="Appearance" description="Customize how the application looks" > } title="Changes Panel" description="Customize how changed files are displayed" > } title="Resource Metrics" description="Configure backend and execution resource sampling" >
); } export function KeyboardShortcutsSettings() { return (
} title="Chat Input" description="Configure chat input behavior" > } title="Keyboard Shortcuts" description="Customize keyboard shortcuts for the command panel" >
); }