feat(webui): expand and organize settings with autosave (#5704)
* feat(webui): expand settings with autosave and live configuration * feat(memory): add long-term memory and idle compaction switches * refactor(webui): clarify settings hierarchy and align compact controls * refactor(webui): keep only memory consolidation in memory settings * refactor(webui): defer runtime changes until explicit restart * refactor(webui): remove default workspace setting * fix(webui): align model lists and remove preset counters * fix(i18n): use natural Chinese labels for chat platforms * fix(i18n): shorten chat settings navigation label * fix(webui): match settings navigation icons to text size * refactor(webui): remove redundant settings sidebar heading * refactor(webui): use icon-only back navigation in settings * fix(webui): remove back arrow hover hint * refactor(webui): remove redundant overview details * refactor(webui): hide secondary descriptions in settings rows * style(webui): replace settings dividers with rounded highlights * refactor(webui): remove redundant model list subtitles and badges * fix(i18n): restore chat translation namespace boundaries * fix(i18n): complete settings translations for all locales * fix(webui): reveal settings only for enabled capabilities * fix(webui): consolidate capabilities and isolate settings feedback * fix(webui): clear restart notices when settings are reverted * fix(webui): anchor restart controls in settings sidebar * fix(webui): shorten sidebar restart label * fix(webui): align settings spacing and control sizes * refactor(webui): unify settings dialogs and interaction feedback * fix(webui): keep settings option groups on one line without scrolling * refactor(webui): align settings spacing and sidebar icon proportions * style(webui): match main sidebar typography to settings * style(webui): use monospace for sidebar session handles * refactor(webui): remove heartbeat configuration from automations * feat(webui): expose configuration actions beside capability toggles * style(webui): remove ellipsis from configuration actions * refactor(webui): remove redundant app configuration controls * feat(webui): add compact sidebar navigation and shortcut hints * fix(webui): synchronize npm dependency lockfile * test(webui): align input radius expectation with pill styling * feat(webui): show daily token usage and cache breakdown * feat(webui): add model usage details and cache hit rates * feat(webui): chart daily token usage by model * refactor(webui): simplify usage details and model labels * fix(webui): hide usage dialog date range * refactor(webui): consolidate model usage into chart legends * fix(webui): enforce restart choices and correct settings test route * fix(webui): polish settings localization and controls * fix(webui): avoid repeated usage legend labels * fix(webui): skip empty usage columns in keyboard navigation * test(webui): assert settings behavior positively * feat(webui): refine sidebar navigation and add drag resizing * style(webui): soften sidebar scroll edges * style(webui): harmonize sidebar typography and text colors * feat(webui): move channels to the main sidebar * style(webui): remove dotted underlines from settings hints * fix(webui): unify tooltip hover delay * fix(webui): support Seatbelt sandbox settings * fix(webui): remove unused appearance density preference * fix(webui): align settings input values consistently * style(webui): group compact settings controls before inputs * feat(webui): edit multiline settings in compact dialogs * feat(webui): add continuous settings scrolling with gentle snapping * Revert "feat(webui): add continuous settings scrolling with gentle snapping" This reverts commit f0978c261a53c844185eeab4d0c3190fbd196fe6.
This commit is contained in:
1 parent
20f115bf46
commit
8ea683679d
244 files changed
+6929
-3900
No files matched your search
@@ -8,7 +8,8 @@ import {
|
||||
Archive,
|
||||
Brain,
|
||||
CalendarClock,
|
||||
Menu,
|
||||
MessageCircle,
|
||||
PanelLeftClose,
|
||||
Search,
|
||||
Settings,
|
||||
SquarePen,
|
||||
@@ -27,11 +28,13 @@ import {
|
||||
SidebarSelectionHighlight,
|
||||
} from "@/components/SidebarSelectionHighlight";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import type {
|
||||
ChatSummary,
|
||||
SidebarViewState,
|
||||
} from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { sidebarShortcutAria, sidebarShortcutLabel } from "@/lib/sidebar-shortcuts";
|
||||
|
||||
interface SidebarProps {
|
||||
sessions: ChatSummary[];
|
||||
@@ -64,11 +67,12 @@ interface SidebarProps {
|
||||
onOpenApps: () => void;
|
||||
onOpenSkills: () => void;
|
||||
onOpenAutomations: () => void;
|
||||
onOpenChannels: () => void;
|
||||
onSettingsIntent?: () => void;
|
||||
onOpenSearch: () => void;
|
||||
activeUtility?: "apps" | "skills" | "automations" | null;
|
||||
activeUtility?: "apps" | "skills" | "automations" | "channels" | null;
|
||||
onToggleArchived: () => void;
|
||||
onCollapse: () => void;
|
||||
onCollapse?: () => void;
|
||||
onExpand?: () => void;
|
||||
containActionMenus?: boolean;
|
||||
collapsed?: boolean;
|
||||
@@ -102,38 +106,62 @@ function isApplePlatform(): boolean {
|
||||
return /mac|iphone|ipad|ipod/i.test(`${platform} ${userAgentPlatform}`);
|
||||
}
|
||||
|
||||
function newChatShortcutLabel(): string {
|
||||
return isApplePlatform() ? "⌘⇧O" : "Ctrl+Shift+O";
|
||||
}
|
||||
|
||||
export function Sidebar(props: SidebarProps) {
|
||||
const { t } = useTranslation();
|
||||
const [menuPortalContainer, setMenuPortalContainer] =
|
||||
useState<HTMLElement | null>(null);
|
||||
const collapsed = Boolean(props.collapsed);
|
||||
const toggleLabel = t("thread.header.toggleSidebar");
|
||||
const newChatShortcut = newChatShortcutLabel();
|
||||
const apple = isApplePlatform();
|
||||
const activeActionRef = useRef<HTMLButtonElement>(null);
|
||||
const activeActionId = props.newChatActive
|
||||
const activeActionId = collapsed && props.newChatActive
|
||||
? "new-chat"
|
||||
: props.activeUtility
|
||||
? `utility:${props.activeUtility}`
|
||||
: null;
|
||||
|
||||
const newChatButton = (
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.newChat")}
|
||||
iconOnly
|
||||
className={collapsed ? undefined : "rounded-full border border-border/70 bg-background/80 shadow-sm"}
|
||||
onClick={props.onNewChat}
|
||||
active={props.newChatActive}
|
||||
selectionRef={collapsed ? activeActionRef : undefined}
|
||||
icon={<SquarePen className="h-4 w-4" />}
|
||||
shortcut={sidebarShortcutLabel("newChat", apple)}
|
||||
ariaKeyShortcuts={sidebarShortcutAria("newChat")}
|
||||
/>
|
||||
);
|
||||
const searchButton = (
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.searchAria")}
|
||||
shortcut={sidebarShortcutLabel("search", apple)}
|
||||
ariaKeyShortcuts={sidebarShortcutAria("search")}
|
||||
iconOnly
|
||||
onClick={props.onOpenSearch}
|
||||
icon={<Search className="h-4 w-4" />}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<nav
|
||||
ref={props.containActionMenus ? setMenuPortalContainer : undefined}
|
||||
aria-label={t("sidebar.navigation")}
|
||||
className={cn(
|
||||
"flex h-full w-full min-w-0 flex-col text-sidebar-foreground",
|
||||
"flex h-full w-full min-w-0 flex-col text-sidebar-content",
|
||||
props.hostChromeInset ? "bg-transparent" : "bg-sidebar",
|
||||
)}
|
||||
>
|
||||
<div
|
||||
data-testid="sidebar-brand-row"
|
||||
className={cn(
|
||||
"flex items-start px-3 pb-2.5 pt-3",
|
||||
collapsed ? "w-14 justify-start" : "justify-between",
|
||||
"flex items-start gap-1 pb-4 pt-3",
|
||||
collapsed ? "w-14 justify-start px-3" : "justify-between ps-4 pe-2",
|
||||
)}
|
||||
>
|
||||
<button
|
||||
@@ -145,11 +173,11 @@ export function Sidebar(props: SidebarProps) {
|
||||
onClick={collapsed ? props.onExpand : undefined}
|
||||
tabIndex={collapsed ? 0 : -1}
|
||||
className={cn(
|
||||
"host-no-drag flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded-xl transition-colors",
|
||||
"host-no-drag flex h-8 w-8 shrink-0 items-center justify-center rounded-xl transition-colors",
|
||||
props.hostChromeInset && "mt-5",
|
||||
collapsed
|
||||
? "-ml-0.5 hover:bg-sidebar-accent/75"
|
||||
: "pointer-events-none -ml-0.5",
|
||||
? "hover:bg-sidebar-accent/60"
|
||||
: "pointer-events-none",
|
||||
)}
|
||||
>
|
||||
<img
|
||||
@@ -160,15 +188,14 @@ export function Sidebar(props: SidebarProps) {
|
||||
/>
|
||||
</button>
|
||||
{!collapsed && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={t("sidebar.collapse")}
|
||||
onClick={props.onCollapse}
|
||||
className="host-no-drag mt-1 h-7 w-7 rounded-lg text-muted-foreground/85 hover:bg-sidebar-accent/75 hover:text-sidebar-foreground"
|
||||
>
|
||||
<Menu className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<div className={cn("flex min-w-0 flex-1 items-center justify-end gap-1", props.hostChromeInset && "mt-5")}>
|
||||
{searchButton}
|
||||
{newChatButton}
|
||||
{props.onCollapse && (
|
||||
<SidebarActionButton collapsed={false} label={t("sidebar.collapse")} iconOnly
|
||||
onClick={props.onCollapse} icon={<PanelLeftClose className="h-4 w-4" />} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -177,29 +204,16 @@ export function Sidebar(props: SidebarProps) {
|
||||
activeId={activeActionId}
|
||||
scope="actions"
|
||||
className={cn(
|
||||
"relative space-y-1.5 px-2 pb-2",
|
||||
collapsed && "flex w-14 flex-col items-center px-0",
|
||||
"relative gap-0.5 pb-3",
|
||||
collapsed ? "flex w-14 flex-col items-center px-0" : "flex flex-col px-2",
|
||||
)}
|
||||
>
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.newChat")}
|
||||
onClick={props.onNewChat}
|
||||
active={props.newChatActive}
|
||||
selectionRef={activeActionRef}
|
||||
icon={<SquarePen className="h-4 w-4" />}
|
||||
shortcut={newChatShortcut}
|
||||
ariaKeyShortcuts="Meta+Shift+O Control+Shift+O"
|
||||
/>
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.searchAria")}
|
||||
onClick={props.onOpenSearch}
|
||||
icon={<Search className="h-4 w-4" />}
|
||||
/>
|
||||
{collapsed && <>{newChatButton}{searchButton}</>}
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.apps")}
|
||||
shortcut={sidebarShortcutLabel("apps", apple)}
|
||||
ariaKeyShortcuts={sidebarShortcutAria("apps")}
|
||||
onClick={props.onOpenApps}
|
||||
onIntent={props.onSettingsIntent}
|
||||
active={props.activeUtility === "apps"}
|
||||
@@ -209,6 +223,8 @@ export function Sidebar(props: SidebarProps) {
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.skills.title")}
|
||||
shortcut={sidebarShortcutLabel("skills", apple)}
|
||||
ariaKeyShortcuts={sidebarShortcutAria("skills")}
|
||||
onClick={props.onOpenSkills}
|
||||
onIntent={props.onSettingsIntent}
|
||||
active={props.activeUtility === "skills"}
|
||||
@@ -218,12 +234,25 @@ export function Sidebar(props: SidebarProps) {
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.automations", { defaultValue: "Automations" })}
|
||||
shortcut={sidebarShortcutLabel("automations", apple)}
|
||||
ariaKeyShortcuts={sidebarShortcutAria("automations")}
|
||||
onClick={props.onOpenAutomations}
|
||||
onIntent={props.onSettingsIntent}
|
||||
active={props.activeUtility === "automations"}
|
||||
selectionRef={activeActionRef}
|
||||
icon={<CalendarClock className="h-4 w-4" />}
|
||||
/>
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("settings.nav.channels")}
|
||||
shortcut={sidebarShortcutLabel("channels", apple)}
|
||||
ariaKeyShortcuts={sidebarShortcutAria("channels")}
|
||||
onClick={props.onOpenChannels}
|
||||
onIntent={props.onSettingsIntent}
|
||||
active={props.activeUtility === "channels"}
|
||||
selectionRef={activeActionRef}
|
||||
icon={<MessageCircle className="h-4 w-4" />}
|
||||
/>
|
||||
{props.archivedCount ? (
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
@@ -236,6 +265,7 @@ export function Sidebar(props: SidebarProps) {
|
||||
<div
|
||||
className={cn(
|
||||
"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden transition-opacity duration-200",
|
||||
props.onExpand && !collapsed && "me-3",
|
||||
collapsed && "pointer-events-none opacity-0",
|
||||
)}
|
||||
>
|
||||
@@ -288,26 +318,31 @@ export function Sidebar(props: SidebarProps) {
|
||||
</div>
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center gap-1 bg-sidebar/55 px-2.5 py-3 text-xs",
|
||||
"flex items-center justify-between gap-1 bg-sidebar/55 px-2.5 py-3 text-xs",
|
||||
collapsed && "w-14 flex-col px-0",
|
||||
)}
|
||||
>
|
||||
<SidebarActionButton
|
||||
collapsed={collapsed}
|
||||
label={t("sidebar.settings")}
|
||||
iconOnly
|
||||
shortcut={sidebarShortcutLabel("settings", apple)}
|
||||
ariaKeyShortcuts={sidebarShortcutAria("settings")}
|
||||
onClick={props.onOpenSettings}
|
||||
onIntent={props.onSettingsIntent}
|
||||
className={collapsed ? undefined : "flex-1"}
|
||||
className="w-9"
|
||||
icon={<Settings className="h-4 w-4" />}
|
||||
/>
|
||||
<ConnectionBadge />
|
||||
</div>
|
||||
</nav>
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function SidebarActionButton({
|
||||
collapsed,
|
||||
iconOnly = false,
|
||||
label,
|
||||
icon,
|
||||
onClick,
|
||||
@@ -319,6 +354,7 @@ function SidebarActionButton({
|
||||
selectionRef,
|
||||
}: {
|
||||
collapsed: boolean;
|
||||
iconOnly?: boolean;
|
||||
label: string;
|
||||
icon: ReactNode;
|
||||
onClick: () => void;
|
||||
@@ -329,9 +365,9 @@ function SidebarActionButton({
|
||||
onIntent?: () => void;
|
||||
selectionRef?: RefObject<HTMLButtonElement>;
|
||||
}) {
|
||||
const title = shortcut ? `${label} (${shortcut})` : collapsed ? label : undefined;
|
||||
const compact = collapsed || iconOnly;
|
||||
|
||||
return (
|
||||
const button = (
|
||||
<Button
|
||||
ref={active ? selectionRef : undefined}
|
||||
type="button"
|
||||
@@ -339,41 +375,37 @@ function SidebarActionButton({
|
||||
aria-label={label}
|
||||
aria-current={active ? "page" : undefined}
|
||||
aria-keyshortcuts={ariaKeyShortcuts}
|
||||
title={title}
|
||||
onClick={() => onClick()}
|
||||
onFocus={onIntent}
|
||||
onPointerEnter={onIntent}
|
||||
className={cn(
|
||||
"touch-target group h-8 min-w-0 gap-2 overflow-hidden rounded-xl font-medium",
|
||||
"touch-target group h-8 min-w-0 gap-2 overflow-hidden rounded-xl font-normal",
|
||||
SIDEBAR_SELECTION_ACTION_ITEM_CLASS,
|
||||
collapsed
|
||||
? "w-9 justify-center gap-0 px-0"
|
||||
: "w-full justify-start gap-2 px-3 text-[12.5px]",
|
||||
? "w-8 justify-center gap-0 px-0"
|
||||
: iconOnly ? "w-8 shrink-0 justify-center gap-0 rounded-xl px-0"
|
||||
: "w-full justify-start gap-2 px-2 text-[13px] leading-5 [&_svg]:h-[18px] [&_svg]:w-[18px] [&_svg]:stroke-[1.75]",
|
||||
active
|
||||
? "text-sidebar-accent-foreground"
|
||||
: "text-sidebar-foreground/85 hover:bg-sidebar-foreground/[0.035] hover:text-sidebar-foreground dark:hover:bg-white/[0.05]",
|
||||
: "text-sidebar-content settings-hover hover:text-sidebar-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"flex shrink-0 items-center justify-center transition-transform duration-300 ease-out",
|
||||
collapsed ? "translate-x-0" : "translate-x-0",
|
||||
)}
|
||||
aria-hidden
|
||||
>
|
||||
<span className="flex shrink-0 items-center justify-center" aria-hidden>
|
||||
{icon}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 overflow-hidden truncate whitespace-nowrap transition-[max-width,opacity,transform] duration-200 ease-out",
|
||||
collapsed
|
||||
? "max-w-0 -translate-x-1 opacity-0"
|
||||
: "max-w-[12rem] translate-x-0 opacity-100",
|
||||
)}
|
||||
>
|
||||
{!compact && <span className="min-w-0 max-w-[12rem] truncate whitespace-nowrap">
|
||||
{label}
|
||||
</span>
|
||||
</span>}
|
||||
</Button>
|
||||
);
|
||||
return compact || shortcut ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
||||
<TooltipContent side={collapsed ? "right" : "bottom"} className="flex items-center gap-4">
|
||||
<span>{label}</span>
|
||||
{shortcut ? <kbd className="whitespace-nowrap font-sans text-muted-foreground">{shortcut}</kbd> : null}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
) : button;
|
||||
}
|
||||
Reference in new issue
Block a user