DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
feat(web): add classic/modern layout switch with Notion-style modern chrome
Bingxi Zhao (Frank)6ab4f9a76614
diff --git a/web/app/(utility)/layout.tsx b/web/app/(utility)/layout.tsxindex f95cdfb53..26490a27e 100644--- a/web/app/(utility)/layout.tsx+++ b/web/app/(utility)/layout.tsx@@ -1,5 +1,6 @@import UtilitySidebar from "@/components/sidebar/UtilitySidebar";import AppShell from "@/components/layout/AppShell";+import { LayoutPageBar } from "@/features/ui-layout/slots";import { CapabilityAccessProvider } from "@/components/access/CapabilityAccessContext";import CapabilityGate from "@/components/access/CapabilityGate";@@ -10,7 +11,7 @@ export default function UtilityLayout({}>) {return (<CapabilityAccessProvider>- <AppShell sidebar={<UtilitySidebar />}>+ <AppShell sidebar={<UtilitySidebar />} pageBar={<LayoutPageBar />}><CapabilityGate>{children}</CapabilityGate></AppShell></CapabilityAccessProvider>diff --git a/web/app/(workspace)/co-writer/page.tsx b/web/app/(workspace)/co-writer/page.tsxindex 90753f0c1..23fc5eb87 100644--- a/web/app/(workspace)/co-writer/page.tsx+++ b/web/app/(workspace)/co-writer/page.tsx@@ -183,6 +183,7 @@ export default function CoWriterHomePage() {}}/><PageHeader+ icon={PenLine}title={t("Co-Writer")}description={t("Manage your markdown drafts and projects.")}action={diff --git a/web/app/(workspace)/layout.tsx b/web/app/(workspace)/layout.tsxindex 6d5809ead..c617eb6b9 100644--- a/web/app/(workspace)/layout.tsx+++ b/web/app/(workspace)/layout.tsx@@ -1,6 +1,7 @@import TaskBoardRuntime from "@/components/tasks/TaskBoardRuntime";import WorkspaceSidebar from "@/components/sidebar/WorkspaceSidebar";import AppShell from "@/components/layout/AppShell";+import { LayoutPageBar } from "@/features/ui-layout/slots";import { CapabilityAccessProvider } from "@/components/access/CapabilityAccessContext";import CapabilityGate from "@/components/access/CapabilityGate";import { ChatRuntimeProvider } from "@/features/chat";@@ -23,7 +24,7 @@ export default function WorkspaceLayout({/chat → /chat/<id>, which remounts the page. The open documentmust not die with it. */}<ReadingProvider>- <AppShell sidebar={<WorkspaceSidebar />}>+ <AppShell sidebar={<WorkspaceSidebar />} pageBar={<LayoutPageBar />}><CapabilityGate>{children}</CapabilityGate></AppShell></ReadingProvider>diff --git a/web/app/(workspace)/learning/page.tsx b/web/app/(workspace)/learning/page.tsxindex d5de85075..d0741861a 100644--- a/web/app/(workspace)/learning/page.tsx+++ b/web/app/(workspace)/learning/page.tsx@@ -1,5 +1,5 @@-import { LearningDashboard } from '@/components/learning/LearningDashboard'+import { LayoutLearningHome } from "@/features/ui-layout/slots"export default function LearningPage() {- return <LearningDashboard />+ return <LayoutLearningHome />}diff --git a/web/app/(workspace)/partners/page.tsx b/web/app/(workspace)/partners/page.tsxindex 846afc800..d021be08b 100644--- a/web/app/(workspace)/partners/page.tsx+++ b/web/app/(workspace)/partners/page.tsx@@ -11,7 +11,7 @@import { FeaturePage, PageHeader, pageActionClass, pageGridClass } from '@/components/layout/FeaturePage'import { useEffect, useState } from "react";import Link from "next/link";-import { HeartHandshake, Loader2, Plus, Users } from "lucide-react";+import { HeartHandshake, Loader2, Plus, Users, MessageCircle } from "lucide-react";import { useTranslation } from "react-i18next";import { listPartners, type PartnerInfo } from "@/lib/partners-api";import { listPartnerGroups, type PartnerGroup } from "@/lib/partner-groups-api";@@ -76,6 +76,7 @@ export default function PartnersPage() {return (<FeaturePage><PageHeader+ icon={MessageCircle}titleId="partners"title={t("Partners")}description={anyAssigneddiff --git a/web/app/globals.css b/web/app/globals.cssindex 0f3e09938..44eb501e9 100644--- a/web/app/globals.css+++ b/web/app/globals.css@@ -8,8 +8,15 @@container: feature-page / inline-size;}+.dt-page-icon {+ /* Revealed per UI layout; see features/ui-layout/modern/modern.css. */+ display: none;+}+.dt-page-title {font-size: 27px;+ /* A UI layout token: see features/ui-layout/{classic,modern}. */+ font-family: var(--dt-page-title-font, theme("fontFamily.sans"));}.dt-page-action,@@ -1454,78 +1461,3 @@ a[href^="#dt-locator-"]:hover {visibility: hidden;pointer-events: none;}--/* dt-exp: the same application, with four contextual navigation shelves. */-.dt-product-sidebar { container-type: inline-size; border-right: 1px solid var(--border); }-.dt-product-sidebar .dt-category-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 10px 10px; flex-shrink: 0; }-.dt-category-bar [role="tablist"] { display: flex; flex: 1; align-items: center; min-width: 0; gap: 1px; }-.dt-category-bar [role="tab"] { position: relative; display: flex; align-items: center; justify-content: center; flex: 1; min-width: 30px; height: 36px; gap: 7px; padding: 0 7px; color: var(--muted-foreground); border-radius: 10px; transition: color 140ms, background-color 140ms; }-.dt-category-bar [role="tab"] > svg, .dt-category-bar [role="tab"] > span:not(.dt-category-pill) { position: relative; z-index: 1; flex-shrink: 0; }-.dt-category-bar [role="tab"] > span:not(.dt-category-pill) { display: none; font-size: 13px; font-weight: 600; white-space: nowrap; }-.dt-category-bar [role="tab"].is-active { flex: 1.9; color: var(--foreground); }-.dt-category-bar [role="tab"].is-active > span:not(.dt-category-pill) { display: inline; }-.dt-category-pill { position: absolute; inset: 0; border-radius: 10px; background: var(--accent); }-.dt-category-bar [role="tab"]:not(.is-active):hover, .dt-nav-icon:hover { background: var(--accent); color: var(--foreground); }-.dt-nav-icon { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; color: var(--muted-foreground); transition: background-color 140ms, color 140ms; }-.dt-category-bar button:focus-visible, .dt-navigation-row:focus-visible, .dt-nav-icon:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }-.dt-product-sidebar .dt-category-bar.is-collapsed { flex-direction: column; padding: 4px; }-.dt-category-bar.is-collapsed [role="tablist"] { flex-direction: column; gap: 5px; }-.dt-category-bar.is-collapsed [role="tab"] { width: 38px; height: 38px; flex: none; }-.dt-category-bar.is-collapsed [role="tab"] > span:not(.dt-category-pill) { display: none; }-.dt-nav-search { width: 100%; margin-top: 8px; height: 32px; background: var(--background); border: 1px solid var(--border); border-radius: 7px; padding: 0 9px; font-size: 12px; outline: none; }-.dt-nav-search:focus { border-color: var(--ring); }-.dt-category-content { padding: 0 8px 16px; }-.dt-navigation-section { margin-top: 17px; }-.dt-navigation-heading { display: flex; justify-content: space-between; align-items: center; min-height: 28px; margin-bottom: 4px; padding: 0 9px; font-size: 11px; font-weight: 600; color: var(--muted-foreground); }-.dt-navigation-row { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 7px 9px; border-radius: 7px; text-align: left; color: var(--muted-foreground); font-size: 13px; transition: background-color 130ms, color 130ms; }-.dt-navigation-row > svg { flex-shrink: 0; opacity: .85; }-.dt-navigation-row:hover, .dt-navigation-row.is-active { background: var(--accent); color: var(--foreground); }-.dt-navigation-row.is-active { font-weight: 500; }-.dt-navigation-empty { padding: 6px 9px; font-size: 11.5px; line-height: 1.7; color: var(--muted-foreground); }-.dt-category-content-fixed { display: flex; flex-direction: column; height: 100%; min-height: 0; padding-bottom: 0; }-.dt-category-content-fixed > .dt-navigation-section { flex-shrink: 0; margin-top: 4px; }-.dt-partner-navigation { display: flex; flex: 1; flex-direction: column; min-height: 0; gap: 12px; padding-top: 14px; }-.dt-partner-preview { flex-shrink: 0; }-.dt-partner-navigation .dt-navigation-heading { flex-shrink: 0; }-.dt-navigation-heading h2 { display: flex; align-items: center; min-width: 0; gap: 7px; font: inherit; }-.dt-navigation-count { font-size: 10px; font-weight: 400; font-variant-numeric: tabular-nums; opacity: .7; }-.dt-navigation-actions { display: flex; align-items: center; gap: 3px; }-.dt-navigation-view-all { display: inline-flex; align-items: center; gap: 1px; padding: 4px; border-radius: 5px; font-size: 11px; font-weight: 400; white-space: nowrap; transition: background-color 140ms, color 140ms; }-.dt-navigation-view-all:hover { background: var(--accent); color: var(--foreground); }-.dt-partner-roster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 2px 4px 0; }-.dt-partner-roster-item { display: flex; align-items: center; flex-direction: column; gap: 6px; padding: 7px 3px; width: 100%; min-width: 0; border-radius: 8px; transition: background-color 140ms, color 140ms; }-.dt-partner-roster-item:hover, .dt-partner-roster-item[aria-current="page"] { background: var(--accent); color: var(--foreground); }-.dt-partner-roster-item > span:last-child { font-size: 11px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; max-width: 100%; color: var(--muted-foreground); }-.dt-partner-sessions { display: flex; flex: 1; flex-direction: column; min-height: 0; padding-top: 10px; border-top: 1px solid var(--border); }-/* Keep the tooltip's visually hidden text inside this scroll container too. */-.dt-partner-session-list { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 0 8px; }-.dt-partner-session-list .dt-navigation-row { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 9px; row-gap: 2px; }-.dt-partner-session-list .dt-navigation-row > svg { grid-row: 1 / 3; align-self: start; margin-top: 2px; }-.dt-partner-session-list .dt-navigation-row > span { grid-column: 2; max-width: 100%; }-.dt-partner-session-list .dt-navigation-row > span:last-child { font-size: 11px; font-weight: 400; }-.dt-partner-session-list:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 7px; }-.dt-navigation-view-all:focus-visible, .dt-partner-roster-item:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }-.dt-new-conversation { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; margin: 4px 3px 8px; border: 1px solid var(--border); border-radius: 22px; background: var(--background); font-size: 13px; font-weight: 500; box-shadow: 0 2px 5px rgb(0 0 0 / .025); transition: background-color 140ms, box-shadow 140ms; }-.dt-new-conversation:hover { background: var(--accent); box-shadow: 0 2px 8px rgb(0 0 0 / .045); }-@container (max-width: 240px) { .dt-category-bar [role="tab"] { padding: 0 4px; gap: 4px; } .dt-category-bar [role="tab"] > span:not(.dt-category-pill) { font-size: 12px; } }--@media (prefers-reduced-motion: reduce) { .dt-category-content { animation: none; } .dt-product-sidebar * { transition-duration: 0ms !important; } }--.dt-category-panel:not([hidden]) { display: flex; flex: 1; min-height: 0; flex-direction: column; }-.dt-learning-navigation { display: flex; flex: 1; flex-direction: column; min-height: 0; padding-top: 14px; }-.dt-learning-overview { display: flex; align-items: center; flex-shrink: 0; border-radius: 7px; padding-right: 4px; }-.dt-learning-overview:hover, .dt-learning-overview.is-active { background: var(--accent); }-.dt-learning-overview > a { display: flex; align-items: center; flex: 1; min-width: 0; gap: 9px; padding: 9px; font-size: 13px; font-weight: 500; }-.dt-learning-overview > a:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 7px; }-.dt-learning-record-toolbar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; padding: 12px 5px 4px; }-.dt-learning-record-toolbar select { min-width: 0; max-width: 80%; padding: 4px; background: transparent; color: var(--muted-foreground); font-size: 11px; border-radius: 5px; cursor: pointer; }-.dt-learning-record-toolbar select:hover { background: var(--accent); }-.dt-learning-record-toolbar select:focus-visible { outline: 2px solid var(--ring); }-.dt-learning-record-toolbar option { background: var(--background); color: var(--foreground); }-.dt-learning-search { flex-shrink: 0; margin: 0 4px 8px; width: calc(100% - 8px); }-.dt-learning-record-list { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }-.dt-learning-record-list:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 7px; }-.dt-learning-time-group { margin-bottom: 14px; }-.dt-learning-time-group > h2 { padding: 8px 9px 5px; font-size: 11px; font-weight: 500; color: var(--muted-foreground); }-.dt-learning-time-group .dt-navigation-row { min-height: 38px; gap: 8px; }-.dt-record-time { flex-shrink: 0; max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 400; color: var(--muted-foreground); opacity: .75; }diff --git a/web/app/layout.tsx b/web/app/layout.tsxindex 14c59ee3a..c649e5d9d 100644--- a/web/app/layout.tsx+++ b/web/app/layout.tsx@@ -1,6 +1,8 @@import type { Metadata } from "next";import { Geist, Lora } from "next/font/google";import "./globals.css";+import "@/features/ui-layout/classic/classic.css";+import "@/features/ui-layout/modern/modern.css";import ThemeScript from "@/components/ThemeScript";import ToastViewport from "@/components/common/ToastViewport";import MotionProvider from "@/components/common/MotionProvider";diff --git a/web/components/ThemeScript.tsx b/web/components/ThemeScript.tsxindex d851a60ce..ffd0fd438 100644--- a/web/components/ThemeScript.tsx+++ b/web/components/ThemeScript.tsx@@ -1,3 +1,9 @@+import {+ DEFAULT_UI_LAYOUT,+ UI_LAYOUT_ATTRIBUTE,+ UI_LAYOUT_STORAGE_KEY,+} from "@/lib/ui-layout";+/*** ThemeScript - Initializes theme from localStorage before React hydration* This prevents the flash of wrong theme on page load.@@ -37,6 +43,16 @@ export default function ThemeScript() {} catch (e) {/* localStorage may be disabled */}+ // UI layout tokens (see lib/ui-layout.ts) must also paint before React.+ try {+ const layout = localStorage.getItem('${UI_LAYOUT_STORAGE_KEY}');+ document.documentElement.setAttribute(+ '${UI_LAYOUT_ATTRIBUTE}',+ layout === 'classic' || layout === 'modern' ? layout : '${DEFAULT_UI_LAYOUT}',+ );+ } catch (e) {+ document.documentElement.setAttribute('${UI_LAYOUT_ATTRIBUTE}', '${DEFAULT_UI_LAYOUT}');+ }})();`;diff --git a/web/components/agents/ConnectedAgents.tsx b/web/components/agents/ConnectedAgents.tsxindex 83148d659..5a907247f 100644--- a/web/components/agents/ConnectedAgents.tsx+++ b/web/components/agents/ConnectedAgents.tsx@@ -4,7 +4,7 @@ import { pageActionClass, pageGridClass } from '@/components/layout/FeaturePage'import Tooltip from "@/shared/ui/Tooltip";import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";-import { Cpu, Loader2, Plug, Plus, Trash2, X } from "lucide-react";+import { Cpu, Loader2, Plug, Plus, Trash2, X, Bot } from "lucide-react";import { agentGlyph } from "@/components/agents/agent-icons";import SpaceSectionHeader from "@/components/space/SpaceSectionHeader";@@ -98,6 +98,7 @@ export default function ConnectedAgents() {return (<section className="space-y-4"><SpaceSectionHeader+ icon={Bot}title={tr({ zh: "连接的智能体", en: "Connected agents" })}description={tr({zh: "把本机智能体或已配置的远程 Hermes 网关接进来,在对话中选中后直接向它提问——运行过程会实时展示。",diff --git a/web/components/chat/home/ChatComposer.tsx b/web/components/chat/home/ChatComposer.tsxindex 459320a92..a657396c2 100644--- a/web/components/chat/home/ChatComposer.tsx+++ b/web/components/chat/home/ChatComposer.tsx@@ -99,6 +99,7 @@ import type { CapabilityDef } from "@/features/capabilities/presentation";import AttachmentProcessingStatus from "./AttachmentProcessingStatus";import type { AttachmentProcessingItem } from "@/features/chat/selectors/attachment-processing";import Tooltip from "@/shared/ui/Tooltip";+import { useCapabilityLabel } from "@/features/ui-layout/tokens";interface PendingAttachment {type: string;@@ -125,6 +126,7 @@ function CapMenuItem({onSelect: (value: string) => void;}) {const { t } = useTranslation();+ const capabilityLabel = useCapabilityLabel();const Icon = cap.icon;return (@@ -142,7 +144,7 @@ function CapMenuItem({/><div className="min-w-0 flex-1"><div className="truncate text-[12.5px] font-medium leading-snug text-[var(--foreground)]">- {t(cap.label)}+ {capabilityLabel(cap)}</div><div className="truncate text-[11px] leading-snug text-[var(--muted-foreground)]">{t(cap.description)}@@ -476,6 +478,7 @@ export default memo(function ChatComposer({showCapabilityChip?: boolean;}) {const { t } = useTranslation();+ const capabilityLabel = useCapabilityLabel();const [partners, setPartners] = useState<PartnerInfo[]>([]);const [partnersLoading, setPartnersLoading] = useState(false);const [partnerLoadError, setPartnerLoadError] = useState(false);@@ -1077,7 +1080,7 @@ export default memo(function ChatComposer({<div className="relative"><div- className={`${styles.surface} relative rounded-[26px] border bg-[var(--card)] shadow-[0_1px_2px_rgba(0,0,0,0.025),0_10px_28px_-10px_rgba(0,0,0,0.08)] transition-colors ${+ className={`${styles.surface} dt-composer-surface relative rounded-[26px] border bg-[var(--card)] shadow-[0_1px_2px_rgba(0,0,0,0.025),0_10px_28px_-10px_rgba(0,0,0,0.08)] transition-colors ${dragging? "border-[var(--primary)] bg-[var(--primary)]/[0.03]": "border-[var(--border)]/55"@@ -1177,13 +1180,13 @@ export default memo(function ChatComposer({<div className={styles.context}>{showCapabilityChip && (<div className="relative min-w-0 max-w-full">- <Tooltip label={t(activeCap.label)} suppressed={capMenuOpen} side="top">+ <Tooltip label={capabilityLabel(activeCap)} suppressed={capMenuOpen} side="top"><buttonref={capBtnRef}aria-haspopup="menu"aria-expanded={capMenuOpen}onClick={() => onSetCapMenuOpen((v) => !v)}- aria-label={t(activeCap.label)}+ aria-label={capabilityLabel(activeCap)}className={`inline-flex h-8 max-w-full items-center rounded-lg px-2 text-[14px] font-medium transition-[background-color,color,transform] duration-150 active:scale-[0.97] ${capMenuOpen? "bg-[var(--primary)]/10 text-[var(--primary)]"@@ -1192,7 +1195,7 @@ export default memo(function ChatComposer({><CapIcon size={16} strokeWidth={1.7} className="shrink-0" /><span className="ml-1.5 inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap">- <span className="min-w-0 truncate">{t(activeCap.label)}</span>+ <span className="min-w-0 truncate">{capabilityLabel(activeCap)}</span><ChevronDown size={13} strokeWidth={2} className={`shrink-0 transition-transform duration-200 ${capMenuOpen ? "rotate-180" : ""}`} /></span></button>diff --git a/web/components/chat/home/HomeShortcuts.tsx b/web/components/chat/home/HomeShortcuts.tsxdeleted file mode 100644index 725c58a13..000000000--- a/web/components/chat/home/HomeShortcuts.tsx+++ /dev/null@@ -1,34 +0,0 @@-'use client'-import Link from 'next/link'-import { Columns3, PenLine, Bot } from 'lucide-react'-import { useTranslation } from 'react-i18next'-import { useAuthStatus } from '@/hooks/useAuthStatus'-import { navVisibleUnderPolicy } from '@/components/sidebar/nav-entries'-export function HomeShortcuts() {- const { t } = useTranslation()- const { learningPolicy } = useAuthStatus()- return (- <nav- aria-label={t('navigation.workspace')}- className="mt-6 flex flex-wrap justify-center gap-2"- >- {[- { href: '/kanban', title: 'Task Board', icon: Columns3 },- { href: '/co-writer', title: 'Co-Writer', icon: PenLine },- { href: '/agents', title: 'My Agents', icon: Bot },- ]- .filter(item => navVisibleUnderPolicy(item.href, learningPolicy?.allowedSurfaces ?? null))- .map(item => (- <Link- key={item.href}- href={item.href}- prefetch={false}- className="inline-flex items-center gap-2 rounded-full bg-muted/50 px-4 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"- >- <item.icon size={15} strokeWidth={1.6} />- {t(item.title)}- </Link>- ))}- </nav>- )-}diff --git a/web/components/chat/home/StandaloneComposer.tsx b/web/components/chat/home/StandaloneComposer.tsxindex 6d8b9a439..5f9f97b1a 100644--- a/web/components/chat/home/StandaloneComposer.tsx+++ b/web/components/chat/home/StandaloneComposer.tsx@@ -24,6 +24,7 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";import dynamic from "next/dynamic";import { MessageSquare } from "lucide-react";import { useTranslation } from "react-i18next";+import { useCapabilityLabel } from "@/features/ui-layout/tokens";import ChatComposer from "@/components/chat/home/ChatComposer";import type { ContextBudget } from "@/components/chat/home/ContextBudgetChip";@@ -672,14 +673,15 @@ function StandaloneComposerImpl({[notebookReferencesPayload, selectedNotebookRecords],);+ const capabilityLabel = useCapabilityLabel();const resolvedCapabilities = useMemo(() => {const list = capabilities?.length ? capabilities : [CHAT_ONLY_CAPABILITY];return list.map((capability) => ({...capability,- label: t(capability.label),+ label: capabilityLabel(capability),description: t(capability.description),}));- }, [capabilities, t]);+ }, [capabilities, capabilityLabel, t]);const activeCap =resolvedCapabilities.find((capability) => capability.value === activeCapValue,diff --git a/web/components/chat/home/StarterSuggestions.tsx b/web/components/chat/home/StarterSuggestions.tsxindex 4b75bdede..810082fad 100644--- a/web/components/chat/home/StarterSuggestions.tsx+++ b/web/components/chat/home/StarterSuggestions.tsx@@ -6,6 +6,7 @@ import Tooltip from "@/shared/ui/Tooltip";import { Loader2, Sparkles } from "lucide-react";import { activeWorkspaceId, scopedUrl } from "@/lib/workspace-scope";import { apiFetch, apiUrl } from "@/lib/api";+import { useUiLayoutLabel } from "@/features/ui-layout/tokens";interface Suggestion {/** The line the learner reads — names the specific thing worth doing next. */@@ -76,6 +77,7 @@ export default function StarterSuggestions({workspaceId?: string;}) {const { t } = useTranslation();+ const heading = useUiLayoutLabel("starterHeading");// Everything generated here is already in the learner's chosen output// language (resolved server-side from their model-output setting) and never// goes through the i18n table — a label that happened to match a key would@@ -185,6 +187,7 @@ export default function StarterSuggestions({// the lines start exactly at the composer's left edge rather than floating// near it.<div className="group/starters mx-auto w-full max-w-[768px] px-6 pb-6 animate-fade-in">+ {view.kind === "ready" && heading && <p className="dt-starter-heading">{heading}</p>}{view.kind === "ready" && (<ul className="flex flex-col items-start">{view.items.map((item) => (@@ -195,7 +198,7 @@ export default function StarterSuggestions({disabled={disabled}onClick={() => onPick(item.prompt)}aria-label={item.prompt}- className="group/line flex max-w-full items-baseline gap-2 py-[5px] text-left font-serif text-[15.5px] leading-[1.45] tracking-[-0.005em] text-[color-mix(in_srgb,var(--foreground)_72%,transparent)] transition-colors duration-200 hover:text-[var(--primary)] focus-visible:text-[var(--primary)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40"+ className="dt-starter-line group/line flex max-w-full items-baseline gap-2 py-[5px] text-left font-serif text-[15.5px] leading-[1.45] tracking-[-0.005em] text-[color-mix(in_srgb,var(--foreground)_72%,transparent)] transition-colors duration-200 hover:text-[var(--primary)] focus-visible:text-[var(--primary)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40"><span className="truncate">{item.label}</span>{/* The arrow is the invitation: coloured at rest so the linediff --git a/web/components/courses/OrganizedSessionList.tsx b/web/components/courses/OrganizedSessionList.tsxindex ad33846a8..8d62802c8 100644--- a/web/components/courses/OrganizedSessionList.tsx+++ b/web/components/courses/OrganizedSessionList.tsx@@ -67,6 +67,8 @@ interface OrganizedSessionListProps {workspaces?: ChatWorkspaceRegistration[];/** Account sidebar only; scoped lists already live within a workspace. */groupWorkspaces?: boolean;+ /** Title the workspace groups as one "Projects" block (modern UI). */+ workspaceHeading?: boolean;onNewWorkspaceChat?: (workspaceId: string) => void;/** Topics whose study conversations get their own group. Omit for none. */masteryTopics?: MasteryTopicLabel[];@@ -111,6 +113,7 @@ export default function OrganizedSessionList({courses,workspaces = [],groupWorkspaces = false,+ workspaceHeading = false,onNewWorkspaceChat,masteryTopics = [],readingCollections = [],@@ -736,8 +739,8 @@ export default function OrganizedSessionList({return (<div className="py-0.5">{workspaceMoveError && <p role="alert" className="px-2 py-1 text-xs text-[var(--destructive)]">{workspaceMoveError}</p>}- {groupWorkspaces && entries.some(entry => entry.kind === "group" && entry.group === "workspace") && (- <h2 className="mb-1 px-1.5 py-1 text-[12.5px] font-medium text-[var(--foreground)]">+ {groupWorkspaces && workspaceHeading && entries.some(entry => entry.kind === "group" && entry.group === "workspace") && (+ <h2 className="dt-projects-heading">{t("navigation.projects")}</h2>)}diff --git a/web/components/knowledge/KnowledgeHome.tsx b/web/components/knowledge/KnowledgeHome.tsxindex d1706c6d2..68bc33d91 100644--- a/web/components/knowledge/KnowledgeHome.tsx+++ b/web/components/knowledge/KnowledgeHome.tsx@@ -5,6 +5,7 @@ import { knowledgeBaseRef } from "@/lib/knowledge-helpers";import { useMemo, useState } from "react";import { useTranslation } from "react-i18next";import {+ BookOpen,Check,ChevronRight,Cloud,@@ -234,6 +235,7 @@ export default function KnowledgeHome({return (<FeaturePage><PageHeader+ icon={BookOpen}title={t("Knowledge Center")}description={t("Manage your knowledge bases and retrieval engines.")}action={diff --git a/web/components/layout/AppShell.tsx b/web/components/layout/AppShell.tsxindex d8d0eca66..a768fcbf6 100644--- a/web/components/layout/AppShell.tsx+++ b/web/components/layout/AppShell.tsx@@ -29,6 +29,8 @@ export function useSidebarDrawer() {interface AppShellProps {/** The route group's sidebar (workspace or utility). */sidebar: ReactNode;+ /** Bar above the page (the layout variant decides what, if anything). */+ pageBar?: ReactNode;homeHref?: string;children: ReactNode;}@@ -49,7 +51,7 @@ interface AppShellProps {* the very first server-rendered paint is already correct on a phone. JS only* owns the part that is stateful anyway: whether the drawer is open.*/-export default function AppShell({ sidebar, children, homeHref = "/" }: AppShellProps) {+export default function AppShell({ sidebar, pageBar, children, homeHref = "/" }: AppShellProps) {const { t } = useTranslation();const pathname = usePathname();const { isMobile } = useDevice();@@ -130,6 +132,7 @@ export default function AppShell({ sidebar, children, homeHref = "/" }: AppShell</Link></div>+ {pageBar}<div className="min-h-0 flex-1 overflow-hidden"><Suspense fallback={<div aria-busy="true" className="h-full bg-[var(--background)]" />}>{children}diff --git a/web/components/layout/FeaturePage.tsx b/web/components/layout/FeaturePage.tsxindex a4c973576..cd2677fd7 100644--- a/web/components/layout/FeaturePage.tsx+++ b/web/components/layout/FeaturePage.tsx@@ -1,9 +1,11 @@import type { ComponentPropsWithRef, ReactNode, Ref, UIEventHandler } from 'react'+import type { LucideIcon } from 'lucide-react'/** Feature page standard, based on Personalized Learning:* - Centered 1180px outer box; horizontal gutters 24px, 36px from 768px.* - Vertical padding 28px, 36px from 1024px; 24px from header to content.- * - Sans page title 27px / 30px at 640px of usable content; no title icon.+ * - Page title 27px / 30px at 640px of usable content; no title icon. Its+ * face is a UI layout token (serif classic, sans modern).* - Sans description 12.5px, section label 13.5px; one h1 per page.* - Actions stack below the title under 640px of content and wrap in order.* - Grids share 520 / 800 / 1040px container breakpoints and a 12px gap.@@ -51,11 +53,12 @@ export function FeaturePage({)}-export const PAGE_TITLE_CLASS = 'dt-page-title min-w-0 break-words font-sans font-semibold leading-normal tracking-[-0.02em] text-[var(--foreground)]'+export const PAGE_TITLE_CLASS = 'dt-page-title min-w-0 break-words font-semibold leading-normal tracking-[-0.02em] text-[var(--foreground)]'export const PAGE_DESCRIPTION_CLASS = 'mt-1.5 max-w-2xl text-[12.5px] leading-relaxed text-[var(--muted-foreground)]'export const PAGE_SECTION_TITLE_CLASS = 'text-[13.5px] font-semibold text-[var(--foreground)]'-/** No decorative title icon or divider. Icons belong to cards and actions.+/** No divider. A page icon is drawn only where the UI layout shows it+ * (`.dt-page-icon` is hidden by default; the modern layout reveals it).* Secondary sections use h2 so a feature page always has one main heading.*/export function PageHeader({@@ -66,6 +69,7 @@ export function PageHeader({level = 1,titleId,headingTour,+ icon: Icon,}: {title: ReactNodedescription?: ReactNode@@ -74,11 +78,17 @@ export function PageHeader({level?: 1 | 2titleId?: stringheadingTour?: string+ icon?: LucideIcon}) {const Heading = level === 1 ? 'h1' : 'h2'return (<header data-page-header className="dt-page-header mb-6 flex min-w-0 flex-col gap-4"><div className="min-w-0">+ {Icon && level === 1 && (+ <span aria-hidden className="dt-page-icon">+ <Icon size={28} strokeWidth={1.5} />+ </span>+ )}<div className="flex flex-wrap items-center gap-2.5"><Heading id={titleId} data-tour={headingTour} className={level === 1 ? PAGE_TITLE_CLASS : PAGE_SECTION_TITLE_CLASS}>{title}diff --git a/web/components/learning/LearningShell.tsx b/web/components/learning/LearningShell.tsxindex 8d5d6c9ff..ee06feff2 100644--- a/web/components/learning/LearningShell.tsx+++ b/web/components/learning/LearningShell.tsx@@ -1,11 +1,14 @@'use client'import Link from 'next/link'-import { ArrowLeft, AlertCircle, RefreshCw } from 'lucide-react'+import { usePathname } from 'next/navigation'+import { ArrowLeft, AlertCircle, BookOpen, RefreshCw, type LucideIcon } from 'lucide-react'import type { ReactNode, Ref, UIEventHandler } from 'react'import { useTranslation } from 'react-i18next'import { LEARNING_HUB } from '@/lib/learning-routes'import { FeaturePage, PageHeader } from '@/components/layout/FeaturePage'+import { useUiLayoutLabel } from '@/features/ui-layout/tokens'+import { LEARNING_SURFACES } from './surfaces'/** The same page rhythm for the hub and each library; readers keep their full-screen layouts. */export function LearningShell({@@ -19,6 +22,7 @@ export function LearningShell({className = '',scrollRef,onScroll,+ icon,}: {title: ReactNodesubtitle: ReactNode@@ -30,8 +34,13 @@ export function LearningShell({className?: stringscrollRef?: Ref<HTMLElement>onScroll?: UIEventHandler<HTMLElement>+ /** Defaults to the icon of the learning surface this page belongs to. */+ icon?: LucideIcon}) {- const { t } = useTranslation()+ const pathname = usePathname()+ const learningLabel = useUiLayoutLabel('learning')+ // usePathname is null outside the App Router (tests, embeds): no icon then.+ const surfaceIcon = LEARNING_SURFACES.find(surface => pathname?.startsWith(surface.href))?.iconreturn (<FeaturePagescrollRef={scrollRef}@@ -41,13 +50,13 @@ export function LearningShell({{back && (<Linkhref={LEARNING_HUB}- className="mb-5 inline-flex items-center gap-1.5 text-xs text-[var(--muted-foreground)] hover:text-[var(--foreground)]"+ className="dt-section-back mb-5 inline-flex items-center gap-1.5 text-xs text-[var(--muted-foreground)] hover:text-[var(--foreground)]"><ArrowLeft size={14} />- {t('Personalized Learning')}+ {learningLabel}</Link>)}- <PageHeader title={title} description={subtitle} action={action} meta={scopeChip} />+ <PageHeader title={title} description={subtitle} action={action} meta={scopeChip} icon={icon ?? surfaceIcon ?? BookOpen} />{tabs}<div className={tabs ? 'mt-6' : ''}>{children}</div></FeaturePage>diff --git a/web/components/memory/MemoryHub.tsx b/web/components/memory/MemoryHub.tsxindex 4643b50a5..f3d157925 100644--- a/web/components/memory/MemoryHub.tsx+++ b/web/components/memory/MemoryHub.tsx@@ -5,6 +5,7 @@ import Link from "next/link";import { useCallback, useEffect, useState } from "react";import {ArrowRight,+ Brain,Layers,Network,RefreshCw,@@ -88,6 +89,7 @@ export default function MemoryHub() {return (<div className="space-y-9"><PageHeader+ icon={Brain}title={t("Memory")}description={t("Everything DeepTutor remembers about you, organised across three layers. Click into any layer to inspect or curate it.")}action={diff --git a/web/components/notebook/NotebookConsole.tsx b/web/components/notebook/NotebookConsole.tsxindex ab7cba871..e470122c5 100644--- a/web/components/notebook/NotebookConsole.tsx+++ b/web/components/notebook/NotebookConsole.tsx@@ -28,6 +28,7 @@ import {type NotebookSummary,} from "@/lib/notebook-api";import { notebookRoute } from "@/lib/resource-routes";+import { useUiLayoutLabel } from "@/features/ui-layout/tokens";const SWATCHES = ["#6366F1",@@ -63,6 +64,7 @@ export default function NotebookConsole({onScopeChanged,}: NotebookConsoleProps) {const { t } = useTranslation();+ const spaceLabel = useUiLayoutLabel("space");const router = useRouter();const library = useNotebookLibrary(initialNotebookId,@@ -255,14 +257,14 @@ export default function NotebookConsole({<div className="flex flex-col gap-2.5 px-3 pb-2.5 pt-3"><Linkhref="/space"- className="group inline-flex w-fit items-center gap-1.5 text-[12px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"+ className="dt-section-back group inline-flex w-fit items-center gap-1.5 text-[12px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"><ArrowLeftsize={13}strokeWidth={1.8}className="transition-transform group-hover:-translate-x-0.5"/>- {t("Learning Space")}+ {spaceLabel}</Link><div className="flex items-center justify-between">diff --git a/web/components/settings/SettingsOverview.tsx b/web/components/settings/SettingsOverview.tsxindex 22d13ab08..b79f5eafb 100644--- a/web/components/settings/SettingsOverview.tsx+++ b/web/components/settings/SettingsOverview.tsx@@ -1,6 +1,7 @@"use client";import Link from "next/link";+import { useCallback, type SetStateAction } from "react";import { ArrowRight } from "lucide-react";import { useTranslation } from "react-i18next";import { APP_LANGUAGES, isAppLanguage, type AppLanguage } from "@/i18n/init";@@ -14,6 +15,14 @@ import {} from "./shared";import { RESPONSE_LANGUAGE_OPTIONS, useUiSettings } from "@/features/settings/store";import { useSettings } from "@/features/settings/store/SettingsStore";+import { useStagedSettings } from "@/features/settings/store/useStagedSettings";+import { useUiLayout } from "@/hooks/useUiLayout";+import { UI_LAYOUTS, writeStoredUiLayout, type UiLayout } from "@/lib/ui-layout";++const UI_LAYOUT_LABELS: Record<UiLayout, string> = {+ classic: "Classic",+ modern: "Modern",+};function LanguageSelect({label,@@ -49,6 +58,17 @@ export default function SettingsOverview() {const { language, responseLanguage, updateLanguage, updateResponseLanguage } =useUiSettings();const { catalogEditable } = useSettings();+ const uiLayout = useUiLayout();+ const setLiveUiLayout = useCallback(+ (action: SetStateAction<UiLayout>) =>+ writeStoredUiLayout(typeof action === "function" ? action(uiLayout) : action),+ [uiLayout],+ );+ const [stagedUiLayout, stageUiLayout] = useStagedSettings(+ "ui-layout",+ uiLayout,+ setLiveUiLayout,+ );return (<div><SettingsPageHeader@@ -96,6 +116,28 @@ export default function SettingsOverview() {}/></SettingSection>+ <SettingSection title={t("Layout")}>+ <SettingRow+ title={t("Interface layout")}+ description={t(+ "Classic keeps the familiar navigation; Modern is the redesigned interface.",+ )}+ control={+ <select+ aria-label={t("Interface layout")}+ value={stagedUiLayout}+ onChange={(event) => stageUiLayout(event.target.value as UiLayout)}+ className={`${selectClass} min-w-[200px] pr-8`}+ >+ {UI_LAYOUTS.map((layout) => (+ <option key={layout} value={layout} className={selectOptionClass}>+ {t(UI_LAYOUT_LABELS[layout])}+ </option>+ ))}+ </select>+ }+ />+ </SettingSection>{catalogEditable && <SettingSectiontitle={t("Set up chat first")}description={t("Connect a provider and choose a language model. Other services are optional.")}diff --git a/web/components/sidebar/CategoryNavigation.tsx b/web/components/sidebar/CategoryNavigation.tsxindex 33035bc61..0c0d7e64f 100644--- a/web/components/sidebar/CategoryNavigation.tsx+++ b/web/components/sidebar/CategoryNavigation.tsx@@ -4,24 +4,15 @@ import { useId, useState, startTransition, type ReactNode } from 'react'import dynamic from 'next/dynamic'import { usePathname, useRouter } from 'next/navigation'import { m, useReducedMotion } from 'framer-motion'-import {- BookOpen,- Home,- Library,- MessageCircle,- Search,- Settings,- Columns3,- PenLine,- Bot,-} from 'lucide-react'+import { BookOpen, Home, Library, MessageCircle, Search, Columns3, PenLine, Bot } from 'lucide-react'import { useTranslation } from 'react-i18next'import Tooltip from '@/shared/ui/Tooltip'import { categoryForPath, type NavigationCategory } from '@/lib/navigation'import { navVisibleUnderPolicy } from './nav-entries'import { useAuthStatus } from '@/hooks/useAuthStatus'import { navigateTask } from '@/lib/workspace-scope'-import { NavigationRow, Section, matches } from './NavigationPrimitives'+import { NavigationRow, Section } from './NavigationPrimitives'+import { SHORTCUTS } from '@/lib/shortcuts'// Feature libraries load when their category opens, not in every workspace.const LearningNavigation = dynamic(() =>@@ -52,23 +43,16 @@ export function useCategoryNavigation() {pathname: stringcategory: NavigationCategory} | null>(null)- const [query, setQuery] = useState('')- const [searchOpen, setSearchOpen] = useState(false)const desired = selection?.pathname === pathname ? selection.category : categoryForPath(pathname)const category = categories.find(item => item.id === desired)?.id ?? categories[0]?.id ?? 'home'return {category,categories,visited,- query,- setQuery,- searchOpen,- setSearchOpen,select: (next: NavigationCategory) => {startTransition(() => {setVisited(previous => [...new Set([...previous, category, next])])setSelection({ pathname, category: next })- setQuery('')})},allowedSurfaces: learningPolicy?.allowedSurfaces ?? null,@@ -76,7 +60,15 @@ export function useCategoryNavigation() {}type Navigation = ReturnType<typeof useCategoryNavigation>-export function CategoryTabs({ nav, collapsed }: { nav: Navigation; collapsed: boolean }) {+export function CategoryTabs({+ nav,+ collapsed,+ onSearch,+}: {+ nav: Navigation+ collapsed: boolean+ onSearch: () => void+}) {const { t } = useTranslation()const router = useRouter()const id = useId()@@ -93,7 +85,14 @@ export function CategoryTabs({ nav, collapsed }: { nav: Navigation; collapsed: baria-orientation={collapsed ? 'vertical' : 'horizontal'}>{nav.categories.map((item, index) => (- <Tooltip key={item.id} label={t(item.label)} side={collapsed ? 'right' : 'bottom'}>+ <Tooltip+ key={item.id}+ label={t(item.label)}+ side={collapsed ? 'right' : 'bottom'}+ shortcut={SHORTCUTS.category(index)}+ // The active tab already prints its name.+ suppressed={!collapsed && nav.category === item.id}+ ><buttonid={`category-${item.id}`}type="button"@@ -132,42 +131,17 @@ export function CategoryTabs({ nav, collapsed }: { nav: Navigation; collapsed: btransition={{ duration: reduced ? 0 : 0.22, ease: [0.22, 1, 0.36, 1] }}/>)}- <item.icon size={19} strokeWidth={1.65} />+ <item.icon size={17} strokeWidth={1.6} /><span>{t(item.label)}</span></button></Tooltip>))}</div>- <Tooltip label={t('navigation.search')} side={collapsed ? 'right' : 'bottom'}>- <button- type="button"- className="dt-nav-icon"- aria-label={t('navigation.search')}- aria-expanded={nav.searchOpen}- onClick={() => {- if (collapsed) navigateTask('/space/chat-history', router.push)- else nav.setSearchOpen(!nav.searchOpen)- }}- >- <Search size={19} strokeWidth={1.65} />+ <Tooltip label={t('navigation.search')} side={collapsed ? 'right' : 'bottom'} shortcut={SHORTCUTS.search}>+ <button type="button" className="dt-nav-icon" aria-label={t('navigation.search')} aria-haspopup="dialog" onClick={onSearch}>+ <Search size={16} strokeWidth={1.6} /></button></Tooltip>- {!collapsed && nav.searchOpen && (- <input- autoFocus- aria-label={t('navigation.search')}- placeholder={t('navigation.search')}- value={nav.query}- onChange={event => nav.setQuery(event.target.value)}- onKeyDown={event => {- if (event.key === 'Escape') {- nav.setQuery('')- nav.setSearchOpen(false)- }- }}- className="dt-nav-search"- />- )}</div>)}@@ -199,11 +173,7 @@ export function CategoryBody({{ href: '/co-writer', label: 'Co-Writer', icon: PenLine },{ href: '/agents', label: 'My Agents', icon: Bot },]- .filter(- item =>- navVisibleUnderPolicy(item.href, nav.allowedSurfaces) &&- matches(t(item.label), nav.query)- )+ .filter(item => navVisibleUnderPolicy(item.href, nav.allowedSurfaces)).map(item => (<NavigationRowkey={item.href}@@ -218,31 +188,19 @@ export function CategoryBody({)}{(nav.category === 'learning' || nav.visited.includes('learning')) && (<div hidden={nav.category !== 'learning'} className="dt-category-panel">- <LearningNavigation- active={nav.category === 'learning'}- query={nav.category === 'learning' ? nav.query : ''}- sessions={sessions}- />+ <LearningNavigation active={nav.category === 'learning'} sessions={sessions} /></div>)}{(nav.category === 'partners' || nav.visited.includes('partners')) && (<div hidden={nav.category !== 'partners'} className="dt-category-panel">- <PartnerNavigation- active={nav.category === 'partners'}- query={nav.category === 'partners' ? nav.query : ''}- />+ <PartnerNavigation active={nav.category === 'partners'} /></div>)}{(nav.category === 'resources' || nav.visited.includes('resources')) && (<div hidden={nav.category !== 'resources'}>- <ResourcesNavigation query={nav.category === 'resources' ? nav.query : ''} />+ <ResourcesNavigation /></div>)}- {nav.searchOpen && matches(t('Settings'), nav.query) && (- <Section title={t('Settings')}>- <NavigationRow href="/settings" label={t('Settings')} icon={Settings} />- </Section>- )}</div>)}diff --git a/web/components/sidebar/CommandPalette.tsx b/web/components/sidebar/CommandPalette.tsxnew file mode 100644index 000000000..4fcf905e8--- /dev/null+++ b/web/components/sidebar/CommandPalette.tsx@@ -0,0 +1,228 @@+'use client'++import { createPortal } from 'react-dom'+import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'+import { useRouter } from 'next/navigation'+import { Bot, Columns3, CornerDownLeft, MessageCircle, PenLine, Search, Settings, Users, type LucideIcon } from 'lucide-react'+import { useTranslation } from 'react-i18next'+import PartnerAvatar from '@/components/partners/PartnerAvatar'+import { DASHBOARD_GROUPS, visibleGroups } from '@/components/space/dashboard-groups'+import { useCapabilityFilter } from '@/features/capabilities/useCapabilityCatalog'+import { useLearningIndex } from '@/hooks/useLearningIndex'+import { usePartnerNavigation } from '@/hooks/usePartnerNavigation'+import { allLearningActivity } from '@/lib/learning-dashboard'+import { scopedUrl, navigateTask } from '@/lib/workspace-scope'+import type { SessionSummary } from '@/lib/session-api'+import { learningSurface } from '@/components/learning/surfaces'+import { navVisibleUnderPolicy } from './nav-entries'++interface PaletteItem {+ id: string+ label: string+ detail?: string+ icon: ReactNode+ run: () => void+}+interface PaletteGroup {+ title: string+ items: PaletteItem[]+}++const glyph = (Icon: LucideIcon) => <Icon size={16} strokeWidth={1.6} />+const includes = (text: string, query: string) => text.toLocaleLowerCase().includes(query)++/**+ * ⌘K: one field that finds anything the sidebar holds — places, conversations,+ * learning, partners — and opens it. It reads the same sources as the sidebar+ * shelves (all client-cached), so opening it costs no extra round trip.+ */+export function CommandPalette({+ open,+ onClose,+ categories,+ allowedSurfaces,+ sessions,+ onSelectSession,+ onNewChat,+}: {+ open: boolean+ onClose: () => void+ categories: readonly { id: string; label: string; icon: LucideIcon; href: string }[]+ allowedSurfaces: string[] | null+ sessions: SessionSummary[]+ onSelectSession?: (sessionId: string) => void | Promise<void>+ onNewChat: () => void+}) {+ const { t, i18n } = useTranslation()+ const router = useRouter()+ const zh = i18n.language.startsWith('zh')+ const available = useCapabilityFilter()+ const { sources } = useLearningIndex(open)+ const { data: partnerData } = usePartnerNavigation(open)+ const [query, setQuery] = useState('')+ const [activeIndex, setActiveIndex] = useState(0)+ const inputRef = useRef<HTMLInputElement>(null)+ const listRef = useRef<HTMLDivElement>(null)+ const restoreFocus = useRef<HTMLElement | null>(null)++ // The shell mounts the palette per opening, so query and selection start fresh.+ useEffect(() => {+ if (!open) return+ restoreFocus.current = document.activeElement as HTMLElement | null+ requestAnimationFrame(() => inputRef.current?.focus())+ return () => restoreFocus.current?.focus?.()+ }, [open])++ const groups = useMemo<PaletteGroup[]>(() => {+ const go = (href: string) => () => navigateTask(href, router.push)+ const q = query.trim().toLocaleLowerCase()+ const places: PaletteItem[] = [+ { id: 'new-chat', label: t('navigation.newChat'), icon: glyph(PenLine), run: onNewChat },+ ...categories.map(item => ({ id: `category:${item.id}`, label: t(item.label), icon: glyph(item.icon), run: go(item.href) })),+ ...[+ { href: '/kanban', label: 'Task Board', icon: Columns3 },+ { href: '/co-writer', label: 'Co-Writer', icon: PenLine },+ { href: '/agents', label: 'My Agents', icon: Bot },+ ]+ .filter(item => navVisibleUnderPolicy(item.href, allowedSurfaces))+ .map(item => ({ id: item.href, label: t(item.label), icon: glyph(item.icon), run: go(item.href) })),+ ...visibleGroups(DASHBOARD_GROUPS, available).flatMap(group =>+ group.items.map(row => ({+ id: `resource:${row.key}`,+ label: zh ? row.title.zh : row.title.en,+ detail: t('navigation.resources'),+ icon: glyph(row.icon),+ run: go(scopedUrl(row.href)),+ }))+ ),+ { id: 'settings', label: t('Settings'), icon: glyph(Settings), run: go('/settings') },+ ]+ const conversations: PaletteItem[] = sessions+ .filter(session => !session.preferences?.archived && !session.preferences?.parent_session_id)+ .map(session => ({+ id: `session:${session.session_id}`,+ label: session.title || t('New conversation'),+ icon: glyph(MessageCircle),+ run: () => void (onSelectSession ? onSelectSession(session.session_id) : go(`/chat/${session.session_id}`)()),+ }))+ const learning: PaletteItem[] = allLearningActivity(sources).map(item => {+ const surface = learningSurface(item.kind)+ return {+ id: `learning:${item.key}`,+ label: item.title,+ detail: t(surface.title),+ icon: glyph(surface.icon),+ run: go(item.href),+ }+ })+ const partners: PaletteItem[] = [+ ...partnerData.partners.map(partner => ({+ id: `partner:${partner.partner_id}`,+ label: partner.name,+ icon: <PartnerAvatar name={partner.name} emoji={partner.emoji} image={partner.avatar} color={partner.color} size={18} />,+ run: go(`/partners/${encodeURIComponent(partner.partner_id)}`),+ })),+ ...partnerData.groups.map(group => ({+ id: `group:${group.group_id}`,+ label: group.name,+ detail: t('Groups'),+ icon: glyph(Users),+ run: go(`/partners/groups/${encodeURIComponent(group.group_id)}`),+ })),+ ]+ const pick = (items: PaletteItem[], idle: number) =>+ q ? items.filter(item => includes(`${item.label} ${item.detail ?? ''}`, q)).slice(0, 6) : items.slice(0, idle)+ return [+ { title: t('navigation.jumpTo'), items: pick(places, 1 + categories.length + 3) },+ { title: t('Conversations'), items: pick(conversations, 5) },+ { title: t('navigation.learning'), items: pick(learning, q ? 6 : 0) },+ { title: t('navigation.partners'), items: pick(partners, q ? 6 : 0) },+ ].filter(group => group.items.length > 0)+ }, [query, categories, allowedSurfaces, available, zh, sessions, sources, partnerData, onSelectSession, onNewChat, router.push, t])++ const flat = groups.flatMap(group => group.items)+ const current = Math.min(activeIndex, Math.max(0, flat.length - 1))++ useEffect(() => {+ listRef.current?.querySelector(`[data-index="${current}"]`)?.scrollIntoView({ block: 'nearest' })+ }, [current])++ if (!open || typeof document === 'undefined') return null++ const run = (item: PaletteItem | undefined) => {+ if (!item) return+ onClose()+ item.run()+ }+ let index = -1+ return createPortal(+ <div className="dt-palette-backdrop" onPointerDown={event => event.target === event.currentTarget && onClose()}>+ <div role="dialog" aria-modal="true" aria-label={t('navigation.searchEverything')} className="dt-palette">+ <div className="dt-palette-field">+ <Search size={17} strokeWidth={1.7} className="shrink-0 opacity-50" />+ <input+ ref={inputRef}+ value={query}+ role="combobox"+ aria-expanded+ aria-controls="dt-palette-results"+ aria-activedescendant={flat[current] ? `dt-palette-${current}` : undefined}+ placeholder={t('navigation.searchEverything')}+ onChange={event => {+ setQuery(event.target.value)+ setActiveIndex(0)+ }}+ onKeyDown={event => {+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {+ event.preventDefault()+ const step = event.key === 'ArrowDown' ? 1 : -1+ setActiveIndex((current + step + flat.length) % Math.max(1, flat.length))+ } else if (event.key === 'Enter') {+ event.preventDefault()+ run(flat[current])+ } else if (event.key === 'Escape') {+ event.preventDefault()+ onClose()+ }+ }}+ />+ </div>+ <div ref={listRef} id="dt-palette-results" role="listbox" className="dt-palette-results">+ {groups.map(group => (+ <div key={group.title} role="group" aria-label={group.title}>+ <div className="dt-palette-group">{group.title}</div>+ {group.items.map(item => {+ index += 1+ const position = index+ return (+ <div+ key={item.id}+ id={`dt-palette-${position}`}+ data-index={position}+ role="option"+ aria-selected={position === current}+ onPointerMove={() => position !== current && setActiveIndex(position)}+ onClick={() => run(item)}+ className="dt-palette-item"+ >+ <span className="dt-palette-icon">{item.icon}</span>+ <span className="min-w-0 flex-1 truncate">{item.label}</span>+ {item.detail && <span className="dt-palette-detail">{item.detail}</span>}+ {position === current && <CornerDownLeft size={14} strokeWidth={1.8} className="shrink-0 opacity-50" />}+ </div>+ )+ })}+ </div>+ ))}+ {!flat.length && <p className="dt-palette-empty">{t('navigation.noResults')}</p>}+ </div>+ <div className="dt-palette-hints" aria-hidden>+ <span><kbd>↑</kbd><kbd>↓</kbd> {t('navigation.paletteSelect')}</span>+ <span><kbd>↵</kbd> {t('navigation.paletteOpen')}</span>+ <span><kbd>esc</kbd> {t('navigation.paletteClose')}</span>+ </div>+ </div>+ </div>,+ document.body+ )+}diff --git a/web/components/sidebar/LearningNavigation.tsx b/web/components/sidebar/LearningNavigation.tsxindex 9973583ad..76746307c 100644--- a/web/components/sidebar/LearningNavigation.tsx+++ b/web/components/sidebar/LearningNavigation.tsx@@ -21,11 +21,9 @@ const GROUP_LABELS: Record<DayGroupKey, string> = {earlier: 'Earlier',}export function LearningNavigation({- query,sessions,active = true,}: {- query: stringsessions: ReactNodeactive?: boolean}) {@@ -47,7 +45,7 @@ export function LearningNavigation({const rows = allLearningActivity(sources).filter(row => {const label = `${row.title} ${row.workspaceName ?? ''} ${t(learningSurface(row.kind).title)}`- return matches(label, query) && matches(label, localQuery)+ return matches(label, localQuery)}).sort((a, b) => b[sort] - a[sort] || a.key.localeCompare(b.key))const grouped = Map.groupBy(rows.slice(0, limit), row => getDayGroupKey(row[sort]))@@ -62,7 +60,7 @@ export function LearningNavigation({if (!event.metaKey && !event.ctrlKey && !event.shiftKey) drawer?.close()}}>- <LayoutGrid size={18} strokeWidth={1.6} />+ <LayoutGrid size={16} strokeWidth={1.6} /><span>{t('navigation.allLearning')}</span></Link><LearningCreateMenu compact />@@ -145,7 +143,7 @@ export function LearningNavigation({))}{!loading && !rows.length && !failed.length && (<p className="dt-navigation-empty">- {t(query || localQuery ? 'navigation.noResults' : 'navigation.noLearning')}+ {t(localQuery ? 'navigation.noResults' : 'navigation.noLearning')}</p>)}{rows.length > limit && (diff --git a/web/components/sidebar/NavigationPrimitives.tsx b/web/components/sidebar/NavigationPrimitives.tsxindex 4179ba164..f14b3271a 100644--- a/web/components/sidebar/NavigationPrimitives.tsx+++ b/web/components/sidebar/NavigationPrimitives.tsx@@ -41,7 +41,7 @@ export function NavigationRow({aria-current={selected ? 'page' : undefined}className={`dt-navigation-row ${selected ? 'is-active' : ''}`}>- {children ?? (Icon && <Icon size={18} strokeWidth={1.6} />)}+ {children ?? (Icon && <Icon size={16} strokeWidth={1.6} />)}<span className="min-w-0 flex-1 truncate">{label}</span>{trailing ??(detail && (diff --git a/web/components/sidebar/PageBar.tsx b/web/components/sidebar/PageBar.tsxnew file mode 100644index 000000000..06457f735--- /dev/null+++ b/web/components/sidebar/PageBar.tsx@@ -0,0 +1,117 @@+'use client'++import Link from 'next/link'+import { usePathname } from 'next/navigation'+import { useState } from 'react'+import { ChevronDown } from 'lucide-react'+import { useTranslation } from 'react-i18next'+import Tooltip from '@/shared/ui/Tooltip'+import { useMenuPopover } from '@/shared/ui/useMenuPopover'+import { useAuthStatus } from '@/hooks/useAuthStatus'+import { useCapabilityFilter } from '@/features/capabilities/useCapabilityCatalog'+import { scopedUrl } from '@/lib/workspace-scope'+import { useWorkspaceChoices } from '@/components/workspaces/useWorkspaceChoices'+import { WorkspaceChoiceList, WorkspaceGlyph } from './WorkspaceMenu'+import { locatePage, pageSections, type PageSection, type PageEntry } from './page-sections'++/** The page name; it opens onto the pages beside it in the same section. */+function PageCrumb({ section, page }: { section: PageSection; page: PageEntry }) {+ const [open, setOpen] = useState(false)+ const rootRef = useMenuPopover<HTMLDivElement>(open, setOpen)+ return (+ <div ref={rootRef} className="relative min-w-0">+ <button+ type="button"+ aria-haspopup="menu"+ aria-expanded={open}+ onClick={() => setOpen(value => !value)}+ className="dt-crumb"+ >+ <page.icon size={16} strokeWidth={1.6} className="shrink-0 opacity-75" />+ <span className="truncate">{page.label}</span>+ </button>+ {open && (+ <div role="menu" aria-label={section.label} className="dt-popover dt-crumb-panel">+ <div className="dt-menu-label">{section.label}</div>+ {section.pages.map(entry => (+ <Link+ key={entry.href}+ role="menuitem"+ href={section.scoped ? scopedUrl(entry.href) : entry.href}+ prefetch={false}+ aria-current={entry.href === page.href ? 'page' : undefined}+ onClick={() => setOpen(false)}+ className="dt-menu-item"+ >+ <entry.icon size={16} strokeWidth={1.6} />+ <span className="min-w-0 flex-1 truncate">{entry.label}</span>+ </Link>+ ))}+ </div>+ )}+ </div>+ )+}++/** Whose content this is — the workspace — and the way to move to another. */+function ScopeChip() {+ const { t } = useTranslation()+ const { active, currentName } = useWorkspaceChoices()+ const [open, setOpen] = useState(false)+ const rootRef = useMenuPopover<HTMLDivElement>(open, setOpen)+ return (+ <div ref={rootRef} className="relative shrink-0">+ <Tooltip+ label={t('navigation.scopeHint', { workspace: currentName })}+ description={t('navigation.scopeAction')}+ suppressed={open}+ >+ <button+ type="button"+ aria-haspopup="menu"+ aria-expanded={open}+ onClick={() => setOpen(value => !value)}+ className="dt-scope-chip"+ >+ <WorkspaceGlyph name={currentName} general={!active} size={16} />+ <span className="max-w-[16ch] truncate">{currentName}</span>+ <ChevronDown size={13} strokeWidth={1.8} className="shrink-0 opacity-60" />+ </button>+ </Tooltip>+ {open && (+ <div role="menu" aria-label={t('Manage workspaces')} className="dt-popover dt-crumb-panel">+ <WorkspaceChoiceList onChoose={() => setOpen(false)} />+ </div>+ )}+ </div>+ )+}++/**+ * Notion-style location bar over every section index page: the page (opening+ * onto its siblings) and, for workspace content, the workspace it belongs to.+ * Rendered by the route layouts above the page, so pages need no wiring and+ * their own "back to section" links become redundant (modern.css hides them).+ */+export function PageBar() {+ const { t, i18n } = useTranslation()+ const pathname = usePathname() ?? ''+ const { learningPolicy } = useAuthStatus()+ const isAvailable = useCapabilityFilter()+ const located = locatePage(+ pathname,+ pageSections({+ t,+ zh: i18n.language.startsWith('zh'),+ allowedSurfaces: learningPolicy?.allowedSurfaces ?? null,+ isAvailable,+ })+ )+ if (!located) return null+ return (+ <nav aria-label={t('navigation.location')} className="dt-page-bar">+ <PageCrumb section={located.section} page={located.page} />+ {located.section.scoped && <ScopeChip />}+ </nav>+ )+}diff --git a/web/components/sidebar/PartnerNavigation.tsx b/web/components/sidebar/PartnerNavigation.tsxindex 82c1d0232..aabcd8d6b 100644--- a/web/components/sidebar/PartnerNavigation.tsx+++ b/web/components/sidebar/PartnerNavigation.tsx@@ -1,24 +1,21 @@'use client'import { useTranslation } from 'react-i18next'-import { NavigationRow, Status, matches } from './NavigationPrimitives'+import { NavigationRow, Status } from './NavigationPrimitives'+import { PartnerRoster } from './PartnerRoster'import { useState } from 'react'import Link from 'next/link'import { usePathname, useSearchParams } from 'next/navigation'-import { Plus, ChevronDown, ChevronRight, Users, MessageCircle } from 'lucide-react'-import Tooltip from '@/shared/ui/Tooltip'-import PartnerAvatar from '@/components/partners/PartnerAvatar'+import { Plus, ChevronDown, ChevronRight, Users } from 'lucide-react'import { usePartnerNavigation } from '@/hooks/usePartnerNavigation'import { partnerSessionHref } from '@/lib/navigation'-export function PartnerNavigation({ query, active = true }: { query: string; active?: boolean }) {+export function PartnerNavigation({ active = true }: { active?: boolean }) {const { t } = useTranslation()const search = useSearchParams()const pathname = usePathname()const { data, loading, error, retry } = usePartnerNavigation(active)const [limit, setLimit] = useState(30)- const partners = data.partners.filter(row => matches(row.name, query))- const groups = data.groups.filter(row => matches(row.name, query))- const sessions = data.sessions.filter(row => matches(`${row.title} ${row.owner_name}`, query))+ const { partners, groups, sessions } = datareturn (<div className="dt-partner-navigation"><section className="dt-partner-preview" aria-labelledby="partner-preview-title">@@ -43,42 +40,14 @@ export function PartnerNavigation({ query, active = true }: { query: string; actaria-label={t('New partner')}className="dt-nav-icon">- <Plus size={16} />+ <Plus size={15} strokeWidth={1.7} /></Link></div></div>- <div className="dt-partner-roster">- {partners.slice(0, 3).map(partner => {- const href = `/partners/${encodeURIComponent(partner.partner_id)}`- return (- <Tooltip- key={partner.partner_id}- label={partner.name}- side="right"- className="min-w-0"- >- <Link- href={href}- prefetch={false}- className="dt-partner-roster-item"- aria-current={pathname === href ? 'page' : undefined}- >- <PartnerAvatar- name={partner.name}- emoji={partner.emoji}- image={partner.avatar}- color={partner.color}- size={36}- />- <span>{partner.name}</span>- </Link>- </Tooltip>- )- })}- </div>+ <PartnerRoster partners={partners} activeHref={pathname} />{!loading && !partners.length && (<p className="dt-navigation-empty">- {t(query ? 'navigation.noResults' : 'No partners yet')}+ {t('No partners yet')}</p>)}</section>@@ -104,7 +73,7 @@ export function PartnerNavigation({ query, active = true }: { query: string; acthref="/partners/groups/new"aria-label={t('New group')}>- <Plus size={16} />+ <Plus size={15} strokeWidth={1.7} /></Link>)}</div>@@ -119,7 +88,7 @@ export function PartnerNavigation({ query, active = true }: { query: string; act))}{!loading && !groups.length && (<p className="dt-navigation-empty">- {t(query ? 'navigation.noResults' : 'navigation.noGroups')}+ {t('navigation.noGroups')}</p>)}</section>@@ -145,7 +114,6 @@ export function PartnerNavigation({ query, active = true }: { query: string; acthref={href}label={row.title || t('New conversation')}detail={row.owner_name}- icon={MessageCircle}active={pathname === href.split('?')[0] && search.get('session') === row.session_key}@@ -154,7 +122,7 @@ export function PartnerNavigation({ query, active = true }: { query: string; act})}{!loading && !sessions.length && !error && (<p className="dt-navigation-empty">- {t(query ? 'navigation.noResults' : 'navigation.noSessions')}+ {t('navigation.noSessions')}</p>)}{sessions.length > limit && (diff --git a/web/components/sidebar/PartnerRoster.tsx b/web/components/sidebar/PartnerRoster.tsxnew file mode 100644index 000000000..dc3123f70--- /dev/null+++ b/web/components/sidebar/PartnerRoster.tsx@@ -0,0 +1,184 @@+'use client'++import Link from 'next/link'+import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'+import PartnerAvatar from '@/components/partners/PartnerAvatar'+import type { PartnerNavigationData } from '@/hooks/usePartnerNavigation'+import { rosterFade, rosterLens } from './roster-lens'++type RosterPartner = PartnerNavigationData['partners'][number]++/** How far compression reaches in from each edge; just over one item. */+const ZONE = 52+/** Past this depth a click brings the partner forward instead of opening it. */+const FORWARD_DEPTH = 0.35+const DRAG_THRESHOLD = 4++/**+ * Every partner in one compact strip that scrolls sideways. Toward an edge+ * with more beyond it, partners pack tighter and smaller (see `rosterLens`),+ * so the strip reads as something you can slide through, not a cut-off row.+ */+export function PartnerRoster({+ partners,+ activeHref,+}: {+ partners: RosterPartner[]+ activeHref: string+}) {+ const stripRef = useRef<HTMLDivElement>(null)+ const frame = useRef(0)+ const dragged = useRef(false)+ const forwardedHref = useRef<string | null>(null)++ const layout = useCallback(() => {+ frame.current = 0+ const strip = stripRef.current+ if (!strip) return+ const viewport = strip.clientWidth+ const maxScroll = strip.scrollWidth - viewport+ const fade = rosterFade({ viewport, scrollLeft: strip.scrollLeft, maxScroll, zone: ZONE })+ strip.style.setProperty('--dt-roster-fade-l', `${fade.left.toFixed(1)}px`)+ strip.style.setProperty('--dt-roster-fade-r', `${fade.right.toFixed(1)}px`)+ for (const item of strip.children) {+ if (!(item instanceof HTMLElement)) continue+ const lens = rosterLens({+ center: item.offsetLeft + item.offsetWidth / 2,+ viewport,+ scrollLeft: strip.scrollLeft,+ maxScroll,+ zone: ZONE,+ })+ item.style.transform = lens.depth ? `translate3d(${lens.dx.toFixed(2)}px, 0, 0) scale(${lens.scale.toFixed(3)})` : ''+ item.style.opacity = lens.opacity < 1 ? lens.opacity.toFixed(3) : ''+ item.style.setProperty('--dt-roster-label', lens.label.toFixed(3))+ item.dataset.depth = lens.depth.toFixed(3)+ }+ }, [])+ const schedule = useCallback(() => {+ if (!frame.current) frame.current = requestAnimationFrame(layout)+ }, [layout])++ /** Scroll an item out of a stack into the flat middle of the strip. */+ const bringForward = useCallback((item: HTMLElement, behavior: ScrollBehavior) => {+ const strip = stripRef.current+ if (!strip) return+ const start = item.offsetLeft - strip.scrollLeft+ const end = start + item.offsetWidth+ if (start < ZONE) strip.scrollBy({ left: start - ZONE, behavior })+ else if (end > strip.clientWidth - ZONE) strip.scrollBy({ left: end - (strip.clientWidth - ZONE), behavior })+ }, [])++ useLayoutEffect(() => {+ const strip = stripRef.current+ if (!strip) return+ // Only a new selection moves the strip: a background refresh of the list+ // must not yank it away from where the learner slid it.+ const active = strip.querySelector<HTMLElement>('[aria-current="page"]')+ if (active && forwardedHref.current !== activeHref) {+ forwardedHref.current = activeHref+ bringForward(active, 'instant')+ }+ layout()+ }, [partners, activeHref, bringForward, layout])++ useEffect(() => {+ const strip = stripRef.current+ if (!strip) return+ // The panel mounts hidden and is sized once its category opens.+ const resize = new ResizeObserver(schedule)+ resize.observe(strip)+ // A mouse wheel only scrolls vertically; turn it sideways while the+ // roster has somewhere to go, and leave the page's scroll alone otherwise.+ const wheel = (event: WheelEvent) => {+ if (Math.abs(event.deltaY) <= Math.abs(event.deltaX)) return+ const maxScroll = strip.scrollWidth - strip.clientWidth+ if (maxScroll <= 0) return+ const next = Math.min(maxScroll, Math.max(0, strip.scrollLeft + event.deltaY))+ if (next === strip.scrollLeft) return+ event.preventDefault()+ strip.scrollLeft = next+ }+ strip.addEventListener('wheel', wheel, { passive: false })+ return () => {+ resize.disconnect()+ strip.removeEventListener('wheel', wheel)+ cancelAnimationFrame(frame.current)+ frame.current = 0+ }+ }, [schedule])++ // Mouse drag scrolls like a touch swipe; touch and trackpads scroll natively.+ const onPointerDown = (event: React.PointerEvent<HTMLDivElement>) => {+ if (event.pointerType !== 'mouse' || event.button !== 0) return+ const strip = event.currentTarget+ const origin = { x: event.clientX, scroll: strip.scrollLeft }+ dragged.current = false+ const move = (moveEvent: PointerEvent) => {+ const delta = moveEvent.clientX - origin.x+ if (!dragged.current && Math.abs(delta) < DRAG_THRESHOLD) return+ if (!dragged.current) {+ dragged.current = true+ strip.setPointerCapture(event.pointerId)+ strip.classList.add('is-dragging')+ }+ strip.scrollLeft = origin.scroll - delta+ }+ const end = () => {+ strip.removeEventListener('pointermove', move)+ strip.removeEventListener('pointerup', end)+ strip.removeEventListener('pointercancel', end)+ strip.classList.remove('is-dragging')+ }+ strip.addEventListener('pointermove', move)+ strip.addEventListener('pointerup', end)+ strip.addEventListener('pointercancel', end)+ }++ return (+ <div+ ref={stripRef}+ className="dt-partner-roster"+ onScroll={schedule}+ onPointerDown={onPointerDown}+ onClickCapture={event => {+ // The release that ends a drag is not a click on whatever is under it.+ if (!dragged.current) return+ dragged.current = false+ event.preventDefault()+ event.stopPropagation()+ }}+ >+ {partners.map(partner => {+ const href = `/partners/${encodeURIComponent(partner.partner_id)}`+ return (+ <Link+ key={partner.partner_id}+ href={href}+ prefetch={false}+ draggable={false}+ aria-label={partner.name}+ className="dt-partner-roster-item"+ aria-current={activeHref === href ? 'page' : undefined}+ onFocus={event => bringForward(event.currentTarget, 'smooth')}+ onClick={event => {+ const item = event.currentTarget+ if (Number(item.dataset.depth) < FORWARD_DEPTH) return+ event.preventDefault()+ bringForward(item, 'smooth')+ }}+ >+ <PartnerAvatar+ name={partner.name}+ emoji={partner.emoji}+ image={partner.avatar}+ color={partner.color}+ size={32}+ />+ <span>{partner.name}</span>+ </Link>+ )+ })}+ </div>+ )+}diff --git a/web/components/sidebar/ResourcesNavigation.tsx b/web/components/sidebar/ResourcesNavigation.tsxindex 3a7492a9c..74ab5d3b8 100644--- a/web/components/sidebar/ResourcesNavigation.tsx+++ b/web/components/sidebar/ResourcesNavigation.tsx@@ -1,12 +1,12 @@'use client'import { useTranslation } from 'react-i18next'-import { NavigationRow, Section, matches } from './NavigationPrimitives'+import { NavigationRow, Section } from './NavigationPrimitives'import { Library } from 'lucide-react'-import { DASHBOARD_GROUPS, visibleGroups } from '@/components/space/SpaceDashboard'+import { DASHBOARD_GROUPS, visibleGroups } from '@/components/space/dashboard-groups'import { useCapabilityFilter } from '@/features/capabilities/useCapabilityCatalog'import { scopedUrl } from '@/lib/workspace-scope'-export function ResourcesNavigation({ query }: { query: string }) {+export function ResourcesNavigation() {const { t, i18n } = useTranslation()const available = useCapabilityFilter()const zh = i18n.language.startsWith('zh')@@ -18,16 +18,14 @@ export function ResourcesNavigation({ query }: { query: string }) {</Section>{groups.map(group => (<Section key={group.label.en} title={zh ? group.label.zh : group.label.en}>- {group.items- .filter(row => matches(zh ? row.title.zh : row.title.en, query))- .map(row => (- <NavigationRow- key={row.key}- href={scopedUrl(row.href)}- label={zh ? row.title.zh : row.title.en}- icon={row.icon}- />- ))}+ {group.items.map(row => (+ <NavigationRow+ key={row.key}+ href={scopedUrl(row.href)}+ label={zh ? row.title.zh : row.title.en}+ icon={row.icon}+ />+ ))}</Section>))}</>diff --git a/web/components/sidebar/SidebarShell.tsx b/web/components/sidebar/SidebarShell.tsxindex 2b0b43364..6a7f06402 100644--- a/web/components/sidebar/SidebarShell.tsx+++ b/web/components/sidebar/SidebarShell.tsx@@ -8,6 +8,7 @@ import { usePathname, useRouter } from "next/navigation";import {useCallback,useEffect,+ useLayoutEffect,useRef,useState,Suspense,@@ -15,7 +16,7 @@ import {type CSSProperties,} from "react";import { useAppShell } from "@/context/AppShellContext";-import { MessageCircle, PanelLeftClose, PanelLeftOpen } from "lucide-react";+import { ChevronsLeft, PanelLeftClose, PanelLeftOpen, SquarePen } from "lucide-react";import { useTranslation } from "react-i18next";import { useChatWorkspaces } from "@/hooks/useChatWorkspaces";@@ -34,6 +35,8 @@ import { CategoryBody, CategoryTabs, useCategoryNavigation } from "@/components/import { isLearningSession } from "@/lib/navigation";import { SECONDARY_NAV, isNavActive } from "@/components/sidebar/nav-entries";import Tooltip from "@/shared/ui/Tooltip";+import { WorkspaceMenu } from "@/components/sidebar/WorkspaceMenu";+import { SHORTCUTS, matchesShortcut } from "@/lib/shortcuts";import {mergeManualOrder,readSessionOrder,@@ -43,6 +46,12 @@ import {// The fallback history list is needed only by shells without organization.const SessionList = dynamic(() => import("@/components/SessionList"), { ssr: false });+// Loaded on first ⌘K, with the learning and partner indexes it searches.+const CommandPalette = dynamic(+ () => import("@/components/sidebar/CommandPalette").then((module) => module.CommandPalette),+ { ssr: false },+);+// Session data arrives after mount; defer its organization UI with it so// every workspace route does not download it as part of the initial shell.const OrganizedSessionList = dynamic(@@ -62,7 +71,7 @@ const OrganizedSessionList = dynamic(},);-interface SidebarShellProps {+export interface SidebarShellProps {/** Reuse the shell's resizing/collapse behavior with embedded navigation. */homeSlot?: (collapsed: boolean) => ReactNode;bodySlot?: (collapsed: boolean) => ReactNode;@@ -130,6 +139,7 @@ export function SidebarShell({const { isMobile } = useDevice();const drawer = useSidebarDrawer();const recentsScrollRef = useRef<HTMLDivElement>(null);+ const [paletteOpen, setPaletteOpen] = useState(false);// One load for the whole column: the workspace groups head their own// section with it and the row menus offer it as a move destination.const { workspaces } = useChatWorkspaces();@@ -178,6 +188,12 @@ export function SidebarShell({writeSessionOrder([]);}, []);+ const startNewChat = () => {+ drawer?.close();+ onNewChat?.();+ navigateTask("/chat", router.push);+ };+const handleHomeClick = (event: React.MouseEvent) => {// Always reset to a fresh session (mirrors the old "New Chat" affordance);// let modifier-clicks fall through to default Link behavior so middle-click@@ -185,84 +201,119 @@ export function SidebarShell({if (event.metaKey || event.ctrlKey || event.shiftKey || event.button === 1)return;event.preventDefault();- drawer?.close();- onNewChat?.();- navigateTask("/chat", router.push);+ startNewChat();+ };++ // Shell shortcuts. The handler is re-bound after every render so it always+ // sees the current category list; the listener itself is installed once.+ const hotkeys = useRef<(event: KeyboardEvent) => void>(() => {});+ const handleHotkey = (event: KeyboardEvent) => {+ if (matchesShortcut(event, SHORTCUTS.search)) {+ event.preventDefault();+ setPaletteOpen((open) => !open);+ } else if (matchesShortcut(event, SHORTCUTS.newChat)) {+ event.preventDefault();+ startNewChat();+ } else {+ const index = categoryNav.categories.findIndex((_, position) =>+ matchesShortcut(event, SHORTCUTS.category(position)),+ );+ if (index < 0) return;+ event.preventDefault();+ const target = categoryNav.categories[index];+ categoryNav.select(target.id);+ if (collapsed) navigateTask(target.href, router.push);+ }};+ useLayoutEffect(() => {+ hotkeys.current = handleHotkey;+ });+ useEffect(() => {+ if (bodySlot) return;+ const onKeyDown = (event: KeyboardEvent) => hotkeys.current(event);+ window.addEventListener("keydown", onKeyDown);+ return () => window.removeEventListener("keydown", onKeyDown);+ }, [bodySlot]);++ const palette =+ !bodySlot && paletteOpen ? (+ <CommandPalette+ open+ onClose={() => setPaletteOpen(false)}+ categories={categoryNav.categories}+ allowedSurfaces={categoryNav.allowedSurfaces}+ sessions={sessions}+ onSelectSession={onSelectSession}+ onNewChat={startNewChat}+ />+ ) : null;// Everything the learner has, minus the archived and minus the tutor threads// that render nested under the conversation that spawned them.//// Keep the complete index here. OrganizedSessionList limits the initial// rendering and exposes older conversations through Show more.+ // The product shell files learning conversations under Learning only; an+ // embedded body (the /preview demo) brings its own lists.const visibleSessions = sessions.filter((session) =>- !session.preferences?.archived && !session.preferences?.parent_session_id &&- (!bodySlot ? (categoryNav.category === "learning" ? isLearningSession(session) : !isLearningSession(session)) : true) &&- (!categoryNav.query || session.title.toLocaleLowerCase().includes(categoryNav.query.toLocaleLowerCase())),+ !session.preferences?.archived &&+ !session.preferences?.parent_session_id &&+ (Boolean(bodySlot) || isLearningSession(session) === (categoryNav.category === "learning")),);- const sessionContent = <>-{/* Conversation history follows the module entries in the same scroller. */}- {showSessions &&- (categoryNav.category !== "learning" || loadingSessions || visibleSessions.length > 0) &&- onSelectSession &&- onRenameSession &&- onDeleteSession ? (- <section className="mt-3 px-2 pt-0.5">- {!onOrganizeSession && <div className="mb-2 px-2 text-xs text-[var(--muted-foreground)]">{t("Recent")}</div>}- {loadingSessions ? (- <SessionList- sessions={[]}- activeSessionId={activeSessionId}- loading- onSelect={onSelectSession}- onRename={onRenameSession}- onDelete={onDeleteSession}- compact- />- ) : onOrganizeSession ? (- <OrganizedSessionList- sessions={visibleSessions}- // Course grouping temporarily hidden pending further product- // work; passing [] keeps the list flat without touching the- // course data callers still fetch.- courses={[]}- workspaces={workspaces}- groupWorkspaces- onNewWorkspaceChat={onNewWorkspaceChat}- masteryTopics={masteryTopics}- readingCollections={readingCollections}- activeSessionId={activeSessionId}- liveSessionIds={liveSessionIds}- manualOrder={sessionOrder}- onReorder={handleReorderSessions}- onResetOrder={handleResetSessionOrder}- scrollRef={recentsScrollRef}- onSelect={(sessionId) => {- drawer?.close();- return onSelectSession(sessionId);- }}- onRename={onRenameSession}- onDelete={onDeleteSession}- onOrganize={onOrganizeSession}- />- ) : (- <SessionList- sessions={visibleSessions}- activeSessionId={activeSessionId}- onSelect={(sessionId) => {- drawer?.close();- return onSelectSession(sessionId);- }}- onRename={onRenameSession}- onDelete={onDeleteSession}- compact- />- )}- </section>- ) : null}-</>;+ // Conversation history follows the category's entries in the same scroller.+ const sessionContent = (+ <>+ {showSessions &&+ (categoryNav.category !== "learning" || loadingSessions || visibleSessions.length > 0) &&+ onSelectSession &&+ onRenameSession &&+ onDeleteSession &&+ onOrganizeSession ? (+ <section className="dt-navigation-section dt-session-section">+ {loadingSessions ? (+ <SessionList+ sessions={[]}+ activeSessionId={activeSessionId}+ loading+ onSelect={onSelectSession}+ onRename={onRenameSession}+ onDelete={onDeleteSession}+ compact+ />+ ) : (+ <OrganizedSessionList+ sessions={visibleSessions}+ // Course grouping temporarily hidden pending further product+ // work; passing [] keeps the list flat without touching the+ // course data callers still fetch.+ courses={[]}+ workspaces={workspaces}+ groupWorkspaces+ workspaceHeading+ onNewWorkspaceChat={onNewWorkspaceChat}+ masteryTopics={masteryTopics}+ readingCollections={readingCollections}+ activeSessionId={activeSessionId}+ liveSessionIds={liveSessionIds}+ manualOrder={sessionOrder}+ onReorder={handleReorderSessions}+ onResetOrder={handleResetSessionOrder}+ scrollRef={recentsScrollRef}+ onSelect={(sessionId) => {+ drawer?.close();+ return onSelectSession(sessionId);+ }}+ onRename={onRenameSession}+ onDelete={onDeleteSession}+ onOrganize={onOrganizeSession}+ />+ )}+ </section>+ ) : null}+ </>+ );/* ---- Collapsed state ---- */if (collapsed) {@@ -293,14 +344,14 @@ export function SidebarShell({</button></div>- {homeSlot ? homeSlot(true) : <CategoryTabs nav={categoryNav} collapsed />}+ {homeSlot ? homeSlot(true) : <CategoryTabs nav={categoryNav} collapsed onSearch={() => setPaletteOpen(true)} />}<div className="min-h-0 w-full flex-1 overflow-y-auto overscroll-contain">{bodySlot ? bodySlot(true) : <CategoryBody nav={categoryNav} collapsed sessions={null} />}</div>{/* Secondary nav + footer */}{footerOverride ? footerOverride(true) : <div className="flex w-full shrink-0 flex-col items-center gap-1 px-1.5">- <Tooltip label={t("navigation.newChat")} side="right"><Link prefetch={false} href="/chat" onClick={handleHomeClick} aria-label={t("navigation.newChat")} className="dt-nav-icon"><MessageCircle size={20} /></Link></Tooltip>+ <Tooltip label={t("navigation.newChat")} side="right"><Link prefetch={false} href="/chat" onClick={handleHomeClick} aria-label={t("navigation.newChat")} className="dt-nav-icon"><SquarePen size={17} strokeWidth={1.6} /></Link></Tooltip><div className="my-1 h-px w-7 bg-border/40" />{SECONDARY_NAV.map((item) => {const active = isNavActive(pathname, item.href);@@ -324,6 +375,7 @@ export function SidebarShell({{renderedFooter}<VersionBadge onNavigate={closeDrawerOnNav} /></div>}+ {palette}</aside>);}@@ -334,37 +386,54 @@ export function SidebarShell({style={{ "--sidebar-width": `${resize.width}px` } as CSSProperties}className={`${bodySlot ? "" : "dt-product-sidebar"} relative flex h-dvh w-[var(--sidebar-width)] max-w-[45vw] shrink-0 flex-col bg-[var(--secondary)] max-md:w-[220px] max-md:max-w-[85vw]`}>- {/* Header: logo + collapse toggle */}- <div className="flex h-[52px] shrink-0 items-center justify-between px-4">- <Link href={brandHref} prefetch={false} className="group flex items-center gap-1.5">- <Image- src="/logo.png"- alt="DeepTutor"- width={22}- height={22}- className="h-[22px] w-[22px] transition-transform duration-200 group-hover:scale-105"- />- <Image- src="/banner.png"- alt="DeepTutor"- width={897}- height={236}- priority- className="h-[22px] w-auto transition-transform duration-200 group-hover:scale-105"- />- </Link>- {/* The rail is a desktop affordance; in the drawer the scrim and the- top-bar toggle already own "make this go away". */}- <button- onClick={() => setCollapsed(true)}- className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)] max-md:hidden"- aria-label={t("Collapse sidebar")}- >- <PanelLeftClose size={15} />- </button>- </div>+ {bodySlot ? (+ <div className="flex h-[52px] shrink-0 items-center justify-between px-4">+ <Link href={brandHref} prefetch={false} className="group flex items-center gap-1.5">+ <Image+ src="/logo.png"+ alt="DeepTutor"+ width={22}+ height={22}+ className="h-[22px] w-[22px] transition-transform duration-200 group-hover:scale-105"+ />+ <Image+ src="/banner.png"+ alt="DeepTutor"+ width={897}+ height={236}+ priority+ className="h-[22px] w-auto transition-transform duration-200 group-hover:scale-105"+ />+ </Link>+ {/* The rail is a desktop affordance; in the drawer the scrim and the+ top-bar toggle already own "make this go away". */}+ <button+ onClick={() => setCollapsed(true)}+ className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)] max-md:hidden"+ aria-label={t("Collapse sidebar")}+ >+ <PanelLeftClose size={15} />+ </button>+ </div>+ ) : (+ <div className="dt-sidebar-header">+ <WorkspaceMenu accountSlot={renderedFooter} onNavigate={() => drawer?.close()} />+ {/* The rail is a desktop affordance; in the drawer the scrim and the+ top-bar toggle already own "make this go away". */}+ <Tooltip label={t("Collapse sidebar")} side="bottom">+ <button+ type="button"+ onClick={() => setCollapsed(true)}+ className="dt-nav-icon max-md:hidden"+ aria-label={t("Collapse sidebar")}+ >+ <ChevronsLeft size={17} strokeWidth={1.6} />+ </button>+ </Tooltip>+ </div>+ )}- {homeSlot ? homeSlot(false) : <CategoryTabs nav={categoryNav} collapsed={false} />}+ {homeSlot ? homeSlot(false) : <CategoryTabs nav={categoryNav} collapsed={false} onSearch={() => setPaletteOpen(true)} />}{/* Partner previews stay visible while their conversation list scrolls. */}<div@@ -377,32 +446,16 @@ export function SidebarShell({</div>{/* Secondary nav + footer */}- {footerOverride ? footerOverride(false) : <div className="shrink-0 px-2 py-2">- <Link prefetch={false} href="/chat" onClick={handleHomeClick} className="dt-new-conversation"><MessageCircle size={18} strokeWidth={1.6} /><span>{t("navigation.newChat")}</span></Link>- {renderedFooter}- <div className="flex items-center gap-1">- {SECONDARY_NAV.map((item) => {- const active = isNavActive(pathname, item.href);- return (- <Link- key={item.href}- href={item.href}- prefetch={false}- onClick={closeDrawerOnNav}- className={`flex min-h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2.5 py-1.5 text-[13px] transition-colors ${- active- ? "bg-[var(--accent)] font-medium text-[var(--foreground)]"- : "text-foreground/85 hover:bg-background/60 hover:text-[var(--foreground)]"- }`}- >- <item.icon size={15} strokeWidth={active ? 1.9 : 1.6} />- <span>{t(item.label)}</span>- </Link>- );- })}- <VersionBadge onNavigate={closeDrawerOnNav} />+ {footerOverride ? footerOverride(false) : (+ <div className="dt-sidebar-footer">+ <Tooltip label={t("navigation.newChat")} side="top" shortcut={SHORTCUTS.newChat} as="div" className="block w-full">+ <Link prefetch={false} href="/chat" onClick={handleHomeClick} className="dt-new-conversation">+ <SquarePen size={16} strokeWidth={1.7} />+ <span>{t("navigation.newChat")}</span>+ </Link>+ </Tooltip></div>- </div>}+ )}{!isMobile && (<divrole="separator"@@ -420,6 +473,7 @@ export function SidebarShell({/></div>)}+ {palette}</aside>);}diff --git a/web/components/sidebar/UtilitySidebar.tsx b/web/components/sidebar/UtilitySidebar.tsxindex 0928c0052..a60b758f3 100644--- a/web/components/sidebar/UtilitySidebar.tsx+++ b/web/components/sidebar/UtilitySidebar.tsx@@ -5,7 +5,7 @@ import { sessionWorkspaceId } from "@/lib/session-api";import { useCallback, useEffect, useRef, useState } from "react";import { useRouter } from "next/navigation";import { useTranslation } from "react-i18next";-import { SidebarShell } from "@/components/sidebar/SidebarShell";+import { LayoutSidebarShell } from "@/features/ui-layout/slots";import { LogoutButton } from "@/components/auth/LogoutButton";import { AdminLink } from "@/components/auth/AdminLink";import { ProfileLink } from "@/components/auth/ProfileLink";@@ -143,7 +143,7 @@ export default function UtilitySidebar() {);return (- <SidebarShell+ <LayoutSidebarShellshowSessionssessions={sessions}courses={courses}diff --git a/web/components/sidebar/WorkspaceMenu.tsx b/web/components/sidebar/WorkspaceMenu.tsxnew file mode 100644index 000000000..31e7872f7--- /dev/null+++ b/web/components/sidebar/WorkspaceMenu.tsx@@ -0,0 +1,113 @@+'use client'++import Image from 'next/image'+import Link from 'next/link'+import { useId, useState, type ReactNode } from 'react'+import { Check, ChevronDown, Settings, Settings2 } from 'lucide-react'+import { useTranslation } from 'react-i18next'+import { useMenuPopover } from '@/shared/ui/useMenuPopover'+import { useWorkspaceChoices } from '@/components/workspaces/useWorkspaceChoices'+import { VersionBadge } from '@/components/sidebar/VersionBadge'++const GLYPH_TINTS = ['#e3655b', '#d9822b', '#c9a227', '#4f9d69', '#3d8fb8', '#6c6fd1', '#a35fc0', '#c25b8a']++/** A stable letter tile for a workspace; the general one wears the logo. */+export function WorkspaceGlyph({ name, general, size = 22 }: { name: string; general: boolean; size?: number }) {+ if (general)+ return (+ <span aria-hidden className="dt-workspace-glyph is-general" style={{ width: size, height: size }}>+ <Image src="/logo.png" alt="" width={size} height={size} className="h-full w-full object-contain" />+ </span>+ )+ let hash = 0+ for (const char of name) hash = (hash * 31 + char.codePointAt(0)!) | 0+ return (+ <span+ aria-hidden+ className="dt-workspace-glyph"+ style={{ width: size, height: size, background: GLYPH_TINTS[Math.abs(hash) % GLYPH_TINTS.length], fontSize: size * 0.5 }}+ >+ {[...name.trim()][0]?.toUpperCase() ?? '·'}+ </span>+ )+}++/** The workspaces as menu items, the current one checked. */+export function WorkspaceChoiceList({ onChoose }: { onChoose?: () => void }) {+ const { t } = useTranslation()+ const { active, choices, choose } = useWorkspaceChoices()+ return (+ <>+ <div className="dt-menu-label">{t('Workspace')}</div>+ {choices.map(row => (+ <button+ key={row.workspace_id || 'general'}+ type="button"+ role="menuitem"+ aria-current={row.workspace_id === active ? 'page' : undefined}+ onClick={() => {+ onChoose?.()+ choose(row.workspace_id)+ }}+ className="dt-menu-item"+ >+ <WorkspaceGlyph name={row.display_name} general={!row.workspace_id} size={20} />+ <span className="min-w-0 flex-1 truncate">{row.display_name}</span>+ {row.workspace_id === active && <Check size={15} strokeWidth={2} className="shrink-0" />}+ </button>+ ))}+ <Link role="menuitem" href="/settings/workspace" prefetch={false} onClick={onChoose} className="dt-menu-item is-quiet">+ <Settings2 size={16} strokeWidth={1.6} />+ <span>{t('Manage workspaces')}</span>+ </Link>+ </>+ )+}++/**+ * The sidebar's header: which workspace this is, and the account-level+ * places (workspaces, settings, profile) that used to sit in the footer.+ */+export function WorkspaceMenu({ accountSlot, onNavigate }: { accountSlot?: ReactNode; onNavigate?: () => void }) {+ const { t } = useTranslation()+ const { active, currentName } = useWorkspaceChoices()+ const [open, setOpen] = useState(false)+ const rootRef = useMenuPopover<HTMLDivElement>(open, setOpen)+ const menuId = useId()+ const close = () => {+ setOpen(false)+ onNavigate?.()+ }+ return (+ <div ref={rootRef} className="dt-workspace-menu">+ <button+ type="button"+ aria-haspopup="menu"+ aria-expanded={open}+ aria-controls={menuId}+ onClick={() => setOpen(value => !value)}+ className="dt-workspace-trigger"+ >+ <WorkspaceGlyph name={currentName} general={!active} />+ <span className="min-w-0 flex-1 truncate text-left">{currentName}</span>+ <ChevronDown size={14} strokeWidth={1.8} className="shrink-0 opacity-60" />+ </button>+ {open && (+ <div id={menuId} role="menu" aria-label={t('Manage workspaces')} className="dt-popover dt-workspace-panel">+ <WorkspaceChoiceList onChoose={close} />+ <div className="dt-menu-divider" />+ <Link role="menuitem" href="/settings" prefetch={false} onClick={close} className="dt-menu-item">+ <Settings size={16} strokeWidth={1.6} />+ <span className="flex-1">{t('Settings')}</span>+ </Link>+ {accountSlot ? <div className="dt-menu-slot">{accountSlot}</div> : null}+ <div className="dt-menu-divider" />+ <div className="dt-menu-footer">+ <span>DeepTutor</span>+ <VersionBadge onNavigate={close} />+ </div>+ </div>+ )}+ </div>+ )+}diff --git a/web/components/sidebar/WorkspaceSidebar.tsx b/web/components/sidebar/WorkspaceSidebar.tsxindex 77ef8decc..3994b2920 100644--- a/web/components/sidebar/WorkspaceSidebar.tsx+++ b/web/components/sidebar/WorkspaceSidebar.tsx@@ -7,7 +7,7 @@ import { workspaceChatHref } from "@/lib/workspaces-api";import { useRouter } from "next/navigation";import { useTranslation } from "react-i18next";-import { SidebarShell } from "@/components/sidebar/SidebarShell";+import { LayoutSidebarShell } from "@/features/ui-layout/slots";import { reconcileUnread } from "@/lib/session-unread";import { LogoutButton } from "@/components/auth/LogoutButton";import { AdminLink } from "@/components/auth/AdminLink";@@ -233,7 +233,7 @@ export default function WorkspaceSidebar() {);return (- <SidebarShell+ <LayoutSidebarShellshowSessionssessions={liveSessions}liveSessionIds={liveSessionIds}diff --git a/web/components/sidebar/page-sections.ts b/web/components/sidebar/page-sections.tsnew file mode 100644index 000000000..6caecab21--- /dev/null+++ b/web/components/sidebar/page-sections.ts@@ -0,0 +1,97 @@+import { BookOpen, Bot, Columns3, Home, LayoutGrid, Library, MessageCircle, PenLine, type LucideIcon } from 'lucide-react'+import { DASHBOARD_GROUPS, visibleGroups } from '@/components/space/dashboard-groups'+import { LEARNING_SURFACES } from '@/components/learning/surfaces'+import { navVisibleUnderPolicy } from './nav-entries'++export interface PageEntry {+ href: string+ label: string+ icon: LucideIcon+}++export interface PageSection {+ id: 'home' | 'partners' | 'learning' | 'resources'+ label: string+ icon: LucideIcon+ /** Content here belongs to the URL's workspace, so its scope is shown. */+ scoped: boolean+ pages: PageEntry[]+}++/**+ * The sidebar's four shelves as one page tree — the same entries, policy and+ * capability gates the shelves apply — so the page bar and the sidebar can+ * never disagree about where a page lives or what sits beside it.+ */+export function pageSections({+ t,+ zh,+ allowedSurfaces,+ isAvailable,+}: {+ t: (key: string) => string+ zh: boolean+ allowedSurfaces: readonly string[] | null+ isAvailable: ((name: string) => boolean) | null+}): PageSection[] {+ const surfaceAllowed = (kind: string) =>+ !allowedSurfaces || allowedSurfaces.includes(kind === 'mastery' || kind === 'practice' ? 'chat' : kind)+ return [+ {+ id: 'home',+ label: t('navigation.home'),+ icon: Home,+ scoped: false,+ pages: [+ { href: '/kanban', label: t('Task Board'), icon: Columns3 },+ { href: '/co-writer', label: t('Co-Writer'), icon: PenLine },+ { href: '/agents', label: t('My Agents'), icon: Bot },+ ].filter(page => navVisibleUnderPolicy(page.href, allowedSurfaces)),+ },+ {+ id: 'partners',+ label: t('navigation.partners'),+ icon: MessageCircle,+ scoped: false,+ pages: [{ href: '/partners', label: t('Partners'), icon: MessageCircle }],+ },+ {+ id: 'learning',+ label: t('navigation.learning'),+ icon: BookOpen,+ scoped: true,+ pages: [+ { href: '/learning', label: t('navigation.allLearning'), icon: LayoutGrid },+ ...LEARNING_SURFACES.filter(surface => surfaceAllowed(surface.kind)).map(surface => ({+ href: surface.href,+ label: t(surface.title),+ icon: surface.icon,+ })),+ ],+ },+ {+ id: 'resources',+ label: t('navigation.resources'),+ icon: Library,+ scoped: true,+ pages: [+ { href: '/space', label: t('navigation.allResources'), icon: Library },+ ...visibleGroups(DASHBOARD_GROUPS, isAvailable).flatMap(group =>+ group.items.map(item => ({ href: item.href, label: zh ? item.title.zh : item.title.en, icon: item.icon }))+ ),+ ],+ },+ ]+}++/**+ * The section and page a pathname is the index page of. Only index pages get+ * the bar: detail views (a conversation, a book, a partner) bring their own.+ */+export function locatePage(pathname: string, sections: PageSection[]) {+ for (const section of sections) {+ const page = section.pages.find(entry => entry.href === pathname)+ if (page) return { section, page }+ }+ return null+}diff --git a/web/components/sidebar/roster-lens.ts b/web/components/sidebar/roster-lens.tsnew file mode 100644index 000000000..238e0d798--- /dev/null+++ b/web/components/sidebar/roster-lens.ts@@ -0,0 +1,93 @@+/**+ * Geometry for the partner roster strip.+ *+ * Items keep their natural spacing in the middle of the strip. Inside the+ * zone at an edge that still has partners beyond it, spacing tightens+ * exponentially toward a floor and each avatar shrinks with its local spacing,+ * so the gaps between them close steadily without the avatars ever touching;+ * the strip's edge fade takes the last of them. A side only compresses as far as there is content to+ * scroll back to, so a strip at its start, or a roster that fits, stays flat.+ */++export interface RosterLensInput {+ /** Item centre in content coordinates (offsetLeft + width / 2). */+ center: number+ /** Visible strip width. */+ viewport: number+ scrollLeft: number+ /** scrollWidth - clientWidth. */+ maxScroll: number+ /** How far the compression reaches into the strip from each edge. */+ zone: number+}++export interface RosterLens {+ /** Horizontal shift from the item's layout position. */+ dx: number+ scale: number+ opacity: number+ /** Name opacity; names leave before the avatars do. */+ label: number+ /** How compressed the item is, 0 (flat) to 1. */+ depth: number+}++/** Tightest spacing, as a share of the natural one. */+const MIN_SPACING = 0.3+/**+ * Avatar scale per unit of local spacing. Neighbours stay apart while+ * slot * f >= avatar * scale; for the roster's 46px slots and 32px avatars+ * that holds for any scale <= 1.43 f; 1.15 f leaves room for the step between+ * an item's own spacing and the gap to its neighbour.+ */+const SCALE_PER_SPACING = 1.15+const MIN_OPACITY = 0.4++const clamp01 = (value: number) => Math.min(1, Math.max(0, value))++/**+ * Visual distance into the zone for a layout distance `into`: the integral of+ * a spacing factor that decays as exp(-x / falloff) down to MIN_SPACING.+ */+function compressed(into: number, falloff: number): number {+ const knee = -falloff * Math.log(MIN_SPACING)+ if (into <= knee) return falloff * (1 - Math.exp(-into / falloff))+ return falloff * (1 - MIN_SPACING) + MIN_SPACING * (into - knee)+}++export function rosterLens({ center, viewport, scrollLeft, maxScroll, zone }: RosterLensInput): RosterLens {+ const flat: RosterLens = { dx: 0, scale: 1, opacity: 1, label: 1, depth: 0 }+ if (viewport <= 0 || zone <= 0) return flat+ const position = center - scrollLeft+ const intoLeft = zone - position+ const intoRight = position - (viewport - zone)+ const side = intoLeft >= intoRight ? -1 : 1+ const into = Math.max(intoLeft, intoRight)+ if (into <= 0) return flat+ // Compression is only as present as the content it stands for.+ const strength = clamp01((side < 0 ? scrollLeft : maxScroll - scrollLeft) / zone)+ if (strength === 0) return flat++ const falloff = zone * 0.9+ const target = side < 0 ? zone - compressed(into, falloff) : viewport - zone + compressed(into, falloff)+ const spacing = Math.max(MIN_SPACING, Math.exp(-into / falloff))+ const fullScale = Math.min(1, spacing * SCALE_PER_SPACING)+ const depth = (1 - spacing) / (1 - MIN_SPACING) * strength+ return {+ dx: (target - position) * strength,+ scale: 1 - (1 - fullScale) * strength,+ opacity: 1 - (1 - MIN_OPACITY) * depth,+ label: 1 - clamp01((into / (zone * 0.5)) * strength),+ depth,+ }+}++/** Edge fade per side, in px: present only where content continues. */+export function rosterFade({ viewport, scrollLeft, maxScroll, zone }: Omit<RosterLensInput, 'center'>) {+ if (viewport <= 0 || zone <= 0) return { left: 0, right: 0 }+ const reach = zone * 0.4+ return {+ left: reach * clamp01(scrollLeft / zone),+ right: reach * clamp01((maxScroll - scrollLeft) / zone),+ }+}diff --git a/web/components/space/SpaceDashboard.tsx b/web/components/space/SpaceDashboard.tsxindex 345807978..3778989c3 100644--- a/web/components/space/SpaceDashboard.tsx+++ b/web/components/space/SpaceDashboard.tsx@@ -4,30 +4,22 @@ import { PageHeader, PAGE_SECTION_TITLE_CLASS, pageGridClass } from '@/componentimport { useCallback, useEffect, useMemo, useState } from "react";import Link from "next/link";import { useTranslation } from "react-i18next";+import { useUiLayoutLabel } from "@/features/ui-layout/tokens";import { useCapabilityFilter } from "@/features/capabilities/useCapabilityCatalog";import {ArrowUpRight,- BookOpen,- Brain,- ClipboardList,- Ear,Github,- History,- NotebookPen,- Plug,- Terminal,- UserRound,- Wand2,- type LucideIcon,+ Library,} from "lucide-react";+import {+ DASHBOARD_GROUPS,+ ALL_ITEMS,+ visibleGroups,+ type DashboardItem,+ type Lang,+ type DashKey,+} from "@/components/space/dashboard-groups";-import { SPACE_MCP_SURFACE, loadMcpSurface } from "@/components/mcp/surface";-import { getCliApps } from "@/lib/cli-apps-api";-import { listSessions } from "@/lib/session-api";-import { listNotebooks, listNotebookEntries } from "@/lib/notebook-api";-import { listPersonas } from "@/lib/personas-api";-import { listKnowledgeBases } from "@/features/knowledge/api/catalog";-import { listSkills } from "@/lib/skills-api";import { scopedUrl } from "@/lib/workspace-scope";/**@@ -39,246 +31,6 @@ import { scopedUrl } from "@/lib/workspace-scope";* section page (which keeps the mini-nav for lateral movement).*/-type Lang = { zh: string; en: string };--type DashKey =- | "knowledge"- | "memory"- | "chat_history"- | "notebooks"- | "journal"- | "question_bank"- | "personas"- | "skills"- | "mcp"- | "cli_apps"- | "whisper";--interface DashboardItem {- key: DashKey;- href: string;- icon: LucideIcon;- title: Lang;- blurb: Lang;- /**- * Unit shown after the live count, e.g. "168 conversations". Omitted- * together with ``load`` for a tile that has nothing to count.- */- unit?: Lang;- /** Icon-tile accent — full class strings so Tailwind keeps them. */- tile: string;- /**- * Live count for the tile. Optional: a surface with no countable rows (an- * ephemeral room, say) renders as title + blurb instead of showing a- * permanently-loading number.- */- load?: () => Promise<number>;- /** GitHub handle of the contributor this surface came from. */- credit?: string;- /**- * Turn capability this surface needs, when it is not served by this- * repository. The tile is withheld unless the backend registry actually- * holds the name, so a stock install never offers a room whose capability- * was never installed (#963).- */- requiresCapability?: string;-}--interface DashboardGroup {- label: Lang;- items: DashboardItem[];-}--const GROUPS: DashboardGroup[] = [- {- label: { zh: "对话与资料", en: "Conversations & Materials" },- items: [- {- key: "chat_history",- href: "/space/chat-history",- icon: History,- title: { zh: "聊天历史", en: "Chat History" },- blurb: {- zh: "回顾并继续此前的对话。",- en: "Review and reopen previous conversations.",- },- unit: { zh: "段对话", en: "conversations" },- tile: "bg-sky-500/10 text-sky-600 dark:text-sky-400",- load: async () => (await listSessions(200, 0, { force: true })).length,- },- {- key: "notebooks",- href: "/notebooks",- icon: NotebookPen,- title: { zh: "笔记本", en: "Notebooks" },- blurb: {- zh: "整理来自对话、研究、智能写作等的产出。",- en: "Organize saved outputs from chat, research, Co-Writer, and more.",- },- unit: { zh: "个笔记本", en: "notebooks" },- tile: "bg-amber-500/10 text-amber-600 dark:text-amber-400",- load: async () => (await listNotebooks()).length,- },- {- key: "journal",- href: "/space/journal",- icon: NotebookPen,- title: { zh: "学习日志", en: "Learning journal" },- blurb: { zh: "查看当前目标、上次会话交接和已确认的学习记录。", en: "Inspect your mission, session handoff and confirmed records." },- tile: "bg-teal-500/10 text-teal-600 dark:text-teal-400",- },- {- key: "question_bank",- href: "/space/questions",- icon: ClipboardList,- title: { zh: "题库", en: "Question Bank" },- blurb: {- zh: "跨会话回顾和整理测验题目。",- en: "Review and organize quiz questions across sessions.",- },- unit: { zh: "道题", en: "questions" },- tile: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",- load: async () => (await listNotebookEntries({ limit: 1 })).total,- },- {- key: "knowledge",- href: "/knowledge-bases",- icon: BookOpen,- title: { zh: "知识中心", en: "Knowledge Center" },- blurb: {- zh: "管理知识库与检索引擎。",- en: "Manage knowledge bases and retrieval engines.",- },- unit: { zh: "个知识库", en: "knowledge bases" },- tile: "bg-blue-500/10 text-blue-600 dark:text-blue-400",- load: async () => (await listKnowledgeBases({ library: true })).length,- },- ],- },- {- label: { zh: "个性化", en: "Personalization" },- items: [- {- key: "personas",- href: "/space/personas",- icon: UserRound,- title: { zh: "Personas", en: "Personas" },- blurb: {- zh: "可在每轮对话中套用的行为预设。",- en: "Behavior presets you can apply per chat turn.",- },- unit: { zh: "个预设", en: "personas" },- tile: "bg-rose-500/10 text-rose-600 dark:text-rose-400",- load: async () => (await listPersonas()).length,- },- {- key: "skills",- href: "/space/skills",- icon: Wand2,- title: { zh: "技能", en: "Skills" },- blurb: {- zh: "模型按需读取的能力手册。",- en: "Capability playbooks the model reads on demand.",- },- unit: { zh: "个技能", en: "skills" },- tile: "bg-indigo-500/10 text-indigo-600 dark:text-indigo-400",- load: async () => (await listSkills()).length,- },- {- key: "mcp",- href: "/space/mcp",- icon: Plug,- title: { zh: "MCP 服务", en: "MCP Services" },- blurb: {- zh: "连接托管 MCP 服务,把它们的工具带进对话。",- en: "Connect hosted MCP services and bring their tools into chat.",- },- unit: { zh: "个服务", en: "services" },- tile: "bg-blue-500/10 text-blue-600 dark:text-blue-400",- // The account's own servers only: the deployment's are shown on the page- // but are not this reader's to count.- load: async () =>- Object.keys((await loadMcpSurface(SPACE_MCP_SURFACE)).servers).length,- },- {- key: "cli_apps",- href: "/space/cli-apps",- icon: Terminal,- title: { zh: "CLI 应用", en: "CLI Apps" },- blurb: {- zh: "来自 CLI-Anything 目录的命令行工具,启用后对话可直接调用。",- en: "Command-line tools from the CLI-Anything catalog, callable from chat.",- },- unit: { zh: "个应用", en: "apps" },- tile: "bg-violet-500/10 text-violet-600 dark:text-violet-400",- // What this reader can actually use, not what the deployment installed:- // an app they were not granted is visible on the page but is not theirs.- load: async () =>- (await getCliApps()).apps.filter(app => app.granted && app.enabled)- .length,- },- {- key: "memory",- href: "/memory",- icon: Brain,- title: { zh: "记忆", en: "Memory" },- blurb: {- zh: "查看与整理导师记住的偏好和学习经历。",- en: "Review what your tutor remembers about you.",- },- tile: "bg-rose-500/10 text-rose-600 dark:text-rose-400",- },- ],- },- {- label: { zh: "更多项目", en: "More Projects" },- items: [- {- key: "whisper",- href: "/whisper",- icon: Ear,- title: { zh: "密语", en: "Whisper" },- blurb: {- zh: "双席位咨询练习房间:督导只对受训者耳语。",- en: "Dual-seat practice room — the supervisor whispers to the trainee only.",- },- tile: "bg-fuchsia-500/10 text-fuchsia-600 dark:text-fuchsia-400",- credit: "alanguan73",- // Served by the out-of-tree psych-academy plugin, not by this repo.- requiresCapability: "whisper_visitor",- },- ],- },-];--const ALL_ITEMS = GROUPS.flatMap(g => g.items);--/**- * The groups to render, given what the backend can actually serve.- *- * `isAvailable` is null while the probe is in flight: gated tiles stay hidden- * until then, so a surface whose capability was never installed does not flash- * into view and out again — an ungated tile is never affected. A group left- * with no tiles is dropped along with its heading, or "More Projects" would- * render as a title over nothing (#963).- */-export function visibleGroups(- groups: DashboardGroup[],- isAvailable: ((name: string) => boolean) | null-): DashboardGroup[] {- return groups- .map(group => ({- ...group,- items: group.items.filter(- item =>- !item.requiresCapability ||- (isAvailable?.(item.requiresCapability) ?? false)- ),- }))- .filter(group => group.items.length > 0);-}--export { GROUPS as DASHBOARD_GROUPS };export default function SpaceDashboard({title,@@ -289,7 +41,8 @@ export default function SpaceDashboard({description?: string;onNavigate?: (href: string) => void;} = {}) {- const { t, i18n } = useTranslation();+ const { i18n } = useTranslation();+ const spaceLabel = useUiLayoutLabel("space");const zh = i18n.language?.toLowerCase().startsWith("zh");const tr = useCallback((l: Lang) => (zh ? l.zh : l.en), [zh]);@@ -297,7 +50,7 @@ export default function SpaceDashboard({const capabilityAvailable = useCapabilityFilter();const groups = useMemo(- () => visibleGroups(GROUPS, capabilityAvailable),+ () => visibleGroups(DASHBOARD_GROUPS, capabilityAvailable),[capabilityAvailable]);@@ -324,7 +77,8 @@ export default function SpaceDashboard({return (<div><PageHeader- title={title ?? t("navigation.resources")}+ icon={Library}+ title={title ?? spaceLabel}description={description ?? tr({zh: "你的对话、智能体、笔记与题目,集中在一处 —— 从这里进入。",en: "Your conversations, agents, notebooks, and questions in one place — enter from here.",diff --git a/web/components/space/SpaceMain.tsx b/web/components/space/SpaceMain.tsxindex fab86d471..5675c6c40 100644--- a/web/components/space/SpaceMain.tsx+++ b/web/components/space/SpaceMain.tsx@@ -6,23 +6,24 @@ import { usePathname } from "next/navigation";import { ArrowLeft } from "lucide-react";import { useTranslation } from "react-i18next";import { FeaturePage } from "@/components/layout/FeaturePage";+import { useUiLayoutLabel } from "@/features/ui-layout/tokens";// Hub-and-spoke: the dashboard at `/space` is the only navigator. Once inside a// section we don't re-list every sibling on a rail — a single "back to the hub"// link keeps the section focused and sends you to the overview to switch.function BackToHub() {- const { t } = useTranslation();+ const spaceLabel = useUiLayoutLabel("space");return (<Linkhref="/space"- className="group inline-flex items-center gap-1.5 text-[13px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"+ className="dt-section-back group inline-flex items-center gap-1.5 text-[13px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"><ArrowLeftsize={15}strokeWidth={1.8}className="transition-transform group-hover:-translate-x-0.5"/>- {t("navigation.resources")}+ {spaceLabel}</Link>);}diff --git a/web/components/space/SpaceSectionHeader.tsx b/web/components/space/SpaceSectionHeader.tsxindex cad648e59..1a176616c 100644--- a/web/components/space/SpaceSectionHeader.tsx+++ b/web/components/space/SpaceSectionHeader.tsx@@ -1,7 +1,10 @@"use client";import { type ReactNode } from "react";+import { usePathname } from "next/navigation";+import type { LucideIcon } from "lucide-react";import { PageHeader } from "@/components/layout/FeaturePage";+import { DASHBOARD_GROUPS } from "@/components/space/dashboard-groups";interface SpaceSectionHeaderProps {title: string;@@ -9,6 +12,8 @@ interface SpaceSectionHeaderProps {action?: ReactNode;meta?: ReactNode;level?: 1 | 2;+ /** Defaults to the icon this section wears on the /space hub. */+ icon?: LucideIcon;}export default function SpaceSectionHeader({@@ -17,8 +22,12 @@ export default function SpaceSectionHeader({action,meta,level,+ icon,}: SpaceSectionHeaderProps) {+ // usePathname is null outside the App Router (tests, embeds).+ const pathname = usePathname() ?? "";+ const hubIcon = DASHBOARD_GROUPS.flatMap((group) => group.items).find((item) => item.href === pathname)?.icon;return (- <PageHeader title={title} description={description} action={action} meta={meta} level={level} />+ <PageHeader title={title} description={description} action={action} meta={meta} level={level} icon={icon ?? hubIcon} />);}diff --git a/web/components/space/dashboard-groups.ts b/web/components/space/dashboard-groups.tsnew file mode 100644index 000000000..2adbddb6b--- /dev/null+++ b/web/components/space/dashboard-groups.ts@@ -0,0 +1,265 @@+/**+ * The /space hub's sections: what each resource is called, where it lives,+ * its icon and live count. Shared by the hub, the sidebar shelf, the ⌘K+ * palette and the page bar, so it carries no component code.+ */+import {+ BookOpen,+ Brain,+ ClipboardList,+ Ear,+ History,+ NotebookPen,+ Plug,+ Terminal,+ UserRound,+ Wand2,+ type LucideIcon,+} from "lucide-react";++import { SPACE_MCP_SURFACE, loadMcpSurface } from "@/components/mcp/surface";+import { getCliApps } from "@/lib/cli-apps-api";+import { listSessions } from "@/lib/session-api";+import { listNotebooks, listNotebookEntries } from "@/lib/notebook-api";+import { listPersonas } from "@/lib/personas-api";+import { listKnowledgeBases } from "@/features/knowledge/api/catalog";+import { listSkills } from "@/lib/skills-api";++export type Lang = { zh: string; en: string };++export type DashKey =+ | "knowledge"+ | "memory"+ | "chat_history"+ | "notebooks"+ | "journal"+ | "question_bank"+ | "personas"+ | "skills"+ | "mcp"+ | "cli_apps"+ | "whisper";++export interface DashboardItem {+ key: DashKey;+ href: string;+ icon: LucideIcon;+ title: Lang;+ blurb: Lang;+ /**+ * Unit shown after the live count, e.g. "168 conversations". Omitted+ * together with ``load`` for a tile that has nothing to count.+ */+ unit?: Lang;+ /** Icon-tile accent — full class strings so Tailwind keeps them. */+ tile: string;+ /**+ * Live count for the tile. Optional: a surface with no countable rows (an+ * ephemeral room, say) renders as title + blurb instead of showing a+ * permanently-loading number.+ */+ load?: () => Promise<number>;+ /** GitHub handle of the contributor this surface came from. */+ credit?: string;+ /**+ * Turn capability this surface needs, when it is not served by this+ * repository. The tile is withheld unless the backend registry actually+ * holds the name, so a stock install never offers a room whose capability+ * was never installed (#963).+ */+ requiresCapability?: string;+}++export interface DashboardGroup {+ label: Lang;+ items: DashboardItem[];+}++export const DASHBOARD_GROUPS: DashboardGroup[] = [+ {+ label: { zh: "对话与资料", en: "Conversations & Materials" },+ items: [+ {+ key: "chat_history",+ href: "/space/chat-history",+ icon: History,+ title: { zh: "聊天历史", en: "Chat History" },+ blurb: {+ zh: "回顾并继续此前的对话。",+ en: "Review and reopen previous conversations.",+ },+ unit: { zh: "段对话", en: "conversations" },+ tile: "bg-sky-500/10 text-sky-600 dark:text-sky-400",+ load: async () => (await listSessions(200, 0, { force: true })).length,+ },+ {+ key: "notebooks",+ href: "/notebooks",+ icon: NotebookPen,+ title: { zh: "笔记本", en: "Notebooks" },+ blurb: {+ zh: "整理来自对话、研究、智能写作等的产出。",+ en: "Organize saved outputs from chat, research, Co-Writer, and more.",+ },+ unit: { zh: "个笔记本", en: "notebooks" },+ tile: "bg-amber-500/10 text-amber-600 dark:text-amber-400",+ load: async () => (await listNotebooks()).length,+ },+ {+ key: "journal",+ href: "/space/journal",+ icon: NotebookPen,+ title: { zh: "学习日志", en: "Learning journal" },+ blurb: { zh: "查看当前目标、上次会话交接和已确认的学习记录。", en: "Inspect your mission, session handoff and confirmed records." },+ tile: "bg-teal-500/10 text-teal-600 dark:text-teal-400",+ },+ {+ key: "question_bank",+ href: "/space/questions",+ icon: ClipboardList,+ title: { zh: "题库", en: "Question Bank" },+ blurb: {+ zh: "跨会话回顾和整理测验题目。",+ en: "Review and organize quiz questions across sessions.",+ },+ unit: { zh: "道题", en: "questions" },+ tile: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",+ load: async () => (await listNotebookEntries({ limit: 1 })).total,+ },+ {+ key: "knowledge",+ href: "/knowledge-bases",+ icon: BookOpen,+ title: { zh: "知识中心", en: "Knowledge Center" },+ blurb: {+ zh: "管理知识库与检索引擎。",+ en: "Manage knowledge bases and retrieval engines.",+ },+ unit: { zh: "个知识库", en: "knowledge bases" },+ tile: "bg-blue-500/10 text-blue-600 dark:text-blue-400",+ load: async () => (await listKnowledgeBases({ library: true })).length,+ },+ ],+ },+ {+ label: { zh: "个性化", en: "Personalization" },+ items: [+ {+ key: "personas",+ href: "/space/personas",+ icon: UserRound,+ title: { zh: "Personas", en: "Personas" },+ blurb: {+ zh: "可在每轮对话中套用的行为预设。",+ en: "Behavior presets you can apply per chat turn.",+ },+ unit: { zh: "个预设", en: "personas" },+ tile: "bg-rose-500/10 text-rose-600 dark:text-rose-400",+ load: async () => (await listPersonas()).length,+ },+ {+ key: "skills",+ href: "/space/skills",+ icon: Wand2,+ title: { zh: "技能", en: "Skills" },+ blurb: {+ zh: "模型按需读取的能力手册。",+ en: "Capability playbooks the model reads on demand.",+ },+ unit: { zh: "个技能", en: "skills" },+ tile: "bg-indigo-500/10 text-indigo-600 dark:text-indigo-400",+ load: async () => (await listSkills()).length,+ },+ {+ key: "mcp",+ href: "/space/mcp",+ icon: Plug,+ title: { zh: "MCP 服务", en: "MCP Services" },+ blurb: {+ zh: "连接托管 MCP 服务,把它们的工具带进对话。",+ en: "Connect hosted MCP services and bring their tools into chat.",+ },+ unit: { zh: "个服务", en: "services" },+ tile: "bg-blue-500/10 text-blue-600 dark:text-blue-400",+ // The account's own servers only: the deployment's are shown on the page+ // but are not this reader's to count.+ load: async () =>+ Object.keys((await loadMcpSurface(SPACE_MCP_SURFACE)).servers).length,+ },+ {+ key: "cli_apps",+ href: "/space/cli-apps",+ icon: Terminal,+ title: { zh: "CLI 应用", en: "CLI Apps" },+ blurb: {+ zh: "来自 CLI-Anything 目录的命令行工具,启用后对话可直接调用。",+ en: "Command-line tools from the CLI-Anything catalog, callable from chat.",+ },+ unit: { zh: "个应用", en: "apps" },+ tile: "bg-violet-500/10 text-violet-600 dark:text-violet-400",+ // What this reader can actually use, not what the deployment installed:+ // an app they were not granted is visible on the page but is not theirs.+ load: async () =>+ (await getCliApps()).apps.filter(app => app.granted && app.enabled)+ .length,+ },+ {+ key: "memory",+ href: "/memory",+ icon: Brain,+ title: { zh: "记忆", en: "Memory" },+ blurb: {+ zh: "查看与整理导师记住的偏好和学习经历。",+ en: "Review what your tutor remembers about you.",+ },+ tile: "bg-rose-500/10 text-rose-600 dark:text-rose-400",+ },+ ],+ },+ {+ label: { zh: "更多项目", en: "More Projects" },+ items: [+ {+ key: "whisper",+ href: "/whisper",+ icon: Ear,+ title: { zh: "密语", en: "Whisper" },+ blurb: {+ zh: "双席位咨询练习房间:督导只对受训者耳语。",+ en: "Dual-seat practice room — the supervisor whispers to the trainee only.",+ },+ tile: "bg-fuchsia-500/10 text-fuchsia-600 dark:text-fuchsia-400",+ credit: "alanguan73",+ // Served by the out-of-tree psych-academy plugin, not by this repo.+ requiresCapability: "whisper_visitor",+ },+ ],+ },+];++export const ALL_ITEMS = DASHBOARD_GROUPS.flatMap(g => g.items);++/**+ * The groups to render, given what the backend can actually serve.+ *+ * `isAvailable` is null while the probe is in flight: gated tiles stay hidden+ * until then, so a surface whose capability was never installed does not flash+ * into view and out again — an ungated tile is never affected. A group left+ * with no tiles is dropped along with its heading, or "More Projects" would+ * render as a title over nothing (#963).+ */+export function visibleGroups(+ groups: DashboardGroup[],+ isAvailable: ((name: string) => boolean) | null+): DashboardGroup[] {+ return groups+ .map(group => ({+ ...group,+ items: group.items.filter(+ item =>+ !item.requiresCapability ||+ (isAvailable?.(item.requiresCapability) ?? false)+ ),+ }))+ .filter(group => group.items.length > 0);+}diff --git a/web/components/workspaces/WorkspaceSwitcher.tsx b/web/components/workspaces/WorkspaceSwitcher.tsxdeleted file mode 100644index f0a1715d9..000000000--- a/web/components/workspaces/WorkspaceSwitcher.tsx+++ /dev/null@@ -1,69 +0,0 @@-'use client'--import { useEffect, useState } from 'react'-import { useSearchParams } from 'next/navigation'-import Link from 'next/link'-import { FolderOpen, Settings2 } from 'lucide-react'-import { useTranslation } from 'react-i18next'-import { useChatWorkspaces } from '@/hooks/useChatWorkspaces'-import { selectWorkspace } from '@/lib/workspace-scope'--export function WorkspaceSwitcher() {- const { t } = useTranslation()- const { workspaces, error } = useChatWorkspaces()- const query = useSearchParams()- const active = query.get('dt_workspace') ?? query.get('workspace') ?? ''- const [draftError, setDraftError] = useState(false)- useEffect(() => {- const failed = () => setDraftError(true)- window.addEventListener('deeptutor:workspace-switch-error', failed)- return () => window.removeEventListener('deeptutor:workspace-switch-error', failed)- }, [])- return (- <div className="mx-3 mb-2 rounded-lg border border-[var(--border)] px-2 py-1.5">- <div className="flex items-center gap-2">- <FolderOpen size={14} className="shrink-0 text-[var(--muted-foreground)]" />- <select- aria-label={t('Active workspace')}- value={active}- onChange={event => selectWorkspace(event.target.value)}- className="min-w-0 flex-1 bg-transparent py-1 text-xs text-[var(--foreground)] outline-none"- >- <option value="">{t('Default workspace')}</option>- {active && !workspaces.some(row => row.workspace_id === active) ? (- <option value={active}>{t('Workspace unavailable')}</option>- ) : null}- {workspaces- .filter(row => !row.archived || row.workspace_id === active)- .map(row => (- <option- key={row.workspace_id}- value={row.workspace_id}- disabled={row.status !== 'ready'}- >- {row.display_name}- {row.archived ? ` (${t('Archived')})` : ''}- </option>- ))}- </select>- <Link- href="/settings/workspace"- aria-label={t('Manage workspaces')}- className="text-[var(--muted-foreground)] hover:text-[var(--foreground)]"- >- <Settings2 size={13} />- </Link>- </div>- {error ? (- <p role="alert" className="mt-1 text-xs text-[var(--destructive)]">- {error}- </p>- ) : null}- {draftError ? (- <p role="alert" className="mt-1 text-xs text-[var(--destructive)]">- {t('Could not save the draft. Free browser storage before switching workspaces.')}- </p>- ) : null}- </div>- )-}diff --git a/web/components/workspaces/useWorkspaceChoices.ts b/web/components/workspaces/useWorkspaceChoices.tsnew file mode 100644index 000000000..9647be8b6--- /dev/null+++ b/web/components/workspaces/useWorkspaceChoices.ts@@ -0,0 +1,31 @@+'use client'++import { usePathname, useSearchParams } from 'next/navigation'+import { useTranslation } from 'react-i18next'+import { useChatWorkspaces } from '@/hooks/useChatWorkspaces'+import { selectWorkspace } from '@/lib/workspace-scope'++/** Switching lands on the section's index: a detail page belongs to the old workspace. */+function switchDestination(pathname: string): string {+ const section = pathname.split('/')[1]+ return section ? `/${section}` : '/chat'+}++/** The workspace this URL is scoped to, the ones it can switch to, and the switch. */+export function useWorkspaceChoices() {+ const { t } = useTranslation()+ const pathname = usePathname() ?? '/'+ const query = useSearchParams()+ const active = query.get('dt_workspace') ?? query.get('workspace') ?? ''+ const { workspaces } = useChatWorkspaces()+ const current = workspaces.find(row => row.workspace_id === active)+ const currentName = active ? (current?.display_name ?? t('Workspace unavailable')) : t('General workspace')+ const choices = [+ { workspace_id: '', display_name: t('General workspace') },+ ...workspaces.filter(row => row.workspace_id === active || (!row.archived && row.status === 'ready')),+ ]+ const choose = (workspaceId: string) => {+ if (workspaceId !== active) void selectWorkspace(workspaceId, switchDestination(pathname))+ }+ return { active, currentName, choices, choose }+}diff --git a/web/features/capabilities/presentation.tsx b/web/features/capabilities/presentation.tsxindex 5a8a4962e..64f641ea3 100644--- a/web/features/capabilities/presentation.tsx+++ b/web/features/capabilities/presentation.tsx@@ -68,7 +68,7 @@ export interface ChatCapabilityDef extends CapabilityDef {export const CHAT_CAPABILITIES: ChatCapabilityDef[] = [{value: "",- label: "Auto",+ label: "Chat",description: "Flexible conversation with any tool",icon: MessageSquare,allowedTools: [diff --git a/web/features/chat/components/ChatWorkspace.tsx b/web/features/chat/components/ChatWorkspace.tsxindex 35f607b66..dabdec056 100644--- a/web/features/chat/components/ChatWorkspace.tsx+++ b/web/features/chat/components/ChatWorkspace.tsx@@ -35,7 +35,6 @@ import { useTranslation } from "react-i18next";import type { SelectedRecord } from "@/lib/notebook-selection-types";import type { SelectedHistorySession } from "@/components/chat/HistorySessionPicker";import type { SelectedQuestionEntry } from "@/components/chat/QuestionBankPicker";-import ChatComposer from "@/components/chat/home/ChatComposer";import { ChatMessageList } from "@/features/chat/messages";import { TurnNavigator } from "@/components/chat/home/TurnNavigator";@@ -155,11 +154,6 @@ import {} from "@/lib/selection-tutor";import { shouldReturnToChatAfterResearch } from "@/lib/deep-research-report";-const HomeShortcuts = dynamic(- () => import("@/components/chat/home/HomeShortcuts").then(module => module.HomeShortcuts),- { loading: () => <div className="h-8" aria-busy="true" /> },-);-const NotebookRecordPicker = dynamic(() => import("@/components/notebook/NotebookRecordPicker"),{@@ -2428,7 +2422,7 @@ export default function ChatWorkspace() {onKeyDown={handleSessionTitleKeyDown}disabled={sessionTitleSaving}aria-label={t("Session title")}- className="min-w-0 flex-1 rounded-xl border border-[var(--border)] bg-[var(--background)] px-3 py-1.5 font-serif text-[17px] font-semibold tracking-[-0.01em] text-[var(--foreground)] shadow-sm outline-none transition focus:border-[var(--ring)] focus:ring-2 focus:ring-[var(--ring)]/20 disabled:opacity-60"+ className="dt-chat-title min-w-0 flex-1 rounded-xl border border-[var(--border)] bg-[var(--background)] px-3 py-1.5 font-serif text-[17px] font-semibold tracking-[-0.01em] text-[var(--foreground)] shadow-sm outline-none transition focus:border-[var(--ring)] focus:ring-2 focus:ring-[var(--ring)]/20 disabled:opacity-60"maxLength={100}/>) : (@@ -2442,7 +2436,7 @@ export default function ChatWorkspace() {type="button"onClick={startSessionTitleEdit}disabled={!canRenameSession}- className="inline-flex min-w-0 max-w-full items-center gap-2 rounded-xl px-2 py-1 text-left font-serif text-[17px] font-semibold tracking-[-0.01em] text-[var(--foreground)] transition hover:bg-[var(--muted)]/55 disabled:cursor-default disabled:hover:bg-transparent"+ className="dt-chat-title inline-flex min-w-0 max-w-full items-center gap-2 rounded-xl px-2 py-1 text-left font-serif text-[17px] font-semibold tracking-[-0.01em] text-[var(--foreground)] transition hover:bg-[var(--muted)]/55 disabled:cursor-default disabled:hover:bg-transparent"><span className="truncate">{displaySessionTitle}</span>{canRenameSession ? (@@ -2503,8 +2497,8 @@ export default function ChatWorkspace() {</div></div>) : !hasMessages ? (- <div className="flex w-full flex-1 min-h-0 items-end justify-center pb-14 px-6">- <div className="w-full max-w-[960px] flex flex-col items-center justify-center gap-4">+ <div className="flex w-full flex-1 min-h-0 items-end justify-center pb-14 animate-fade-in px-6">+ <div className="w-full max-w-[960px] flex items-center justify-center gap-4"><imgsrc="/logo_black.png"alt="DeepTutor"@@ -2513,8 +2507,7 @@ export default function ChatWorkspace() {className="h-10 w-10 select-none"draggable={false}/>- <p className="text-sm font-medium text-muted-foreground">Dito</p>- <h1 className="font-sans text-[36px] font-medium leading-[1.1] tracking-[-0.015em] text-[var(--foreground)]">+ <h1 className="font-serif text-[40px] font-medium leading-[1.1] tracking-[-0.015em] text-[var(--foreground)]">{t(welcomeGreeting)}</h1></div>@@ -2795,7 +2788,6 @@ export default function ChatWorkspace() {inputPlaceholder={askHint || undefined}inputPlaceholderCompletion={askHint}/>- {!hasMessages && !state.workspaceMode && <HomeShortcuts />}{/* Starter chips sit between the composer and the spacer, so theyride up with the composer on the empty screen and disappear themoment the conversation has a first message. Clicking one sendsdiff --git a/web/features/preview/CollectionSurfaces.tsx b/web/features/preview/CollectionSurfaces.tsxindex 4d062cfa9..5a371e9aa 100644--- a/web/features/preview/CollectionSurfaces.tsx+++ b/web/features/preview/CollectionSurfaces.tsx@@ -18,7 +18,7 @@ import { Dialog } from '@/shared/ui/Dialog'import MarkdownRenderer from '@/components/common/MarkdownRenderer'import { MasteryQuestionCard } from '@/components/chat/home/MasteryQuestionCard'import type { MasteryGradeResult } from '@/lib/mastery-question'-import { DASHBOARD_GROUPS } from '@/components/space/SpaceDashboard'+import { DASHBOARD_GROUPS } from '@/components/space/dashboard-groups'import {learningKinds,type Collections,diff --git a/web/features/preview/PreviewNavigation.tsx b/web/features/preview/PreviewNavigation.tsxindex 50bc47d2c..19f525d56 100644--- a/web/features/preview/PreviewNavigation.tsx+++ b/web/features/preview/PreviewNavigation.tsx@@ -19,7 +19,7 @@ import {import Tooltip from '@/shared/ui/Tooltip'import PartnerAvatar from '@/components/partners/PartnerAvatar'import { useSidebarDrawer } from '@/components/layout/AppShell'-import { DASHBOARD_GROUPS } from '@/components/space/SpaceDashboard'+import { DASHBOARD_GROUPS } from '@/components/space/dashboard-groups'import { learningKinds, type Category, type Collections, type LearningRecord } from './collections'import type { PreviewView } from './fixtures'diff --git a/web/features/preview/PreviewWorkspace.tsx b/web/features/preview/PreviewWorkspace.tsxindex a51373e50..83f64e710 100644--- a/web/features/preview/PreviewWorkspace.tsx+++ b/web/features/preview/PreviewWorkspace.tsx@@ -28,7 +28,8 @@ import {import AppShell, { useSidebarDrawer } from '@/components/layout/AppShell'import { SidebarShell } from '@/components/sidebar/SidebarShell'import { FeaturePage, PageHeader, pageActionClass } from '@/components/layout/FeaturePage'-import SpaceDashboard, { DASHBOARD_GROUPS } from '@/components/space/SpaceDashboard'+import SpaceDashboard from '@/components/space/SpaceDashboard'+import { DASHBOARD_GROUPS } from '@/components/space/dashboard-groups'import AgentsHub from '@/components/agents/AgentsHub'import KanbanBoard from '@/features/tasks/components/KanbanBoard'import { startTaskBoardSync } from '@/lib/task-board-store'diff --git a/web/features/settings/navigation/settings-pages.ts b/web/features/settings/navigation/settings-pages.tsindex a19f59d86..5929e6ed8 100644--- a/web/features/settings/navigation/settings-pages.ts+++ b/web/features/settings/navigation/settings-pages.ts@@ -99,8 +99,8 @@ const extraPages: SettingsLeaf[] = [key: 'general',label: { en: 'General', zh: '常规' },blurb: {- en: 'Interface language, response language, and setup help',- zh: '界面语言、回复语言与配置帮助',+ en: 'Interface language, layout, response language, and setup help',+ zh: '界面语言、布局、回复语言与配置帮助',},icon: Settings2,href: '/settings/general',diff --git a/web/features/tasks/components/KanbanBoard.tsx b/web/features/tasks/components/KanbanBoard.tsxindex be2f2fdb0..eac40739d 100644--- a/web/features/tasks/components/KanbanBoard.tsx+++ b/web/features/tasks/components/KanbanBoard.tsx@@ -11,6 +11,7 @@ import {CircleCheck,CircleDashed,CircleDot,+ Columns3,Folder,Plus,RotateCcw,@@ -84,6 +85,7 @@ export default function KanbanBoard() {return (<FeaturePage><SpaceSectionHeader+ icon={Columns3}title={t('Task Board')}description={t('kanban.intro')}action={diff --git a/web/features/ui-layout/classic/ClassicLearningDashboard.tsx b/web/features/ui-layout/classic/ClassicLearningDashboard.tsxnew file mode 100644index 000000000..5a607f82f--- /dev/null+++ b/web/features/ui-layout/classic/ClassicLearningDashboard.tsx@@ -0,0 +1,194 @@+'use client'++// Classic UI snapshot — web/components/learning/LearningDashboard.tsx as it+// ships on dev (frozen at 3cbecb2). Do not evolve this copy; the modern+// learning home lives in components/learning/LearningDashboard.tsx.++import { pageGridClass } from '@/components/layout/FeaturePage'+import { useEffect, useState } from 'react'+import { BookOpen, Route } from 'lucide-react'+import { useTranslation } from 'react-i18next'+import { apiFetch, apiUrl } from '@/lib/api'+import { scopedUrl } from '@/lib/workspace-scope'+import { bookRoute } from '@/lib/learning-routes'+import {+ masterySessionRoute,+ masteryOpeningMessage,+ MASTERY_OPENING_SCOPE,+} from '@/lib/mastery-mode'+import { setPendingPrompt } from '@/lib/pending-prompt'+import {+ learningTodos,+ recentLearningActivity,+ type LearningKind,+ type LearningSources,+} from '@/lib/learning-dashboard'+import {+ LearningShell,+ LearningEmptyState,+ LearningErrorState,+ LearningSkeleton,+} from '@/components/learning/LearningShell'+import { LearningCard } from '@/components/learning/LearningCard'+import { LearningWays } from '@/components/learning/LearningWays'+import { LEARNING_SURFACES, learningSurface } from '@/components/learning/surfaces'++export function ClassicLearningDashboard() {+ const { t } = useTranslation()+ const [sources, setSources] = useState<LearningSources>({+ books: [],+ mastery: [],+ reading: [],+ watching: [],+ })+ const [failed, setFailed] = useState<LearningKind[]>([])+ const [loading, setLoading] = useState(true)+ const [reload, setReload] = useState(0)++ useEffect(() => {+ let alive = true+ let busy = false+ const refresh = async () => {+ if (busy || document.visibilityState === 'hidden') return+ busy = true+ let failures: LearningKind[] = []+ let result: LearningSources = { books: [], mastery: [], reading: [], watching: [] }+ try {+ const response = await apiFetch(apiUrl(scopedUrl('/api/dashboard/learning-index', '')), { signal: AbortSignal.timeout(20000) })+ if (!response.ok) throw new Error('Learning index unavailable')+ const payload = await response.json() as { sources: LearningSources; failed: LearningKind[] }+ result = payload.sources+ failures = payload.failed+ } catch { failures = ['books', 'mastery', 'reading', 'watching'] }+ const { books, mastery, reading, watching } = result+ if (alive) {+ // Preserve previously loaded content if a refresh fails.+ setSources(previous => ({+ books: failures.includes('books') && !books.length ? previous.books : books,+ mastery: failures.includes('mastery') && !mastery.length ? previous.mastery : mastery,+ reading: failures.includes('reading') && !reading.length ? previous.reading : reading,+ watching: failures.includes('watching') && !watching.length ? previous.watching : watching,+ }))+ setFailed(failures)+ setLoading(false)+ }+ busy = false+ }+ void refresh()+ window.addEventListener('focus', refresh)+ document.addEventListener('visibilitychange', refresh)+ const timer = window.setInterval(refresh, 30_000)+ return () => {+ alive = false+ window.clearInterval(timer)+ window.removeEventListener('focus', refresh)+ document.removeEventListener('visibilitychange', refresh)+ }+ }, [reload])++ const todos = learningTodos(sources)+ const recent = recentLearningActivity(sources)+ return (+ <LearningShell+ back={false}+ title={t('Personalized Learning')}+ subtitle={t('One tutor, your own way to learn.')}+ >+ {/* The ways in lead the page: everything below them assumes you already+ chose one. Each opens its own introduction before it commits you. */}+ <LearningWays />+ {failed.length > 0 && (+ <LearningErrorState+ message={t('Some learning activity could not be loaded: {{sources}}.', {+ sources: LEARNING_SURFACES.filter(surface => surface.kind !== "practice" && failed.includes(surface.kind))+ .map(surface => t(surface.title))+ .join(t('source list separator')),+ })}+ onRetry={() => setReload(value => value + 1)}+ />+ )}+ {loading ? (+ <LearningSkeleton count={4} />+ ) : (+ <>+ {(todos.reviews.length > 0 || todos.books.length > 0) && (+ <section aria-labelledby="learning-todos" className="mb-9">+ <h2 id="learning-todos" className="mb-3 text-[13.5px] font-semibold">+ {t('What needs your attention')}+ </h2>+ <div className={pageGridClass(2)}>+ {todos.reviews.map(topic => (+ <LearningCard+ key={`${topic.content_workspace_id}:${topic.path_id}`}+ href={scopedUrl(masterySessionRoute(topic.path_id, 'review', '', topic.content_workspace_id || ''), topic.content_workspace_id || '')}+ title={topic.name || topic.metadata.goal}+ icon={<Route size={19} />}+ subtitle={t('{{count}} reviews due', {+ count: topic.reviews.filter(review => review.due).length,+ })}+ onClick={() =>+ setPendingPrompt(+ masteryOpeningMessage('review', t, {+ dueTitles: topic.reviews+ .filter(review => review.due)+ .slice(0, 5)+ .map(review => review.knowledge_point_name),+ }),+ MASTERY_OPENING_SCOPE+ )+ }+ />+ ))}+ {todos.books.map(book => (+ <LearningCard+ key={`${book.content_workspace_id}:${book.id}`}+ href={scopedUrl(bookRoute(book.id, null, ""), book.content_workspace_id || "")}+ title={book.title}+ icon={<BookOpen size={19} />}+ subtitle={+ <>+ {book.status === 'paused' ? t('Paused') : t('Compiling')}+ {book.status === 'paused' && book.metadata.pause_reason+ ? ` · ${book.metadata.pause_reason}`+ : ''}+ </>+ }+ />+ ))}+ </div>+ </section>+ )}+ {recent.length > 0 && (+ <section aria-labelledby="learning-recent">+ <h2 id="learning-recent" className="mb-3 text-[13.5px] font-semibold">+ {t('Recent activity')}+ </h2>+ <div className={pageGridClass(2)}>+ {recent.map(item => {+ const surface = learningSurface(item.kind)+ return (+ <LearningCard+ key={item.key}+ href={item.href}+ title={item.title}+ updatedAt={item.updatedAt}+ progress={item.progress}+ subtitle={<>{t(surface.title)}{item.workspaceName ? ` · ${item.workspaceName}` : ""}</>}+ icon={<surface.icon size={19} />}+ />+ )+ })}+ </div>+ </section>+ )}+ {!recent.length && failed.length === 0 && (+ <LearningEmptyState+ title={t('Your next learning journey starts here')}+ description={t('Choose a book, a topic, a collection or a video to begin.')}+ />+ )}+ </>+ )}+ </LearningShell>+ )+}diff --git a/web/features/ui-layout/classic/ClassicSidebarShell.tsx b/web/features/ui-layout/classic/ClassicSidebarShell.tsxnew file mode 100644index 000000000..381afd238--- /dev/null+++ b/web/features/ui-layout/classic/ClassicSidebarShell.tsx@@ -0,0 +1,410 @@+"use client";++// Classic UI snapshot — web/components/sidebar/SidebarShell.tsx as it ships on+// dev (frozen at 3cbecb2). Do not evolve this copy; the modern shell lives+// in components/sidebar/SidebarShell.tsx.++import { navigateTask } from "@/lib/workspace-scope";+import Image from "next/image";+import dynamic from "next/dynamic";+import Link from "next/link";+import { usePathname, useRouter } from "next/navigation";+import {+ useCallback,+ useEffect,+ useRef,+ useState,+ type ReactNode,+ type CSSProperties,+} from "react";+import { useAppShell } from "@/context/AppShellContext";+import { PanelLeftClose, PanelLeftOpen } from "lucide-react";+import { useTranslation } from "react-i18next";+import { useChatWorkspaces } from "@/hooks/useChatWorkspaces";+import SessionList from "@/components/SessionList";+import { useSidebarDrawer } from "@/components/layout/AppShell";+import { useDevice } from "@/hooks/useDevice";+import { VersionBadge } from "@/components/sidebar/VersionBadge";+import type {+ SessionOrganizationPatch,+ SessionSummary,+} from "@/lib/session-api";+import type { MasteryTopicLabel } from "@/lib/learning-api";+import type { ReadingCollectionLabel } from "@/lib/reading-workspace-api";+import type { StudyCourse } from "@/lib/courses-api";+import { useSidebarResize } from "@/hooks/useSidebarResize";+import { SidebarHome, SidebarNav } from "@/components/sidebar/SidebarNav";+import { SECONDARY_NAV, isNavActive } from "@/components/sidebar/nav-entries";+import Tooltip from "@/shared/ui/Tooltip";+import {+ mergeManualOrder,+ readSessionOrder,+ writeSessionOrder,+} from "@/lib/sidebar-layout";++// Session data arrives after mount; defer its organization UI with it so+// every workspace route does not download it as part of the initial shell.+const OrganizedSessionList = dynamic(+ () => import("@/components/courses/OrganizedSessionList"),+ {+ ssr: false,+ loading: () => (+ <div aria-busy="true" className="space-y-1.5 px-2 py-1">+ {[1, 2, 3].map((i) => (+ <div+ key={i}+ className="h-4 w-3/4 animate-pulse rounded bg-muted/40"+ />+ ))}+ </div>+ ),+ },+);++export interface SidebarShellProps {+ sessions?: SessionSummary[];+ activeSessionId?: string | null;+ /** Conversations the caller is streaming right now; they sort to the top. */+ liveSessionIds?: ReadonlySet<string>;+ loadingSessions?: boolean;+ showSessions?: boolean;+ /** Clicking the Chat nav item resets to a fresh session via this handler. */+ onNewChat?: () => void;+ onNewWorkspaceChat?: (workspaceId: string) => void;+ workspaceRefreshToken?: number;+ onSelectSession?: (sessionId: string) => void | Promise<void>;+ onRenameSession?: (sessionId: string, title: string) => void | Promise<void>;+ onDeleteSession?: (sessionId: string) => void | Promise<void>;+ courses?: StudyCourse[];+ /** Topic labels for grouping mastery study conversations under their path. */+ masteryTopics?: MasteryTopicLabel[];+ /** Collection labels for grouping reading conversations under their shelf. */+ readingCollections?: ReadingCollectionLabel[];+ onOrganizeSession?: (+ sessionId: string,+ patch: SessionOrganizationPatch,+ ) => void | Promise<void>;+ /**+ * Footer content rendered below the nav. Pass a render function to receive+ * the current ``collapsed`` state so footer items (e.g. Admin / Sign out) can+ * switch to their icon-only variant when the rail is collapsed.+ */+ footerSlot?: ReactNode | ((collapsed: boolean) => ReactNode);+}++export function ClassicSidebarShell({+ sessions = [],+ activeSessionId = null,+ liveSessionIds,+ loadingSessions = false,+ showSessions = false,+ onNewChat,+ onNewWorkspaceChat,+ onSelectSession,+ onRenameSession,+ onDeleteSession,+ masteryTopics = [],+ readingCollections = [],+ onOrganizeSession,+ footerSlot,+}: SidebarShellProps) {+ const pathname = usePathname();+ const router = useRouter();+ const { t } = useTranslation();+ const { sidebarCollapsed, setSidebarCollapsed: setCollapsed } = useAppShell();+ const { isMobile } = useDevice();+ const drawer = useSidebarDrawer();+ const recentsScrollRef = useRef<HTMLDivElement>(null);+ // One load for the whole column: the workspace groups head their own+ // section with it and the row menus offer it as a move destination.+ const { workspaces } = useChatWorkspaces();++ // Inside the mobile drawer the icon-only rail is pointless — the panel is+ // already hidden when you don't want it, so it always opens fully expanded+ // regardless of the persisted desktop preference.+ const collapsed = sidebarCollapsed && !isMobile;+ const resize = useSidebarResize(collapsed || isMobile);++ /** Dismiss the drawer on nav clicks that actually navigate in-place. */+ const closeDrawerOnNav = (event: React.MouseEvent) => {+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.button === 1)+ return;+ drawer?.close();+ };++ const renderedFooter =+ typeof footerSlot === "function" ? footerSlot(collapsed) : footerSlot;+ // The order the learner dragged the history region into — conversation ids+ // and group ids in one list, since the two are peers there. Like the+ // collapse preference above it is per-machine view state, hydrated after+ // mount.+ const [sessionOrder, setSessionOrder] = useState<string[]>([]);+ const sessionOrderRef = useRef<string[]>([]);++ useEffect(() => {+ const stored = readSessionOrder();+ sessionOrderRef.current = stored;+ // eslint-disable-next-line react-hooks/set-state-in-effect+ setSessionOrder(stored);+ }, []);++ // A drag only ever speaks for the entries on screen, so it is merged into+ // the stored order rather than replacing it.+ const handleReorderSessions = useCallback((nextIds: string[]) => {+ const merged = mergeManualOrder(sessionOrderRef.current, nextIds);+ sessionOrderRef.current = merged;+ setSessionOrder(merged);+ writeSessionOrder(merged);+ }, []);++ const handleResetSessionOrder = useCallback(() => {+ sessionOrderRef.current = [];+ setSessionOrder([]);+ writeSessionOrder([]);+ }, []);++ const handleHomeClick = (event: React.MouseEvent) => {+ // Always reset to a fresh session (mirrors the old "New Chat" affordance);+ // let modifier-clicks fall through to default Link behavior so middle-click+ // open-in-new-tab still works.+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.button === 1)+ return;+ event.preventDefault();+ drawer?.close();+ onNewChat?.();+ navigateTask("/chat", router.push);+ };++ // Everything the learner has, minus the archived and minus the tutor threads+ // that render nested under the conversation that spawned them.+ //+ // Keep the complete index here. OrganizedSessionList limits the initial+ // rendering and exposes older conversations through Show more.+ const visibleSessions = sessions.filter(+ (session) =>+ !session.preferences?.archived && !session.preferences?.parent_session_id,+ );++ /* ---- Collapsed state ---- */+ if (collapsed) {+ return (+ <aside className="group/sb relative flex h-dvh w-[60px] shrink-0 flex-col items-center bg-[var(--secondary)] py-3 transition-all duration-200">+ {/* Header: logo + collapse toggle (toggle replaces logo on hover) */}+ <div className="relative mb-2 flex h-9 w-9 items-center justify-center">+ <Link+ href="/"+ prefetch={false}+ aria-label="DeepTutor"+ className="flex items-center justify-center transition-opacity duration-150 group-hover/sb:opacity-0"+ >+ <Image+ src="/logo.png"+ alt="DeepTutor"+ width={22}+ height={22}+ className="h-[22px] w-[22px] rounded-md"+ />+ </Link>+ <button+ onClick={() => setCollapsed(false)}+ className="absolute inset-0 flex items-center justify-center rounded-lg text-[var(--muted-foreground)] opacity-0 transition-all duration-150 hover:bg-background/60 hover:text-[var(--foreground)] group-hover/sb:opacity-100"+ aria-label={t("Expand sidebar")}+ >+ <PanelLeftOpen size={16} />+ </button>+ </div>++ <SidebarHome collapsed onHomeClick={handleHomeClick} />+ <div className="min-h-0 w-full flex-1 overflow-y-auto overscroll-contain">+ <SidebarNav+ collapsed+ onHomeClick={handleHomeClick}+ onNavigate={closeDrawerOnNav}+ />+ </div>++ {/* Secondary nav + footer */}+ <div className="flex w-full shrink-0 flex-col items-center gap-1 px-1.5">+ <div className="my-1 h-px w-7 bg-border/40" />+ {SECONDARY_NAV.map((item) => {+ const active = isNavActive(pathname, item.href);+ return (+ <Tooltip key={item.href} label={t(item.label) as string} side="right">+ <Link+ href={item.href}+ prefetch={false}+ aria-label={t(item.label) as string}+ className={`relative flex h-9 w-9 items-center justify-center rounded-xl transition-all duration-150 ${+ active+ ? "bg-[var(--accent)] text-[var(--foreground)] shadow-sm"+ : "text-foreground/85 hover:bg-background/60 hover:text-[var(--foreground)]"+ }`}+ >+ <item.icon size={18} strokeWidth={active ? 2 : 1.6} />+ </Link>+ </Tooltip>+ );+ })}+ {renderedFooter}+ <VersionBadge onNavigate={closeDrawerOnNav} />+ </div>+ </aside>+ );+ }++ /* ---- Expanded state ---- */+ return (+ <aside+ style={{ "--sidebar-width": `${resize.width}px` } as CSSProperties}+ className="relative flex h-dvh w-[var(--sidebar-width)] max-w-[45vw] shrink-0 flex-col bg-[var(--secondary)] max-md:w-[220px] max-md:max-w-[85vw]"+ >+ {/* Header: logo + collapse toggle */}+ <div className="flex h-[52px] shrink-0 items-center justify-between px-4">+ <Link href="/" prefetch={false} className="group flex items-center gap-1.5">+ <Image+ src="/logo.png"+ alt="DeepTutor"+ width={22}+ height={22}+ className="h-[22px] w-[22px] transition-transform duration-200 group-hover:scale-105"+ />+ <Image+ src="/banner.png"+ alt="DeepTutor"+ width={897}+ height={236}+ priority+ className="h-[22px] w-auto transition-transform duration-200 group-hover:scale-105"+ />+ </Link>+ {/* The rail is a desktop affordance; in the drawer the scrim and the+ top-bar toggle already own "make this go away". */}+ <button+ onClick={() => setCollapsed(true)}+ className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)] max-md:hidden"+ aria-label={t("Collapse sidebar")}+ >+ <PanelLeftClose size={15} />+ </button>+ </div>++ <SidebarHome onHomeClick={handleHomeClick} />++ {/* Modules and conversations share one scroll region below Home. */}+ <div+ ref={recentsScrollRef}+ className="min-h-0 flex-1 overflow-y-auto overscroll-contain pb-2"+ >+ <SidebarNav+ scrollRef={recentsScrollRef}+ collapsed={false}+ onHomeClick={handleHomeClick}+ onNavigate={closeDrawerOnNav}+ />++ {/* Conversation history follows the module entries in the same scroller. */}+ {showSessions &&+ onSelectSession &&+ onRenameSession &&+ onDeleteSession ? (+ <section className="mt-3 px-2 pt-0.5">+ {!onOrganizeSession && <div className="mb-2 px-2 text-xs text-[var(--muted-foreground)]">{t("Recent")}</div>}+ {loadingSessions ? (+ <SessionList+ sessions={[]}+ activeSessionId={activeSessionId}+ loading+ onSelect={onSelectSession}+ onRename={onRenameSession}+ onDelete={onDeleteSession}+ compact+ />+ ) : onOrganizeSession ? (+ <OrganizedSessionList+ sessions={visibleSessions}+ // Course grouping temporarily hidden pending further product+ // work; passing [] keeps the list flat without touching the+ // course data callers still fetch.+ courses={[]}+ workspaces={workspaces}+ groupWorkspaces+ onNewWorkspaceChat={onNewWorkspaceChat}+ masteryTopics={masteryTopics}+ readingCollections={readingCollections}+ activeSessionId={activeSessionId}+ liveSessionIds={liveSessionIds}+ manualOrder={sessionOrder}+ onReorder={handleReorderSessions}+ onResetOrder={handleResetSessionOrder}+ scrollRef={recentsScrollRef}+ onSelect={(sessionId) => {+ drawer?.close();+ return onSelectSession(sessionId);+ }}+ onRename={onRenameSession}+ onDelete={onDeleteSession}+ onOrganize={onOrganizeSession}+ />+ ) : (+ <SessionList+ sessions={visibleSessions}+ activeSessionId={activeSessionId}+ onSelect={(sessionId) => {+ drawer?.close();+ return onSelectSession(sessionId);+ }}+ onRename={onRenameSession}+ onDelete={onDeleteSession}+ compact+ />+ )}+ </section>+ ) : null}+ </div>++ {/* Secondary nav + footer */}+ <div className="shrink-0 border-t border-border/40 px-2 py-2">+ {renderedFooter}+ <div className="flex items-center gap-1">+ {SECONDARY_NAV.map((item) => {+ const active = isNavActive(pathname, item.href);+ return (+ <Link+ key={item.href}+ href={item.href}+ prefetch={false}+ onClick={closeDrawerOnNav}+ className={`flex min-h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2.5 py-1.5 text-[13px] transition-colors ${+ active+ ? "bg-[var(--accent)] font-medium text-[var(--foreground)]"+ : "text-foreground/85 hover:bg-background/60 hover:text-[var(--foreground)]"+ }`}+ >+ <item.icon size={15} strokeWidth={active ? 1.9 : 1.6} />+ <span>{t(item.label)}</span>+ </Link>+ );+ })}+ <VersionBadge onNavigate={closeDrawerOnNav} />+ </div>+ </div>+ {!isMobile && (+ <div+ role="separator"+ aria-label={t("Resize sidebar")}+ aria-orientation="vertical"+ aria-valuemin={resize.min}+ aria-valuemax={resize.max}+ aria-valuenow={resize.width}+ tabIndex={0}+ {...resize.handleProps}+ className="group/resize absolute inset-y-0 -right-1 z-30 w-2 touch-none cursor-col-resize outline-none max-md:hidden"+ >+ <div+ className={`mx-auto h-full w-0.5 transition-colors group-hover/resize:bg-[var(--ring)] group-focus-visible/resize:bg-[var(--ring)] ${resize.resizing ? "bg-[var(--ring)]" : "bg-transparent"}`}+ />+ </div>+ )}+ </aside>+ );+}diff --git a/web/features/ui-layout/classic/classic.css b/web/features/ui-layout/classic/classic.cssnew file mode 100644index 000000000..f61549994--- /dev/null+++ b/web/features/ui-layout/classic/classic.css@@ -0,0 +1,4 @@+/* Classic UI tokens: the values shared components had on dev (3cbecb2). */+:root[data-ui-layout="classic"] {+ --dt-page-title-font: theme("fontFamily.serif");+}diff --git a/web/features/ui-layout/classic/index.ts b/web/features/ui-layout/classic/index.tsnew file mode 100644index 000000000..093a1b4d8--- /dev/null+++ b/web/features/ui-layout/classic/index.ts@@ -0,0 +1,15 @@+import dynamic from "next/dynamic";+import type { UiLayoutSlots } from "../types";+import { ClassicSidebarShell } from "./ClassicSidebarShell";++/**+ * The UI as it ships on dev, frozen. Every file in this folder is a snapshot;+ * fixes that must reach classic users go into the shared code it renders.+ */+export const classicSlots: UiLayoutSlots = {+ SidebarShell: ClassicSidebarShell,+ PageBar: null,+ LearningHome: dynamic(() =>+ import("./ClassicLearningDashboard").then((module) => module.ClassicLearningDashboard),+ ),+};diff --git a/web/features/ui-layout/classic/tokens.ts b/web/features/ui-layout/classic/tokens.tsnew file mode 100644index 000000000..30d2ed379--- /dev/null+++ b/web/features/ui-layout/classic/tokens.ts@@ -0,0 +1,10 @@+import type { UiLayoutTokens } from "../types";++export const classicTokens: UiLayoutTokens = {+ labels: {+ space: "Learning Space",+ learning: "Personalized Learning",+ defaultCapability: "Chat",+ starterHeading: "",+ },+};diff --git a/web/features/ui-layout/modern/index.ts b/web/features/ui-layout/modern/index.tsnew file mode 100644index 000000000..1a18f4df7--- /dev/null+++ b/web/features/ui-layout/modern/index.ts@@ -0,0 +1,13 @@+import dynamic from "next/dynamic";+import { PageBar } from "@/components/sidebar/PageBar";+import { SidebarShell } from "@/components/sidebar/SidebarShell";+import type { UiLayoutSlots } from "../types";++/** The dt-exp redesign. Its components live where they always have. */+export const modernSlots: UiLayoutSlots = {+ SidebarShell,+ PageBar,+ LearningHome: dynamic(() =>+ import("@/components/learning/LearningDashboard").then((module) => module.LearningDashboard),+ ),+};diff --git a/web/features/ui-layout/modern/modern.css b/web/features/ui-layout/modern/modern.cssnew file mode 100644index 000000000..7c7d2b00a--- /dev/null+++ b/web/features/ui-layout/modern/modern.css@@ -0,0 +1,278 @@+/* Modern UI tokens and styles. Shared components read the tokens;+ everything else here styles modern-only components. */++/* ---- Foundation ------------------------------------------------------+ One ink drives every neutral: text, borders and hover fills are that ink+ at fixed strengths, so surfaces stay quiet on white and on the grey+ sidebar alike. Shadows are layered (hairline + soft lift), never a single+ heavy drop. */+:root[data-ui-layout="modern"] {+ --dt-page-title-font: theme("fontFamily.sans");+ --dt-ink: 55 53 47;+ --dt-shadow-xs: 0 0 0 1px rgb(15 15 15 / 0.04), 0 1px 2px rgb(15 15 15 / 0.06);+ --dt-shadow-sm: 0 0 0 1px rgb(15 15 15 / 0.05), 0 2px 4px rgb(15 15 15 / 0.06), 0 6px 16px -6px rgb(15 15 15 / 0.1);+ --dt-shadow-md: 0 0 0 1px rgb(15 15 15 / 0.05), 0 3px 6px rgb(15 15 15 / 0.08), 0 9px 24px rgb(15 15 15 / 0.14);+ --dt-radius-sm: 6px;+ --dt-radius-md: 8px;+ --dt-radius-lg: 12px;+ --dt-ease: cubic-bezier(0.2, 0, 0, 1);+}+:root[data-ui-layout="modern"].dark,+:root[data-ui-layout="modern"].theme-glass {+ --dt-ink: 255 255 255;+ --dt-shadow-xs: 0 0 0 1px rgb(255 255 255 / 0.06), 0 1px 2px rgb(0 0 0 / 0.3);+ --dt-shadow-sm: 0 0 0 1px rgb(255 255 255 / 0.07), 0 2px 4px rgb(0 0 0 / 0.3), 0 6px 16px -6px rgb(0 0 0 / 0.4);+ --dt-shadow-md: 0 0 0 1px rgb(255 255 255 / 0.08), 0 3px 6px rgb(0 0 0 / 0.3), 0 9px 24px rgb(0 0 0 / 0.45);+}++/* The default light theme turns warm: Notion-like warm grey canvas and ink.+ The brand blue stays, kept for actions and links. */+:root[data-ui-layout="modern"].theme-snow {+ --foreground: #37352f;+ --card-foreground: #37352f;+ --popover-foreground: #37352f;+ --secondary-foreground: #37352f;+ --accent-foreground: #37352f;+ --muted-foreground: #787774;+ --secondary: #f8f8f7;+ --muted: #f1f1ef;+ --accent: rgb(55 53 47 / 0.06);+ --border: rgb(55 53 47 / 0.09);+ --input: rgb(55 53 47 / 0.16);+ --shadow-raised: var(--dt-shadow-md);+}++/* ---- Pages -----------------------------------------------------------+ Titles are bold and tight; every FeaturePage gets more air above it. */+:root[data-ui-layout="modern"] .dt-page-title {+ font-weight: 700;+ letter-spacing: -0.025em;+ line-height: 1.2;+}+@container feature-page (min-width: 640px) {+ :root[data-ui-layout="modern"] .dt-page-title { font-size: 32px; }+}+/* The page's own icon, Notion-style, sitting above its title. */+:root[data-ui-layout="modern"] .dt-page-icon {+ display: flex; align-items: center; justify-content: center;+ width: 52px; height: 52px; margin-bottom: 18px;+ border-radius: 14px; background: var(--muted); color: rgb(var(--dt-ink) / 0.72);+ box-shadow: inset 0 0 0 1px rgb(var(--dt-ink) / 0.04);+}+:root[data-ui-layout="modern"] [data-page-header] > div > p { margin-top: 8px; font-size: 14px; line-height: 1.6; }+:root[data-ui-layout="modern"] [data-feature-page] > .dt-page-container { padding-top: 48px; }+@media (min-width: 1024px) {+ :root[data-ui-layout="modern"] [data-feature-page] > .dt-page-container { padding-top: 64px; }+}++/* The same application, with four contextual navigation shelves. */+.dt-product-sidebar {+ container-type: inline-size;+ border-right: 1px solid var(--border);+ --dt-nav-row: 32px;+ --dt-nav-pad-x: 10px;+ --dt-nav-gap: 8px;+ --dt-nav-radius: 7px;+ --dt-nav-text: 13px;+ --dt-nav-list-text: 12.5px;+ --dt-nav-label: 12px;+ --dt-nav-ink: color-mix(in srgb, var(--foreground) 82%, transparent);+}+.dt-product-sidebar .dt-category-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 2px 8px 8px; flex-shrink: 0; }+.dt-category-bar [role="tablist"] { display: flex; flex: 1; align-items: center; min-width: 0; gap: 1px; }+.dt-category-bar [role="tab"] { position: relative; display: flex; align-items: center; justify-content: center; flex: 1; min-width: 30px; height: var(--dt-nav-row); gap: 6px; padding: 0 8px; color: var(--muted-foreground); border-radius: var(--dt-nav-radius); transition: color 140ms, background-color 140ms; }+.dt-category-bar [role="tab"] > svg, .dt-category-bar [role="tab"] > span:not(.dt-category-pill) { position: relative; z-index: 1; flex-shrink: 0; }+.dt-category-bar [role="tab"] > span:not(.dt-category-pill) { display: none; font-size: var(--dt-nav-list-text); font-weight: 500; white-space: nowrap; }+.dt-category-bar [role="tab"].is-active { flex: 1.9; color: var(--foreground); }+.dt-category-bar [role="tab"].is-active > span:not(.dt-category-pill) { display: inline; }+.dt-category-pill { position: absolute; inset: 0; border-radius: var(--dt-nav-radius); background: var(--accent); }+.dt-category-bar [role="tab"]:not(.is-active):hover, .dt-nav-icon:hover { background: var(--accent); color: var(--foreground); }+.dt-nav-icon { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--dt-nav-radius); color: var(--muted-foreground); transition: background-color 140ms, color 140ms; }+.dt-category-bar button:focus-visible, .dt-navigation-row:focus-visible, .dt-nav-icon:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }+.dt-product-sidebar .dt-category-bar.is-collapsed { flex-direction: column; padding: 4px; }+.dt-category-bar.is-collapsed [role="tablist"] { flex-direction: column; gap: 5px; }+.dt-category-bar.is-collapsed [role="tab"] { width: 36px; height: 36px; flex: none; }+.dt-category-bar.is-collapsed [role="tab"] > span:not(.dt-category-pill) { display: none; }+.dt-category-content { padding: 0 8px 16px; }+.dt-navigation-section { margin-top: 14px; }+.dt-navigation-heading, .dt-product-sidebar .dt-projects-heading { display: flex; justify-content: space-between; align-items: center; min-height: 26px; margin-bottom: 2px; padding: 0 var(--dt-nav-pad-x); font-size: var(--dt-nav-label); font-weight: 500; color: var(--muted-foreground); }+.dt-navigation-row { display: flex; align-items: center; gap: var(--dt-nav-gap); min-height: var(--dt-nav-row); padding: 6px var(--dt-nav-pad-x); border-radius: var(--dt-nav-radius); text-align: left; color: var(--dt-nav-ink); font-size: var(--dt-nav-text); transition: background-color 130ms, color 130ms; }+/* OrganizedSessionList insets its rows 6px; 4px more lands its icons in the+ same column as the navigation rows above (8 + 4 + 6 = row padding 10 + 8). */+.dt-session-section { padding: 0 4px; }+.dt-product-sidebar .dt-session-section .dt-projects-heading { padding: 0 6px; }+.dt-navigation-row > svg { flex-shrink: 0; opacity: .8; }+.dt-navigation-row:hover, .dt-navigation-row.is-active { background: var(--accent); color: var(--foreground); }+.dt-navigation-row.is-active { font-weight: 500; }+.dt-navigation-empty { padding: 4px var(--dt-nav-pad-x); font-size: 11.5px; line-height: 1.7; color: var(--muted-foreground); }+.dt-category-content-fixed { display: flex; flex-direction: column; height: 100%; min-height: 0; padding-bottom: 0; }+.dt-category-content-fixed > .dt-navigation-section { flex-shrink: 0; margin-top: 4px; }+.dt-partner-navigation { display: flex; flex: 1; flex-direction: column; min-height: 0; gap: 14px; padding-top: 10px; }+.dt-partner-preview { flex-shrink: 0; }+.dt-partner-navigation .dt-navigation-heading { flex-shrink: 0; }+.dt-navigation-heading h2 { display: flex; align-items: center; min-width: 0; gap: 7px; font: inherit; }+.dt-navigation-count { font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; opacity: .6; }+.dt-navigation-actions { display: flex; align-items: center; gap: 2px; margin-right: -6px; }+.dt-navigation-actions .dt-nav-icon { width: 24px; height: 24px; border-radius: 6px; }+.dt-navigation-view-all { display: inline-flex; align-items: center; gap: 1px; height: 24px; padding: 0 4px 0 6px; border-radius: 6px; font-size: 11.5px; font-weight: 400; white-space: nowrap; transition: background-color 140ms, color 140ms; }+.dt-navigation-view-all:hover { background: var(--accent); color: var(--foreground); }+/* Roster: one compact strip that slides sideways; PartnerRoster packs what+ continues past an edge. The selected partner is marked on its avatar. */+.dt-partner-roster {+ /* The offsetParent its items measure against. */+ position: relative;+ display: flex;+ overflow-x: auto;+ overscroll-behavior-x: contain;+ scroll-snap-type: x proximity;+ scroll-padding-inline: 52px;+ /* Set by PartnerRoster: fades only the sides that have more beyond them. */+ mask-image: linear-gradient(to right, transparent, #000 var(--dt-roster-fade-l, 0px), #000 calc(100% - var(--dt-roster-fade-r, 0px)), transparent);+ scrollbar-width: none;+ padding: 3px 0 2px;+ cursor: grab;+ user-select: none;+}+.dt-partner-roster::-webkit-scrollbar { display: none; }+.dt-partner-roster.is-dragging { cursor: grabbing; scroll-snap-type: none; }+.dt-partner-roster-item { position: relative; display: flex; flex: 0 0 46px; align-items: center; flex-direction: column; gap: 5px; padding: 4px 1px 2px; min-width: 0; scroll-snap-align: start; transform-origin: 50% 20px; will-change: transform, opacity; -webkit-user-drag: none; }+.dt-partner-roster-item > :first-child { transition: box-shadow 160ms; }+.dt-partner-roster-item:hover > :first-child { box-shadow: 0 0 0 2px var(--secondary), 0 0 0 3.5px color-mix(in srgb, var(--foreground) 22%, transparent); }+.dt-partner-roster-item[aria-current="page"] > :first-child { box-shadow: 0 0 0 2px var(--secondary), 0 0 0 3.5px var(--foreground); }+.dt-partner-roster-item[aria-current="page"] > span:last-child { color: var(--foreground); font-weight: 500; }+.dt-partner-roster-item:hover > span:last-child { color: var(--foreground); }+.dt-partner-roster-item > span:last-child { font-size: 11px; line-height: 15px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; max-width: 100%; color: var(--muted-foreground); opacity: var(--dt-roster-label, 1); transition: color 140ms; }+.dt-partner-roster-item:focus-visible { outline: none; }+.dt-partner-roster-item:focus-visible > :first-child { box-shadow: 0 0 0 2px var(--secondary), 0 0 0 4px var(--ring); }+.dt-partner-sessions { display: flex; flex: 1; flex-direction: column; min-height: 0; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }+/* Keep the tooltip's visually hidden text inside this scroll container too. */+.dt-partner-session-list { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 0 8px; }+.dt-partner-session-list .dt-navigation-row, .dt-learning-record-list .dt-navigation-row { font-size: var(--dt-nav-list-text); }+/* Lists that scroll above the footer fade out instead of being cut by it. */+.dt-partner-session-list, .dt-learning-record-list { mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent); }+.dt-partner-session-list:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 7px; }+.dt-navigation-view-all:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }+@container (max-width: 240px) { .dt-category-bar [role="tab"] { padding: 0 5px; gap: 4px; } .dt-category-bar [role="tab"] > span:not(.dt-category-pill) { font-size: 12px; } }++@media (prefers-reduced-motion: reduce) { .dt-category-content { animation: none; } .dt-product-sidebar * { transition-duration: 0ms !important; } }++.dt-category-panel:not([hidden]) { display: flex; flex: 1; min-height: 0; flex-direction: column; }+.dt-learning-navigation { display: flex; flex: 1; flex-direction: column; min-height: 0; padding-top: 10px; }+.dt-learning-overview { display: flex; align-items: center; flex-shrink: 0; border-radius: var(--dt-nav-radius); padding-right: 4px; }+.dt-learning-overview:hover, .dt-learning-overview.is-active { background: var(--accent); }+.dt-learning-overview > a { display: flex; align-items: center; flex: 1; min-width: 0; min-height: var(--dt-nav-row); gap: var(--dt-nav-gap); padding: 6px var(--dt-nav-pad-x); font-size: var(--dt-nav-text); font-weight: 500; }+.dt-learning-overview > a:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 7px; }+.dt-learning-record-toolbar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; padding: 12px 5px 4px; }+.dt-learning-record-toolbar select { min-width: 0; max-width: 80%; padding: 4px; background: transparent; color: var(--muted-foreground); font-size: 11.5px; border-radius: 6px; cursor: pointer; }+.dt-learning-record-toolbar select:hover { background: var(--accent); }+.dt-learning-record-toolbar select:focus-visible { outline: 2px solid var(--ring); }+.dt-learning-record-toolbar option { background: var(--background); color: var(--foreground); }+.dt-learning-search { flex-shrink: 0; margin: 0 4px 8px; width: calc(100% - 8px); }+.dt-learning-record-list { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }+.dt-learning-record-list:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 7px; }+.dt-learning-time-group { margin-bottom: 14px; }+.dt-learning-time-group > h2 { padding: 8px var(--dt-nav-pad-x) 4px; font-size: var(--dt-nav-label); font-weight: 500; color: var(--muted-foreground); }+.dt-record-time { flex-shrink: 0; max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 400; color: var(--muted-foreground); opacity: .75; }++/* ---- Sidebar header: the workspace menu ------------------------------ */+.dt-sidebar-header { display: flex; align-items: center; gap: 4px; height: 52px; padding: 0 8px; flex-shrink: 0; }+.dt-sidebar-header > .dt-nav-icon { opacity: 0; transition: opacity 140ms, background-color 140ms, color 140ms; }+.dt-product-sidebar:hover .dt-sidebar-header > .dt-nav-icon,+.dt-sidebar-header > .dt-nav-icon:focus-visible { opacity: 1; }+.dt-workspace-menu { position: relative; flex: 1; min-width: 0; }+.dt-workspace-trigger { display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 8px; border-radius: var(--dt-radius-md); font-size: 13.5px; font-weight: 600; color: var(--foreground); transition: background-color 140ms; }+.dt-workspace-trigger:hover, .dt-workspace-trigger[aria-expanded="true"] { background: var(--accent); }+.dt-workspace-trigger:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }+.dt-workspace-glyph { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 6px; color: #fff; font-weight: 600; line-height: 1; }+.dt-workspace-glyph.is-general { padding: 1px; background: transparent; }+.dt-popover {+ position: absolute; z-index: 60; top: calc(100% + 4px); left: 0;+ padding: 6px; border-radius: var(--dt-radius-lg); background: var(--popover); color: var(--popover-foreground);+ box-shadow: var(--dt-shadow-md); transform-origin: top left; animation: dt-pop-in 140ms var(--dt-ease);+}+.dt-workspace-panel { width: max(100%, 260px); }+.dt-menu-label { padding: 6px 8px 4px; font-size: 11.5px; font-weight: 500; color: var(--muted-foreground); }+.dt-menu-item, .dt-menu-slot :is(a, button) {+ display: flex; align-items: center; gap: 9px; width: 100%; min-height: 32px; padding: 5px 8px;+ border-radius: var(--dt-radius-sm); font-size: 13px; color: var(--foreground); text-align: left; transition: background-color 120ms;+}+.dt-menu-item:hover, .dt-menu-item:focus-visible, .dt-menu-slot :is(a, button):hover { background: var(--accent); outline: none; }+.dt-menu-item.is-quiet { color: var(--muted-foreground); }+.dt-menu-item > svg { flex-shrink: 0; opacity: .8; }+.dt-menu-slot :is(a, button) { color: var(--foreground) !important; background: transparent; }+.dt-menu-divider { height: 1px; margin: 6px 4px; background: var(--border); }+.dt-menu-footer { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 0 8px; font-size: 11.5px; color: var(--muted-foreground); }+@keyframes dt-pop-in { from { opacity: 0; transform: scale(.97) translateY(-2px); } to { opacity: 1; transform: none; } }++/* ---- Sidebar footer: one generous new-conversation button ------------ */+.dt-sidebar-footer { flex-shrink: 0; padding: 8px 10px 12px; }+.dt-new-conversation {+ display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 40px;+ border-radius: 999px; background: var(--background); color: var(--foreground);+ font-size: 13.5px; font-weight: 500; box-shadow: var(--dt-shadow-sm);+ transition: box-shadow 160ms var(--dt-ease), transform 160ms var(--dt-ease), background-color 160ms;+}+.dt-new-conversation > svg { flex-shrink: 0; opacity: .75; }+.dt-new-conversation:hover { box-shadow: var(--dt-shadow-md); }+.dt-new-conversation:active { transform: scale(.985); }+.dt-new-conversation:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }++/* ---- ⌘K command palette --------------------------------------------- */+.dt-palette-backdrop { position: fixed; inset: 0; z-index: 900; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgb(15 15 15 / 0.32); animation: dt-fade-in 120ms ease-out; }+.dt-palette {+ display: flex; flex-direction: column; width: min(640px, 100%); max-height: min(560px, 76vh); overflow: hidden;+ border-radius: 14px; background: var(--popover); color: var(--popover-foreground); box-shadow: var(--dt-shadow-md);+ animation: dt-pop-in 160ms var(--dt-ease);+}+.dt-palette-field { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }+.dt-palette-field input { flex: 1; min-width: 0; background: transparent; font-size: 15px; outline: none; color: var(--foreground); }+.dt-palette-field input::placeholder { color: var(--muted-foreground); }+.dt-palette-results { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }+.dt-palette-group { padding: 10px 10px 4px; font-size: 11.5px; font-weight: 500; color: var(--muted-foreground); }+.dt-palette-item { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: var(--dt-radius-md); font-size: 13.5px; cursor: pointer; }+.dt-palette-item[aria-selected="true"] { background: var(--accent); }+.dt-palette-icon { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 20px; color: var(--muted-foreground); }+.dt-palette-detail { flex-shrink: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted-foreground); }+.dt-palette-empty { padding: 28px 12px; text-align: center; font-size: 13px; color: var(--muted-foreground); }+.dt-palette-hints { display: flex; gap: 16px; height: 36px; align-items: center; padding: 0 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted-foreground); flex-shrink: 0; }+.dt-palette-hints kbd { display: inline-flex; min-width: 18px; height: 18px; align-items: center; justify-content: center; margin-right: 2px; padding: 0 4px; border-radius: 4px; background: var(--muted); font-family: inherit; font-size: 10.5px; }+@keyframes dt-fade-in { from { opacity: 0; } to { opacity: 1; } }+@media (prefers-reduced-motion: reduce) { .dt-palette, .dt-palette-backdrop, .dt-popover { animation: none; } }++/* ---- Chat home ----------------------------------------------------------+ The greeting stays as classic has it — the mark beside a serif line, as+ Claude does — warm against the sans UI. The composer and the suggestions+ join the modern surfaces. */+:root[data-ui-layout="modern"] .dt-composer-surface {+ border-radius: 20px; border-color: transparent;+ box-shadow: 0 0 0 1px rgb(var(--dt-ink) / 0.09), 0 4px 12px -4px rgb(15 15 15 / 0.06), 0 18px 40px -16px rgb(15 15 15 / 0.12);+ transition: box-shadow 200ms var(--dt-ease);+}+:root[data-ui-layout="modern"] .dt-composer-surface:focus-within {+ box-shadow: 0 0 0 1px rgb(var(--dt-ink) / 0.16), 0 4px 12px -4px rgb(15 15 15 / 0.08), 0 22px 48px -16px rgb(15 15 15 / 0.16);+}+.dt-starter-heading { margin: 4px 0 6px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); }+:root[data-ui-layout="modern"] .dt-starter-line {+ font-family: theme("fontFamily.sans"); font-size: 14px; letter-spacing: 0; color: rgb(var(--dt-ink) / 0.8);+}+:root[data-ui-layout="modern"] .dt-starter-line:hover { color: var(--foreground); }+:root[data-ui-layout="modern"] .dt-chat-title { font-family: theme("fontFamily.sans"); font-size: 15px; letter-spacing: -0.01em; }++/* ---- Page bar: where this page lives, and whose it is ----------------- */+.dt-page-bar { display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 10px; flex-shrink: 0; }+@media (max-width: 767px) { .dt-page-bar { display: none; } }+.dt-crumb, .dt-scope-chip {+ display: inline-flex; align-items: center; gap: 7px; height: 28px; max-width: 100%; padding: 0 8px;+ border-radius: var(--dt-radius-sm); font-size: 13.5px; color: var(--foreground); transition: background-color 120ms;+}+.dt-scope-chip { gap: 6px; font-size: 13px; color: var(--muted-foreground); }+.dt-crumb:hover, .dt-crumb[aria-expanded="true"], .dt-scope-chip:hover, .dt-scope-chip[aria-expanded="true"] { background: var(--accent); }+.dt-crumb:focus-visible, .dt-scope-chip:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }+.dt-crumb-panel { width: 248px; max-height: min(420px, 70vh); overflow-y: auto; }+.dt-menu-item[aria-current="page"] { background: color-mix(in srgb, var(--primary) 9%, transparent); }+/* The bar replaces each section's "← back" link; detail pages without the+ bar keep theirs. */+main:has(.dt-page-bar) .dt-section-back { display: none; }+/* With the bar above, pages need less air of their own. */+main:has(.dt-page-bar) [data-feature-page] > .dt-page-container { padding-top: 28px; }+@media (min-width: 1024px) { main:has(.dt-page-bar) [data-feature-page] > .dt-page-container { padding-top: 40px; } }diff --git a/web/features/ui-layout/modern/tokens.ts b/web/features/ui-layout/modern/tokens.tsnew file mode 100644index 000000000..0cdb25e6d--- /dev/null+++ b/web/features/ui-layout/modern/tokens.ts@@ -0,0 +1,10 @@+import type { UiLayoutTokens } from "../types";++export const modernTokens: UiLayoutTokens = {+ labels: {+ space: "navigation.resources",+ learning: "navigation.learning",+ defaultCapability: "Auto",+ starterHeading: "navigation.ideasForYou",+ },+};diff --git a/web/features/ui-layout/slots.tsx b/web/features/ui-layout/slots.tsxnew file mode 100644index 000000000..a413ece8b--- /dev/null+++ b/web/features/ui-layout/slots.tsx@@ -0,0 +1,33 @@+"use client";++import { useUiLayout } from "@/hooks/useUiLayout";+import type { UiLayout } from "@/lib/ui-layout";+import { classicSlots } from "./classic";+import { modernSlots } from "./modern";+import type { SidebarShellProps, UiLayoutSlots } from "./types";++const UI_LAYOUT_SLOTS: Record<UiLayout, UiLayoutSlots> = {+ classic: classicSlots,+ modern: modernSlots,+};++function useSlots(): UiLayoutSlots {+ return UI_LAYOUT_SLOTS[useUiLayout()];+}++// Shared code renders these and never the variants' components directly.++export function LayoutSidebarShell(props: SidebarShellProps) {+ const { SidebarShell } = useSlots();+ return <SidebarShell {...props} />;+}++export function LayoutPageBar() {+ const { PageBar } = useSlots();+ return PageBar ? <PageBar /> : null;+}++export function LayoutLearningHome() {+ const { LearningHome } = useSlots();+ return <LearningHome />;+}diff --git a/web/features/ui-layout/tokens.ts b/web/features/ui-layout/tokens.tsnew file mode 100644index 000000000..177a79bb6--- /dev/null+++ b/web/features/ui-layout/tokens.ts@@ -0,0 +1,32 @@+"use client";++import { useCallback } from "react";+import { useTranslation } from "react-i18next";+import { useUiLayout } from "@/hooks/useUiLayout";+import type { UiLayout } from "@/lib/ui-layout";+import { classicTokens } from "./classic/tokens";+import { modernTokens } from "./modern/tokens";+import type { UiLayoutTokens } from "./types";++const UI_LAYOUT_TOKENS: Record<UiLayout, UiLayoutTokens> = {+ classic: classicTokens,+ modern: modernTokens,+};++/** Translated copy for a label the two UIs name differently. */+export function useUiLayoutLabel(key: keyof UiLayoutTokens["labels"]): string {+ const { t } = useTranslation();+ const label = UI_LAYOUT_TOKENS[useUiLayout()].labels[key];+ // An empty token means "this layout shows nothing here".+ return label ? t(label) : "";+}++/** The mode picker's name for a capability; the default one is layout copy. */+export function useCapabilityLabel(): (capability: { value: string; label: string }) => string {+ const { t } = useTranslation();+ const defaultLabel = useUiLayoutLabel("defaultCapability");+ return useCallback(+ (capability) => (capability.value === "" ? defaultLabel : t(capability.label)),+ [defaultLabel, t],+ );+}diff --git a/web/features/ui-layout/types.ts b/web/features/ui-layout/types.tsnew file mode 100644index 000000000..e8cc3bf0f--- /dev/null+++ b/web/features/ui-layout/types.ts@@ -0,0 +1,40 @@+import type { ComponentType } from "react";+import type { SidebarShellProps } from "./classic/ClassicSidebarShell";++export type { SidebarShellProps };++/*+ * Everything that differs between the two product UIs, in three layers:+ *+ * - Slots (`slots.tsx`) — components that differ wholesale.+ * - Tokens (`tokens.ts`) — copy that differs; a leaf, safe to import anywhere.+ * - CSS (`<variant>/*.css`) — custom properties on <html data-ui-layout>.+ *+ * Shared code renders a slot or reads a token and never asks which layout is+ * active. A difference that is not expressed here does not exist: to change+ * something for one UI only, add a slot or token, or fork the component into+ * that variant's folder — never branch on the layout inside a shared component.+ */++export interface UiLayoutSlots {+ /** Workspace + utility sidebar. Receives what both route groups pass. */+ SidebarShell: ComponentType<SidebarShellProps>;+ /** `/learning` page body. */+ LearningHome: ComponentType;+ /** Location bar above section index pages, or none. */+ PageBar: ComponentType | null;+}++export interface UiLayoutTokens {+ /** i18n keys for copy the two UIs name differently. */+ labels: {+ /** The /space hub and its back links. */+ space: string;+ /** The /learning hub and its back links. */+ learning: string;+ /** The default chat capability in the mode picker. */+ defaultCapability: string;+ /** Heading over the chat home's suggestions; empty for none. */+ starterHeading: string;+ };+}diff --git a/web/hooks/useUiLayout.ts b/web/hooks/useUiLayout.tsnew file mode 100644index 000000000..1ba1c67c1--- /dev/null+++ b/web/hooks/useUiLayout.ts@@ -0,0 +1,31 @@+"use client";++import { useSyncExternalStore } from "react";+import {+ DEFAULT_UI_LAYOUT,+ UI_LAYOUT_EVENT,+ UI_LAYOUT_STORAGE_KEY,+ applyUiLayoutToDocument,+ readStoredUiLayout,+ type UiLayout,+} from "@/lib/ui-layout";++function subscribe(onChange: () => void): () => void {+ const onStorage = (event: StorageEvent) => {+ if (event.key !== UI_LAYOUT_STORAGE_KEY) return;+ // Another tab switched; keep this tab's <html> tokens in step.+ applyUiLayoutToDocument(readStoredUiLayout());+ onChange();+ };+ window.addEventListener(UI_LAYOUT_EVENT, onChange);+ window.addEventListener("storage", onStorage);+ return () => {+ window.removeEventListener(UI_LAYOUT_EVENT, onChange);+ window.removeEventListener("storage", onStorage);+ };+}++/** The active UI layout. SSR and hydration render the default, then adopt. */+export function useUiLayout(): UiLayout {+ return useSyncExternalStore(subscribe, readStoredUiLayout, () => DEFAULT_UI_LAYOUT);+}diff --git a/web/lib/settings-extensions.ts b/web/lib/settings-extensions.tsindex 484402965..dbb504238 100644--- a/web/lib/settings-extensions.ts+++ b/web/lib/settings-extensions.ts@@ -49,6 +49,13 @@ export async function applyExtensionPayload(}return;}+ if (key === "ui-layout") {+ // Browser-local: there is no endpoint, the browser is the store.+ const { isUiLayout, writeStoredUiLayout } = await import("@/lib/ui-layout");+ if (!isUiLayout(payload)) throw new Error(`Invalid UI layout: ${String(payload)}`);+ writeStoredUiLayout(payload);+ return;+ }if (key.startsWith("subagent:")) {const { updateSubagentSettings } = await import("@/lib/subagents-api");await updateSubagentSettings({ backends: { [key.slice(9)]: payload } });diff --git a/web/lib/shortcuts.ts b/web/lib/shortcuts.tsnew file mode 100644index 000000000..386607708--- /dev/null+++ b/web/lib/shortcuts.ts@@ -0,0 +1,47 @@+/**+ * Keyboard shortcuts: one description used both to match a key event and to+ * print the keys in a tooltip, so the two can never disagree.+ */++export interface Shortcut {+ /** A letter or digit, e.g. "K" or "1". */+ key: string+ /** ⌘ on macOS, Ctrl elsewhere. */+ mod?: boolean+ alt?: boolean+ shift?: boolean+}++export function isMacPlatform(): boolean {+ if (typeof navigator === 'undefined') return false+ return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent)+}++/** The keys as printed: ⌘ ⌥ ⇧ K on macOS, Ctrl Alt Shift K elsewhere. */+export function shortcutKeys(shortcut: Shortcut, mac = isMacPlatform()): string[] {+ const keys: string[] = []+ if (shortcut.mod) keys.push(mac ? '⌘' : 'Ctrl')+ if (shortcut.alt) keys.push(mac ? '⌥' : 'Alt')+ if (shortcut.shift) keys.push(mac ? '⇧' : 'Shift')+ keys.push(shortcut.key.toUpperCase())+ return keys+}++function physicalCode(key: string): string {+ return /^\d$/.test(key) ? `Digit${key}` : `Key${key.toUpperCase()}`+}++export function matchesShortcut(event: KeyboardEvent, shortcut: Shortcut, mac = isMacPlatform()): boolean {+ const mod = mac ? event.metaKey : event.ctrlKey+ if (Boolean(shortcut.mod) !== mod) return false+ if (Boolean(shortcut.alt) !== event.altKey || Boolean(shortcut.shift) !== event.shiftKey) return false+ // ⌥ rewrites event.key on macOS (⌥1 is "¡"), so compare the physical key.+ return event.code === physicalCode(shortcut.key)+}++/** The modern shell's shortcuts, in one place. */+export const SHORTCUTS = {+ search: { key: 'K', mod: true },+ newChat: { key: 'O', mod: true, shift: true },+ category: (index: number): Shortcut => ({ key: String(index + 1), mod: true, alt: true }),+} as constdiff --git a/web/lib/ui-layout.ts b/web/lib/ui-layout.tsnew file mode 100644index 000000000..dd03d29cd--- /dev/null+++ b/web/lib/ui-layout.ts@@ -0,0 +1,41 @@+import { browserStorage } from "@/shared/storage";++/**+ * Which product UI the app renders.+ *+ * - `classic` — the UI as it ships on dev, kept as a frozen snapshot.+ * - `modern` — the dt-exp redesign, free to keep evolving.+ *+ * A browser-local preference: it picks a presentation, never data, so it does+ * not belong in the account's interface.json. `ThemeScript` mirrors it onto+ * `<html data-ui-layout>` before hydration so variant CSS tokens paint right.+ */+export type UiLayout = "classic" | "modern";++export const UI_LAYOUTS: readonly UiLayout[] = ["classic", "modern"];+export const DEFAULT_UI_LAYOUT: UiLayout = "modern";+export const UI_LAYOUT_STORAGE_KEY = "deeptutor.ui-layout";+export const UI_LAYOUT_EVENT = "deeptutor:ui-layout";+export const UI_LAYOUT_ATTRIBUTE = "data-ui-layout";++export function isUiLayout(value: unknown): value is UiLayout {+ return value === "classic" || value === "modern";+}++export function readStoredUiLayout(): UiLayout {+ if (typeof window === "undefined") return DEFAULT_UI_LAYOUT;+ const stored = browserStorage.readRaw("local", UI_LAYOUT_STORAGE_KEY);+ return isUiLayout(stored) ? stored : DEFAULT_UI_LAYOUT;+}++export function applyUiLayoutToDocument(layout: UiLayout): void {+ if (typeof document === "undefined") return;+ document.documentElement.setAttribute(UI_LAYOUT_ATTRIBUTE, layout);+}++export function writeStoredUiLayout(layout: UiLayout): void {+ if (typeof window === "undefined") return;+ browserStorage.writeRaw("local", UI_LAYOUT_STORAGE_KEY, layout);+ applyUiLayoutToDocument(layout);+ window.dispatchEvent(new CustomEvent(UI_LAYOUT_EVENT, { detail: { layout } }));+}diff --git a/web/locales/de/app.json b/web/locales/de/app.jsonindex 768c9e2ff..0d1f61e7e 100644--- a/web/locales/de/app.json+++ b/web/locales/de/app.json@@ -1554,6 +1554,11 @@"Wrap long lines": "Lange Zeilen umbrechen","Choose the interface language.": "Wähle die Sprache der Benutzeroberfläche.","Interface language": "UI-Sprache",+ "Layout": "Layout",+ "Interface layout": "Oberflächenlayout",+ "Classic keeps the familiar navigation; Modern is the redesigned interface.": "Klassisch behält die vertraute Navigation; Modern ist die neu gestaltete Oberfläche.",+ "Classic": "Klassisch",+ "Modern": "Modern","Controls navigation, settings, and status text only.": "Steuert nur Navigation, Einstellungen und Statustexte.","Model output language": "Modell-Ausgabesprache","Sets the default language for chat and capability responses.": "Legt die Standardsprache für Chat- und Funktionsantworten fest.",@@ -5519,7 +5524,16 @@"navigation.learning": "Lernen","navigation.resources": "Materialien","navigation.categories": "Main sections",- "navigation.search": "Search this section",+ "navigation.search": "Suchen",+ "navigation.location": "Ort",+ "navigation.scopeHint": "Inhalt in {{workspace}}",+ "navigation.scopeAction": "Klicken, um den Arbeitsbereich zu wechseln",+ "navigation.ideasForYou": "Ideen für dich",+ "navigation.searchEverything": "Suchen oder springen…",+ "navigation.jumpTo": "Springen zu",+ "navigation.paletteSelect": "Auswählen",+ "navigation.paletteOpen": "Öffnen",+ "navigation.paletteClose": "Schließen","navigation.workspace": "Workspace","navigation.newChat": "New conversation","navigation.sortLearning": "Lerneinträge sortieren",diff --git a/web/locales/en/app.json b/web/locales/en/app.jsonindex 8a20b97ee..21bbe0fed 100644--- a/web/locales/en/app.json+++ b/web/locales/en/app.json@@ -1554,6 +1554,11 @@"Wrap long lines": "Wrap long lines","Choose the interface language.": "Choose the interface language.","Interface language": "Interface language",+ "Layout": "Layout",+ "Interface layout": "Interface layout",+ "Classic keeps the familiar navigation; Modern is the redesigned interface.": "Classic keeps the familiar navigation; Modern is the redesigned interface.",+ "Classic": "Classic",+ "Modern": "Modern","Controls navigation, settings, and status text only.": "Controls navigation, settings, and status text only.","Model output language": "Model output language","Sets the default language for chat and capability responses.": "Sets the default language for chat and capability responses.",@@ -5519,7 +5524,16 @@"navigation.learning": "Learning","navigation.resources": "Resources","navigation.categories": "Main sections",- "navigation.search": "Search this section",+ "navigation.search": "Search",+ "navigation.location": "Location",+ "navigation.scopeHint": "Content in {{workspace}}",+ "navigation.scopeAction": "Click to switch workspace",+ "navigation.ideasForYou": "Ideas for you",+ "navigation.searchEverything": "Search or jump to…",+ "navigation.jumpTo": "Jump to",+ "navigation.paletteSelect": "Select",+ "navigation.paletteOpen": "Open",+ "navigation.paletteClose": "Close","navigation.workspace": "Workspace","navigation.newChat": "New conversation","navigation.sortLearning": "Sort learning records",diff --git a/web/locales/fr/app.json b/web/locales/fr/app.jsonindex cb0ca479f..ecb1b1ac0 100644--- a/web/locales/fr/app.json+++ b/web/locales/fr/app.json@@ -2018,6 +2018,11 @@"Snow keeps things minimal; Glass adds translucent panels. Dark mode follows the same accent palette.": "Neige reste minimaliste ; Verre ajoute des panneaux translucides. Le mode sombre suit la même palette d'accent.","Choose the interface language.": "Choisissez la langue de l'interface.","Interface language": "Langue de l'interface",+ "Layout": "Disposition",+ "Interface layout": "Disposition de l’interface",+ "Classic keeps the familiar navigation; Modern is the redesigned interface.": "Classique conserve la navigation habituelle ; Moderne est l’interface repensée.",+ "Classic": "Classique",+ "Modern": "Moderne","Controls navigation, settings, and status text only.": "Ne concerne que la navigation, les paramètres et les textes de statut.","Model output language": "Langue de sortie du modèle","Sets the default language for chat and capability responses.": "Définit la langue par défaut des réponses de la conversation et des capacités.",@@ -5899,7 +5904,16 @@"navigation.learning": "Apprentissage","navigation.resources": "Ressources","navigation.categories": "Main sections",- "navigation.search": "Search this section",+ "navigation.search": "Rechercher",+ "navigation.location": "Emplacement",+ "navigation.scopeHint": "Contenu de {{workspace}}",+ "navigation.scopeAction": "Cliquez pour changer d’espace de travail",+ "navigation.ideasForYou": "Idées pour vous",+ "navigation.searchEverything": "Rechercher ou accéder à…",+ "navigation.jumpTo": "Accéder à",+ "navigation.paletteSelect": "Sélectionner",+ "navigation.paletteOpen": "Ouvrir",+ "navigation.paletteClose": "Fermer","navigation.workspace": "Workspace","navigation.newChat": "New conversation","navigation.sortLearning": "Trier les activités",diff --git a/web/locales/pl/app.json b/web/locales/pl/app.jsonindex 81ba69b74..2cf0a84b5 100644--- a/web/locales/pl/app.json+++ b/web/locales/pl/app.json@@ -1553,6 +1553,11 @@"Wrap long lines": "Zawijaj długie wiersze","Choose the interface language.": "Wybierz język interfejsu.","Interface language": "Język interfejsu",+ "Layout": "Układ",+ "Interface layout": "Układ interfejsu",+ "Classic keeps the familiar navigation; Modern is the redesigned interface.": "Klasyczny zachowuje znaną nawigację; Nowoczesny to przeprojektowany interfejs.",+ "Classic": "Klasyczny",+ "Modern": "Nowoczesny","Controls navigation, settings, and status text only.": "Dotyczy tylko nawigacji, ustawień i tekstów statusu.","Model output language": "Język wyjściowy modelu","Sets the default language for chat and capability responses.": "Ustawia domyślny język dla odpowiedzi czatu i funkcji.",@@ -5535,7 +5540,16 @@"navigation.learning": "Nauka","navigation.resources": "Materiały","navigation.categories": "Main sections",- "navigation.search": "Search this section",+ "navigation.search": "Szukaj",+ "navigation.location": "Lokalizacja",+ "navigation.scopeHint": "Treści w {{workspace}}",+ "navigation.scopeAction": "Kliknij, aby zmienić obszar roboczy",+ "navigation.ideasForYou": "Pomysły dla Ciebie",+ "navigation.searchEverything": "Szukaj lub przejdź do…",+ "navigation.jumpTo": "Przejdź do",+ "navigation.paletteSelect": "Wybierz",+ "navigation.paletteOpen": "Otwórz",+ "navigation.paletteClose": "Zamknij","navigation.workspace": "Workspace","navigation.newChat": "New conversation","navigation.sortLearning": "Sortuj naukę",diff --git a/web/locales/uk/app.json b/web/locales/uk/app.jsonindex a8ab8730b..a33de4ff9 100644--- a/web/locales/uk/app.json+++ b/web/locales/uk/app.json@@ -1517,6 +1517,11 @@"Wrap long lines": "Переносити довгі рядки","Choose the interface language.": "Оберіть мову інтерфейсу.","Interface language": "Мова інтерфейсу",+ "Layout": "Макет",+ "Interface layout": "Макет інтерфейсу",+ "Classic keeps the familiar navigation; Modern is the redesigned interface.": "Класичний зберігає звичну навігацію; Сучасний — це перероблений інтерфейс.",+ "Classic": "Класичний",+ "Modern": "Сучасний","Controls navigation, settings, and status text only.": "Керує лише текстом навігації, налаштувань і статусу.","Model output language": "Мова відповідей моделі","Sets the default language for chat and capability responses.": "Встановлює мову за замовчуванням для відповідей чату та функцій.",@@ -5535,7 +5540,16 @@"navigation.learning": "Навчання","navigation.resources": "Матеріали","navigation.categories": "Main sections",- "navigation.search": "Search this section",+ "navigation.search": "Пошук",+ "navigation.location": "Розташування",+ "navigation.scopeHint": "Вміст у {{workspace}}",+ "navigation.scopeAction": "Натисніть, щоб змінити робочий простір",+ "navigation.ideasForYou": "Ідеї для вас",+ "navigation.searchEverything": "Пошук або перехід…",+ "navigation.jumpTo": "Перейти до",+ "navigation.paletteSelect": "Вибрати",+ "navigation.paletteOpen": "Відкрити",+ "navigation.paletteClose": "Закрити","navigation.workspace": "Workspace","navigation.newChat": "New conversation","navigation.sortLearning": "Сортувати навчання",diff --git a/web/locales/zh/app.json b/web/locales/zh/app.jsonindex 0f5f60d89..608431280 100644--- a/web/locales/zh/app.json+++ b/web/locales/zh/app.json@@ -972,6 +972,11 @@"Wrap long lines": "长行换行","Choose the interface language.": "选择界面语言。","Interface language": "界面语言",+ "Layout": "布局",+ "Interface layout": "界面布局",+ "Classic keeps the familiar navigation; Modern is the redesigned interface.": "经典保留熟悉的导航;现代是重新设计的新界面。",+ "Classic": "经典",+ "Modern": "现代","Controls navigation, settings, and status text only.": "只控制导航、设置和状态文案。","Model output language": "模型输出语言","Sets the default language for chat and capability responses.": "设置聊天及各项能力回复所使用的默认语言。",@@ -5519,7 +5524,16 @@"navigation.learning": "学习","navigation.resources": "资料","navigation.categories": "主要栏目",- "navigation.search": "搜索当前栏目",+ "navigation.search": "搜索",+ "navigation.location": "页面位置",+ "navigation.scopeHint": "内容属于「{{workspace}}」",+ "navigation.scopeAction": "点击以切换工作区",+ "navigation.ideasForYou": "为你推荐",+ "navigation.searchEverything": "搜索或跳转…",+ "navigation.jumpTo": "跳转到",+ "navigation.paletteSelect": "选择",+ "navigation.paletteOpen": "打开",+ "navigation.paletteClose": "关闭","navigation.workspace": "工作台","navigation.newChat": "新对话","navigation.sortLearning": "学习记录排序",diff --git a/web/shared/ui/Tooltip.tsx b/web/shared/ui/Tooltip.tsxindex 6f4c5efef..a7f97f6f7 100644--- a/web/shared/ui/Tooltip.tsx+++ b/web/shared/ui/Tooltip.tsx@@ -13,6 +13,7 @@ import {type ReactElement,} from "react";import type { TooltipSide } from "./tooltip-position";+import type { Shortcut } from "@/lib/shortcuts";const loadTooltipLayer = () => import("./TooltipLayer");const TooltipLayer = lazy(loadTooltipLayer);@@ -33,6 +34,8 @@ export interface TooltipProps {delay?: number;/** Suppress a tooltip while its trigger owns an open popover or menu. */suppressed?: boolean;+ /** Keys that trigger the same action, printed after the label. */+ shortcut?: Shortcut;}export function Tooltip({@@ -44,6 +47,7 @@ export function Tooltip({side = "bottom",delay = 180,suppressed = false,+ shortcut,}: TooltipProps) {const id = useId();const wrapperRef = useRef<HTMLElement>(null);@@ -179,6 +183,7 @@ export function Tooltip({id={id}label={label}description={description}+ shortcut={shortcut}side={side}onMount={markLayerMounted}/>diff --git a/web/shared/ui/TooltipLayer.tsx b/web/shared/ui/TooltipLayer.tsxindex 266416074..41099df05 100644--- a/web/shared/ui/TooltipLayer.tsx+++ b/web/shared/ui/TooltipLayer.tsx@@ -7,6 +7,7 @@ import {type RefObject,} from "react";import { createPortal } from "react-dom";+import { shortcutKeys, type Shortcut } from "@/lib/shortcuts";import {placeTooltip,type TooltipPosition,@@ -18,6 +19,7 @@ export default function TooltipLayer({id,label,description,+ shortcut,side,onMount,}: {@@ -25,6 +27,7 @@ export default function TooltipLayer({id: string;label: string;description?: string;+ shortcut?: Shortcut;side: TooltipSide;onMount: () => void;}) {@@ -67,7 +70,18 @@ export default function TooltipLayer({}className={`pointer-events-none fixed z-[1000] max-w-72 rounded-lg bg-[var(--foreground)] px-2.5 py-1.5 text-left text-[11px] font-medium leading-snug text-[var(--background)] shadow-lg [overflow-wrap:anywhere] ${position ? "opacity-100" : "opacity-0"}`}>- <span className="block">{label}</span>+ {shortcut ? (+ <span className="flex items-center gap-2">+ <span>{label}</span>+ <kbd className="inline-flex items-center gap-0.5 font-sans text-[11px] font-normal tracking-wide opacity-60">+ {shortcutKeys(shortcut).map((key) => (+ <span key={key}>{key}</span>+ ))}+ </kbd>+ </span>+ ) : (+ <span className="block">{label}</span>+ )}{description ? (<span className="mt-0.5 block font-normal opacity-80">{description}diff --git a/web/shared/ui/useMenuPopover.ts b/web/shared/ui/useMenuPopover.tsnew file mode 100644index 000000000..573a5b5fd--- /dev/null+++ b/web/shared/ui/useMenuPopover.ts@@ -0,0 +1,43 @@+"use client";++import { useEffect, useRef, type Dispatch, type SetStateAction } from "react";++/**+ * Menu-button behaviour for a small popover: focus the first item on open,+ * close on outside pointer or Escape (returning focus to the trigger), and+ * move between `[role="menuitem"]`s with the arrow keys.+ */+export function useMenuPopover<T extends HTMLElement>(+ open: boolean,+ setOpen: Dispatch<SetStateAction<boolean>>,+) {+ const rootRef = useRef<T>(null);+ useEffect(() => {+ if (!open) return;+ const root = rootRef.current;+ root?.querySelector<HTMLElement>('[role="menuitem"][aria-current="page"], [role="menuitem"]')?.focus();+ const dismiss = (event: PointerEvent) => {+ if (!root?.contains(event.target as Node)) setOpen(false);+ };+ const keys = (event: KeyboardEvent) => {+ if (event.key === "Escape") {+ setOpen(false);+ root?.querySelector<HTMLElement>('[aria-haspopup="menu"]')?.focus();+ return;+ }+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;+ event.preventDefault();+ const items = [...(root?.querySelectorAll<HTMLElement>('[role="menuitem"]') ?? [])];+ const index = items.indexOf(document.activeElement as HTMLElement);+ const next = event.key === "ArrowDown" ? index + 1 : index - 1;+ items[(next + items.length) % items.length]?.focus();+ };+ document.addEventListener("pointerdown", dismiss);+ document.addEventListener("keydown", keys);+ return () => {+ document.removeEventListener("pointerdown", dismiss);+ document.removeEventListener("keydown", keys);+ };+ }, [open, setOpen]);+ return rootRef;+}diff --git a/web/tests/learning-journal-panel.spec.tsx b/web/tests/learning-journal-panel.spec.tsxindex 95f2cf8e4..6452b43e5 100644--- a/web/tests/learning-journal-panel.spec.tsx+++ b/web/tests/learning-journal-panel.spec.tsx@@ -5,7 +5,10 @@ import LearningJournalPanel from "@/components/space/LearningJournalPanel";import { getLearningJournal, type LearningJournal } from "@/lib/learning-journal-api";const route = vi.hoisted(() => ({ workspace: "a" }));-vi.mock("next/navigation", () => ({ useSearchParams: () => new URLSearchParams({ dt_workspace: route.workspace }) }));+vi.mock("next/navigation", () => ({+ usePathname: () => "/space/journal",+ useSearchParams: () => new URLSearchParams({ dt_workspace: route.workspace }),+}));vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string) => key }) }));vi.mock("@/lib/learning-journal-api", () => ({ getLearningJournal: vi.fn() }));const empty: LearningJournal = {diff --git a/web/tests/learning-navigation.spec.tsx b/web/tests/learning-navigation.spec.tsxindex 2b57a529c..6dca17802 100644--- a/web/tests/learning-navigation.spec.tsx+++ b/web/tests/learning-navigation.spec.tsx@@ -17,19 +17,19 @@ vi.mock('@/hooks/useLearningIndex', () => ({ useLearningIndex: () => ({beforeEach(() => localStorage.clear())it('sorts by creation independently of activity and retains the preference', () => {- const view = render(<LearningNavigation query="" sessions={null} />)+ const view = render(<LearningNavigation sessions={null} />)const records = () => within(screen.getByRole('region', { name: 'navigation.learningRecords' })).getAllByRole('link')expect(records()[0]).toHaveTextContent('Older material')fireEvent.change(screen.getByRole('combobox', { name: 'navigation.sortLearning' }), { target: { value: 'createdAt' } })expect(records()[0]).toHaveTextContent('Newly created material')expect(records()[1]).toHaveAttribute('href', '/learning/practice?question=1&dt_workspace=physics')view.unmount()- render(<LearningNavigation query="" sessions={null} />)+ render(<LearningNavigation sessions={null} />)expect(records()[0]).toHaveTextContent('Newly created material')})it('searches records without discarding the rest of the library', () => {- render(<LearningNavigation query="" sessions={null} />)+ render(<LearningNavigation sessions={null} />)fireEvent.click(screen.getByRole('button', { name: 'navigation.searchLearning' }))const input = screen.getByRole('textbox', { name: 'navigation.searchLearning' })fireEvent.change(input, { target: { value: 'recently' } })diff --git a/web/tests/page-sections.spec.ts b/web/tests/page-sections.spec.tsnew file mode 100644index 000000000..971a26cf7--- /dev/null+++ b/web/tests/page-sections.spec.ts@@ -0,0 +1,29 @@+import { describe, expect, it } from 'vitest'+import { locatePage, pageSections } from '@/components/sidebar/page-sections'++const sections = (allowedSurfaces: string[] | null = null) =>+ pageSections({ t: key => key, zh: false, allowedSurfaces, isAvailable: () => false })++describe('page sections', () => {+ it('places each index page in the shelf the sidebar shows it under', () => {+ expect(locatePage('/space/journal', sections())?.section.id).toBe('resources')+ expect(locatePage('/learning', sections())?.section.id).toBe('learning')+ expect(locatePage('/kanban', sections())?.section.id).toBe('home')+ expect(locatePage('/partners', sections())?.section.scoped).toBe(false)+ expect(locatePage('/space', sections())?.section.scoped).toBe(true)+ })++ it('leaves detail views and the chat to their own headers', () => {+ expect(locatePage('/chat', sections())).toBeNull()+ expect(locatePage('/partners/frank', sections())).toBeNull()+ expect(locatePage('/notebooks/abc', sections())).toBeNull()+ })++ it('applies the same gates as the sidebar shelves', () => {+ const learning = sections(['books']).find(section => section.id === 'learning')!+ expect(learning.pages.map(page => page.label)).toEqual(['navigation.allLearning', 'Books'])+ // Capability-gated resources stay hidden until the backend registers them.+ const resources = sections().find(section => section.id === 'resources')!+ expect(resources.pages.some(page => page.href === '/whisper')).toBe(false)+ })+})diff --git a/web/tests/practice-entrypoints.spec.tsx b/web/tests/practice-entrypoints.spec.tsxindex 5e6e10d12..9251dc015 100644--- a/web/tests/practice-entrypoints.spec.tsx+++ b/web/tests/practice-entrypoints.spec.tsx@@ -7,6 +7,7 @@ import * as api from "@/lib/practice-api";const replace = vi.fn();vi.mock("next/navigation", () => ({+ usePathname: () => "/learning/practice",useSearchParams: () => new URLSearchParams("course=course-a&workspace=work-a&view=mistakes"),useRouter: () => ({ replace }),}));diff --git a/web/tests/roster-lens.spec.ts b/web/tests/roster-lens.spec.tsnew file mode 100644index 000000000..49c8c0f67--- /dev/null+++ b/web/tests/roster-lens.spec.ts@@ -0,0 +1,60 @@+import { describe, expect, it } from 'vitest'+import { rosterFade, rosterLens } from '@/components/sidebar/roster-lens'++// The roster's real geometry: 46px slots, 32px avatars, 52px zones, 8 partners.+const SLOT = 46+const AVATAR = 32+const ZONE = 52+const VIEWPORT = 255+const COUNT = 8+const MAX_SCROLL = SLOT * COUNT - VIEWPORT++function avatars(scrollLeft: number, maxScroll = MAX_SCROLL) {+ return Array.from({ length: COUNT }, (_, index) => {+ const center = index * SLOT + SLOT / 2+ const lens = rosterLens({ center, viewport: VIEWPORT, scrollLeft, maxScroll, zone: ZONE })+ const visual = center - scrollLeft + lens.dx+ const half = (AVATAR * lens.scale) / 2+ return { ...lens, left: visual - half, right: visual + half }+ })+}++describe('rosterLens', () => {+ it('leaves a roster that fits completely flat', () => {+ for (const item of avatars(0, 0)) expect(item).toMatchObject({ dx: 0, scale: 1, opacity: 1, label: 1, depth: 0 })+ })++ it('compresses only the side that has partners beyond it', () => {+ const items = avatars(0)+ expect(items[0].depth).toBe(0)+ expect(items.at(-1)!.depth).toBeGreaterThan(0.5)+ expect(items.at(-1)!.label).toBe(0)+ })++ it('packs toward an edge with ever-tighter gaps but never lets avatars touch', () => {+ for (let scrollLeft = 0; scrollLeft <= MAX_SCROLL; scrollLeft += 3) {+ const items = avatars(scrollLeft)+ const gaps = items.slice(1).map((item, index) => item.left - items[index].right)+ for (const gap of gaps) expect(gap).toBeGreaterThan(0.5)+ }+ const atStart = avatars(0)+ const gaps = atStart.slice(1).map((item, index) => item.left - atStart[index].right)+ const firstCompressed = gaps.findIndex(gap => gap < SLOT - AVATAR - 0.01)+ expect(firstCompressed).toBeGreaterThan(0)+ expect(gaps[firstCompressed + 1]).toBeLessThan(gaps[firstCompressed])+ })++ it('moves items continuously as a stack starts to form', () => {+ const still = avatars(0)+ const nudged = avatars(0.5)+ still.forEach((item, index) => expect(Math.abs(nudged[index].left + 0.5 - item.left)).toBeLessThan(1.5))+ })+})++describe('rosterFade', () => {+ it('fades only edges with content past them', () => {+ expect(rosterFade({ viewport: VIEWPORT, scrollLeft: 0, maxScroll: MAX_SCROLL, zone: ZONE })).toMatchObject({ left: 0 })+ expect(rosterFade({ viewport: VIEWPORT, scrollLeft: MAX_SCROLL, maxScroll: MAX_SCROLL, zone: ZONE }).right).toBe(0)+ expect(rosterFade({ viewport: VIEWPORT, scrollLeft: 0, maxScroll: 0, zone: ZONE })).toEqual({ left: 0, right: 0 })+ })+})diff --git a/web/tests/shortcuts.spec.ts b/web/tests/shortcuts.spec.tsnew file mode 100644index 000000000..2f1133834--- /dev/null+++ b/web/tests/shortcuts.spec.ts@@ -0,0 +1,24 @@+import { describe, expect, it } from 'vitest'+import { SHORTCUTS, matchesShortcut, shortcutKeys } from '@/lib/shortcuts'++const key = (init: KeyboardEventInit) => new KeyboardEvent('keydown', init)++describe('shortcuts', () => {+ it('matches ⌥-digit by physical key, since macOS rewrites event.key', () => {+ const optionTwo = key({ key: '™', code: 'Digit2', metaKey: true, altKey: true })+ expect(matchesShortcut(optionTwo, SHORTCUTS.category(1), true)).toBe(true)+ expect(matchesShortcut(optionTwo, SHORTCUTS.category(0), true)).toBe(false)+ })++ it('uses ⌘ on macOS and Ctrl elsewhere, and requires the exact modifiers', () => {+ expect(matchesShortcut(key({ key: 'k', code: 'KeyK', metaKey: true }), SHORTCUTS.search, true)).toBe(true)+ expect(matchesShortcut(key({ key: 'k', code: 'KeyK', ctrlKey: true }), SHORTCUTS.search, true)).toBe(false)+ expect(matchesShortcut(key({ key: 'k', code: 'KeyK', ctrlKey: true }), SHORTCUTS.search, false)).toBe(true)+ expect(matchesShortcut(key({ key: 'K', code: 'KeyK', metaKey: true, shiftKey: true }), SHORTCUTS.search, true)).toBe(false)+ })++ it('prints the same keys it matches', () => {+ expect(shortcutKeys(SHORTCUTS.newChat, true)).toEqual(['⌘', '⇧', 'O'])+ expect(shortcutKeys(SHORTCUTS.category(2), false)).toEqual(['Ctrl', 'Alt', '3'])+ })+})diff --git a/web/tests/sidebar-lazy-history.spec.tsx b/web/tests/sidebar-lazy-history.spec.tsxindex d066a0f2b..aefe8b9f7 100644--- a/web/tests/sidebar-lazy-history.spec.tsx+++ b/web/tests/sidebar-lazy-history.spec.tsx@@ -81,8 +81,10 @@ it("loads conversation history while navigation remains usable, then preserves sexpect(scroller).not.toContainElement(screen.getByRole("tab", { name: "navigation.home" }),);+ // Settings lives in the header's workspace menu, outside the history scroller.+ fireEvent.click(screen.getByRole("button", { name: /General workspace/ }));expect(scroller).not.toContainElement(- screen.getByRole("link", { name: "Settings" }),+ screen.getByRole("menuitem", { name: "Settings" }),);fireEvent.click(await screen.findByText("Retained session"));diff --git a/web/tests/space-dashboard-capability-gate.test.ts b/web/tests/space-dashboard-capability-gate.test.tsindex 22eee8510..b9bc7016a 100644--- a/web/tests/space-dashboard-capability-gate.test.ts+++ b/web/tests/space-dashboard-capability-gate.test.ts@@ -3,7 +3,7 @@ import assert from "node:assert/strict";import {DASHBOARD_GROUPS,visibleGroups,-} from "../components/space/SpaceDashboard";+} from "../components/space/dashboard-groups";// #963: /whisper ships its pages here but its capability comes from an// out-of-tree plugin, so a stock install offered a room the backend could notdiff --git a/web/tests/ui-layout.spec.tsx b/web/tests/ui-layout.spec.tsxnew file mode 100644index 000000000..4cdb7731c--- /dev/null+++ b/web/tests/ui-layout.spec.tsx@@ -0,0 +1,46 @@+import { act, render, screen } from '@testing-library/react'+import { beforeEach, expect, it, vi } from 'vitest'+import { LayoutSidebarShell } from '@/features/ui-layout/slots'+import { useCapabilityLabel, useUiLayoutLabel } from '@/features/ui-layout/tokens'+import { applyExtensionPayload } from '@/lib/settings-extensions'+import { UI_LAYOUT_STORAGE_KEY, writeStoredUiLayout } from '@/lib/ui-layout'++vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }))+vi.mock('@/features/ui-layout/classic/ClassicSidebarShell', () => ({ ClassicSidebarShell: () => <nav>classic sidebar</nav> }))+vi.mock('@/components/sidebar/SidebarShell', () => ({ SidebarShell: () => <nav>modern sidebar</nav> }))++beforeEach(() => {+ localStorage.clear()+ document.documentElement.removeAttribute('data-ui-layout')+})++function Labels() {+ const space = useUiLayoutLabel('space')+ const capabilityLabel = useCapabilityLabel()+ return (+ <p>+ {[space, capabilityLabel({ value: '', label: 'Chat' }), capabilityLabel({ value: 'deep_solve', label: 'Deep Solve' })].join(' / ')}+ </p>+ )+}++it('renders the modern UI by default and switches slots and tokens together', () => {+ render(<><LayoutSidebarShell /><Labels /></>)+ expect(screen.getByText('modern sidebar')).toBeInTheDocument()+ expect(screen.getByText('navigation.resources / Auto / Deep Solve')).toBeInTheDocument()++ act(() => writeStoredUiLayout('classic'))++ expect(screen.getByText('classic sidebar')).toBeInTheDocument()+ expect(screen.queryByText('modern sidebar')).not.toBeInTheDocument()+ expect(screen.getByText('Learning Space / Chat / Deep Solve')).toBeInTheDocument()+ expect(document.documentElement).toHaveAttribute('data-ui-layout', 'classic')+})++it('applies a drafted layout with no endpoint and rejects unknown values', async () => {+ await applyExtensionPayload('ui-layout', 'classic')+ expect(localStorage.getItem(UI_LAYOUT_STORAGE_KEY)).toBe('classic')++ await expect(applyExtensionPayload('ui-layout', 'retro')).rejects.toThrow('Invalid UI layout')+ expect(localStorage.getItem(UI_LAYOUT_STORAGE_KEY)).toBe('classic')+})diff --git a/web/tests/watching-browser.spec.tsx b/web/tests/watching-browser.spec.tsxindex 6f8090d4f..d32933ea6 100644--- a/web/tests/watching-browser.spec.tsx+++ b/web/tests/watching-browser.spec.tsx@@ -8,7 +8,7 @@ const mock = vi.hoisted(() => ({browse: vi.fn(),push: vi.fn(),}));-vi.mock("next/navigation", () => ({ useRouter: () => ({ push: mock.push }) }));+vi.mock("next/navigation", () => ({ usePathname: () => "/learning/reading", useRouter: () => ({ push: mock.push }) }));const translate = (key: string) => key;vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: translate }) }));vi.mock("@/hooks/useAuthStatus", () => ({diff --git a/web/tests/workspace-sidebar-grouping.spec.tsx b/web/tests/workspace-sidebar-grouping.spec.tsxindex 14eb00bd4..90345d21e 100644--- a/web/tests/workspace-sidebar-grouping.spec.tsx+++ b/web/tests/workspace-sidebar-grouping.spec.tsx@@ -59,7 +59,7 @@ it('keeps an empty workspace visible and allows starting its first chat', () =>it('keeps unassigned chats in a peer Recent section with independent five-row limits', () => {const unassigned = rows.map((row, index) => ({ ...row, id: `recent-${index}`, session_id: `recent-${index}`, title: `Recent ${index}`, content_workspace_id: '' }))- const view = render(<OrganizedSessionList sessions={[...unassigned, ...rows]} courses={[]} workspaces={[workspace]} groupWorkspaces+ const view = render(<OrganizedSessionList sessions={[...unassigned, ...rows]} courses={[]} workspaces={[workspace]} groupWorkspaces workspaceHeadingactiveSessionId={null} onSelect={vi.fn()} onRename={vi.fn()} onDelete={vi.fn()} onOrganize={vi.fn()} />)const workspaceGroup = view.container.querySelector('[data-group-id="workspace:physics"]')! as HTMLElementconst recentGroup = view.container.querySelector('[data-group-id="recent:unassigned"]')! as HTMLElement