DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
refactor(settings): persistent navigator, searchable, one click to any page
Bingxi Zhao (Frank)af2c225c7398
diff --git a/web/app/(utility)/settings/agents/page.tsx b/web/app/(utility)/settings/agents/page.tsxindex 4091a41dc..ba2788062 100644--- a/web/app/(utility)/settings/agents/page.tsx+++ b/web/app/(utility)/settings/agents/page.tsx@@ -1,7 +1,18 @@"use client";-import SettingsSectionGrid from "@/components/settings/SettingsSectionGrid";+import { useEffect } from "react";+import { useRouter } from "next/navigation";-export default function AgentsSettingsPage() {- return <SettingsSectionGrid categoryKey="agents" />;+/**+ * Former sub-hub. The settings navigator lists these pages directly now, so a+ * grid that only repeated those links was a click with nothing behind it.+ * Kept as a redirect because the route is bookmarkable and was linked from+ * the old breadcrumb.+ */+export default function RedirectToFirstLeaf() {+ const router = useRouter();+ useEffect(() => {+ router.replace("/settings/agents/claude-code");+ }, [router]);+ return null;}diff --git a/web/app/(utility)/settings/chat/page.tsx b/web/app/(utility)/settings/chat/page.tsxindex a571c90cb..98270be04 100644--- a/web/app/(utility)/settings/chat/page.tsx+++ b/web/app/(utility)/settings/chat/page.tsx@@ -1,7 +1,18 @@"use client";-import SettingsSectionGrid from "@/components/settings/SettingsSectionGrid";+import { useEffect } from "react";+import { useRouter } from "next/navigation";-export default function ChatSettingsPage() {- return <SettingsSectionGrid categoryKey="chat" />;+/**+ * Former sub-hub. The settings navigator lists these pages directly now, so a+ * grid that only repeated those links was a click with nothing behind it.+ * Kept as a redirect because the route is bookmarkable and was linked from+ * the old breadcrumb.+ */+export default function RedirectToFirstLeaf() {+ const router = useRouter();+ useEffect(() => {+ router.replace("/settings/tools");+ }, [router]);+ return null;}diff --git a/web/app/(utility)/settings/models/page.tsx b/web/app/(utility)/settings/models/page.tsxindex 0dc4dd233..25e4ace7d 100644--- a/web/app/(utility)/settings/models/page.tsx+++ b/web/app/(utility)/settings/models/page.tsx@@ -1,7 +1,18 @@"use client";-import SettingsSectionGrid from "@/components/settings/SettingsSectionGrid";+import { useEffect } from "react";+import { useRouter } from "next/navigation";-export default function ModelsSettingsPage() {- return <SettingsSectionGrid categoryKey="models" />;+/**+ * Former sub-hub. The settings navigator lists these pages directly now, so a+ * grid that only repeated those links was a click with nothing behind it.+ * Kept as a redirect because the route is bookmarkable and was linked from+ * the old breadcrumb.+ */+export default function RedirectToFirstLeaf() {+ const router = useRouter();+ useEffect(() => {+ router.replace("/settings/connections");+ }, [router]);+ return null;}diff --git a/web/app/(utility)/settings/page.tsx b/web/app/(utility)/settings/page.tsxindex a13078f9b..ee4fb7906 100644--- a/web/app/(utility)/settings/page.tsx+++ b/web/app/(utility)/settings/page.tsx@@ -1,5 +1,7 @@-import SettingsHub from "@/components/settings/SettingsHub";+"use client";-export default function SettingsIndexPage() {- return <SettingsHub />;+import SettingsOverview from "@/components/settings/SettingsOverview";++export default function SettingsPage() {+ return <SettingsOverview />;}diff --git a/web/components/settings/ServiceConfigEditor.tsx b/web/components/settings/ServiceConfigEditor.tsxindex f92701065..ff8fd06dd 100644--- a/web/components/settings/ServiceConfigEditor.tsx+++ b/web/components/settings/ServiceConfigEditor.tsx@@ -161,6 +161,7 @@ export function ServiceConfigEditor({ service }: { service: ServiceName }) {draft.services[service].active_profile_id === deepLink.to;const [showApiKey, setShowApiKey] = useState(false);+ const [confirmingProfileDelete, setConfirmingProfileDelete] = useState(false);const [diagnosticsOpen, setDiagnosticsOpen] = useState(false);const [editingModelId, setEditingModelId] = useState<string | null>(null);const [editingModelName, setEditingModelName] = useState("");@@ -177,6 +178,8 @@ export function ServiceConfigEditor({ service }: { service: ServiceName }) {if (lastProfileKey !== profileKey) {setLastProfileKey(profileKey);if (showApiKey) setShowApiKey(false);+ // A pending confirmation must not carry over to a different profile.+ if (confirmingProfileDelete) setConfirmingProfileDelete(false);}const searchProviderRaw =@@ -521,9 +524,38 @@ export function ServiceConfigEditor({ service }: { service: ServiceName }) {);})}</div>+ {/* Deleting takes the whole provider with it — its key and every+ model under it — and it sits one hairline below the list the+ user is clicking through, so it asks first. */}<div className="mt-2 border-t border-[var(--border)]/40 pt-2">+ {confirmingProfileDelete ? (+ <div className="px-1.5 py-1">+ <p className="text-[11px] leading-relaxed text-[var(--muted-foreground)]">+ {t("Delete this profile and every model under it?")}+ </p>+ <div className="mt-1.5 flex items-center gap-1.5">+ <button+ type="button"+ onClick={() => setConfirmingProfileDelete(false)}+ className="h-6 rounded-md px-2 text-[11px] text-[var(--muted-foreground)] hover:text-[var(--foreground)]"+ >+ {t("Cancel")}+ </button>+ <button+ type="button"+ onClick={() => {+ removeActiveProfile(service);+ setConfirmingProfileDelete(false);+ }}+ className="h-6 rounded-md bg-red-500/10 px-2 text-[11px] font-medium text-red-600 transition-colors hover:bg-red-500/15 dark:text-red-400"+ >+ {t("Delete")}+ </button>+ </div>+ </div>+ ) : (<button- onClick={() => removeActiveProfile(service)}+ onClick={() => setConfirmingProfileDelete(true)}disabled={!activeProfile || isManagedCodex}className="flex w-full items-center gap-1.5 rounded-lg px-3 py-1.5 text-left text-[11px] text-[var(--muted-foreground)]/60 transition-colors hover:bg-red-500/5 hover:text-red-500 disabled:opacity-30"title={@@ -539,6 +571,7 @@ export function ServiceConfigEditor({ service }: { service: ServiceName }) {: t("Delete profile")}</span></button>+ )}</div></aside>diff --git a/web/components/settings/SettingsBreadcrumb.tsx b/web/components/settings/SettingsBreadcrumb.tsxdeleted file mode 100644index 44202e7fb..000000000--- a/web/components/settings/SettingsBreadcrumb.tsx+++ /dev/null@@ -1,61 +0,0 @@-"use client";--import { Fragment } from "react";-import Link from "next/link";-import { usePathname } from "next/navigation";-import { ChevronRight } from "lucide-react";-import { useTranslation } from "react-i18next";--import { breadcrumbFor, type Lang } from "@/lib/settings-nav";--// Top-left location trail, e.g. 设置 / 模型 / LLM. Earlier crumbs are links;-// the current page is plain text. Replaces the old single "back" link so the-// user always knows where they are inside Settings and can jump up a level.-export default function SettingsBreadcrumb() {- const pathname = usePathname() ?? "";- const { t, i18n } = useTranslation();- const zh = i18n.language?.toLowerCase().startsWith("zh");- const tr = (l: Lang) => (zh ? l.zh : l.en);-- const crumbs = breadcrumbFor(pathname);-- return (- <nav- aria-label={t("Breadcrumb")}- className="flex items-center gap-1 text-[12.5px] text-[var(--muted-foreground)]"- >- {crumbs.map((crumb, i) => {- const last = i === crumbs.length - 1;- return (- <Fragment key={`${crumb.label.en}-${i}`}>- {i > 0 && (- <ChevronRight- size={13}- strokeWidth={1.8}- className="shrink-0 text-[var(--muted-foreground)]/40"- />- )}- {crumb.href && !last ? (- <Link- href={crumb.href}- className="rounded px-0.5 transition-colors hover:text-[var(--foreground)]"- >- {tr(crumb.label)}- </Link>- ) : (- <span- className={- last- ? "px-0.5 font-medium text-[var(--foreground)]"- : "px-0.5"- }- >- {tr(crumb.label)}- </span>- )}- </Fragment>- );- })}- </nav>- );-}diff --git a/web/components/settings/SettingsContext.tsx b/web/components/settings/SettingsContext.tsxindex 1145b6bc4..77c74656c 100644--- a/web/components/settings/SettingsContext.tsx+++ b/web/components/settings/SettingsContext.tsx@@ -308,11 +308,10 @@ export type TourStep = {descKey: string;};-// Tour step order broadly follows the category order in-// ``web/lib/settings-nav.ts`` so the guided walk moves through the hub's-// sections top to bottom. Each step names the route it lives on (the Status-// step targets the resident module on the hub itself); the overlay resolves-// the ``data-tour`` target after the page renders.+// The walk now runs down the settings navigator, which is on screen for+// every route, so each step points at the first row of a group rather than+// at a hub block that no longer exists. The overlay resolves the+// ``data-tour`` target after the page renders.export const TOUR_STEPS: TourStep[] = [{target: "tour-status",@@ -321,37 +320,37 @@ export const TOUR_STEPS: TourStep[] = [descKey: "settingsTour.status.desc",},{- target: "tour-cat-appearance",+ target: "tour-nav-appearance",route: "/settings",titleKey: "settingsTour.appearance.title",descKey: "settingsTour.appearance.desc",},{- target: "tour-cat-network",+ target: "tour-nav-network",route: "/settings",titleKey: "settingsTour.network.title",descKey: "settingsTour.network.desc",},{- target: "tour-cat-models",+ target: "tour-nav-models",route: "/settings",titleKey: "settingsTour.models.title",descKey: "settingsTour.models.desc",},{- target: "tour-cat-knowledge",+ target: "tour-nav-knowledge",route: "/settings",titleKey: "settingsTour.knowledge.title",descKey: "settingsTour.knowledge.desc",},{- target: "tour-cat-chat",+ target: "tour-nav-chat",route: "/settings",titleKey: "settingsTour.chat.title",descKey: "settingsTour.chat.desc",},{- target: "tour-cat-memory",+ target: "tour-nav-memory",route: "/settings",titleKey: "settingsTour.memory.title",descKey: "settingsTour.memory.desc",diff --git a/web/components/settings/SettingsHub.tsx b/web/components/settings/SettingsHub.tsxdeleted file mode 100644index ad9af5ce1..000000000--- a/web/components/settings/SettingsHub.tsx+++ /dev/null@@ -1,294 +0,0 @@-"use client";--import { useCallback, useEffect, useMemo, useState } from "react";-import Link from "next/link";-import { useRouter } from "next/navigation";-import { useTranslation } from "react-i18next";-import { ChevronRight, Rocket, Sparkles, type LucideIcon } from "lucide-react";--import { apiFetch, apiUrl } from "@/lib/api";-import { setPendingPrompt } from "@/lib/pending-prompt";-import {- serviceReadiness,- useSettings,- type ServiceReadiness,-} from "@/components/settings/SettingsContext";-import SettingsStatusPanel from "@/components/settings/SettingsStatusPanel";-import {- SETTINGS_CATEGORIES,- type Lang,- type SettingsCategory,-} from "@/lib/settings-nav";--/**- * Settings hub — the landing page of `/settings`.- *- * Six category blocks and a resident Status module, nothing else. The blocks- * are intentionally calmer than the Learning Space tiles (monochrome inline- * icons, a chevron, a quiet preview line instead of a focal count) so Settings- * reads as a control surface rather than a dashboard. Categories with several- * settings (Models, Chat) open a sub-hub; the rest link straight to their leaf.- */--type NetworkPreview = {- apiBase: string;-};--export default function SettingsHub() {- const { i18n } = useTranslation();- const router = useRouter();- const zh = i18n.language?.toLowerCase().startsWith("zh");- const tr = useCallback((l: Lang) => (zh ? l.zh : l.en), [zh]);-- const { catalog, catalogEditable, diagnosticsResults, startTour } =- useSettings();-- // Model preview: how many of the model-service leaves are configured.- const modelStats = useMemo(() => {- const cat = SETTINGS_CATEGORIES.find((c) => c.key === "models");- const services = (cat?.children ?? []).filter((l) => l.service);- if (catalogEditable !== true) {- return {- total: services.length,- configured: -1,- passed: 0,- failed: 0,- states: [] as ServiceReadiness[],- };- }- const states = services.map((leaf) =>- serviceReadiness(catalog, leaf.service!, diagnosticsResults),- );- return {- total: services.length,- configured: states.filter((state) => state !== "not_configured").length,- passed: states.filter((state) => state === "passed").length,- failed: states.filter((state) => state === "failed").length,- states,- };- }, [catalog, catalogEditable, diagnosticsResults]);-- // Network preview: a guarded peek at the effective browser API base. Fails- // quietly (non-admins get 403) → the block falls back to its blurb.- const [network, setNetwork] = useState<NetworkPreview | null>(null);- useEffect(() => {- let cancelled = false;- (async () => {- try {- const res = await apiFetch(apiUrl("/api/v1/settings/network"));- if (!res.ok) return;- const data = (await res.json()) as {- effective?: { browser_api_base?: string };- };- if (cancelled) return;- setNetwork({ apiBase: data.effective?.browser_api_base || "" });- } catch {- /* leave null → block shows its blurb */- }- })();- return () => {- cancelled = true;- };- }, []);-- return (- <div>- <header className="mb-7 flex items-start justify-between gap-4">- <div className="min-w-0">- <h1 className="font-serif text-[24px] font-semibold leading-tight tracking-tight text-[var(--foreground)]">- {tr({ zh: "设置", en: "Settings" })}- </h1>- <p className="mt-1.5 max-w-xl text-[13px] leading-relaxed text-[var(--muted-foreground)]">- {tr({- zh: "管理外观、模型与服务、知识库、聊天与记忆。",- en: "Manage appearance, models and services, knowledge base, chat, and memory.",- })}- </p>- </div>- <div className="flex shrink-0 items-center gap-2">- {/* Explicit entry point into the setup capability. It opens chat with- the request already typed rather than sending it, so the user- stays in control of what is asked. */}- <button- type="button"- onClick={() => {- setPendingPrompt(- tr({- zh: "帮我配置一下 DeepTutor,先看看现在缺什么。",- en: "Help me configure DeepTutor — start by checking what's missing.",- }),- );- router.push("/home");- }}- className="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-[var(--border)]/60 px-3 py-1.5 text-[12.5px] font-medium text-[var(--muted-foreground)] transition-colors hover:border-[var(--border)] hover:text-[var(--foreground)]"- >- <Sparkles size={13} />- {tr({ zh: "让 DeepTutor 帮我配", en: "Set up with DeepTutor" })}- </button>- <button- type="button"- onClick={startTour}- className="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-[var(--border)]/60 px-3 py-1.5 text-[12.5px] font-medium text-[var(--muted-foreground)] transition-colors hover:border-[var(--border)] hover:text-[var(--foreground)]"- >- <Rocket size={13} />- {tr({ zh: "引导", en: "Tour" })}- </button>- </div>- </header>-- <SettingsStatusPanel />-- <div className="mt-5 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">- {SETTINGS_CATEGORIES.map((category) => (- <CategoryBlock- key={category.key}- category={category}- tr={tr}- modelStats={category.key === "models" ? modelStats : undefined}- network={category.key === "network" ? network : undefined}- />- ))}- </div>- </div>- );-}--function CategoryBlock({- category,- tr,- modelStats,- network,-}: {- category: SettingsCategory;- tr: (l: Lang) => string;- modelStats?: {- total: number;- configured: number;- passed: number;- failed: number;- states: ServiceReadiness[];- };- network?: NetworkPreview | null;-}) {- const Icon: LucideIcon = category.icon;-- return (- <Link- href={category.href}- data-tour={`tour-cat-${category.key}`}- className="group relative flex min-h-[120px] flex-col justify-between rounded-2xl border border-[var(--border)]/70 bg-[var(--card)] p-5 transition-all duration-150 hover:border-[var(--foreground)]/20 hover:shadow-[0_4px_24px_-16px_rgba(0,0,0,0.3)]"- >- <div className="flex items-start justify-between gap-3">- <div className="flex items-center gap-2.5">- <Icon- size={19}- strokeWidth={1.6}- className="text-[var(--muted-foreground)] transition-colors group-hover:text-[var(--foreground)]"- />- <h3 className="text-[15.5px] font-medium tracking-tight text-[var(--foreground)]">- {tr(category.label)}- </h3>- </div>- <ChevronRight- size={16}- className="mt-0.5 shrink-0 text-[var(--muted-foreground)]/30 transition-all group-hover:translate-x-0.5 group-hover:text-[var(--muted-foreground)]"- />- </div>-- <div className="mt-4">- {modelStats ? (- <ModelPreview stats={modelStats} blurb={tr(category.blurb)} tr={tr} />- ) : network !== undefined && network !== null ? (- <NetworkPreviewRow network={network} tr={tr} />- ) : (- <p className="text-[12.5px] leading-relaxed text-[var(--muted-foreground)]">- {tr(category.blurb)}- </p>- )}- </div>- </Link>- );-}--function ModelPreview({- stats,- blurb,- tr,-}: {- stats: {- total: number;- configured: number;- passed: number;- failed: number;- states: ServiceReadiness[];- };- blurb: string;- tr: (l: Lang) => string;-}) {- // Restricted deployments (no editable catalog) can't know — show the blurb.- if (stats.configured < 0) {- return (- <p className="text-[12.5px] leading-relaxed text-[var(--muted-foreground)]">- {blurb}- </p>- );- }- return (- <div className="flex items-center gap-2.5">- <div className="flex items-center gap-1">- {stats.states.map((state, i) => (- <span- key={i}- className={`h-1.5 w-1.5 rounded-full ${- state === "passed"- ? "bg-emerald-500"- : state === "failed"- ? "bg-red-500"- : state === "untested"- ? "bg-zinc-400 dark:bg-zinc-500"- : "bg-zinc-300/60 dark:bg-zinc-700"- }`}- />- ))}- </div>- <span className="text-[12px] tabular-nums text-[var(--muted-foreground)]">- {stats.failed > 0- ? tr({- zh: `${stats.configured}/${stats.total} 已配置 · ${stats.failed} 个失败`,- en: `${stats.configured}/${stats.total} configured · ${stats.failed} failed`,- })- : stats.passed > 0- ? tr({- zh: `${stats.configured}/${stats.total} 已配置 · ${stats.passed} 个通过`,- en: `${stats.configured}/${stats.total} configured · ${stats.passed} passed`,- })- : tr({- zh: `${stats.configured}/${stats.total} 已配置`,- en: `${stats.configured}/${stats.total} configured`,- })}- </span>- </div>- );-}--function NetworkPreviewRow({- network,- tr,-}: {- network: NetworkPreview;- tr: (l: Lang) => string;-}) {- return (- <div className="flex items-center gap-2 text-[12px] text-[var(--muted-foreground)]">- <span className="shrink-0 text-[var(--muted-foreground)]/70">- {tr({ zh: "API", en: "API" })}- </span>- <span- className="truncate font-mono text-[11.5px] text-[var(--foreground)]"- title={network.apiBase}- >- {network.apiBase || tr({ zh: "本地", en: "local" })}- </span>- </div>- );-}diff --git a/web/components/settings/SettingsMain.tsx b/web/components/settings/SettingsMain.tsxindex 4826f6025..d399ce821 100644--- a/web/components/settings/SettingsMain.tsx+++ b/web/components/settings/SettingsMain.tsx@@ -2,54 +2,42 @@import { usePathname } from "next/navigation";-import SettingsBreadcrumb from "@/components/settings/SettingsBreadcrumb";+import SettingsNav from "@/components/settings/SettingsNav";import { SettingsToolbar } from "@/components/settings/SettingsToolbar";import { SettingsLoadStatusBanner } from "@/components/settings/SettingsLoadStatusBanner";-import { SETTINGS_HUB_HREF, isNavOnlyRoute } from "@/lib/settings-nav";--// Two-level hub: the dashboard at `/settings` is the entry; categories with-// several settings open a sub-hub, the rest go straight to a leaf. Every page-// below the hub carries a breadcrumb top-left so the user knows where they-// are. The sticky Save Draft / Apply toolbar rides above the scroll area on-// leaf pages only — nav-only pages (hub, sub-hubs) have nothing to save.+import { isNavOnlyRoute } from "@/lib/settings-nav";+/**+ * Settings shell: a persistent navigator on the left, one page on the right.+ *+ * This replaces a hub → sub-hub → leaf walk where the only way to reach a+ * second setting was to climb back to the root. The breadcrumb went with it —+ * the column already shows where you are, and a trail repeating the page title+ * directly above the page title was two lines saying one thing.+ */export default function SettingsMain({children,}: Readonly<{ children: React.ReactNode }>) {const pathname = usePathname() ?? "";- const isHub = pathname === SETTINGS_HUB_HREF;-- if (isHub) {- return (- <div className="h-full overflow-y-auto bg-[var(--background)] [scrollbar-gutter:stable]">- <div className="mx-auto w-full max-w-5xl px-8 py-8 pb-12">- {children}- </div>- </div>- );- }-const showToolbar = !isNavOnlyRoute(pathname);return (- <div className="flex h-full min-w-0 flex-col overflow-hidden bg-[var(--background)]">- <div className="mx-auto w-full max-w-5xl px-10 pt-5">- <SettingsBreadcrumb />- {showToolbar && (- <div className="mt-2">- <SettingsToolbar />- </div>- )}- <SettingsLoadStatusBanner />+ <div className="flex h-full min-w-0 bg-[var(--background)]">+ <div className="hidden h-full shrink-0 border-r border-[var(--border)]/60 py-5 pl-6 pr-3 md:block">+ <SettingsNav /></div>- {/* Inner scroll container. Sticky elements inside (e.g. the profile-list- aside in ServiceConfigEditor) anchor to this ancestor instead of the- outer flex column, so the left column stays put while the right side- scrolls. ``min-h-0`` is required for the flex child to constrain to- remaining space — without it, ``overflow-y-auto`` would never clip. */}- <div className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]">- <div className="mx-auto w-full max-w-5xl px-10 pb-16">- <div className="mt-4">{children}</div>+ <div className="flex h-full min-w-0 flex-1 flex-col overflow-hidden">+ <div className="w-full px-8 pt-5">+ {showToolbar && <SettingsToolbar />}+ <SettingsLoadStatusBanner />+ </div>+ {/* Inner scroll container. Sticky elements inside (e.g. the profile-list+ aside in ServiceConfigEditor) anchor to this ancestor instead of the+ outer flex column, so the left column stays put while the right side+ scrolls. ``min-h-0`` is required for the flex child to constrain to+ remaining space — without it, ``overflow-y-auto`` would never clip. */}+ <div className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]">+ <div className="w-full max-w-3xl px-8 pb-16 pt-2">{children}</div></div></div></div>diff --git a/web/components/settings/SettingsNav.tsx b/web/components/settings/SettingsNav.tsxnew file mode 100644index 000000000..c4a3e4a87--- /dev/null+++ b/web/components/settings/SettingsNav.tsx@@ -0,0 +1,205 @@+"use client";++import { useCallback, useEffect, useMemo, useState } from "react";+import Link from "next/link";+import { usePathname } from "next/navigation";+import { Search, X } from "lucide-react";+import { useTranslation } from "react-i18next";++import { fetchAuthStatus } from "@/lib/auth";+import {+ SETTINGS_CATEGORIES,+ SETTINGS_HUB_HREF,+ type Lang,+ type SettingsLeaf,+} from "@/lib/settings-nav";+import { serviceReadiness, useSettings } from "./SettingsContext";++/**+ * The settings navigator — one persistent column, every page one click away.+ *+ * Settings used to be a folder tree: the hub listed seven categories, four of+ * those opened a second grid, and the leaf was the third click. Changing two+ * things in different categories meant walking back up to the root in between,+ * because nothing but a breadcrumb ever showed where else you could go. Every+ * comparable product — VS Code, Slack, GitHub, Stripe, Dify, Open WebUI —+ * keeps the whole map on screen instead, and so does this.+ *+ * Search filters to matching pages rather than opening a separate results+ * view: with two dozen pages the question is almost always "which page is that+ * on", and the answer is more useful in place.+ */++type Row = { leaf: SettingsLeaf; category: Lang };++export default function SettingsNav() {+ const pathname = usePathname() ?? "";+ const { t, i18n } = useTranslation();+ const zh = i18n.language?.toLowerCase().startsWith("zh");+ const tr = useCallback((value: Lang) => (zh ? value.zh : value.en), [zh]);+ const { catalog, catalogEditable, diagnosticsResults } = useSettings();++ const [query, setQuery] = useState("");+ const [hideAdminOnly, setHideAdminOnly] = useState(false);++ useEffect(() => {+ let cancelled = false;+ fetchAuthStatus().then((authStatus) => {+ if (cancelled || !authStatus) return;+ setHideAdminOnly(Boolean(authStatus.enabled) && !authStatus.is_admin);+ });+ return () => {+ cancelled = true;+ };+ }, []);++ // A category with children contributes its leaves; one without is itself a+ // row, so a single-page category never costs an extra level of nesting.+ const groups = useMemo(+ () =>+ SETTINGS_CATEGORIES.map((category) => ({+ key: category.key,+ label: category.label,+ rows: (+ category.children ?? [+ {+ key: category.key,+ href: category.href,+ label: category.label,+ blurb: category.blurb,+ icon: category.icon,+ tile: "",+ } satisfies SettingsLeaf,+ ]+ )+ .filter((leaf) => !(leaf.adminOnly && hideAdminOnly))+ .map((leaf) => ({ leaf, category: category.label }) satisfies Row),+ standalone: !category.children,+ })),+ [hideAdminOnly],+ );++ const needle = query.trim().toLowerCase();+ const matches = useCallback(+ (row: Row) =>+ !needle ||+ [row.leaf.label.en, row.leaf.label.zh, row.leaf.blurb.en, row.leaf.blurb.zh]+ .join(" ")+ .toLowerCase()+ .includes(needle),+ [needle],+ );++ const visible = groups+ .map((group) => ({ ...group, rows: group.rows.filter(matches) }))+ .filter((group) => group.rows.length > 0);++ // Only the failure state earns a mark here: "not configured yet" is the+ // normal state of most of these services and would dot half the column.+ const failing = useCallback(+ (leaf: SettingsLeaf) =>+ leaf.service !== undefined &&+ catalogEditable === true &&+ serviceReadiness(catalog, leaf.service, diagnosticsResults) === "failed",+ [catalog, catalogEditable, diagnosticsResults],+ );++ return (+ <nav+ aria-label={t("Settings sections")}+ className="flex h-full w-[196px] shrink-0 flex-col gap-3 overflow-y-auto pb-8 pr-1 pt-1"+ >+ <div className="relative">+ <Search className="pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-[var(--muted-foreground)]/60" />+ <input+ value={query}+ onChange={(event) => setQuery(event.target.value)}+ placeholder={t("Search settings")}+ aria-label={t("Search settings")}+ className="w-full rounded-md bg-[var(--muted)]/40 py-1.5 pl-7 pr-6 text-[12px] text-[var(--foreground)] outline-none placeholder:text-[var(--muted-foreground)]/60 focus:bg-[var(--muted)]/70"+ />+ {query && (+ <button+ type="button"+ onClick={() => setQuery("")}+ aria-label={t("Clear")}+ className="absolute right-1 top-1/2 -translate-y-1/2 rounded p-1 text-[var(--muted-foreground)] hover:text-[var(--foreground)]"+ >+ <X className="h-3 w-3" />+ </button>+ )}+ </div>++ <Row+ href={SETTINGS_HUB_HREF}+ label={t("Overview")}+ active={pathname === SETTINGS_HUB_HREF}+ tourId="tour-nav-overview"+ />++ {visible.length === 0 && (+ <p className="px-2 text-[11.5px] leading-relaxed text-[var(--muted-foreground)]">+ {t("No settings match “{{query}}”.", { query: query.trim() })}+ </p>+ )}++ {visible.map((group) => (+ <div key={group.key}>+ {!group.standalone && (+ <div className="px-2 pb-1 text-[11px] font-medium text-[var(--muted-foreground)]/70">+ {tr(group.label)}+ </div>+ )}+ <div className="space-y-px">+ {group.rows.map(({ leaf }, index) => (+ <Row+ key={leaf.key}+ href={leaf.href}+ label={tr(leaf.label)}+ active={pathname === leaf.href}+ failing={failing(leaf)}+ tourId={index === 0 ? `tour-nav-${group.key}` : undefined}+ />+ ))}+ </div>+ </div>+ ))}+ </nav>+ );+}++function Row({+ href,+ label,+ active,+ failing,+ tourId,+}: {+ href: string;+ label: string;+ active: boolean;+ failing?: boolean;+ /** Only the first row of a group carries it, so the tour lands on the group. */+ tourId?: string;+}) {+ return (+ <Link+ href={href}+ data-tour={tourId}+ aria-current={active ? "page" : undefined}+ className={`flex items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[12.5px] leading-tight transition-colors ${+ active+ ? "bg-[var(--muted)]/70 font-medium text-[var(--foreground)]"+ : "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/35 hover:text-[var(--foreground)]"+ }`}+ >+ <span className="truncate">{label}</span>+ {failing && (+ <span+ aria-hidden+ className="h-1.5 w-1.5 shrink-0 rounded-full bg-red-400"+ />+ )}+ </Link>+ );+}diff --git a/web/components/settings/SettingsOverview.tsx b/web/components/settings/SettingsOverview.tsxnew file mode 100644index 000000000..5fe4b9ea6--- /dev/null+++ b/web/components/settings/SettingsOverview.tsx@@ -0,0 +1,264 @@+"use client";++import { useCallback, useMemo } from "react";+import Link from "next/link";+import { ArrowUpRight, Check } from "lucide-react";+import { useTranslation } from "react-i18next";++import ProviderIcon from "@/components/common/ProviderIcon";+import SettingsStatusPanel from "@/components/settings/SettingsStatusPanel";+import { setPendingPrompt } from "@/lib/pending-prompt";+import {+ SETTINGS_CATEGORIES,+ type Lang,+ type SettingsLeaf,+} from "@/lib/settings-nav";+import {+ getActiveModel,+ getActiveProfile,+ serviceReadiness,+ useSettings,+} from "./SettingsContext";++/**+ * The settings landing page.+ *+ * It used to be a grid of seven cards whose only job was to link to the seven+ * categories — a directory, now that the navigator lists every page anyway.+ * What it could not answer, and what a landing page is for, is "what state am+ * I actually in": which services are set up, which failed their last test, and+ * whether something is sitting in a draft waiting to be applied.+ */+export default function SettingsOverview() {+ const { t, i18n } = useTranslation();+ const zh = i18n.language?.toLowerCase().startsWith("zh");+ const tr = useCallback((value: Lang) => (zh ? value.zh : value.en), [zh]);+ const {+ catalog,+ catalogEditable,+ diagnosticsResults,+ draftState,+ storedDraft,+ startTour,+ } = useSettings();++ const modelLeaves = useMemo(+ () =>+ (+ SETTINGS_CATEGORIES.find((category) => category.key === "models")+ ?.children ?? []+ ).filter((leaf): leaf is SettingsLeaf & { service: NonNullable<SettingsLeaf["service"]> } =>+ Boolean(leaf.service),+ ),+ [],+ );++ const states = useMemo(+ () =>+ catalogEditable !== true+ ? []+ : modelLeaves.map((leaf) => ({+ leaf,+ readiness: serviceReadiness(catalog, leaf.service, diagnosticsResults),+ })),+ [catalog, catalogEditable, diagnosticsResults, modelLeaves],+ );++ const failed = states.filter((item) => item.readiness === "failed");+ const missing = states.filter((item) => item.readiness === "not_configured");+ const ready = states.length - failed.length - missing.length;++ // Everything the user can act on, most urgent first. An empty list is worth+ // saying out loud — "nothing needs attention" is information, and the blank+ // panel it replaces is not.+ const attention: { key: string; text: string; href: string; label: string }[] =+ [];+ if (draftState !== "clean") {+ attention.push({+ key: "draft",+ text:+ draftState === "saved"+ ? t("A saved draft is waiting to be applied.")+ : t("There are changes you have not saved anywhere yet."),+ href: "/settings/llm",+ label: t("Review"),+ });+ }+ for (const item of failed) {+ attention.push({+ key: `failed-${item.leaf.key}`,+ text: t("{{service}} failed its last connection test.", {+ service: tr(item.leaf.label),+ }),+ href: item.leaf.href,+ label: t("Open"),+ });+ }++ const active = useMemo(() => {+ if (catalogEditable !== true) return [];+ return (+ [+ { key: "llm", label: { zh: "语言模型", en: "Language model" } },+ { key: "embedding", label: { zh: "嵌入模型", en: "Embedding" } },+ ] as const+ ).map(({ key, label }) => {+ const profile = getActiveProfile(catalog, key);+ const model = getActiveModel(catalog, key);+ return {+ key,+ label,+ binding: profile?.binding ?? "",+ model: model?.model ?? "",+ href: key === "llm" ? "/settings/llm" : "/settings/embedding",+ };+ });+ }, [catalog, catalogEditable]);++ return (+ <div>+ <header className="mb-6 flex items-start justify-between gap-4">+ <div className="min-w-0">+ <h1 className="font-serif text-[24px] font-semibold leading-tight tracking-tight text-[var(--foreground)]">+ {t("Settings")}+ </h1>+ <p className="mt-1.5 text-[13px] leading-relaxed text-[var(--muted-foreground)]">+ {catalogEditable === true && states.length > 0+ ? t("{{ready}} of {{total}} model services set up.", {+ ready,+ total: states.length,+ })+ : t("Appearance, models, knowledge, chat, and memory.")}+ </p>+ </div>+ <button+ type="button"+ onClick={() => {+ setPendingPrompt(+ tr({+ zh: "帮我配置一下 DeepTutor,先看看现在缺什么。",+ en: "Help me configure DeepTutor — start by checking what's missing.",+ }),+ );+ }}+ className="hidden shrink-0 items-center gap-1.5 rounded-lg border border-[var(--border)] px-3 py-1.5 text-[12px] font-medium text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)] sm:inline-flex"+ >+ {t("Set up with DeepTutor")}+ </button>+ </header>++ <SettingsStatusPanel />++ {catalogEditable === true && (+ <>+ <Section title={t("Needs attention")}>+ {attention.length === 0 ? (+ <div className="flex items-center gap-2 px-4 py-3 text-[12.5px] text-[var(--muted-foreground)]">+ <Check className="h-3.5 w-3.5 text-emerald-500" />+ {t("Nothing to do — everything configured is working.")}+ </div>+ ) : (+ attention.map((item, index) => (+ <div+ key={item.key}+ className={`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 px-4 py-3 ${+ index === 0 ? "" : "border-t border-[var(--border)]"+ }`}+ >+ <span className="text-[12.5px] text-[var(--foreground)]">+ {item.text}+ </span>+ <Link+ href={item.href}+ className="inline-flex items-center gap-1 text-[11.5px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"+ >+ {item.label}+ <ArrowUpRight className="h-3 w-3" />+ </Link>+ </div>+ ))+ )}+ </Section>++ {active.some((item) => item.model) && (+ <Section title={t("In use")}>+ {active.filter((item) => item.model).map((item, index) => (+ <div+ key={item.key}+ className={`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 px-4 py-3 ${+ index === 0 ? "" : "border-t border-[var(--border)]"+ }`}+ >+ <span className="text-[12.5px] text-[var(--muted-foreground)]">+ {tr(item.label)}+ </span>+ <Link+ href={item.href}+ className="inline-flex min-w-0 items-center gap-1.5 text-[12px] text-[var(--foreground)] transition-opacity hover:opacity-70"+ >+ {item.binding && (+ <ProviderIcon provider={item.binding} size={13} />+ )}+ <span className="truncate font-mono text-[11.5px]">+ {item.model}+ </span>+ <ArrowUpRight className="h-3 w-3 shrink-0 text-[var(--muted-foreground)]" />+ </Link>+ </div>+ ))}+ </Section>+ )}++ {missing.length > 0 && (+ <Section title={t("Not set up yet")}>+ <div className="flex flex-wrap gap-x-4 gap-y-2 px-4 py-3">+ {missing.map((item) => (+ <Link+ key={item.leaf.key}+ href={item.leaf.href}+ className="inline-flex items-center gap-1 text-[12px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"+ >+ {tr(item.leaf.label)}+ <ArrowUpRight className="h-3 w-3" />+ </Link>+ ))}+ </div>+ </Section>+ )}+ </>+ )}++ <button+ type="button"+ onClick={startTour}+ className="mt-6 text-[11.5px] text-[var(--muted-foreground)] underline-offset-2 transition-colors hover:text-[var(--foreground)] hover:underline"+ >+ {t("Take the tour")}+ </button>+ {storedDraft?.updated_at && (+ <p className="mt-2 text-[11px] text-[var(--muted-foreground)]/70">+ {t("Draft saved {{when}}", { when: storedDraft.updated_at })}+ </p>+ )}+ </div>+ );+}++function Section({+ title,+ children,+}: {+ title: string;+ children: React.ReactNode;+}) {+ return (+ <section className="mt-6">+ <h2 className="mb-2 text-[12px] font-medium text-[var(--muted-foreground)]">+ {title}+ </h2>+ <div className="overflow-hidden rounded-xl border border-[var(--border)]">+ {children}+ </div>+ </section>+ );+}diff --git a/web/components/settings/SettingsSectionGrid.tsx b/web/components/settings/SettingsSectionGrid.tsxdeleted file mode 100644index 58f96a161..000000000--- a/web/components/settings/SettingsSectionGrid.tsx+++ /dev/null@@ -1,211 +0,0 @@-"use client";--import { useCallback, useEffect, useState } from "react";-import Link from "next/link";-import { useTranslation } from "react-i18next";-import { ArrowUpRight } from "lucide-react";--import { fetchAuthStatus } from "@/lib/auth";-import {- serviceReadiness,- useSettings,-} from "@/components/settings/SettingsContext";-import {- SETTINGS_CATEGORIES,- type Lang,- type SettingsLeaf,-} from "@/lib/settings-nav";--/**- * Second-level grid for a sub-hub category (Models, Chat). Lists the- * category's leaves as tiles — colored icon, configured chip for model- * services, and a blurb — the focused view the user reaches by clicking the- * hub block.- */-export default function SettingsSectionGrid({- categoryKey,-}: {- categoryKey: string;-}) {- const { i18n } = useTranslation();- const zh = i18n.language?.toLowerCase().startsWith("zh");- const tr = useCallback((l: Lang) => (zh ? l.zh : l.en), [zh]);-- const { catalog, catalogEditable, diagnosticsResults } = useSettings();-- const category = SETTINGS_CATEGORIES.find((c) => c.key === categoryKey);-- const [hideAdminOnly, setHideAdminOnly] = useState(false);- useEffect(() => {- let cancelled = false;- fetchAuthStatus().then((authStatus) => {- if (cancelled || !authStatus) return;- setHideAdminOnly(Boolean(authStatus.enabled) && !authStatus.is_admin);- });- return () => {- cancelled = true;- };- }, []);-- const chipFor = useCallback(- (- leaf: SettingsLeaf,- ): { label: Lang; tone: "ok" | "bad" | "neutral"; dot: boolean } | null => {- if (catalogEditable !== true) return null;- // Two leaves in the Models grid configure the catalog without owning a- // service of their own; their chip counts what they hold instead.- if (leaf.key === "connections") {- const count = (catalog.connections ?? []).length;- return count > 0- ? {- tone: "neutral",- dot: true,- label: { zh: `${count} 个连接`, en: `${count} connected` },- }- : { tone: "neutral", dot: false, label: { zh: "未配置", en: "Not set" } };- }- if (leaf.key === "task-models") {- const count = Object.keys(catalog.services.llm.tasks ?? {}).length;- return count > 0- ? {- tone: "neutral",- dot: true,- label: { zh: `${count} 项已指定`, en: `${count} pinned` },- }- : {- tone: "neutral",- dot: false,- label: { zh: "跟随默认", en: "Inherited" },- };- }- if (!leaf.service) return null;- const readiness = serviceReadiness(- catalog,- leaf.service,- diagnosticsResults,- );- if (readiness === "failed") {- return {- tone: "bad",- dot: true,- label: { zh: "测试失败", en: "Test failed" },- };- }- if (readiness === "passed") {- return {- tone: "ok",- dot: true,- label: { zh: "测试通过", en: "Test passed" },- };- }- if (readiness === "untested") {- return {- tone: "neutral",- dot: true,- label: { zh: "已配置", en: "Configured" },- };- }- return {- tone: "neutral",- dot: false,- label: { zh: "未配置", en: "Not set" },- };- },- [catalog, catalogEditable, diagnosticsResults],- );-- if (!category?.children) return null;-- const leaves = category.children.filter(- (leaf) => !(leaf.adminOnly && hideAdminOnly),- );-- return (- <div>- <header className="mb-6">- <h1 className="font-serif text-[22px] font-semibold tracking-tight text-[var(--foreground)]">- {tr(category.label)}- </h1>- <p className="mt-1.5 text-[13px] leading-relaxed text-[var(--muted-foreground)]">- {tr(category.blurb)}- </p>- </header>-- <div className="grid gap-3 sm:grid-cols-2">- {leaves.map((leaf) => (- <LeafCard key={leaf.key} leaf={leaf} chip={chipFor(leaf)} tr={tr} />- ))}- </div>- </div>- );-}--function LeafCard({- leaf,- chip,- tr,-}: {- leaf: SettingsLeaf;- chip: { label: Lang; tone: "ok" | "bad" | "neutral"; dot: boolean } | null;- tr: (l: Lang) => string;-}) {- const Icon = leaf.icon;- const tone = chip?.tone ?? "neutral";- return (- <Link- href={leaf.href}- className="group relative flex flex-col rounded-xl border border-[var(--border)] bg-[var(--card)] p-4 transition-all duration-150 hover:-translate-y-0.5 hover:border-[var(--foreground)]/20 hover:shadow-[0_6px_20px_-12px_rgba(0,0,0,0.25)]"- >- <div className="flex items-start gap-3">- <span- aria-hidden- className={`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${leaf.tile}`}- >- <Icon size={18} strokeWidth={1.7} />- </span>- <div className="min-w-0 flex-1">- <div className="flex items-center gap-2">- <h3 className="truncate text-[14.5px] font-medium leading-tight tracking-tight text-[var(--foreground)]">- {tr(leaf.label)}- </h3>- {chip && (- <span- className={`inline-flex shrink-0 items-center gap-1 text-[10.5px] font-medium ${- chip.dot- ? `rounded-full px-1.5 py-0.5 ${- tone === "bad"- ? "bg-red-500/10 text-red-600 dark:text-red-400"- : tone === "ok"- ? "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400"- : "bg-zinc-500/10 text-zinc-600 dark:text-zinc-300"- }`- : "text-[var(--muted-foreground)]"- }`}- >- {chip.dot && (- <span- className={`h-1.5 w-1.5 rounded-full ${- tone === "bad"- ? "bg-red-500"- : tone === "ok"- ? "bg-emerald-500"- : "bg-zinc-400 dark:bg-zinc-500"- }`}- />- )}- {tr(chip.label)}- </span>- )}- </div>- </div>- <ArrowUpRight- size={16}- className="shrink-0 text-[var(--muted-foreground)]/40 transition-colors group-hover:text-[var(--foreground)]"- />- </div>- <p className="mt-3 text-[12.5px] leading-relaxed text-[var(--muted-foreground)]">- {tr(leaf.blurb)}- </p>- </Link>- );-}diff --git a/web/lib/settings-nav.ts b/web/lib/settings-nav.tsindex faab8eaa3..f8abde188 100644--- a/web/lib/settings-nav.ts+++ b/web/lib/settings-nav.ts@@ -269,6 +269,21 @@ const AGENT_CHILDREN: SettingsLeaf[] = [tile: "bg-sky-500/10 text-sky-600 dark:text-sky-400",adminOnly: true,},+ {+ // Supported everywhere else — backend kind, icon, label, its own settings+ // page — but missing from this list, so the page was reachable only by+ // typing the URL. Gemini CLI is retired and this is what replaced it.+ key: "agent-antigravity",+ href: "/settings/agents/antigravity",+ label: { zh: "Antigravity CLI", en: "Antigravity CLI" },+ blurb: {+ zh: "DeepTutor 调用本机 Antigravity CLI 时的模型与运行参数。",+ en: "Model and run params for the local Antigravity CLI.",+ },+ icon: GeminiGlyph as unknown as LucideIcon,+ tile: "bg-sky-500/10 text-sky-600 dark:text-sky-400",+ adminOnly: true,+ },{key: "agent-kimi",href: "/settings/agents/kimi",diff --git a/web/locales/en/app.json b/web/locales/en/app.jsonindex 2fa7f2d89..1f1e2b68a 100644--- a/web/locales/en/app.json+++ b/web/locales/en/app.json@@ -3614,5 +3614,20 @@"Put these settings into effect.": "Put these settings into effect.","Go back to what is currently live.": "Go back to what is currently live.","Could not save the draft: {{message}}": "Could not save the draft: {{message}}",- "Could not apply: {{message}}": "Could not apply: {{message}}"+ "Could not apply: {{message}}": "Could not apply: {{message}}",+ "Search settings": "Search settings",+ "Settings sections": "Settings sections",+ "No settings match “{{query}}”.": "No settings match “{{query}}”.",+ "Nothing to do — everything configured is working.": "Nothing to do — everything configured is working.",+ "A saved draft is waiting to be applied.": "A saved draft is waiting to be applied.",+ "There are changes you have not saved anywhere yet.": "There are changes you have not saved anywhere yet.",+ "{{service}} failed its last connection test.": "{{service}} failed its last connection test.",+ "In use": "In use",+ "Not set up yet": "Not set up yet",+ "{{ready}} of {{total}} model services set up.": "{{ready}} of {{total}} model services set up.",+ "Appearance, models, knowledge, chat, and memory.": "Appearance, models, knowledge, chat, and memory.",+ "Take the tour": "Take the tour",+ "Draft saved {{when}}": "Draft saved {{when}}",+ "Set up with DeepTutor": "Set up with DeepTutor",+ "Delete this profile and every model under it?": "Delete this profile and every model under it?"}diff --git a/web/locales/zh/app.json b/web/locales/zh/app.jsonindex 1e06031cb..e14b1cd08 100644--- a/web/locales/zh/app.json+++ b/web/locales/zh/app.json@@ -3614,5 +3614,20 @@"Put these settings into effect.": "让这些设置生效。","Go back to what is currently live.": "回到当前生效的设置。","Could not save the draft: {{message}}": "草稿保存失败:{{message}}",- "Could not apply: {{message}}": "应用失败:{{message}}"+ "Could not apply: {{message}}": "应用失败:{{message}}",+ "Search settings": "搜索设置",+ "Settings sections": "设置分区",+ "No settings match “{{query}}”.": "没有匹配「{{query}}」的设置。",+ "Nothing to do — everything configured is working.": "没有待处理项 —— 已配置的都在正常工作。",+ "A saved draft is waiting to be applied.": "有一份已保存的草稿等待应用。",+ "There are changes you have not saved anywhere yet.": "有一些更改还没有保存到任何地方。",+ "{{service}} failed its last connection test.": "{{service}} 上次连接测试失败。",+ "In use": "当前使用",+ "Not set up yet": "尚未配置",+ "{{ready}} of {{total}} model services set up.": "已配置 {{ready}}/{{total}} 个模型服务。",+ "Appearance, models, knowledge, chat, and memory.": "外观、模型、知识库、聊天与记忆。",+ "Take the tour": "看看引导",+ "Draft saved {{when}}": "草稿保存于 {{when}}",+ "Set up with DeepTutor": "让 DeepTutor 帮我配置",+ "Delete this profile and every model under it?": "删除这个配置,以及它下面的所有模型?"}