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
+96
-38
@@ -12,9 +12,12 @@ import { Eye, EyeOff, Moon, ShieldCheck, Sun, X } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { channelUiPresentation } from "@/channel-plugins/registry";
|
||||
import { Sidebar } from "@/components/Sidebar";
|
||||
import { SidebarResizeHandle, SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH } from "@/components/SidebarResizeHandle";
|
||||
import { matchSidebarShortcut } from "@/lib/sidebar-shortcuts";
|
||||
import type { SidebarDeleteItem } from "@/components/ChatList";
|
||||
import type { SettingsSectionKey } from "@/components/settings/SettingsView";
|
||||
import { ThreadVisibilityContext } from "@/hooks/useThreadVisibility";
|
||||
import type { SettingsExitGuard } from "@/components/settings/contracts";
|
||||
import { PaneWorkbench } from "@/components/workbench/PaneWorkbench";
|
||||
import {
|
||||
MAX_WORKBENCH_PANES,
|
||||
@@ -109,6 +112,7 @@ const RESTART_STARTED_KEY = "nanobot-webui.restartStartedAt";
|
||||
const RESTART_ROUTE_KEY = "nanobot-webui.restartRoute";
|
||||
const RESTART_ROUTE_TTL_MS = 5 * 60 * 1000;
|
||||
const SIDEBAR_WIDTH = 272;
|
||||
const SIDEBAR_WIDTH_STORAGE_KEY = "nanobot-webui.sidebar.width";
|
||||
const SIDEBAR_RAIL_WIDTH = 56;
|
||||
const MOBILE_SIDEBAR_WIDTH = `min(${SIDEBAR_WIDTH}px, calc(100vw - 0.75rem))`;
|
||||
const TOKEN_REFRESH_MARGIN_MS = 30_000;
|
||||
@@ -116,7 +120,7 @@ const TOKEN_REFRESH_MIN_DELAY_MS = 5_000;
|
||||
const PAIRING_POLL_INTERVAL_MS = 5_000;
|
||||
const PAIRING_IDLE_POLL_INTERVAL_MS = 15_000;
|
||||
const PAIRING_DISMISS_SNOOZE_MS = 30_000;
|
||||
type ShellView = "chat" | "settings" | "apps" | "automations" | "skills";
|
||||
type ShellView = "chat" | "settings" | "apps" | "automations" | "skills" | "channels";
|
||||
type ShellRoute = {
|
||||
view: ShellView;
|
||||
activeKey: string | null;
|
||||
@@ -161,7 +165,9 @@ function SurfaceLoadingFallback({ label }: { label?: string }) {
|
||||
}
|
||||
|
||||
const SETTINGS_SECTION_KEYS: SettingsSectionKey[] = [
|
||||
"capabilities",
|
||||
"overview",
|
||||
"about",
|
||||
"appearance",
|
||||
"models",
|
||||
"image",
|
||||
@@ -170,6 +176,7 @@ const SETTINGS_SECTION_KEYS: SettingsSectionKey[] = [
|
||||
"channels",
|
||||
"apps",
|
||||
"automations",
|
||||
"memory",
|
||||
"skills",
|
||||
"runtime",
|
||||
"advanced",
|
||||
@@ -184,7 +191,7 @@ function defaultShellRoute(): ShellRoute {
|
||||
}
|
||||
|
||||
function shellViewForSettingsSection(section: SettingsSectionKey): ShellView {
|
||||
if (section === "apps" || section === "automations" || section === "skills") return section;
|
||||
if (section === "apps" || section === "automations" || section === "skills" || section === "channels") return section;
|
||||
return "settings";
|
||||
}
|
||||
|
||||
@@ -252,6 +259,9 @@ function readShellRoute(): ShellRoute {
|
||||
if (path === "/automations") {
|
||||
return { view: "automations", activeKey, settingsSection: "automations" };
|
||||
}
|
||||
if (path === "/channels") {
|
||||
return { view: "channels", activeKey, settingsSection: "channels" };
|
||||
}
|
||||
if (path === "/skills") {
|
||||
return { view: "skills", activeKey, settingsSection: "skills" };
|
||||
}
|
||||
@@ -430,6 +440,16 @@ function AuthForm({
|
||||
);
|
||||
}
|
||||
|
||||
function readSidebarWidth(): number {
|
||||
try {
|
||||
const width = Number(window.localStorage.getItem(SIDEBAR_WIDTH_STORAGE_KEY));
|
||||
return Number.isFinite(width) && width >= SIDEBAR_MIN_WIDTH
|
||||
? Math.min(SIDEBAR_MAX_WIDTH, width) : SIDEBAR_WIDTH;
|
||||
} catch {
|
||||
return SIDEBAR_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
function readSidebarOpen(): boolean {
|
||||
if (typeof window === "undefined") return true;
|
||||
try {
|
||||
@@ -1042,6 +1062,8 @@ function Shell({
|
||||
useState<SettingsSectionKey>(initialRouteRef.current.settingsSection);
|
||||
const [hostSidebarOpen, setHostSidebarOpen] =
|
||||
useState<boolean>(readSidebarOpen);
|
||||
const [sidebarWidth, setSidebarWidth] = useState(readSidebarWidth);
|
||||
const [sidebarDragging, setSidebarDragging] = useState(false);
|
||||
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
|
||||
const [sessionSearchOpen, setSessionSearchOpen] = useState(false);
|
||||
const mobileWorkbench = useMediaQuery("(max-width: 767px)");
|
||||
@@ -1089,6 +1111,12 @@ function Shell({
|
||||
const skills = useSkills(getToken);
|
||||
const pageVisible = usePageVisibility();
|
||||
const [settingsSnapshot, setSettingsSnapshot] = useState<SettingsPayload | null>(null);
|
||||
const settingsExitGuardRef = useRef<SettingsExitGuard | null>(null);
|
||||
const currentShellRouteRef = useRef<ShellRoute>({ view, activeKey, settingsSection: settingsInitialSection });
|
||||
currentShellRouteRef.current = { view, activeKey, settingsSection: settingsInitialSection };
|
||||
const registerSettingsExitGuard = useCallback((guard: SettingsExitGuard | null) => {
|
||||
settingsExitGuardRef.current = guard;
|
||||
}, []);
|
||||
const [workspaceError, setWorkspaceError] = useState<string | null>(null);
|
||||
const [draftWorkspaceScope, setDraftWorkspaceScope] =
|
||||
useState<WorkspaceScopePayload | null>(null);
|
||||
@@ -1119,10 +1147,15 @@ function Shell({
|
||||
|
||||
const navigate = useCallback(
|
||||
(route: ShellRoute, options?: { replace?: boolean }) => {
|
||||
setActiveKey(route.activeKey);
|
||||
setView(route.view);
|
||||
setSettingsInitialSection(route.settingsSection);
|
||||
writeShellRoute(route, options?.replace);
|
||||
const leave = () => {
|
||||
setActiveKey(route.activeKey);
|
||||
setView(route.view);
|
||||
setSettingsInitialSection(route.settingsSection);
|
||||
writeShellRoute(route, options?.replace);
|
||||
};
|
||||
if (currentShellRouteRef.current.view === "settings" && route.view !== "settings" && settingsExitGuardRef.current) {
|
||||
settingsExitGuardRef.current(leave);
|
||||
} else leave();
|
||||
},
|
||||
[],
|
||||
);
|
||||
@@ -1130,6 +1163,18 @@ function Shell({
|
||||
useEffect(() => {
|
||||
const applyRoute = () => {
|
||||
const route = readShellRoute();
|
||||
if (currentShellRouteRef.current.view === "settings" && route.view !== "settings" && settingsExitGuardRef.current) {
|
||||
writeShellRoute(currentShellRouteRef.current, true);
|
||||
settingsExitGuardRef.current(() => {
|
||||
setActiveKey(route.activeKey);
|
||||
setView(route.view);
|
||||
setSettingsInitialSection(route.settingsSection);
|
||||
writeShellRoute(route, true);
|
||||
setWorkspaceError(null);
|
||||
if (route.view === "chat" && !route.activeKey) setDraftWorkspaceScope(null);
|
||||
});
|
||||
return;
|
||||
}
|
||||
setActiveKey(route.activeKey);
|
||||
setView(route.view);
|
||||
setSettingsInitialSection(route.settingsSection);
|
||||
@@ -1184,7 +1229,12 @@ function Shell({
|
||||
} catch {
|
||||
// ignore storage errors (private mode, etc.)
|
||||
}
|
||||
}, [hostSidebarOpen]);
|
||||
try {
|
||||
window.localStorage.setItem(SIDEBAR_WIDTH_STORAGE_KEY, String(sidebarWidth));
|
||||
} catch {
|
||||
// Storage can be unavailable in private browsing.
|
||||
}
|
||||
}, [hostSidebarOpen, sidebarWidth]);
|
||||
|
||||
useEffect(() => {
|
||||
writeSessionUpdateChatIds(updatedChatIds);
|
||||
@@ -1442,10 +1492,6 @@ function Shell({
|
||||
});
|
||||
}, [client, loading, sessions]);
|
||||
|
||||
const closeHostSidebar = useCallback(() => {
|
||||
setHostSidebarOpen(false);
|
||||
}, []);
|
||||
|
||||
const openHostSidebar = useCallback(() => {
|
||||
setHostSidebarOpen(true);
|
||||
}, []);
|
||||
@@ -1884,28 +1930,6 @@ function Shell({
|
||||
updateWorkbenchState,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: globalThis.KeyboardEvent) => {
|
||||
if (event.defaultPrevented) return;
|
||||
const commandShiftO =
|
||||
(event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey;
|
||||
if (commandShiftO && event.key.toLowerCase() === "o") {
|
||||
event.preventDefault();
|
||||
onNewChat();
|
||||
return;
|
||||
}
|
||||
const plainCommandK =
|
||||
(event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey;
|
||||
if (!plainCommandK) return;
|
||||
if (event.key.toLowerCase() !== "k") return;
|
||||
event.preventDefault();
|
||||
onOpenSessionSearch();
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [onNewChat, onOpenSessionSearch]);
|
||||
|
||||
const onSelectSearchResult = useCallback(
|
||||
(key: string) => {
|
||||
setSessionSearchOpen(false);
|
||||
@@ -1916,7 +1940,7 @@ function Shell({
|
||||
|
||||
const onOpenSettings = useCallback((section: SettingsSectionKey = "overview") => {
|
||||
setSessionSearchOpen(false);
|
||||
navigate({ view: "settings", activeKey, settingsSection: section });
|
||||
navigate({ view: shellViewForSettingsSection(section), activeKey, settingsSection: section });
|
||||
setMobileSidebarOpen(false);
|
||||
}, [activeKey, navigate]);
|
||||
|
||||
@@ -1940,12 +1964,31 @@ function Shell({
|
||||
setMobileSidebarOpen(false);
|
||||
}, [activeKey, navigate]);
|
||||
|
||||
const onOpenChannels = useCallback(() => {
|
||||
setSessionSearchOpen(false);
|
||||
navigate({ view: "channels", activeKey, settingsSection: "channels" });
|
||||
setMobileSidebarOpen(false);
|
||||
}, [activeKey, navigate]);
|
||||
|
||||
const onOpenSkills = useCallback(() => {
|
||||
setSessionSearchOpen(false);
|
||||
navigate({ view: "skills", activeKey, settingsSection: "skills" });
|
||||
setMobileSidebarOpen(false);
|
||||
}, [activeKey, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
const actions = { newChat: onNewChat, search: onOpenSessionSearch, apps: onOpenApps,
|
||||
skills: onOpenSkills, automations: onOpenAutomations, channels: onOpenChannels, settings: () => onOpenSettings() };
|
||||
const handleKeyDown = (event: globalThis.KeyboardEvent) => {
|
||||
const action = matchSidebarShortcut(event);
|
||||
if (!action) return;
|
||||
event.preventDefault();
|
||||
actions[action]();
|
||||
};
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [onNewChat, onOpenSessionSearch, onOpenApps, onOpenSkills, onOpenAutomations, onOpenChannels, onOpenSettings]);
|
||||
|
||||
const onSettingsSectionChange = useCallback(
|
||||
(section: SettingsSectionKey) => {
|
||||
navigate({
|
||||
@@ -2426,6 +2469,10 @@ function Shell({
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (view === "channels") {
|
||||
document.title = t("app.documentTitle.chat", { title: t("settings.nav.channels") });
|
||||
return;
|
||||
}
|
||||
if (view === "skills") {
|
||||
document.title = t("app.documentTitle.chat", {
|
||||
title: t("settings.nav.skills", { defaultValue: "Skills" }),
|
||||
@@ -2486,10 +2533,11 @@ function Shell({
|
||||
onOpenSettings,
|
||||
onOpenApps,
|
||||
onOpenAutomations,
|
||||
onOpenChannels,
|
||||
onOpenSkills,
|
||||
onSettingsIntent,
|
||||
onOpenSearch: onOpenSessionSearch,
|
||||
activeUtility: view === "apps" || view === "automations" || view === "skills" ? view : null,
|
||||
activeUtility: view === "apps" || view === "automations" || view === "skills" || view === "channels" ? view : null,
|
||||
onToggleArchived,
|
||||
pinnedKeys: sidebarPinnedTabKeys,
|
||||
archivedKeys: sidebarArchivedTabKeys,
|
||||
@@ -2507,7 +2555,7 @@ function Shell({
|
||||
archivedCount: sidebarArchivedTabKeys.length,
|
||||
defaultWorkspacePath: workspaces?.default_scope.project_path ?? null,
|
||||
};
|
||||
const hostSidebarFlowWidth = hostSidebarOpen ? SIDEBAR_WIDTH : SIDEBAR_RAIL_WIDTH;
|
||||
const hostSidebarFlowWidth = hostSidebarOpen ? sidebarWidth : SIDEBAR_RAIL_WIDTH;
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.classList.toggle("native-host", showHostChrome);
|
||||
@@ -2555,9 +2603,10 @@ function Shell({
|
||||
{showMainSidebar ? (
|
||||
<aside
|
||||
data-testid="host-sidebar-flow"
|
||||
id="main-sidebar"
|
||||
className={cn(
|
||||
"relative z-20 hidden shrink-0 overflow-hidden lg:block",
|
||||
"transition-[width] duration-300 ease-out",
|
||||
sidebarDragging ? "select-none" : "transition-[width] duration-300 ease-out motion-reduce:transition-none",
|
||||
)}
|
||||
style={{
|
||||
width: hostSidebarFlowWidth,
|
||||
@@ -2575,10 +2624,18 @@ function Shell({
|
||||
{...sidebarProps}
|
||||
collapsed={!hostSidebarOpen}
|
||||
hostChromeInset={showHostChrome}
|
||||
onCollapse={closeHostSidebar}
|
||||
onExpand={openHostSidebar}
|
||||
/>
|
||||
</div>
|
||||
<SidebarResizeHandle
|
||||
width={sidebarWidth}
|
||||
open={hostSidebarOpen}
|
||||
onDraggingChange={setSidebarDragging}
|
||||
onResize={(width, open) => {
|
||||
if (open) setSidebarWidth(width);
|
||||
setHostSidebarOpen(open);
|
||||
}}
|
||||
/>
|
||||
</aside>
|
||||
) : null}
|
||||
|
||||
@@ -2764,6 +2821,7 @@ function Shell({
|
||||
<div className="absolute inset-0 flex flex-col">
|
||||
<Suspense fallback={<SurfaceLoadingFallback />}>
|
||||
<SettingsView
|
||||
registerExitGuard={registerSettingsExitGuard}
|
||||
theme={theme}
|
||||
initialSection={settingsInitialSection}
|
||||
initialSettings={settingsSnapshot}
|
||||
|
||||
Reference in new issue
Block a user