DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(settings): restore what the removed hub carried, and the narrow layout
Bingxi Zhao (Frank)f76c37cf9f35
diff --git a/web/components/settings/ServiceConfigEditor.tsx b/web/components/settings/ServiceConfigEditor.tsxindex ff8fd06dd..0abe8bd7e 100644--- a/web/components/settings/ServiceConfigEditor.tsx+++ b/web/components/settings/ServiceConfigEditor.tsx@@ -406,9 +406,10 @@ export function ServiceConfigEditor({ service }: { service: ServiceName }) {</div>)}{activeProfile ? (- <div className="grid grid-cols-[200px_minmax(0,1fr)] items-start gap-5">- {/* ── Profile list (sticky so it stays put while the editor scrolls) ── */}- <aside className="sticky top-4 self-start rounded-xl border border-[var(--border)]/60 bg-[var(--card)]/40 p-2">+ <div className="grid grid-cols-1 items-start gap-5 md:grid-cols-[200px_minmax(0,1fr)]">+ {/* ── Profile list (sticky so it stays put while the editor scrolls;+ stacked above the editor when there is no room beside it) ── */}+ <aside className="self-start rounded-xl border border-[var(--border)]/60 bg-[var(--card)]/40 p-2 md:sticky md:top-4"><div className="px-2 pb-2 pt-1 text-[11px] font-medium uppercase tracking-wide text-[var(--muted-foreground)]/70">{t("Profiles")}</div>diff --git a/web/components/settings/SettingsMain.tsx b/web/components/settings/SettingsMain.tsxindex d399ce821..77a1507d7 100644--- a/web/components/settings/SettingsMain.tsx+++ b/web/components/settings/SettingsMain.tsx@@ -2,7 +2,9 @@import { usePathname } from "next/navigation";-import SettingsNav from "@/components/settings/SettingsNav";+import SettingsNav, {+ SettingsNavCompact,+} from "@/components/settings/SettingsNav";import { SettingsToolbar } from "@/components/settings/SettingsToolbar";import { SettingsLoadStatusBanner } from "@/components/settings/SettingsLoadStatusBanner";import { isNavOnlyRoute } from "@/lib/settings-nav";@@ -28,6 +30,11 @@ export default function SettingsMain({</div><div className="flex h-full min-w-0 flex-1 flex-col overflow-hidden"><div className="w-full px-8 pt-5">+ {/* Below `md` the column is hidden, so this is the only way out of+ the page you landed on. */}+ <div className="mb-2">+ <SettingsNavCompact />+ </div>{showToolbar && <SettingsToolbar />}<SettingsLoadStatusBanner /></div>diff --git a/web/components/settings/SettingsNav.tsx b/web/components/settings/SettingsNav.tsxindex c4a3e4a87..4e3885183 100644--- a/web/components/settings/SettingsNav.tsx+++ b/web/components/settings/SettingsNav.tsx@@ -2,8 +2,8 @@import { useCallback, useEffect, useMemo, useState } from "react";import Link from "next/link";-import { usePathname } from "next/navigation";-import { Search, X } from "lucide-react";+import { usePathname, useRouter } from "next/navigation";+import { ChevronDown, Search, X } from "lucide-react";import { useTranslation } from "react-i18next";import { fetchAuthStatus } from "@/lib/auth";@@ -32,30 +32,20 @@ import { serviceReadiness, useSettings } from "./SettingsContext";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();+type Group = {+ key: string;+ label: Lang;+ rows: Row[];+ standalone: boolean;+};- 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(+/**+ * The same map both layouts render. 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.+ */+function useGroups(hideAdminOnly: boolean): Group[] {+ return useMemo(() =>SETTINGS_CATEGORIES.map((category) => ({key: category.key,@@ -78,6 +68,78 @@ export default function SettingsNav() {})),[hideAdminOnly],);+}++function useHideAdminOnly(): boolean {+ 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;+ };+ }, []);+ return hideAdminOnly;+}++/**+ * Narrow-screen navigator.+ *+ * The column is hidden below `md`, and the breadcrumb it replaced is gone, so+ * without this a phone landing on a settings page has no way back to any other+ * one. A native select is the right control here: it groups, it is one tap,+ * and the platform renders it better than anything reimplemented.+ */+export function SettingsNavCompact() {+ const pathname = usePathname() ?? "";+ const router = useRouter();+ const { t, i18n } = useTranslation();+ const zh = i18n.language?.toLowerCase().startsWith("zh");+ const tr = (value: Lang) => (zh ? value.zh : value.en);+ const groups = useGroups(useHideAdminOnly());++ return (+ <div className="relative md:hidden">+ <select+ value={pathname}+ aria-label={t("Settings sections")}+ onChange={(event) => router.push(event.target.value)}+ className="w-full appearance-none rounded-lg border border-[var(--border)] bg-[var(--background)] py-2 pl-3 pr-8 text-[13px] font-medium text-[var(--foreground)] outline-none"+ >+ <option value={SETTINGS_HUB_HREF}>{t("Overview")}</option>+ {groups.map((group) =>+ group.standalone ? (+ <option key={group.key} value={group.rows[0]?.leaf.href}>+ {tr(group.label)}+ </option>+ ) : (+ <optgroup key={group.key} label={tr(group.label)}>+ {group.rows.map(({ leaf }) => (+ <option key={leaf.key} value={leaf.href}>+ {tr(leaf.label)}+ </option>+ ))}+ </optgroup>+ ),+ )}+ </select>+ <ChevronDown className="pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--muted-foreground)]" />+ </div>+ );+}++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 groups = useGroups(useHideAdminOnly());const needle = query.trim().toLowerCase();const matches = useCallback(@@ -158,6 +220,7 @@ export default function SettingsNav() {label={tr(leaf.label)}active={pathname === leaf.href}failing={failing(leaf)}+ hint={tr(leaf.blurb)}tourId={index === 0 ? `tour-nav-${group.key}` : undefined}/>))}@@ -173,12 +236,15 @@ function Row({label,active,failing,+ hint,tourId,}: {href: string;label: string;active: boolean;failing?: boolean;+ /** The one-line description the old sub-hub tiles showed under each name. */+ hint?: string;/** Only the first row of a group carries it, so the tour lands on the group. */tourId?: string;}) {@@ -186,6 +252,7 @@ function Row({<Linkhref={href}data-tour={tourId}+ title={hint}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 ${activediff --git a/web/components/settings/SettingsOverview.tsx b/web/components/settings/SettingsOverview.tsxindex 5fe4b9ea6..1bc460f3a 100644--- a/web/components/settings/SettingsOverview.tsx+++ b/web/components/settings/SettingsOverview.tsx@@ -1,11 +1,12 @@"use client";-import { useCallback, useMemo } from "react";+import { useCallback, useEffect, useMemo, useState } 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 { apiFetch, apiUrl } from "@/lib/api";import SettingsStatusPanel from "@/components/settings/SettingsStatusPanel";import { setPendingPrompt } from "@/lib/pending-prompt";import {@@ -18,6 +19,7 @@ import {getActiveProfile,serviceReadiness,useSettings,+ type ServiceReadiness,} from "./SettingsContext";/**@@ -95,25 +97,46 @@ export default function SettingsOverview() {});}- 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]);+ // What each service actually resolves to right now. Search names a provider+ // rather than a model, so it reports that instead of an empty string.+ const { detail, binding } = useMemo(() => {+ const detail: Record<string, string> = {};+ const binding: Record<string, string> = {};+ if (catalogEditable !== true) return { detail, binding };+ for (const leaf of modelLeaves) {+ const profile = getActiveProfile(catalog, leaf.service);+ binding[leaf.key] =+ (leaf.service === "search" ? profile?.provider : profile?.binding) ?? "";+ detail[leaf.key] =+ leaf.service === "search"+ ? (profile?.provider ?? "")+ : (getActiveModel(catalog, leaf.service)?.model ?? "");+ }+ return { detail, binding };+ }, [catalog, catalogEditable, modelLeaves]);++ // The effective browser API base. The old hub previewed it on its Network+ // card, and it is the first thing to check on a Docker or LAN install, so it+ // did not deserve to disappear with that card.+ const [apiBase, setApiBase] = useState("");+ 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) setApiBase(data.effective?.browser_api_base || "");+ } catch {+ /* non-admins get 403; the row simply does not render */+ }+ })();+ return () => {+ cancelled = true;+ };+ }, []);return (<div>@@ -180,54 +203,55 @@ export default function SettingsOverview() {)}</Section>- {active.some((item) => item.model) && (- <Section title={t("In use")}>- {active.filter((item) => item.model).map((item, index) => (+ <Section title={t("Model services")}>+ {states.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 ${+ key={item.leaf.key}+ className={`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 px-4 py-2.5 ${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"+ href={item.leaf.href}+ className="text-[12.5px] 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)]" />+ {tr(item.leaf.label)}</Link>+ <span className="flex min-w-0 items-center gap-2">+ {detail[item.leaf.key] && (+ <span className="flex min-w-0 items-center gap-1.5">+ {binding[item.leaf.key] && (+ <ProviderIcon+ provider={binding[item.leaf.key]}+ size={12}+ />+ )}+ <span className="truncate font-mono text-[11px] text-[var(--muted-foreground)]">+ {detail[item.leaf.key]}+ </span>+ </span>+ )}+ <ReadinessChip readiness={item.readiness} />+ </span></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>- )}</>)}+ {apiBase && (+ <p className="mt-5 text-[11.5px] text-[var(--muted-foreground)]">+ {t("Browser API base")}{" "}+ <Link+ href="/settings/network"+ className="font-mono text-[var(--foreground)]/70 underline-offset-2 hover:underline"+ >+ {apiBase}+ </Link>+ </p>+ )}+<buttontype="button"onClick={startTour}@@ -244,6 +268,27 @@ export default function SettingsOverview() {);}+function ReadinessChip({ readiness }: { readiness: ServiceReadiness }) {+ const { t } = useTranslation();+ const label: Record<ServiceReadiness, string> = {+ passed: t("Test passed"),+ failed: t("Test failed"),+ untested: t("Configured"),+ not_configured: t("Not set"),+ };+ const tone: Record<ServiceReadiness, string> = {+ passed: "text-emerald-600 dark:text-emerald-400",+ failed: "text-red-500",+ untested: "text-[var(--muted-foreground)]",+ not_configured: "text-[var(--muted-foreground)]/60",+ };+ return (+ <span className={`shrink-0 text-[11px] ${tone[readiness]}`}>+ {label[readiness]}+ </span>+ );+}+function Section({title,children,diff --git a/web/locales/en/app.json b/web/locales/en/app.jsonindex 1f1e2b68a..2d0c716a6 100644--- a/web/locales/en/app.json+++ b/web/locales/en/app.json@@ -1207,11 +1207,11 @@"settingsTour.appearance.title": "Appearance","settingsTour.appearance.desc": "Visual theme and interface language. Changes apply immediately.","settingsTour.status.title": "Status",- "settingsTour.status.desc": "Whether the backend is up and what the running DeepTutor processes cost in memory — always visible here on the hub.",+ "settingsTour.status.desc": "Whether the backend is up and what the running DeepTutor processes cost in memory — always visible on the overview.","settingsTour.network.title": "Network","settingsTour.network.desc": "Ports, the browser-facing API base, and CORS origins — for Docker, LAN, and reverse-proxy deployments.","settingsTour.models.title": "Models",- "settingsTour.models.desc": "Open this to configure language, embedding, search, voice, and generation models — all seven services live here.",+ "settingsTour.models.desc": "Language, embedding, search, voice, and generation models — all seven services, plus the connections that supply them.","settingsTour.knowledge.title": "Knowledge Base","settingsTour.knowledge.desc": "Choose the document parsing engine that turns uploads into text.","settingsTour.chat.title": "Chat",@@ -3629,5 +3629,7 @@"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?"+ "Delete this profile and every model under it?": "Delete this profile and every model under it?",+ "Model services": "Model services",+ "Test passed": "Test passed"}diff --git a/web/locales/zh/app.json b/web/locales/zh/app.jsonindex e14b1cd08..71105c44c 100644--- a/web/locales/zh/app.json+++ b/web/locales/zh/app.json@@ -1239,11 +1239,11 @@"settingsTour.appearance.title": "外观","settingsTour.appearance.desc": "选择视觉主题和界面语言,改动立即生效。","settingsTour.status.title": "状态",- "settingsTour.status.desc": "后端是否在线,以及 DeepTutor 各进程当前占用的内存,常驻主页一目了然。",+ "settingsTour.status.desc": "后端是否在线,以及运行中的 DeepTutor 进程占用多少内存 —— 总览页常驻显示。","settingsTour.network.title": "网络","settingsTour.network.desc": "端口、浏览器访问后端的 API 地址与 CORS 来源——Docker、局域网、反向代理部署在这里配。","settingsTour.models.title": "模型",- "settingsTour.models.desc": "点进来配置语言、向量、搜索、语音与生成模型——七项服务都在这一组里。",+ "settingsTour.models.desc": "语言、嵌入、搜索、语音与生成模型 —— 七个服务,以及为它们供给凭据的连接。","settingsTour.knowledge.title": "知识库","settingsTour.knowledge.desc": "选择文档解析引擎,决定上传文档如何转成文本。","settingsTour.chat.title": "聊天",@@ -3629,5 +3629,7 @@"Take the tour": "看看引导","Draft saved {{when}}": "草稿保存于 {{when}}","Set up with DeepTutor": "让 DeepTutor 帮我配置",- "Delete this profile and every model under it?": "删除这个配置,以及它下面的所有模型?"+ "Delete this profile and every model under it?": "删除这个配置,以及它下面的所有模型?",+ "Model services": "模型服务",+ "Test passed": "测试通过"}