Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): 侧边栏导航支持自定义顺序与显示 (#5472)
Dash24551276ff34
diff --git a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.tsindex b5827857be..a1dc5be937 100644--- a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts+++ b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts@@ -76,8 +76,13 @@ describe('远程机器切换入口并入 SidebarTopNav(置顶段上方,固定不expect(sidebarShellSource).toContain('useOwnsTopNavScrollableRows()');expect(sidebarShellSource).not.toMatch(/^import .*from 'react-router-dom'/m);- // cc-agent:展开态声明接管,并把可滚动段画进滚动容器;rail 态交回 Shell。- expect(sidebarUpperSource).toContain('useOwnTopNavScrollableRows(!isCollapsed)');+ // cc-agent:展开态把可滚动段画进滚动容器;rail 态也由 CollapsedView 按导航偏好+ // 整段渲染(SidebarRailNavigation),Shell 不再补 rail 伙伴图标。+ expect(sidebarUpperSource).toContain('useOwnTopNavScrollableRows(true)');+ expect(sidebarUpperSource).toContain('<SidebarRailNavigation');+ expect(sidebarShellSource).toContain(+ '!ownsTopNavScrollableRows && <SidebarTopNav section="rail" />',+ );expect(sidebarUpperSource).toContain('<SidebarTopNav section="scrollable" />');const scrollRefIdx = sidebarUpperSource.indexOf('ref={sidebarScrollRef}');const scrollableRowsIdx = sidebarUpperSource.indexOf('<SidebarTopNav section="scrollable" />');@@ -88,7 +93,10 @@ describe('远程机器切换入口并入 SidebarTopNav(置顶段上方,固定不expect(topNavSource).toContain("const pinSearch = section === 'scrollable' && search.query.trim().length > 0",);- expect(topNavSource).toContain("pinSearch && 'sticky top-0 z-30 bg-[var(--cmd-palette-bg)]'");+ // 搜索可排在中间,底部间距只在钉住时补上(未钉住时由后续行的 gap 承担)。+ expect(topNavSource).toContain(+ "pinSearch && 'sticky top-0 z-30 bg-[var(--cmd-palette-bg)] pb-2.5'",+ );expect(topNavSource).toContain("if (section === 'scrollable')");expect(sidebarUpperSource).toContain('lastListScrollTopRef.current = el.scrollTop');expect(sidebarUpperSource).toContain(@@ -121,29 +129,41 @@ describe('远程机器切换入口并入 SidebarTopNav(置顶段上方,固定不expect(featureContextSource).toContain('export function useOwnsTopNavScrollableRows');});- it('插件主视图紧随插件入口,面板恢复入口仍位于插件区与搜索之间', () => {- const expandedPluginsIdx = topNavSource.indexOf('{pluginsRow}');- const expandedMainViewsIdx = topNavSource.indexOf('{mainViewRows}', expandedPluginsIdx);- const expandedRestoreIdx = topNavSource.indexOf('{restoreRow}', expandedPluginsIdx);- const expandedSearchIdx = topNavSource.indexOf('{searchRow}', expandedRestoreIdx);- expect(expandedPluginsIdx).toBeGreaterThanOrEqual(0);- expect(expandedMainViewsIdx).toBeGreaterThan(expandedPluginsIdx);- expect(expandedRestoreIdx).toBeGreaterThan(expandedMainViewsIdx);- expect(expandedSearchIdx).toBeGreaterThan(expandedRestoreIdx);-- const persistentPluginsIdx = topNavSource.lastIndexOf('{pluginsRow}');- const persistentMainViewsIdx = topNavSource.indexOf('{mainViewRows}', persistentPluginsIdx);- const persistentRestoreIdx = topNavSource.indexOf('{restoreRow}', persistentMainViewsIdx);- expect(persistentPluginsIdx).toBeGreaterThan(expandedPluginsIdx);- expect(persistentMainViewsIdx).toBeGreaterThan(persistentPluginsIdx);- expect(persistentRestoreIdx).toBeGreaterThan(persistentMainViewsIdx);-- const railPluginsIdx = sidebarUpperSource.indexOf("label={t('sidebar.tabs.plugins')}");- const railRestoreIdx = sidebarUpperSource.indexOf('<GhostPanelRestoreEntry', railPluginsIdx);- const railSearchIdx = sidebarUpperSource.indexOf('<ConversationSearchBox', railRestoreIdx);- expect(railPluginsIdx).toBeGreaterThanOrEqual(0);- expect(railRestoreIdx).toBeGreaterThan(railPluginsIdx);- expect(railSearchIdx).toBeGreaterThan(railRestoreIdx);+ // 导航改为用户自定义顺序:内置入口与插件主视图按保存顺序排列,面板恢复入口+ // 紧随其后,「更多」收尾;展开态与 rail 同一契约。+ it('插件主视图与内置入口按保存顺序排列,面板恢复入口在其后、「更多」收尾', () => {+ expect(topNavSource).toContain('<GhostMainViewNavEntry item={app} variant="row" />');+ const scrollRowsIdx = topNavSource.indexOf('{orderedNavigationRows}');+ const scrollRestoreIdx = topNavSource.indexOf('{restoreRow}', scrollRowsIdx);+ const scrollMoreIdx = topNavSource.indexOf('{customizeRow}', scrollRestoreIdx);+ expect(scrollRowsIdx).toBeGreaterThanOrEqual(0);+ expect(scrollRestoreIdx).toBeGreaterThan(scrollRowsIdx);+ expect(scrollMoreIdx).toBeGreaterThan(scrollRestoreIdx);++ const persistentRowsIdx = topNavSource.lastIndexOf('orderedNavigationRows');+ const persistentRestoreIdx = topNavSource.indexOf(+ '!customizing && restoreRow',+ persistentRowsIdx,+ );+ const persistentMoreIdx = topNavSource.indexOf(+ '!customizing && customizeRow',+ persistentRestoreIdx,+ );+ expect(persistentRowsIdx).toBeGreaterThan(scrollRowsIdx);+ expect(persistentRestoreIdx).toBeGreaterThan(persistentRowsIdx);+ expect(persistentMoreIdx).toBeGreaterThan(persistentRestoreIdx);++ const railStart = topNavSource.indexOf('export function SidebarRailNavigation');+ const railTilesIdx = topNavSource.indexOf('variant="rail" />', railStart);+ const railRestoreIdx = topNavSource.indexOf(+ '<GhostPanelRestoreEntry variant="rail"',+ railTilesIdx,+ );+ const railMoreIdx = topNavSource.indexOf('<SidebarNavigationMoreMenu', railRestoreIdx);+ expect(railStart).toBeGreaterThanOrEqual(0);+ expect(railTilesIdx).toBeGreaterThan(railStart);+ expect(railRestoreIdx).toBeGreaterThan(railTilesIdx);+ expect(railMoreIdx).toBeGreaterThan(railRestoreIdx);});// 2026-08-12 用户反馈:滚动后首行紧贴固定的「新建」被硬切、露出半截字。diff --git a/apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx b/apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsxindex 49be80059d..7ca138e52f 100644--- a/apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx+++ b/apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx@@ -14,7 +14,7 @@ import {import { useTranslation } from 'react-i18next';import { useMatch, useNavigate } from 'react-router-dom';-import { useGhostMainViews } from '@/cindy-brain/ghostMainViews';+import { useGhostMainViews, type GhostMainViewItem } from '@/cindy-brain/ghostMainViews';import { cn } from '@/lib/utils';import type { GhostMainViewIcon } from '../../../shared/ghost';@@ -28,7 +28,7 @@ const ROW_ACTIVE_CLASS =const RAIL_ACTIVE_CLASS ='[--button-face-bg:var(--chat-input-chip-bg)] text-[var(--msg-assistant-text)] enabled:hover:[--button-face-bg:var(--chat-input-chip-bg)] enabled:active:[--button-face-bg:var(--chat-input-chip-bg)]';-const MAIN_VIEW_ICONS: Record<GhostMainViewIcon, LucideIcon> = {+export const MAIN_VIEW_ICONS: Record<GhostMainViewIcon, LucideIcon> = {puzzle: Puzzle,globe: Globe,code: Code,@@ -42,76 +42,82 @@ const MAIN_VIEW_ICONS: Record<GhostMainViewIcon, LucideIcon> = {/** Expanded and rail variants consume the exact same sorted visibility projection. */export function GhostMainViewNavEntries({ variant }: { variant: 'row' | 'rail' }) {+ const { sidebarVisible } = useGhostMainViews();+ return sidebarVisible.map((item) => (+ <GhostMainViewNavEntry key={item.ghostId} item={item} variant={variant} />+ ));+}++/** One plugin main-view entry; the sidebar navigation places it in the saved order. */+export function GhostMainViewNavEntry({+ item,+ variant,+}: {+ item: GhostMainViewItem;+ variant: 'row' | 'rail';+}) {const { t } = useTranslation();const navigate = useNavigate();const activeMatch = useMatch('/apps/:ghostId');- const activeGhostId = activeMatch?.params.ghostId;- const { sidebarVisible } = useGhostMainViews();-- return sidebarVisible.map((item) => {- const active = activeGhostId === item.ghostId;- const Icon = MAIN_VIEW_ICONS[item.icon];- const icon = (- <Icon- aria-hidden="true"- size={variant === 'row' ? 15 : 18}- strokeWidth={1.8}- className="shrink-0"- />- );- const open = () => navigate(`/apps/${encodeURIComponent(item.ghostId)}`);- const openDetails = () =>- navigate(`/settings?tab=ghosts&ghost=${encodeURIComponent(item.ghostId)}`);-- if (variant === 'rail') {- return (- <Tip key={item.ghostId} text={item.title} side="right">- <button- type="button"- aria-label={item.title}- aria-current={active ? 'page' : undefined}- onClick={open}- className={cn(SIDEBAR_RAIL_ICON_BUTTON_CLASS, active && RAIL_ACTIVE_CLASS)}- >- {icon}- </button>- </Tip>- );- }+ const active = activeMatch?.params.ghostId === item.ghostId;+ const Icon = MAIN_VIEW_ICONS[item.icon];+ const icon = (+ <Icon+ aria-hidden="true"+ size={variant === 'row' ? 15 : 18}+ strokeWidth={1.8}+ className="shrink-0"+ />+ );+ const open = () => navigate(`/apps/${encodeURIComponent(item.ghostId)}`);+ const openDetails = () =>+ navigate(`/settings?tab=ghosts&ghost=${encodeURIComponent(item.ghostId)}`);+ if (variant === 'rail') {return (- <div- key={item.ghostId}- className={cn(ROW_CLASS, 'group/main-view gap-0 px-0', active && ROW_ACTIVE_CLASS)}- >+ <Tip text={item.title} side="right"><buttontype="button"aria-label={item.title}- title={item.title}- data-native-title="truncated-text"aria-current={active ? 'page' : undefined}onClick={open}- className="flex min-w-0 flex-1 items-center gap-2.5 self-stretch rounded-full pl-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ className={cn(SIDEBAR_RAIL_ICON_BUTTON_CLASS, active && RAIL_ACTIVE_CLASS)}>{icon}- <span className="min-w-0 truncate leading-none">{item.title}</span></button>- <Tip text={t('settings.ghosts.page.manageAria', { name: item.manifest.name })} side="right">- <button- type="button"- onClick={openDetails}- aria-label={t('settings.ghosts.page.manageAria', { name: item.manifest.name })}- className={cn(- 'pointer-events-none mr-1.5 grid size-6 shrink-0 place-items-center rounded-full opacity-0 transition-[background-color,color,opacity] duration-150 focus-visible:pointer-events-auto focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] group-hover/main-view:pointer-events-auto group-hover/main-view:opacity-100 group-focus-within/main-view:pointer-events-auto group-focus-within/main-view:opacity-100',- active- ? 'text-sidebar-item-active-foreground hover:bg-[var(--sidebar-item-active-border)] hover:text-sidebar-item-active-foreground'- : 'text-[var(--sidebar-nav-text)] hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)]',- )}- >- <SlidersHorizontal size={14} aria-hidden="true" />- </button>- </Tip>- </div>+ </Tip>);- });+ }++ return (+ <div className={cn(ROW_CLASS, 'group/main-view gap-0 px-0', active && ROW_ACTIVE_CLASS)}>+ <button+ type="button"+ aria-label={item.title}+ title={item.title}+ data-native-title="truncated-text"+ aria-current={active ? 'page' : undefined}+ onClick={open}+ className="flex min-w-0 flex-1 items-center gap-2.5 self-stretch rounded-full pl-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ >+ {icon}+ <span className="min-w-0 truncate leading-none">{item.title}</span>+ </button>+ <Tip text={t('settings.ghosts.page.manageAria', { name: item.manifest.name })} side="right">+ <button+ type="button"+ onClick={openDetails}+ aria-label={t('settings.ghosts.page.manageAria', { name: item.manifest.name })}+ className={cn(+ 'pointer-events-none mr-1.5 grid size-6 shrink-0 place-items-center rounded-full opacity-0 transition-[background-color,color,opacity] duration-150 focus-visible:pointer-events-auto focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] group-hover/main-view:pointer-events-auto group-hover/main-view:opacity-100 group-focus-within/main-view:pointer-events-auto group-focus-within/main-view:opacity-100',+ active+ ? 'text-sidebar-item-active-foreground hover:bg-[var(--sidebar-item-active-border)] hover:text-sidebar-item-active-foreground'+ : 'text-[var(--sidebar-nav-text)] hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)]',+ )}+ >+ <SlidersHorizontal size={14} aria-hidden="true" />+ </button>+ </Tip>+ </div>+ );}diff --git a/apps/desktop/src/renderer/components/sidebar/Sidebar.tsx b/apps/desktop/src/renderer/components/sidebar/Sidebar.tsxindex 486382a4b1..a9a4b5ab42 100644--- a/apps/desktop/src/renderer/components/sidebar/Sidebar.tsx+++ b/apps/desktop/src/renderer/components/sidebar/Sidebar.tsx@@ -230,7 +230,8 @@ export function Sidebar({{/* 任务列表页把「新建」以外的行搬进自己的列表滚动区(向上滚一起滚走,对齐 Codex);此时这里只渲染固定的「新建」。其它视图仍整块渲染常驻行。 */}{isRail ? (- <SidebarTopNav section="rail" />+ // 任务视图的 rail 自己按导航偏好渲染全部入口;其它 Feature 只借伙伴图标。+ !ownsTopNavScrollableRows && <SidebarTopNav section="rail" />) : (<SidebarTopNav section={ownsTopNavScrollableRows ? 'pinned' : 'all'} />)}diff --git a/apps/desktop/src/renderer/components/sidebar/SidebarNavigationCustomize.tsx b/apps/desktop/src/renderer/components/sidebar/SidebarNavigationCustomize.tsxnew file mode 100644index 0000000000..71e70bae5d--- /dev/null+++ b/apps/desktop/src/renderer/components/sidebar/SidebarNavigationCustomize.tsx@@ -0,0 +1,271 @@+import { useState } from 'react';+import { Check, GripVertical, Puzzle } from 'lucide-react';+import { useTranslation } from 'react-i18next';++import { useGhostMainViews } from '@/cindy-brain/ghostMainViews';+import { useAuth } from '@/contexts/AuthContext';+import { useReducedMotion } from '@/hooks/useReducedMotion';+import { Button } from '@/components/ui/button';+import { Tip } from '@/components/ui/tooltip';+import { cn } from '@/lib/utils';++import { MAIN_VIEW_ICONS } from './GhostMainViewNavEntries';+import {+ DEFAULT_SIDEBAR_NAVIGATION_VISIBLE,+ SIDEBAR_NAVIGATION_ITEMS,+ SIDEBAR_NAVIGATION_ITEM_ICONS,+ appEntryId,+ getSidebarNavigationPrefs,+ ghostIdOfEntry,+ isBuiltInEntry,+ mergeAbsentOrderEntries,+ resolveSidebarNavigationOrder,+ setSidebarNavigationPrefs,+ type SidebarNavigationAppEntryId,+ type SidebarNavigationEntryId,+ type SidebarNavigationItemId,+ useSidebarNavigationPrefs,+} from './sidebarNavigationPrefs';+import { SortableList } from './SortableList';++interface SidebarNavigationCustomizeProps {+ onDone: () => void;+}++interface CustomizeDraft {+ order: SidebarNavigationEntryId[];+ /** Built-in entries shown at the top level. */+ visible: ReadonlySet<SidebarNavigationItemId>;+ /** Plugin main views placed at the top level; the rest sit in More (their default). */+ appsAtTop: ReadonlySet<SidebarNavigationAppEntryId>;+}++/**+ * 管理一级入口(含带主视图的插件)的勾选与顺序;草稿在“完成”时一次性提交,+ * 取消离开不会改偏好。勾选只决定入口在最外层还是收进「更多」;插件是否进侧边栏+ * 由插件自己的「在侧边栏显示」开关决定,关掉的插件不会出现在这里。+ */+export function SidebarNavigationCustomize({ onDone }: SidebarNavigationCustomizeProps) {+ const { t } = useTranslation();+ const { dataOwnerId } = useAuth();+ const prefs = useSidebarNavigationPrefs(dataOwnerId);+ const { sidebarVisible } = useGhostMainViews();+ const appIds = sidebarVisible.map((item) => item.ghostId);+ const apps = new Map(sidebarVisible.map((item) => [item.ghostId, item]));+ const [initial] = useState<CustomizeDraft>(() => ({+ order: resolveSidebarNavigationOrder(prefs.order, appIds),+ visible: new Set(prefs.visible),+ appsAtTop: new Set(prefs.appsAtTop),+ }));+ const [draft, setDraft] = useState<CustomizeDraft>(initial);+ const reducedMotion = useReducedMotion();+ const [resetting, setResetting] = useState(false);++ // Plugins switched on or off while the panel is open join or leave the list.+ const orderedItems = resolveSidebarNavigationOrder(draft.order, appIds);+ const checkedIn = (state: CustomizeDraft, id: SidebarNavigationEntryId) =>+ isBuiltInEntry(id)+ ? state.visible.has(id)+ : state.appsAtTop.has(id as SidebarNavigationAppEntryId);+ const isChecked = (id: SidebarNavigationEntryId) => checkedIn(draft, id);+ const labelFor = (id: SidebarNavigationEntryId) => {+ const ghostId = ghostIdOfEntry(id);+ return ghostId === null+ ? t('sidebar.navigation.items.' + id)+ : (apps.get(ghostId)?.title ?? ghostId);+ };+ // The same icon the entry shows in the sidebar, so each row is recognisable at a glance.+ const iconFor = (id: SidebarNavigationEntryId) => {+ const ghostId = ghostIdOfEntry(id);+ if (ghostId === null) return SIDEBAR_NAVIGATION_ITEM_ICONS[id as SidebarNavigationItemId];+ const app = apps.get(ghostId);+ return app ? MAIN_VIEW_ICONS[app.icon] : Puzzle;+ };+ const toggle = (id: SidebarNavigationEntryId) => {+ setDraft((current) => {+ if (isBuiltInEntry(id)) {+ const visible = new Set(current.visible);+ if (visible.has(id)) visible.delete(id);+ else visible.add(id);+ return { ...current, visible };+ }+ const appId = id as SidebarNavigationAppEntryId;+ const appsAtTop = new Set(current.appsAtTop);+ if (appsAtTop.has(appId)) appsAtTop.delete(appId);+ else appsAtTop.add(appId);+ return { ...current, appsAtTop };+ });+ };+ const move = (source: SidebarNavigationEntryId, target: SidebarNavigationEntryId) => {+ if (source === target) return;+ setDraft((current) => {+ const order = resolveSidebarNavigationOrder(current.order, appIds);+ const sourceIndex = order.indexOf(source);+ const targetIndex = order.indexOf(target);+ if (sourceIndex < 0 || targetIndex < 0) return current;+ const next = order.filter((id) => id !== source);+ // Downward drops go after the target; upward drops go before it.+ next.splice(targetIndex, 0, source);+ return { ...current, order: next };+ });+ };+ const moveBy = (id: SidebarNavigationEntryId, direction: -1 | 1) => {+ const index = orderedItems.indexOf(id);+ const target = orderedItems[index + direction];+ if (target) move(id, target);+ };+ const save = () => {+ if (resetting) {+ // Resetting drops every override, so future defaults keep applying: plugins fall+ // back to More, including ones whose own sidebar switch is off right now. Only+ // entries checked again after resetting are kept at the top level.+ // A reorder made after resetting is kept; an untouched reset stores the bare default.+ const resetOrder = resolveSidebarNavigationOrder(SIDEBAR_NAVIGATION_ITEMS, appIds);+ const reordered = orderedItems.some((id, index) => id !== resetOrder[index]);+ setSidebarNavigationPrefs(dataOwnerId, {+ order: reordered ? orderedItems : [...SIDEBAR_NAVIGATION_ITEMS],+ visible: SIDEBAR_NAVIGATION_ITEMS.filter((id) => draft.visible.has(id)),+ appsAtTop: [...draft.appsAtTop],+ });+ onDone();+ return;+ }+ // Preserve edits made in another window while this draft was open: only entries+ // toggled here override the latest saved state.+ const latest = getSidebarNavigationPrefs(dataOwnerId);+ const latestState: CustomizeDraft = {+ order: latest.order,+ visible: new Set(latest.visible),+ appsAtTop: new Set(latest.appsAtTop),+ };+ const resolve = (id: SidebarNavigationEntryId) =>+ checkedIn(draft, id) !== checkedIn(initial, id)+ ? checkedIn(draft, id)+ : checkedIn(latestState, id);+ // Only a drag or arrow move replaces the order; plugins switching on or off in the+ // meantime merely change which entries are listed.+ const orderChanged = draft.order !== initial.order;+ // Plugins absent from the panel (sidebar switch off) keep whatever was saved for them.+ const appEntries = new Set<SidebarNavigationAppEntryId>([+ ...latest.appsAtTop,+ ...appIds.map(appEntryId),+ ]);+ setSidebarNavigationPrefs(dataOwnerId, {+ // Plugins missing from the panel keep their saved place inside the new order.+ order: orderChanged ? mergeAbsentOrderEntries(orderedItems, latest.order) : latest.order,+ visible: SIDEBAR_NAVIGATION_ITEMS.filter(resolve),+ appsAtTop: [...appEntries].filter(resolve),+ });+ onDone();+ };++ return (+ <div+ role="dialog"+ aria-label={t('sidebar.navigation.customize.title')}+ className="mx-2 mb-2 rounded-xl border border-sidebar-border bg-[var(--surface-elevated)] p-3 shadow-[shadow:var(--shadow-menu)]"+ >+ <div className="mb-2 flex items-center justify-between gap-2 px-1">+ <h2 className="text-sm font-medium text-[var(--text-primary)]">+ {t('sidebar.navigation.customize.title')}+ </h2>+ <Button variant="primary" size="sm" compact onClick={save}>+ {t('sidebar.navigation.customize.done')}+ </Button>+ </div>+ {/* Pointer-driven sort shared with the sidebar lists: the whole row floats with+ the cursor and the others make room live, so the drop position is visible. */}+ <SortableList+ items={orderedItems}+ getId={(id) => id}+ onReorder={(ids) =>+ setDraft((current) => ({+ ...current,+ order: ids as SidebarNavigationEntryId[],+ }))+ }+ reducedMotion={reducedMotion}+ // Rows drag from their label or handle; only the checkbox stays a plain click.+ filter="[role='checkbox']"+ className="flex flex-col gap-0.5"+ renderItem={(id) => {+ const visible = isChecked(id);+ const Icon = iconFor(id);+ return (+ // The whole row toggles; the checkbox stays the focusable control, and its+ // keyboard activation bubbles here as the same click.+ <div+ onClick={() => toggle(id)}+ className="group/nav-entry flex h-9 cursor-pointer items-center gap-2 rounded-lg px-1 hover:bg-sidebar-item-hover"+ >+ <button+ type="button"+ role="checkbox"+ aria-checked={visible}+ aria-label={labelFor(id)}+ // Same round selection mark as ShareMessageCheckbox: inverse fill when+ // checked, a neutral outline otherwise. Blue stays reserved for focus.+ className={cn(+ 'grid size-5 shrink-0 place-items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ visible+ ? 'bg-[var(--accent-cta-bg-pure)] text-[var(--accent-pure-cta-fg)]'+ : 'border border-[var(--border-default)] group-hover/nav-entry:border-[var(--text-secondary)]',+ )}+ >+ {visible && <Check size={12} strokeWidth={2.5} aria-hidden />}+ </button>+ <Icon+ aria-hidden="true"+ size={15}+ strokeWidth={1.8}+ className="shrink-0 text-[var(--sidebar-nav-text)]"+ />+ <span className="min-w-0 flex-1 truncate text-sm text-[var(--text-primary)]">+ {labelFor(id)}+ </span>+ <Tip+ text={t('sidebar.navigation.customize.reorder', { name: labelFor(id) })}+ side="right"+ >+ <button+ type="button"+ aria-label={t('sidebar.navigation.customize.reorder', { name: labelFor(id) })}+ aria-keyshortcuts="ArrowUp ArrowDown"+ // The handle is for dragging and arrow-key moves, not for toggling.+ onClick={(event) => event.stopPropagation()}+ onKeyDown={(event) => {+ if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {+ event.preventDefault();+ moveBy(id, event.key === 'ArrowUp' ? -1 : 1);+ }+ }}+ className="grid size-7 shrink-0 cursor-grab place-items-center rounded-lg text-[var(--text-tertiary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ >+ <GripVertical aria-hidden="true" size={16} />+ </button>+ </Tip>+ </div>+ );+ }}+ />+ <Button+ variant="primary"+ tone="quiet"+ size="sm"+ compact+ className="mt-2"+ onClick={() => {+ setDraft({+ order: resolveSidebarNavigationOrder(SIDEBAR_NAVIGATION_ITEMS, appIds),+ visible: new Set(DEFAULT_SIDEBAR_NAVIGATION_VISIBLE),+ // Plugins default to More, the same place a newly arrived plugin starts.+ appsAtTop: new Set(),+ });+ setResetting(true);+ }}+ >+ {t('sidebar.navigation.customize.reset')}+ </Button>+ </div>+ );+}diff --git a/apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx b/apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsxindex 9099af2013..8863a4981c 100644--- a/apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx+++ b/apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx@@ -1,10 +1,9 @@-import { useNavigationAttention } from '@/lib/navigationAttentionStore';-import { NavigationCountBadge } from '@/components/sidebar/NavigationCountBadge';/*** SidebarTopNav —— 侧栏顶部常驻动作/导航列表(取代原 HorizontalTabbar)。* ---------------------------------------------------------------------------- * 一条同级、等权的列表行,按顺序:新建 / 自动任务 / Plugins / 伙伴 /- * 最小化插件面板恢复入口(按需) / 搜索。+ * 一条同级、等权的列表行:新建固定;自动任务 / Plugins / 伙伴 / 搜索与带主视图的插件+ * 按用户偏好排序与显示(插件的显隐沿用其「在侧边栏显示」开关);未勾选的进「更多」。+ * 最小化插件面板恢复入口仍按需出现。* - 新建 / 自动任务:项目(cc-agent)视图的动作 —— 在任意视图点击都跳回项目视图并执行。* - Plugins:主视图切换(navigateToView),命中当前视图时高亮。* - 伙伴:原位切换为「返回任务」动作,随目标更换文案和图标,不显示选中高亮。@@ -14,40 +13,81 @@ import { NavigationCountBadge } from '@/components/sidebar/NavigationCountBadge'* - 远程机器切换 2026-08-13 起不再占行:并入主列表段头标题(「全部任务」即* 范围下拉,见 MachineSwitcherMenu 头注),省一行且标题不再与范围脱节。* 去掉了原来的「项目(Bot)」标签 —— 项目即默认主视图,无单独入口。- * rail 态的搜索仍是 CollapsedView 里独立的 ConversationSearchBox 图标弹窗(不走本行 / context)。+ * rail 态由 SidebarRailNavigation 渲染同一套偏好(顺序 / 显示 / 「更多」);搜索仍是+ * CollapsedView 提供的 ConversationSearchBox 图标弹窗(不走本行 / context)。** 与 Shell"不感知路由"的原则:本组件是原 HorizontalTabbar 的同位替代,封装了* 自身的路由 / cc-agent 数据,Shell 仍只负责把它渲染在顶行(见 Sidebar.tsx)。*- * rail(收窄)态不渲染本组件(同 HorizontalTabbar,仅 !isRail 时显示)。+ * rail(收窄)态:任务视图用 SidebarRailNavigation;其它 Feature 的 rail 只由+ * section="rail" 补一个伙伴入口。*/-import { useCallback } from 'react';-import { ArrowLeft, Bot, CirclePlus, Plug, Timer } from 'lucide-react';+import { Fragment, useCallback, useEffect, useRef, useState } from 'react';+import {+ ArrowLeft,+ CirclePlus,+ Ellipsis,+ SlidersHorizontal,+ type LucideIcon,+} from 'lucide-react';import { useLocation, useNavigate, useMatch } from 'react-router-dom';import { useTranslation } from 'react-i18next';import { cn } from '@/lib/utils';+import { useNavigationAttention } from '@/lib/navigationAttentionStore';+import { NavigationCountBadge } from '@/components/sidebar/NavigationCountBadge';+import { useAuth } from '@/contexts/AuthContext';import { AttentionDot } from '@/components/sidebar/AttentionDot';import { useAnyGhostUnread } from '@/cindy-brain/ghostUnreadStore';+import { useGhostMainViews, type GhostMainViewItem } from '@/cindy-brain/ghostMainViews';+import { useInstalledGhosts } from '@/cindy-brain/useInstalledGhosts';import { GhostPanelRestoreEntry } from '@/cindy-brain/GhostPanelRestoreEntry';import { useActiveMainView } from '@/hooks/useActiveMainView';import { SidebarInlineSearch } from '@/features/cc-agent/sidebar/SidebarInlineSearch';-import { SidebarIconButton } from './SidebarIconButton';+import { SidebarIconButton, SIDEBAR_RAIL_ICON_BUTTON_CLASS } from './SidebarIconButton';+import { Tip } from '@/components/ui/tooltip';import { useConversationSearchContext } from '@/features/cc-agent/sidebar/conversationSearchContext';-import { GhostMainViewNavEntries } from './GhostMainViewNavEntries';+import { GhostMainViewNavEntry, MAIN_VIEW_ICONS } from './GhostMainViewNavEntries';import { makeGenericNewMakerRouteState } from '@/features/cc-agent/lib/genericNewMakerRouteState';+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';+import { SidebarNavigationCustomize } from './SidebarNavigationCustomize';+import {+ SIDEBAR_NAVIGATION_ITEM_ICONS,+ ghostIdOfEntry,+ isBuiltInEntry,+ markSidebarAppArrivalsSeen,+ reconcileSidebarAppArrivals,+ resolveSidebarNavigationOrder,+ useSidebarNavigationPrefs,+ useSidebarUnseenApps,+ type SidebarNavigationAppEntryId,+ type SidebarNavigationEntryId,+ type SidebarNavigationItemId,+} from './sidebarNavigationPrefs';/** 列表行通用样式 —— 各行同款 pill 行。 */const ROW_CLASS ='flex h-8 w-full items-center gap-2.5 rounded-full px-3 text-sm font-normal text-[var(--sidebar-nav-text)] transition-colors hover:bg-sidebar-item-hover';-/** 命中当前视图(自动任务 / Plugin 与 Skill 管理 / issue)时的高亮 —— 与下方会话列表+/** 命中当前视图(自动任务 / Plugin 与 Skill 管理)时的高亮 —— 与下方会话列表* 选中行同款反相胶囊(sidebar-item-active 族;2026-07-21 用户裁决,替代原 chat-input-chip* 灰 chip,顶部导航选中态与对话选中样式统一)。hover:bg-sidebar-item-active 抵消* ROW_CLASS 的半透明 hover(cn/twMerge last-wins),避免选中胶囊 hover 时闪回半透明。 */const ROW_ACTIVE_CLASS ='bg-sidebar-item-active font-medium text-sidebar-item-active-foreground shadow-[inset_0_0_0_1px_var(--sidebar-item-active-border)] hover:bg-sidebar-item-active';+// Native window dragging ignores a portal's z-index. Keep both menu surfaces+// below the 46px titlebar / 50px invisible drag strip, including collision shifts.+const NAV_MENU_COLLISION_PADDING = { top: 58, right: 8, bottom: 8, left: 8 };+const NAV_MENU_CLASS =+ 'min-w-[172px] max-h-[var(--radix-dropdown-menu-content-available-height)] overflow-y-auto';+/*** 渲染范围。任务列表页把「新建」以外的行搬进列表滚动区(向上滚时一起滚走,* 对齐 Codex;2026-08-12 用户裁决),因此本组件要能分两段渲染:@@ -59,21 +99,367 @@ const ROW_ACTIVE_CLASS =*/export type SidebarTopNavSection = 'all' | 'pinned' | 'scrollable' | 'rail';+export interface SidebarNavigationAction {+ label: string;+ icon: LucideIcon;+ onSelect: () => void;+ active: boolean;+ showDot: boolean;+ /** Attention count shown at the entry's end (99+ overflow), with its spoken label. */+ count?: { value: number; label: string };+}++function EntryCountBadge({ count, className }: { count?: SidebarNavigationAction['count']; className?: string }) {+ return count ? <NavigationCountBadge count={count.value} label={count.label} className={className} /> : null;+}++/** One definition per built-in entry, shared by the rows, the rail and More. */+function useSidebarNavigationActions(+ openSearch: () => void,+): Record<SidebarNavigationItemId, SidebarNavigationAction> {+ const { t } = useTranslation();+ const navigate = useNavigate();+ const location = useLocation();+ const { activeKey, navigateToView } = useActiveMainView();+ const onScheduleMatch = useMatch('/cc-agent/scheduled');+ // 任一插件有未读 → 入口行尾一颗**静态**绿点(聚合入口按 AttentionDot 规范不呼吸,+ // 呼吸留给单条卡片;见 AttentionDot 头部的形态规范)。+ const hasGhostUnread = useAnyGhostUnread();+ // `activeKey` is intentionally sticky for the other navigation rows, but this+ // action must describe the actual destination. Settings and other auxiliary+ // routes should continue to offer entry to Teammates, not a stale return.+ const isBotsView = isBotsPath(location.pathname);+ // The teammate entry counts what waits at its destination: unread teammate+ // messages, or tasks needing attention once it has become "back to tasks".+ const navigationCounts = useNavigationAttention();+ const botsCount = isBotsView ? navigationCounts.tasks : navigationCounts.teammates;+ return {+ automations: {+ label: t('ccAgent.layout.automations'),+ icon: SIDEBAR_NAVIGATION_ITEM_ICONS.automations,+ onSelect: () => navigate('/cc-agent/scheduled'),+ active: Boolean(onScheduleMatch),+ showDot: false,+ },+ plugins: {+ label: t('sidebar.tabs.plugins'),+ icon: SIDEBAR_NAVIGATION_ITEM_ICONS.plugins,+ onSelect: () => navigateToView('plugins'),+ active: activeKey === 'plugins',+ showDot: hasGhostUnread,+ },+ bots: {+ label: t(isBotsView ? 'sidebar.backToSessions' : 'sidebar.tabs.bots'),+ icon: isBotsView ? ArrowLeft : SIDEBAR_NAVIGATION_ITEM_ICONS.bots,+ onSelect: () => navigateToView(isBotsView ? 'cc-agent' : 'bots'),+ active: false,+ showDot: false,+ count: {+ value: botsCount,+ label: t(isBotsView ? 'sidebar.taskAttentionCount' : 'sidebar.teammateUnreadCount', { count: botsCount }),+ },+ },+ search: {+ label: t('sidebar.navigation.items.search'),+ icon: SIDEBAR_NAVIGATION_ITEM_ICONS.search,+ onSelect: openSearch,+ active: false,+ showDot: false,+ },+ };+}++function isBotsPath(pathname: string): boolean {+ return pathname === '/bots' || pathname.startsWith('/bots/');+}++/**+ * Built-in entries and plugin main views in one saved order. A plugin takes part+ * only while its own "show in sidebar" switch is on; Customize then decides whether+ * it sits at the top level or in More, like the built-ins.+ */+function useSidebarNavigationEntries(): {+ order: SidebarNavigationEntryId[];+ hidden: SidebarNavigationEntryId[];+ isVisible: (id: SidebarNavigationEntryId) => boolean;+ appFor: (id: SidebarNavigationEntryId) => GhostMainViewItem | undefined;+ /** Plugin entries that just arrived in More and have not been looked at. */+ unseen: ReadonlySet<SidebarNavigationEntryId>;+ markSeen: () => void;+} {+ const { dataOwnerId } = useAuth();+ const prefs = useSidebarNavigationPrefs(dataOwnerId);+ const { sidebarVisible } = useGhostMainViews();+ const rosterReady = useInstalledGhosts().length > 0;+ const sidebarGhostIds = sidebarVisible.map((item) => item.ghostId).join('\n');+ // Plugins entering the sidebar for the first time start in More, flagged as new.+ // Wait for the account and its installed roster: both are per data owner.+ useEffect(() => {+ if (dataOwnerId) {+ reconcileSidebarAppArrivals(+ dataOwnerId,+ sidebarGhostIds ? sidebarGhostIds.split('\n') : [],+ rosterReady,+ );+ }+ }, [dataOwnerId, sidebarGhostIds, rosterReady]);+ const unseenGhostIds = useSidebarUnseenApps(dataOwnerId);+ const apps = new Map(sidebarVisible.map((item) => [item.ghostId, item]));+ const order = resolveSidebarNavigationOrder(prefs.order, sidebarVisible.map((item) => item.ghostId));+ const isVisible = (id: SidebarNavigationEntryId) => ghostIdOfEntry(id) === null+ ? prefs.visible.includes(id as SidebarNavigationItemId)+ : prefs.appsAtTop.includes(id as SidebarNavigationAppEntryId);+ const appFor = (id: SidebarNavigationEntryId) => {+ const ghostId = ghostIdOfEntry(id);+ return ghostId === null ? undefined : apps.get(ghostId);+ };+ const hidden = order.filter((id) => !isVisible(id));+ const unseen = new Set(hidden.filter((id) => {+ const ghostId = ghostIdOfEntry(id);+ return ghostId !== null && unseenGhostIds.includes(ghostId);+ }));+ const markSeen = () => {+ if (dataOwnerId) markSidebarAppArrivalsSeen(dataOwnerId);+ };+ return { order, hidden, isVisible, appFor, unseen, markSeen };+}++/** Quiet grayscale tag for entries that just joined More. */+function NewTag({ className }: { className?: string }) {+ const { t } = useTranslation();+ return (+ <span+ className={cn(+ 'shrink-0 rounded-full bg-[var(--surface-chip)] px-1.5 py-px text-10 font-medium leading-4 text-[var(--text-primary)]',+ className,+ )}+ >+ {t('sidebar.navigation.new')}+ </span>+ );+}++/** Unchecked entries and (when there is room) the customize panel; empty menus render nothing. */+function SidebarNavigationMoreMenu({+ trigger,+ hiddenIds,+ actions,+ appFor,+ unseen,+ onSeen,+ onCustomize,+ onCloseAutoFocus,+}: {+ trigger: React.ReactNode;+ hiddenIds: readonly SidebarNavigationEntryId[];+ actions: Record<SidebarNavigationItemId, SidebarNavigationAction>;+ appFor: (id: SidebarNavigationEntryId) => GhostMainViewItem | undefined;+ unseen: ReadonlySet<SidebarNavigationEntryId>;+ /** Called when the menu closes after showing new entries. */+ onSeen: () => void;+ onCustomize?: () => void;+ onCloseAutoFocus?: (event: Event) => void;+}) {+ const { t } = useTranslation();+ const navigate = useNavigate();+ // A press on a plugin item's manage button reaches the item's own select next;+ // this flag routes that one selection to the plugin details instead of its page.+ const openDetailsRef = useRef(false);+ if (hiddenIds.length === 0 && !onCustomize) return null;+ return (+ // New entries keep their tag while the menu is open, then count as seen.+ <DropdownMenu onOpenChange={(open) => { if (!open && unseen.size > 0) onSeen(); }}>+ <DropdownMenuTrigger asChild>{trigger}</DropdownMenuTrigger>+ <DropdownMenuContent+ side="right"+ align="start"+ sideOffset={8}+ collisionPadding={NAV_MENU_COLLISION_PADDING}+ className={NAV_MENU_CLASS}+ onCloseAutoFocus={onCloseAutoFocus}+ >+ {hiddenIds.map((id) => {+ const app = appFor(id);+ if (app) {+ const AppIcon = MAIN_VIEW_ICONS[app.icon];+ const manageLabel = t('settings.ghosts.page.manageAria', { name: app.manifest.name });+ const ghostId = encodeURIComponent(app.ghostId);+ return (+ <DropdownMenuItem+ key={id}+ onSelect={() => {+ const openDetails = openDetailsRef.current;+ openDetailsRef.current = false;+ navigate(openDetails ? `/settings?tab=ghosts&ghost=${ghostId}` : `/apps/${ghostId}`);+ }}+ className="group/more-app gap-2.5"+ >+ <AppIcon size={16} strokeWidth={1.8} />+ <span className="min-w-0 flex-1 truncate">{app.title}</span>+ {unseen.has(id) && <NewTag />}+ {/* Same manage action as the plugin's sidebar row, revealed with the item. */}+ <Tip text={manageLabel} side="right">+ <button+ type="button"+ tabIndex={-1}+ aria-label={manageLabel}+ onClick={() => {+ openDetailsRef.current = true;+ }}+ className="-mr-1 grid size-6 shrink-0 place-items-center rounded-full text-[var(--text-secondary)] opacity-0 transition-[background-color,color,opacity] duration-150 hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)] group-data-[highlighted]/more-app:opacity-100"+ >+ <SlidersHorizontal size={14} aria-hidden="true" />+ </button>+ </Tip>+ </DropdownMenuItem>+ );+ }+ const action = isBuiltInEntry(id) ? actions[id] : null;+ if (!action) return null;+ const Icon = action.icon;+ return (+ <DropdownMenuItem key={id} onSelect={action.onSelect} className="gap-2.5">+ <Icon size={16} strokeWidth={1.8} />+ {action.label}+ {action.showDot && <AttentionDot size={6} className="ml-auto" />}+ <EntryCountBadge count={action.count} className="ml-auto" />+ </DropdownMenuItem>+ );+ })}+ {onCustomize && (+ <>+ {hiddenIds.length > 0 && <DropdownMenuSeparator />}+ <DropdownMenuItem onSelect={onCustomize} className="gap-2.5">+ <SlidersHorizontal size={16} strokeWidth={1.8} />+ {t('sidebar.navigation.customize.title')}+ </DropdownMenuItem>+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ );+}++export interface SidebarRailSearchOptions {+ /** Open on mount: a hidden Search was chosen from More. */+ defaultOpen: boolean;+ onOpenChange: (open: boolean) => void;+}++/**+ * 任务视图 rail 的导航段:与展开态同一份偏好 —— 勾选项(含插件主视图)按保存顺序+ * 成图标,其后是面板恢复入口,最后「更多」收纳未勾选项。+ * 搜索图标由调用方提供(依赖任务列表的数据),这里只决定它的位置与显隐。+ */+export function SidebarRailNavigation({+ renderSearch,+ forceSearch = false,+}: {+ renderSearch: (options: SidebarRailSearchOptions) => React.ReactNode;+ /** A project-scoped search request needs the tile even while Search is unchecked. */+ forceSearch?: boolean;+}): React.ReactElement {+ const { t } = useTranslation();+ const entries = useSidebarNavigationEntries();+ const [searchOpen, setSearchOpen] = useState(false);+ const [openSearchOnMount, setOpenSearchOnMount] = useState(false);+ const pendingSearchRef = useRef(false);+ // Open after More has closed: its focus return would otherwise dismiss the popover.+ const actions = useSidebarNavigationActions(() => {+ pendingSearchRef.current = true;+ });+ const handleMoreCloseAutoFocus = (event: Event) => {+ if (!pendingSearchRef.current) return;+ pendingSearchRef.current = false;+ event.preventDefault();+ setOpenSearchOnMount(true);+ setSearchOpen(true);+ };+ const handleSearchOpenChange = (open: boolean) => {+ setSearchOpen(open);+ if (!open) setOpenSearchOnMount(false);+ };+ const showSearch = entries.isVisible('search') || forceSearch || searchOpen;+ const tiles = entries.order.filter((id) => entries.isVisible(id) || (id === 'search' && showSearch));++ return (+ <>+ {tiles.map((id) => {+ const app = entries.appFor(id);+ if (app) return <GhostMainViewNavEntry key={id} item={app} variant="rail" />;+ if (id === 'search') {+ return (+ <Fragment key={id}>+ {renderSearch({ defaultOpen: openSearchOnMount, onOpenChange: handleSearchOpenChange })}+ </Fragment>+ );+ }+ if (!isBuiltInEntry(id)) return null;+ const action = actions[id];+ return (+ <SidebarIconButton+ key={id}+ icon={action.icon}+ label={action.label}+ active={action.active}+ aria-current={action.active ? 'page' : undefined}+ aria-description={action.count?.value ? action.count.label : undefined}+ showDot={action.showDot}+ badge={<EntryCountBadge count={action.count} />}+ onClick={action.onSelect}+ />+ );+ })}+ <GhostPanelRestoreEntry variant="rail" className={SIDEBAR_RAIL_ICON_BUTTON_CLASS} />+ <SidebarNavigationMoreMenu+ hiddenIds={entries.hidden}+ actions={actions}+ appFor={entries.appFor}+ unseen={entries.unseen}+ onSeen={entries.markSeen}+ onCloseAutoFocus={handleMoreCloseAutoFocus}+ trigger={+ <Tip text={t('sidebar.navigation.more')} side="right">+ <button+ type="button"+ className={cn(SIDEBAR_RAIL_ICON_BUTTON_CLASS, 'relative')}+ aria-label={entries.unseen.size > 0+ ? `${t('sidebar.navigation.more')} · ${t('sidebar.navigation.new')}`+ : t('sidebar.navigation.more')}+ >+ <Ellipsis size={18} />+ {/* The rail has no room for the tag; a static dot marks new entries. */}+ {entries.unseen.size > 0 && (+ <AttentionDot size={6} className="absolute right-1.5 top-1.5" />+ )}+ </button>+ </Tip>+ }+ />+ </>+ );+}+export function SidebarTopNav({section = 'all',}: {section?: SidebarTopNavSection;} = {}): React.ReactElement {const { t } = useTranslation();- const navigationCounts = useNavigationAttention();const navigate = useNavigate();const location = useLocation();- const { activeKey, navigateToView } = useActiveMainView();- const onScheduleMatch = useMatch('/cc-agent/scheduled');+ const { navigateToView } = useActiveMainView();const { search, allKnownProjects, openSignal } = useConversationSearchContext();- // 任一插件有未读 → 入口行尾一颗**静态**绿点(聚合入口按 AttentionDot 规范不呼吸,- // 呼吸留给单条卡片;见 AttentionDot 头部的形态规范)。- const hasGhostUnread = useAnyGhostUnread();+ const { dataOwnerId } = useAuth();+ const navigationPrefs = useSidebarNavigationPrefs(dataOwnerId);+ const entries = useSidebarNavigationEntries();+ const [customizing, setCustomizing] = useState(false);+ const [showHiddenSearch, setShowHiddenSearch] = useState(false);+ const [searchOpenSignal, setSearchOpenSignal] = useState(0);+ const actions = useSidebarNavigationActions(() => {+ setShowHiddenSearch(true);+ setSearchOpenSignal((signal) => signal + 1);+ });// 通用新建继承当前任务的电脑,由草稿页集中迁移;同机保留已选项目。const handleNew = () => {@@ -87,90 +473,51 @@ export function SidebarTopNav({const showPinned = section !== 'scrollable' && section !== 'rail';const showScrollable = section !== 'pinned' && section !== 'rail';const pinSearch = section === 'scrollable' && search.query.trim().length > 0;- const automationsRow = showScrollable ? (- <button- onClick={() => navigate('/cc-agent/scheduled')}- className={cn(ROW_CLASS, onScheduleMatch && ROW_ACTIVE_CLASS)}- aria-label={t('ccAgent.layout.automations')}- aria-current={onScheduleMatch ? 'page' : undefined}- >- <Timer- size={15}- strokeWidth={1.8}- className={cn(- 'shrink-0',- // 选中反相胶囊上图标跟随 active 前景(图标自带显式色,行级 text 覆盖不到它)。- onScheduleMatch- ? 'text-sidebar-item-active-foreground'- : 'text-[var(--sidebar-nav-text)]',- )}- />- <span className="leading-none">{t('ccAgent.layout.automations')}</span>- </button>- ) : null;- const pluginsRow = showScrollable ? (- <button- onClick={() => navigateToView('plugins')}- className={cn(ROW_CLASS, activeKey === 'plugins' && ROW_ACTIVE_CLASS)}- aria-label={t('sidebar.tabs.plugins')}- aria-current={activeKey === 'plugins' ? 'page' : undefined}- >- <Plug- size={15}- strokeWidth={1.8}- className={cn(- 'shrink-0',- // 同上:选中反相胶囊上图标跟随 active 前景。- activeKey === 'plugins'- ? 'text-sidebar-item-active-foreground'- : 'text-[var(--sidebar-nav-text)]',- )}- />- <span className="leading-none">{t('sidebar.tabs.plugins')}</span>- {hasGhostUnread && <AttentionDot size={6} className="ml-auto mr-0.5" />}- </button>- ) : null;- // `activeKey` is intentionally sticky for the other navigation rows, but this- // action must describe the actual destination. Settings and other auxiliary- // routes should continue to offer entry to Teammates, not a stale return.- const isBotsView = location.pathname === '/bots' || location.pathname.startsWith('/bots/');- const botsActionLabel = t(isBotsView ? 'sidebar.backToSessions' : 'sidebar.tabs.bots');- const badgeCount = isBotsView ? navigationCounts.tasks : navigationCounts.teammates;- const badgeLabel = t(isBotsView ? 'sidebar.taskAttentionCount' : 'sidebar.teammateUnreadCount', { count: badgeCount });- const BotsActionIcon = isBotsView ? ArrowLeft : Bot;- const botsRow = showScrollable ? (- <button- onClick={() => navigateToView(isBotsView ? 'cc-agent' : 'bots')}- className={ROW_CLASS}- aria-label={botsActionLabel}- aria-description={badgeCount > 0 ? badgeLabel : undefined}- >- <BotsActionIcon- size={15}- strokeWidth={1.8}- className="shrink-0 text-[var(--sidebar-nav-text)]"- />- <span className="leading-none">{botsActionLabel}</span>- <NavigationCountBadge count={badgeCount} label={badgeLabel} className="ml-auto" />- </button>- ) : null;if (section === 'rail') {- // The bots feature owns the rail tile while its route is active. Reuse- // that tile for the return action instead of rendering a duplicate here.- if (isBotsView) return <></>;+ // Other features' rails only borrow the teammate tile; the task rail renders+ // the full navigation itself. The bots feature owns the tile on its route.+ const bots = actions.bots;+ if (isBotsPath(location.pathname) || !navigationPrefs.visible.includes('bots')) return <></>;return (<div className="flex shrink-0 justify-center px-2 pt-2 pb-1"><SidebarIconButton- icon={BotsActionIcon}- label={botsActionLabel}- aria-description={badgeCount > 0 ? badgeLabel : undefined}- badge={<NavigationCountBadge count={badgeCount} label={badgeLabel} />}- onClick={() => navigateToView(isBotsView ? 'cc-agent' : 'bots')}+ icon={bots.icon}+ label={bots.label}+ aria-description={bots.count?.value ? bots.count.label : undefined}+ badge={<EntryCountBadge count={bots.count} />}+ onClick={bots.onSelect}/></div>);}- const mainViewRows = showScrollable ? <GhostMainViewNavEntries variant="row" /> : null;+ const renderActionRow = (id: Exclude<SidebarNavigationItemId, 'search'>) => {+ const action = actions[id];+ const Icon = action.icon;+ return (+ <button+ onClick={action.onSelect}+ className={cn(ROW_CLASS, action.active && ROW_ACTIVE_CLASS)}+ aria-label={action.label}+ aria-current={action.active ? 'page' : undefined}+ aria-description={action.count?.value ? action.count.label : undefined}+ >+ <Icon+ size={15}+ strokeWidth={1.8}+ className={cn(+ 'shrink-0',+ // 选中反相胶囊上图标跟随 active 前景(图标自带显式色,行级 text 覆盖不到它)。+ action.active+ ? 'text-sidebar-item-active-foreground'+ : 'text-[var(--sidebar-nav-text)]',+ )}+ />+ <span className="leading-none">{action.label}</span>+ {action.showDot && <AttentionDot size={6} className="ml-auto mr-0.5" />}+ <EntryCountBadge count={action.count} className="ml-auto" />+ </button>+ );+ };const restoreRow = showScrollable ? (<GhostPanelRestoreEntry variant="row" className={ROW_CLASS} />) : null;@@ -178,36 +525,106 @@ export function SidebarTopNav({<SidebarInlineSearchsearch={search}allKnownProjects={allKnownProjects}- openSignal={openSignal}+ openSignal={openSignal + searchOpenSignal}onSearchActive={ensureConversationView}+ onFocusLeave={() => setShowHiddenSearch(false)}+ />+ ) : null;+ const rowFor = (id: SidebarNavigationEntryId): React.ReactNode => {+ if (!showScrollable) return null;+ const app = entries.appFor(id);+ if (app) return <GhostMainViewNavEntry item={app} variant="row" />;+ if (id === 'search') return searchRow;+ return isBuiltInEntry(id) ? renderActionRow(id) : null;+ };+ // A running query or a locked project search keeps its input reachable even+ // when the navigation entry is hidden in preferences.+ const showSearch = entries.isVisible('search') || showHiddenSearch ||+ search.query.length > 0 || Boolean(search.lockedProjectKey);+ const orderedIds = entries.order.filter((id) =>+ entries.isVisible(id) || (id === 'search' && showSearch),+ );+ const renderRows = (ids: readonly SidebarNavigationEntryId[]) => ids+ .map((id) => <Fragment key={id}>{rowFor(id)}</Fragment>);+ const orderedNavigationRows = renderRows(orderedIds);+ const customizeRow = showScrollable ? (+ <SidebarNavigationMoreMenu+ hiddenIds={entries.hidden}+ actions={actions}+ appFor={entries.appFor}+ unseen={entries.unseen}+ onSeen={entries.markSeen}+ onCustomize={() => setCustomizing(true)}+ trigger={+ <button+ type="button"+ className={ROW_CLASS}+ aria-label={entries.unseen.size > 0+ ? `${t('sidebar.navigation.more')} · ${t('sidebar.navigation.new')}`+ : t('sidebar.navigation.more')}+ >+ <Ellipsis+ size={15}+ strokeWidth={1.8}+ className="shrink-0 text-[var(--sidebar-nav-text)]"+ />+ <span className="leading-none">{t('sidebar.navigation.more')}</span>+ {entries.unseen.size > 0 && <NewTag className="ml-auto" />}+ </button>+ }/>) : null;// 滚动段把搜索行拆成滚动容器的直接子项:sticky 才能钉在结果列表上,// 不被短导航父盒的底边提前带走。输入框仍是同一份实例。if (section === 'scrollable') {+ // Search stays a direct child of the scrolling container so a live query+ // can stick to its top. The rows before and after it keep their saved order.+ const searchIndex = orderedIds.indexOf('search');+ const rowsBeforeSearch = renderRows(orderedIds.slice(0, searchIndex));+ const rowsAfterSearch = renderRows(orderedIds.slice(searchIndex + 1));return (<>- <div className="flex flex-col gap-0.5 pr-3 pl-3">- {automationsRow}- {pluginsRow}- {botsRow}- {mainViewRows}- {restoreRow}- </div>- <div- className={cn(- // -mt-1.5 抵消滚动容器 gap-2,与上面两行仍保持 gap-0.5。- 'px-3 pb-2.5 -mt-1.5',- pinSearch && 'sticky top-0 z-30 bg-[var(--cmd-palette-bg)]',- )}- >- {searchRow}- </div>+ {customizing ? (+ <SidebarNavigationCustomize+ // A draft belongs to one account; switching accounts starts a fresh one.+ key={dataOwnerId ?? ''}+ onDone={() => setCustomizing(false)}+ />+ ) : !showSearch ? (+ <div className="flex flex-col gap-0.5 pr-3 pl-3">+ {orderedNavigationRows}+ {restoreRow}+ {customizeRow}+ </div>+ ) : (+ <>+ {searchIndex > 0 && (+ <div className="flex flex-col gap-0.5 pr-3 pl-3">{rowsBeforeSearch}</div>+ )}+ <div+ className={cn(+ 'px-3',+ searchIndex > 0 && '-mt-1.5',+ pinSearch && 'sticky top-0 z-30 bg-[var(--cmd-palette-bg)] pb-2.5',+ )}+ >+ {searchRow}+ </div>+ {/* Entries after Search stay reachable while a query is pinned; the+ results follow them instead of replacing them. */}+ <div className="-mt-1.5 flex flex-col gap-0.5 pr-3 pl-3">+ {rowsAfterSearch}+ {restoreRow}+ {customizeRow}+ </div>+ </>+ )}</>);}+ // Persistent-view contract: saved navigation order -> {restoreRow} -> More.return (// pt-1(原 2.5):顶行 chrome 收窄到 46px 后,列表整体上提贴近顶行(对齐 Codex)。// 分段渲染时(section≠'all')两段各自成块,由调用方分别放进固定区 / 滚动区;@@ -231,12 +648,18 @@ export function SidebarTopNav({<span className="leading-none">{t('ccAgent.layout.new')}</span></button>)}- {automationsRow}- {pluginsRow}- {botsRow}- {mainViewRows}- {restoreRow}- {searchRow}+ {showScrollable &&+ (customizing ? (+ <SidebarNavigationCustomize+ // A draft belongs to one account; switching accounts starts a fresh one.+ key={dataOwnerId ?? ''}+ onDone={() => setCustomizing(false)}+ />+ ) : (+ orderedNavigationRows+ ))}+ {showScrollable && !customizing && restoreRow}+ {showScrollable && !customizing && customizeRow}</div>);}diff --git a/apps/desktop/src/renderer/components/sidebar/__tests__/SidebarNavigationCustomize.test.tsx b/apps/desktop/src/renderer/components/sidebar/__tests__/SidebarNavigationCustomize.test.tsxnew file mode 100644index 0000000000..53307e4106--- /dev/null+++ b/apps/desktop/src/renderer/components/sidebar/__tests__/SidebarNavigationCustomize.test.tsx@@ -0,0 +1,453 @@+// @vitest-environment jsdom++import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { SidebarNavigationCustomize } from '../SidebarNavigationCustomize';+import {+ __testing as navigationTesting,+ getSidebarKnownApps,+ mergeAbsentOrderEntries,+ reconcileSidebarAppArrivals,+ getSidebarNavigationPrefs,+ setSidebarNavigationPrefs,+} from '../sidebarNavigationPrefs';++type MainViewMock = { ghostId: string; title: string; icon: 'globe' };+const OWNER = 'owner-1';+const PREFS_KEY = `sidebar-navigation:v2.owner.${OWNER}`;+const mainViewsMock = vi.hoisted(() => ({+ routeCapable: [] as MainViewMock[],+ sidebarVisible: [] as MainViewMock[],+}));+const visibilityMock = vi.hoisted(() => ({+ write: vi.fn<(owner: unknown, ghostId: string, visible: boolean) => Promise<boolean>>(+ async () => true,+ ),+}));+const SITES: MainViewMock = { ghostId: 'xd-sites', title: '站点', icon: 'globe' };++vi.mock('@/cindy-brain/ghostMainViews', () => ({+ useGhostMainViews: () => ({+ declared: mainViewsMock.routeCapable,+ routeCapable: mainViewsMock.routeCapable,+ sidebarVisible: mainViewsMock.sidebarVisible,+ }),+}));+vi.mock('@/cindy-brain/mainViewVisibilityStore', () => ({+ currentMainViewVisibilityOwner: () => ({ dataOwnerId: 'owner', generation: 1 }),+ writeMainViewSidebarVisible: visibilityMock.write,+}));+vi.mock('@/lib/toast', () => ({ toast: { error: vi.fn() } }));+vi.mock('@/contexts/AuthContext', () => ({ useAuth: () => ({ dataOwnerId: 'owner-1' }) }));+vi.mock('@/hooks/useReducedMotion', () => ({ useReducedMotion: () => false }));+// SortableJS needs real pointer geometry; jsdom cannot drive it. Capture the list+// props so tests can assert the drag contract and replay a finished drag.+const sortableMock = vi.hoisted(() => ({+ props: null as null | { onReorder: (ids: string[]) => void; filter?: string },+}));+vi.mock('../SortableList', () => ({+ SortableList: (props: {+ items: readonly string[];+ renderItem: (item: string, index: number) => React.ReactNode;+ onReorder: (ids: string[]) => void;+ filter?: string;+ }) => {+ sortableMock.props = props;+ return (+ <div>+ {props.items.map((item, index) => (+ <div key={item}>{props.renderItem(item, index)}</div>+ ))}+ </div>+ );+ },+}));+vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string, vars?: { name?: string }) => (vars?.name ? `${key}: ${vars.name}` : key),+ }),+}));++const defaults = () => ({+ order: ['automations', 'plugins', 'bots', 'search'] as const,+ visible: ['automations', 'plugins', 'bots', 'search'] as const,+});++beforeEach(() => {+ localStorage.clear();+ navigationTesting.resetArrivals();+ navigationTesting.resetPrefsCache();+ mainViewsMock.routeCapable = [];+ mainViewsMock.sidebarVisible = [];+ visibilityMock.write.mockClear();+ setSidebarNavigationPrefs(OWNER, {+ order: [...defaults().order],+ visible: [...defaults().visible],+ });+});+afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+});++function order(): string[] {+ return screen.getAllByRole('checkbox').map((element) => element.getAttribute('aria-label') ?? '');+}++describe('sidebar navigation customization', () => {+ it('applies a finished drag and saves only explicit overrides', () => {+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ // Rows drag from anywhere except the checkbox, which stays a plain toggle.+ expect(sortableMock.props?.filter).toBe("[role='checkbox']");+ act(() => sortableMock.props!.onReorder(['plugins', 'bots', 'search', 'automations']));+ expect(order()).toEqual([+ 'sidebar.navigation.items.plugins',+ 'sidebar.navigation.items.bots',+ 'sidebar.navigation.items.search',+ 'sidebar.navigation.items.automations',+ ]);+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER).order).toEqual([+ 'plugins',+ 'bots',+ 'search',+ 'automations',+ ]);+ expect(JSON.parse(localStorage.getItem(PREFS_KEY)!)).toEqual({+ order: ['plugins', 'bots', 'search', 'automations'],+ });+ });++ it('reorders with arrow keys and preserves untouched external changes', () => {+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ const grip = screen.getByRole('button', {+ name: 'sidebar.navigation.customize.reorder: sidebar.navigation.items.plugins',+ });+ fireEvent.keyDown(grip, { key: 'ArrowUp' });+ fireEvent.click(screen.getByRole('checkbox', { name: 'sidebar.navigation.items.search' }));+ act(() =>+ setSidebarNavigationPrefs(OWNER, {+ order: [...defaults().order],+ visible: ['automations', 'plugins', 'search'],+ }),+ );+ expect(order()[0]).toBe('sidebar.navigation.items.plugins');+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER)).toEqual({+ order: ['plugins', 'automations', 'bots', 'search'],+ visible: ['automations', 'plugins'],+ appsAtTop: [],+ });+ });++ it('keeps the saved state in memory if storage fails', () => {+ vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => {+ throw new Error('full');+ });+ setSidebarNavigationPrefs(OWNER, {+ order: [...defaults().order],+ visible: ['automations', 'plugins', 'bots'],+ });+ expect(getSidebarNavigationPrefs(OWNER).visible).not.toContain('search');+ });++ it('clears overrides when resetting to the product defaults', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['bots', 'search', 'plugins', 'automations'],+ visible: ['search'],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.reset' }));+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER)).toEqual({+ order: [...defaults().order],+ visible: [...defaults().visible],+ appsAtTop: [],+ });+ expect(JSON.parse(localStorage.getItem(PREFS_KEY)!)).toEqual({});+ });++ it('drops the retired Issue entry from saved v2 preferences', () => {+ localStorage.setItem(+ PREFS_KEY,+ JSON.stringify({+ order: ['plugins', 'issues', 'automations', 'bots'],+ visibility: { issues: true, plugins: false },+ }),+ );+ act(() => window.dispatchEvent(new StorageEvent('storage', { key: PREFS_KEY })));+ expect(getSidebarNavigationPrefs(OWNER)).toEqual({+ order: ['plugins', 'automations', 'bots', 'search'],+ visible: ['automations', 'bots', 'search'],+ appsAtTop: [],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ expect(order()).not.toContain('sidebar.navigation.items.issues');+ });++ it('keeps edits made after choosing reset', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['bots', 'automations', 'plugins', 'search'],+ visible: ['bots'],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.reset' }));+ fireEvent.click(screen.getByRole('checkbox', { name: 'sidebar.navigation.items.search' }));+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER)).toEqual({+ order: [...defaults().order],+ visible: ['automations', 'plugins', 'bots'],+ appsAtTop: [],+ });+ });+ it('lists sidebar plugins and saves unchecking as a move into More', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ appsAtTop: ['app:xd-sites'],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ expect(order()).toEqual([+ 'sidebar.navigation.items.automations',+ 'sidebar.navigation.items.plugins',+ 'sidebar.navigation.items.bots',+ 'sidebar.navigation.items.search',+ '站点',+ ]);+ const sites = screen.getByRole('checkbox', { name: '站点' });+ expect(sites.getAttribute('aria-checked')).toBe('true');+ fireEvent.click(sites);+ expect(sites.getAttribute('aria-checked')).toBe('false');+ fireEvent.keyDown(+ screen.getByRole('button', { name: 'sidebar.navigation.customize.reorder: 站点' }),+ { key: 'ArrowUp' },+ );+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ // Unchecking only moves the plugin into More; its own sidebar switch is untouched.+ expect(visibilityMock.write).not.toHaveBeenCalled();+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual([]);+ expect(getSidebarNavigationPrefs(OWNER).order).toEqual([+ 'automations',+ 'plugins',+ 'bots',+ 'app:xd-sites',+ 'search',+ ]);+ });++ it('shows a sidebar plugin without a placement unchecked, as it sits in More', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ expect(screen.getByRole('checkbox', { name: '站点' }).getAttribute('aria-checked')).toBe(+ 'false',+ );+ });++ it('leaves out plugins switched off in their own settings and keeps their saved place', () => {+ mainViewsMock.routeCapable = [SITES];+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ appsAtTop: ['app:xd-sites'],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ expect(screen.queryByRole('checkbox', { name: '站点' })).toBeNull();+ fireEvent.click(screen.getByRole('checkbox', { name: 'sidebar.navigation.items.bots' }));+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual(['app:xd-sites']);+ });++ it('drops every plugin placement on reset, including ones switched off for now', () => {+ const off = { ghostId: 'off', title: 'Off', icon: 'globe' as const };+ mainViewsMock.routeCapable = [SITES, off];+ mainViewsMock.sidebarVisible = [SITES];+ setSidebarNavigationPrefs(OWNER, {+ order: ['app:xd-sites', 'automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins'],+ appsAtTop: ['app:xd-sites', 'app:off'],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ expect(screen.getByRole('checkbox', { name: '站点' }).getAttribute('aria-checked')).toBe(+ 'true',+ );+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.reset' }));+ expect(screen.getByRole('checkbox', { name: '站点' }).getAttribute('aria-checked')).toBe(+ 'false',+ );+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER)).toEqual({+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ appsAtTop: [],+ });+ // No overrides remain, so later product defaults keep applying.+ expect(JSON.parse(localStorage.getItem(PREFS_KEY)!)).toEqual({});+ });++ it('keeps a plugin re-checked after reset at the top level', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.reset' }));+ fireEvent.click(screen.getByRole('checkbox', { name: '站点' }));+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual(['app:xd-sites']);+ });++ it('toggles from anywhere in the row except the drag handle', () => {+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ const bots = screen.getByRole('checkbox', { name: 'sidebar.navigation.items.bots' });+ expect(bots.getAttribute('aria-checked')).toBe('true');+ fireEvent.click(screen.getByText('sidebar.navigation.items.bots'));+ expect(bots.getAttribute('aria-checked')).toBe('false');+ fireEvent.click(bots.parentElement!);+ expect(bots.getAttribute('aria-checked')).toBe('true');+ fireEvent.click(bots);+ expect(bots.getAttribute('aria-checked')).toBe('false');+ fireEvent.click(+ screen.getByRole('button', {+ name: 'sidebar.navigation.customize.reorder: sidebar.navigation.items.bots',+ }),+ );+ expect(bots.getAttribute('aria-checked')).toBe('false');+ });+ it('shows each entry with the icon it uses in the sidebar', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ const rowOf = (name: string) => screen.getByRole('checkbox', { name }).parentElement!;+ expect(+ rowOf('sidebar.navigation.items.automations').querySelector('.lucide-timer'),+ ).not.toBeNull();+ expect(rowOf('sidebar.navigation.items.plugins').querySelector('.lucide-plug')).not.toBeNull();+ expect(rowOf('sidebar.navigation.items.bots').querySelector('.lucide-bot')).not.toBeNull();+ expect(rowOf('sidebar.navigation.items.search').querySelector('.lucide-search')).not.toBeNull();+ expect(rowOf('站点').querySelector('.lucide-globe')).not.toBeNull();+ });+ it('keeps a separate layout for each account', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['search', 'automations', 'plugins', 'bots'],+ visible: ['search'],+ });+ expect(getSidebarNavigationPrefs('owner-2')).toEqual({+ order: [...defaults().order],+ visible: [...defaults().visible],+ appsAtTop: [],+ });+ expect(localStorage.getItem('sidebar-navigation:v2.owner.owner-2')).toBeNull();+ // A fresh window reads each account's layout back from its own key.+ navigationTesting.resetPrefsCache();+ expect(getSidebarNavigationPrefs(OWNER).visible).toEqual(['search']);+ // Without an account the defaults apply and nothing is written.+ setSidebarNavigationPrefs(null, { order: [...defaults().order], visible: [] });+ expect(getSidebarNavigationPrefs(null).visible).toEqual([...defaults().visible]);+ });+ it('keeps a switched-off plugin at its place when other entries are reordered', () => {+ mainViewsMock.routeCapable = [SITES];+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'app:xd-sites', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ expect(order()).not.toContain('站点');+ act(() => sortableMock.props!.onReorder(['plugins', 'automations', 'bots', 'search']));+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER).order).toEqual([+ 'plugins',+ 'automations',+ 'app:xd-sites',+ 'bots',+ 'search',+ ]);+ });++ it('keeps a plugin switched off in another window at its place on save', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ setSidebarNavigationPrefs(OWNER, {+ order: ['app:xd-sites', 'automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ });+ const view = render(<SidebarNavigationCustomize onDone={() => {}} />);+ mainViewsMock.sidebarVisible = [];+ view.rerender(<SidebarNavigationCustomize onDone={() => {}} />);+ fireEvent.click(screen.getByRole('checkbox', { name: 'sidebar.navigation.items.bots' }));+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER).order).toEqual([+ 'app:xd-sites',+ 'automations',+ 'plugins',+ 'bots',+ 'search',+ ]);+ });++ it('keeps a reorder made after choosing reset', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['search', 'bots', 'plugins', 'automations'],+ visible: ['search'],+ });+ render(<SidebarNavigationCustomize onDone={() => {}} />);+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.reset' }));+ act(() => sortableMock.props!.onReorder(['bots', 'automations', 'plugins', 'search']));+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs(OWNER).order).toEqual([+ 'bots',+ 'automations',+ 'plugins',+ 'search',+ ]);+ });++ it('places entries missing from an edited order after their previous neighbour', () => {+ expect(+ mergeAbsentOrderEntries(+ ['plugins', 'automations', 'search'],+ ['app:first', 'automations', 'app:mid', 'plugins', 'search', 'app:last'],+ ),+ ).toEqual(['app:first', 'plugins', 'automations', 'app:mid', 'search', 'app:last']);+ });++ it('records nothing until the installed roster is known', () => {+ reconcileSidebarAppArrivals(OWNER, [], false);+ expect(localStorage.getItem('sidebar-navigation:apps:v1')).toBeNull();+ // The real roster arriving afterwards is the first run: existing plugins stay at the top.+ reconcileSidebarAppArrivals(OWNER, ['xd-sites'], true);+ expect(getSidebarKnownApps(OWNER)).toEqual(['xd-sites']);+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual(['app:xd-sites']);+ });++ it('starts the first sidebar plugin in More after an empty but known baseline', () => {+ reconcileSidebarAppArrivals(OWNER, [], true);+ expect(getSidebarKnownApps(OWNER)).toEqual([]);+ reconcileSidebarAppArrivals(OWNER, ['xd-sites'], true);+ // No placement is written: plugins default to More.+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual([]);+ expect(getSidebarKnownApps(OWNER)).toEqual(['xd-sites']);+ });++ it('retries the first run when the top-level placement of existing plugins cannot be stored', () => {+ const originalSetItem = Storage.prototype.setItem;+ const setItem = vi.spyOn(Storage.prototype, 'setItem').mockImplementation(function (+ this: Storage,+ key: string,+ value: string,+ ) {+ if (key.startsWith('sidebar-navigation:v2.owner.')) throw new Error('refused');+ originalSetItem.call(this, key, value);+ });+ reconcileSidebarAppArrivals(OWNER, ['xd-sites'], true);+ expect(localStorage.getItem('sidebar-navigation:apps:v1')).toBeNull();+ setItem.mockRestore();+ // Once storage accepts the placement, the same first run is recorded.+ reconcileSidebarAppArrivals(OWNER, ['xd-sites'], true);+ expect(getSidebarKnownApps(OWNER)).toEqual(['xd-sites']);+ expect(JSON.parse(localStorage.getItem(PREFS_KEY)!).visibility).toEqual({+ 'app:xd-sites': true,+ });+ });+});diff --git a/apps/desktop/src/renderer/components/sidebar/__tests__/SidebarTopNav.bots.test.tsx b/apps/desktop/src/renderer/components/sidebar/__tests__/SidebarTopNav.bots.test.tsxindex 0200aa868d..cb3e11317f 100644--- a/apps/desktop/src/renderer/components/sidebar/__tests__/SidebarTopNav.bots.test.tsx+++ b/apps/desktop/src/renderer/components/sidebar/__tests__/SidebarTopNav.bots.test.tsx@@ -1,28 +1,84 @@// @vitest-environment jsdom-import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';+import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react';import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom';-import { afterEach, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { MainViewHistoryProvider } from '@/contexts/MainViewHistoryContext';import { publishNavigationAttention } from '@/lib/navigationAttentionStore';-import { SidebarTopNav } from '../SidebarTopNav';+import { SidebarRailNavigation, SidebarTopNav, type SidebarRailSearchOptions } from '../SidebarTopNav';+import {+ __testing as navigationTesting,+ getSidebarNavigationPrefs,+ setSidebarNavigationPrefs,+} from '../sidebarNavigationPrefs';++const OWNER = 'owner-1';+const searchMock = vi.hoisted(() => ({ query: '', lockedProjectKey: null as string | null }));+type MainViewMock = { ghostId: string; title: string; icon: 'globe'; manifest: { name: string } };+const mainViewsMock = vi.hoisted(() => ({+ routeCapable: [] as MainViewMock[],+ sidebarVisible: [] as MainViewMock[],+}));+const authMock = vi.hoisted(() => ({ owner: 'owner-1' as string | null }));+vi.mock('@/contexts/AuthContext', () => ({ useAuth: () => ({ dataOwnerId: authMock.owner }) }));+// A non-empty installed roster marks the plugin list as loaded (Main sends none mid-switch).+const installedMock = vi.hoisted(() => ({ ghosts: [{ manifest: { id: 'bundled' } }] as unknown[] }));+vi.mock('@/cindy-brain/useInstalledGhosts', () => ({ useInstalledGhosts: () => installedMock.ghosts }));+const SITES: MainViewMock = {+ ghostId: 'xd-sites', title: '站点', icon: 'globe', manifest: { name: 'XD Sites' },+};vi.mock('react-i18next', () => ({useTranslation: () => ({- t: (key: string) =>- ({ 'sidebar.tabs.bots': '伙伴', 'sidebar.backToSessions': '返回任务' })[key] ?? key,+ t: (key: string, vars?: { name?: string }) =>+ ({ 'sidebar.tabs.bots': '伙伴', 'sidebar.backToSessions': '返回任务' })[key] ??+ (vars?.name ? `${key}: ${vars.name}` : key),}),}));vi.mock('@/cindy-brain/ghostUnreadStore', () => ({ useAnyGhostUnread: () => false }));+vi.mock('@/cindy-brain/ghostMainViews', () => ({+ useGhostMainViews: () => ({+ declared: mainViewsMock.routeCapable,+ routeCapable: mainViewsMock.routeCapable,+ sidebarVisible: mainViewsMock.sidebarVisible,+ }),+}));vi.mock('@/cindy-brain/GhostPanelRestoreEntry', () => ({ GhostPanelRestoreEntry: () => null }));-vi.mock('../GhostMainViewNavEntries', () => ({ GhostMainViewNavEntries: () => null }));-vi.mock('@/features/cc-agent/sidebar/SidebarInlineSearch', () => ({ SidebarInlineSearch: () => null }));+vi.mock('../GhostMainViewNavEntries', () => ({+ GhostMainViewNavEntry: ({ item, variant }: { item: { title: string }; variant: string }) =>+ <button aria-label={item.title} data-variant={variant} />,+ MAIN_VIEW_ICONS: { globe: () => null },+}));+vi.mock('@/features/cc-agent/sidebar/SidebarInlineSearch', () => ({+ SidebarInlineSearch: ({ openSignal, onFocusLeave }: { openSignal: number; onFocusLeave?: () => void }) =>+ <button aria-label="Search row" data-open-signal={openSignal} onBlur={onFocusLeave}>Search row</button>,+}));vi.mock('@/features/cc-agent/sidebar/conversationSearchContext', () => ({- useConversationSearchContext: () => ({ search: { query: '' }, allKnownProjects: [] }),+ useConversationSearchContext: () => ({ search: searchMock, allKnownProjects: [], openSignal: 0 }),}));afterEach(() => { cleanup(); publishNavigationAttention({ tasks: 0, teammates: 0 }); });+/** Pretend the owner's first run already happened, so plugins keep their default (More). */+function seedKnownPlugins(ids: string[]) {+ localStorage.setItem('sidebar-navigation:apps:v1', JSON.stringify({ [OWNER]: { known: ids, unseen: [] } }));+ navigationTesting.resetArrivals();+}+beforeEach(() => {+ searchMock.query = '';+ searchMock.lockedProjectKey = null;+ mainViewsMock.routeCapable = [];+ mainViewsMock.sidebarVisible = [];+ authMock.owner = 'owner-1';+ installedMock.ghosts = [{ manifest: { id: 'bundled' } }];+ localStorage.removeItem('sidebar-navigation:apps:v1');+ navigationTesting.resetArrivals();+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ });+});+function NavigationHarness() {const location = useLocation();const navigate = useNavigate();@@ -50,6 +106,13 @@ function Harness({ initialPath, owner = 'one' }: { initialPath: string; owner?:}describe('Sidebar teammate return action', () => {+ const openMore = () => {+ fireEvent.pointerDown(screen.getByRole('button', { name: 'sidebar.navigation.more' }), {+ button: 0,+ ctrlKey: false,+ });+ };+it('shows the destination count, preserves it when switching sections, hides zero and reuses 99+ overflow', () => {publishNavigationAttention({ tasks: 4, teammates: 105 });render(<Harness initialPath="/cc-agent" />);@@ -62,6 +125,221 @@ describe('Sidebar teammate return action', () => {expect(screen.getByRole('button', { name: '伙伴' }).textContent).toBe('伙伴');});+ it('keeps the teammate count on its More item and narrow rail tile', () => {+ publishNavigationAttention({ tasks: 0, teammates: 3 });+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'search'],+ });+ render(<Harness initialPath="/cc-agent" />);+ fireEvent.pointerDown(screen.getByRole('button', { name: 'sidebar.navigation.more' }), { button: 0, ctrlKey: false });+ expect(screen.getByRole('menuitem', { name: /伙伴/ }).textContent).toBe('伙伴3');+ cleanup();+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ });+ render(<MainViewHistoryProvider><MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarRailNavigation renderSearch={() => null} />+ </MemoryRouter></MainViewHistoryProvider>);+ expect(screen.getByRole('button', { name: '伙伴' }).textContent).toBe('3');+ });++ it('moves every unchecked entry into More and opens the same destination', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['bots', 'plugins', 'search', 'automations'],+ visible: [],+ });+ render(<Harness initialPath="/cc-agent/session-1" />);+ expect(screen.queryByRole('button', { name: 'ccAgent.layout.automations' })).toBeNull();+ expect(screen.queryByRole('button', { name: 'sidebar.tabs.plugins' })).toBeNull();+ expect(screen.queryByRole('button', { name: '伙伴' })).toBeNull();+ expect(screen.queryByRole('button', { name: 'Search row' })).toBeNull();++ openMore();+ const hidden = ['伙伴', 'sidebar.tabs.plugins', 'sidebar.navigation.items.search', 'ccAgent.layout.automations'];+ const items = hidden.map((name) => screen.getByRole('menuitem', { name }));+ expect(items.every((item, index) =>+ index === 0 || Boolean(items[index - 1].compareDocumentPosition(item) & Node.DOCUMENT_POSITION_FOLLOWING),+ )).toBe(true);+ fireEvent.click(items[0]);+ expect(screen.getByTestId('location').textContent).toBe('/bots/list');++ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: '返回任务' }));+ expect(screen.getByTestId('location').textContent).toBe('/cc-agent/session-1');++ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: 'sidebar.tabs.plugins' }));+ expect(screen.getByTestId('location').textContent).toBe('/plugins');++ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: 'ccAgent.layout.automations' }));+ expect(screen.getByTestId('location').textContent).toBe('/cc-agent/scheduled');+ });++ it('opens an unchecked Search from More without changing its saved visibility', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots'],+ });+ render(<Harness initialPath="/cc-agent" />);+ expect(screen.queryByRole('button', { name: 'Search row' })).toBeNull();+ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: 'sidebar.navigation.items.search' }));+ expect(screen.getByRole('button', { name: 'Search row' }).getAttribute('data-open-signal')).toBe('1');+ openMore();+ expect(screen.getByRole('menuitem', { name: 'sidebar.navigation.items.search' })).toBeTruthy();+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'sidebar.navigation.items.search' }), { key: 'Escape' });+ fireEvent.blur(screen.getByRole('button', { name: 'Search row' }));+ expect(screen.queryByRole('button', { name: 'Search row' })).toBeNull();+ });++ it('keeps checked entries out of More', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'search'],+ });+ render(<Harness initialPath="/cc-agent" />);+ openMore();+ expect(screen.queryByRole('menuitem', { name: 'ccAgent.layout.automations' })).toBeNull();+ expect(screen.queryByRole('menuitem', { name: 'sidebar.navigation.items.search' })).toBeNull();+ expect(screen.getByRole('menuitem', { name: 'sidebar.tabs.plugins' })).toBeTruthy();+ expect(screen.getByRole('menuitem', { name: '伙伴' })).toBeTruthy();+ });++ it('places Search in the saved order and does not add an Issue entry', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['search', 'plugins', 'automations', 'bots'],+ visible: ['search', 'plugins', 'automations', 'bots'],+ });+ render(<Harness initialPath="/cc-agent" />);+ const search = screen.getByRole('button', { name: 'Search row' });+ const plugins = screen.getByRole('button', { name: 'sidebar.tabs.plugins' });+ expect(search.compareDocumentPosition(plugins) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ expect(screen.queryByRole('button', { name: 'sidebar.tabs.issues' })).toBeNull();+ });++ it('hides Search until an active query needs its input again', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots'],+ });+ const view = render(<Harness initialPath="/cc-agent" />);+ expect(screen.queryByRole('button', { name: 'Search row' })).toBeNull();+ searchMock.query = 'needle';+ view.rerender(<Harness initialPath="/cc-agent" />);+ expect(screen.getByRole('button', { name: 'Search row' })).toBeTruthy();+ // More stays reachable while the query is pinned.+ expect(screen.getByRole('button', { name: 'sidebar.navigation.more' })).toBeTruthy();+ searchMock.query = '';+ view.rerender(<Harness initialPath="/cc-agent" />);+ expect(screen.queryByRole('button', { name: 'Search row' })).toBeNull();+ });++ it('keeps entries after a mid-list Search reachable while a query is pinned', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'search', 'plugins', 'bots'],+ visible: ['automations', 'search', 'plugins', 'bots'],+ });+ searchMock.query = 'needle';+ render(<Harness initialPath="/cc-agent" />);+ const search = screen.getByRole('button', { name: 'Search row' });+ const plugins = screen.getByRole('button', { name: 'sidebar.tabs.plugins' });+ expect(search.compareDocumentPosition(plugins) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ expect(screen.getByRole('button', { name: '伙伴' })).toBeTruthy();+ expect(screen.getByRole('button', { name: 'sidebar.navigation.more' })).toBeTruthy();+ });++ it('keeps a hidden Search accessible for a project-scoped search', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots'],+ });+ searchMock.lockedProjectKey = 'project-1';+ render(<Harness initialPath="/cc-agent" />);+ expect(screen.getByRole('button', { name: 'Search row' })).toBeTruthy();+ });+ it('places a plugin main view in the saved order like any other entry', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'app:xd-sites', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ });+ render(<Harness initialPath="/cc-agent" />);+ const automations = screen.getByRole('button', { name: 'ccAgent.layout.automations' });+ const sites = screen.getByRole('button', { name: '站点' });+ const plugins = screen.getByRole('button', { name: 'sidebar.tabs.plugins' });+ expect(automations.compareDocumentPosition(sites) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ expect(sites.compareDocumentPosition(plugins) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ openMore();+ expect(screen.queryByRole('menuitem', { name: /站点/ })).toBeNull();+ });+ it('keeps a plugin without a top-level placement in More and opens its page', () => {+ seedKnownPlugins(['xd-sites']);+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ render(<Harness initialPath="/cc-agent" />);+ expect(screen.queryByRole('button', { name: '站点' })).toBeNull();+ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: /站点/ }));+ expect(screen.getByTestId('location').textContent).toBe('/apps/xd-sites');+ });+ it('leaves a plugin out of the sidebar and More once its own switch is off', () => {+ mainViewsMock.routeCapable = [SITES];+ render(<Harness initialPath="/cc-agent" />);+ expect(screen.queryByRole('button', { name: '站点' })).toBeNull();+ openMore();+ expect(screen.queryByRole('menuitem', { name: /站点/ })).toBeNull();+ });+ it('keeps a Customize choice from forcing a switched-on plugin to the top level', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ render(<Harness initialPath="/cc-agent" />);+ expect(screen.getByRole('button', { name: '站点' })).toBeTruthy();+ act(() => setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ appsAtTop: [],+ }));+ expect(screen.queryByRole('button', { name: '站点' })).toBeNull();+ });+ it('keeps the plugin manage action on its More item', () => {+ seedKnownPlugins(['xd-sites']);+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ render(<Harness initialPath="/cc-agent" />);+ openMore();+ const item = screen.getByRole('menuitem', { name: /站点/ });+ const manage = within(item).getByRole('button', { name: 'settings.ghosts.page.manageAria: XD Sites' });+ fireEvent.click(manage);+ expect(screen.getByTestId('location').textContent).toBe('/settings?tab=ghosts&ghost=xd-sites');+ // The flag is one-shot: the next plain selection opens the plugin page again.+ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: /站点/ }));+ expect(screen.getByTestId('location').textContent).toBe('/apps/xd-sites');+ });+ it('lists only unchecked entries and Customize in More', () => {+ render(<Harness initialPath="/cc-agent" />);+ openMore();+ expect(screen.getAllByRole('menuitem').map((item) => item.textContent))+ .toEqual(['sidebar.navigation.customize.title']);+ });+ it('respects hidden teammate navigation in the narrow rail', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins'],+ });+ render(<MainViewHistoryProvider><MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarTopNav section="rail" />+ </MemoryRouter></MainViewHistoryProvider>);+ expect(screen.queryByRole('button', { name: '伙伴' })).toBeNull();+ act(() => setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ }));+ });it('keeps the previous task when visiting automations before teammates', () => {const sessionPath = '/cc-agent/session-1?remoteHostId=host-1#message-2';render(<Harness initialPath={sessionPath} />);@@ -153,3 +431,272 @@ describe('Sidebar teammate return action', () => {expect(screen.getByTestId('location').textContent).toBe('/cc-agent');});});++describe('Narrow rail navigation', () => {+ function RailHarness({ forceSearch = false }: { forceSearch?: boolean }) {+ const location = useLocation();+ return (+ <>+ <SidebarRailNavigation+ forceSearch={forceSearch}+ renderSearch={({ defaultOpen, onOpenChange }: SidebarRailSearchOptions) => (+ <button+ aria-label="Rail search"+ data-default-open={String(defaultOpen)}+ onClick={() => onOpenChange(false)}+ />+ )}+ />+ <output data-testid="location">{location.pathname}</output>+ </>+ );+ }+ const renderRail = (props: { forceSearch?: boolean } = {}) => render(+ <MainViewHistoryProvider>+ <MemoryRouter initialEntries={['/cc-agent/session-1']}>+ <RailHarness {...props} />+ </MemoryRouter>+ </MainViewHistoryProvider>,+ );+ const openMore = () => {+ fireEvent.pointerDown(screen.getByRole('button', { name: 'sidebar.navigation.more' }), {+ button: 0,+ ctrlKey: false,+ });+ };++ it('lays out checked entries in the saved order', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['search', 'bots', 'automations', 'plugins'],+ visible: ['search', 'bots', 'automations', 'plugins'],+ });+ renderRail();+ const names = ['Rail search', '伙伴', 'ccAgent.layout.automations', 'sidebar.tabs.plugins'];+ const tiles = names.map((name) => screen.getByRole('button', { name }));+ expect(tiles.every((tile, index) =>+ index === 0 || Boolean(tiles[index - 1].compareDocumentPosition(tile) & Node.DOCUMENT_POSITION_FOLLOWING),+ )).toBe(true);+ });++ it('drops More when nothing is hidden', () => {+ renderRail();+ expect(screen.queryByRole('button', { name: 'sidebar.navigation.more' })).toBeNull();+ act(() => setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'bots', 'search'],+ }));+ openMore();+ expect(screen.getByRole('menuitem', { name: 'sidebar.tabs.plugins' })).toBeTruthy();+ });++ it('lays out plugin main views in the saved order and keeps hidden ones in More', () => {+ const other: MainViewMock = { ghostId: 'other', title: 'Other', icon: 'globe', manifest: { name: 'Other' } };+ const off: MainViewMock = { ghostId: 'off', title: 'Off', icon: 'globe', manifest: { name: 'Off' } };+ seedKnownPlugins(['xd-sites', 'other']);+ mainViewsMock.routeCapable = [SITES, other, off];+ mainViewsMock.sidebarVisible = [SITES, other];+ setSidebarNavigationPrefs(OWNER, {+ order: ['app:xd-sites', 'automations', 'plugins', 'bots', 'search', 'app:other', 'app:off'],+ visible: ['automations', 'plugins', 'bots', 'search'],+ appsAtTop: ['app:xd-sites'],+ });+ renderRail();+ const sites = screen.getByRole('button', { name: '站点' });+ expect(sites.getAttribute('data-variant')).toBe('rail');+ expect(sites.compareDocumentPosition(screen.getByRole('button', { name: 'ccAgent.layout.automations' }))+ & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ expect(screen.queryByRole('button', { name: 'Other' })).toBeNull();+ expect(screen.queryByRole('button', { name: 'Off' })).toBeNull();+ openMore();+ expect(screen.queryByRole('menuitem', { name: /Off/ })).toBeNull();+ fireEvent.click(screen.getByRole('menuitem', { name: /Other/ }));+ expect(screen.getByTestId('location').textContent).toBe('/apps/other');+ });++ it('moves unchecked entries into More and opens the same destination', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['plugins', 'automations', 'bots', 'search'],+ visible: ['search'],+ });+ renderRail();+ expect(screen.queryByRole('button', { name: 'sidebar.tabs.plugins' })).toBeNull();+ expect(screen.queryByRole('button', { name: 'ccAgent.layout.automations' })).toBeNull();+ expect(screen.queryByRole('button', { name: '伙伴' })).toBeNull();++ openMore();+ expect(screen.queryByRole('menuitem', { name: 'sidebar.navigation.items.search' })).toBeNull();+ expect(screen.queryByRole('menuitem', { name: 'sidebar.navigation.customize.title' })).toBeNull();+ fireEvent.click(screen.getByRole('menuitem', { name: 'ccAgent.layout.automations' }));+ expect(screen.getByTestId('location').textContent).toBe('/cc-agent/scheduled');++ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: 'sidebar.tabs.plugins' }));+ expect(screen.getByTestId('location').textContent).toBe('/plugins');++ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: '伙伴' }));+ expect(screen.getByTestId('location').textContent).toBe('/bots/list');+ });++ it('opens an unchecked Search from More and hides it again once closed', async () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots'],+ });+ renderRail();+ expect(screen.queryByRole('button', { name: 'Rail search' })).toBeNull();+ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: 'sidebar.navigation.items.search' }));+ const search = await screen.findByRole('button', { name: 'Rail search' });+ expect(search.getAttribute('data-default-open')).toBe('true');+ fireEvent.click(search);+ expect(screen.queryByRole('button', { name: 'Rail search' })).toBeNull();+ });++ it('keeps a hidden Search for a project-scoped search request', () => {+ setSidebarNavigationPrefs(OWNER, {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'plugins', 'bots'],+ });+ renderRail({ forceSearch: true });+ expect(screen.getByRole('button', { name: 'Rail search' }).getAttribute('data-default-open'))+ .toBe('false');+ });+});++describe('Plugins joining the sidebar', () => {+ const NEWCOMER: MainViewMock = { ghostId: 'newcomer', title: 'Newcomer', icon: 'globe', manifest: { name: 'Newcomer' } };+ const renderNav = () => render(+ <MainViewHistoryProvider>+ <MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarTopNav section="all" />+ </MemoryRouter>+ </MainViewHistoryProvider>,+ );+ const openMore = (name: string | RegExp = /sidebar\.navigation\.more/) => {+ fireEvent.pointerDown(screen.getByRole('button', { name }), { button: 0, ctrlKey: false });+ };++ it('keeps plugins already in the sidebar where they are on the first run', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ renderNav();+ expect(screen.getByRole('button', { name: '站点' })).toBeTruthy();+ expect(screen.queryByText('sidebar.navigation.new')).toBeNull();+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual(['app:xd-sites']);+ });++ it('places a newly arrived plugin in More and flags it until More has been opened', () => {+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ const view = renderNav();+ mainViewsMock.routeCapable = [SITES, NEWCOMER];+ mainViewsMock.sidebarVisible = [SITES, NEWCOMER];+ view.rerender(+ <MainViewHistoryProvider>+ <MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarTopNav section="all" />+ </MemoryRouter>+ </MainViewHistoryProvider>,+ );+ expect(screen.queryByRole('button', { name: 'Newcomer' })).toBeNull();+ // The newcomer needs no placement write: plugins default to More.+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual(['app:xd-sites']);+ const more = screen.getByRole('button', { name: 'sidebar.navigation.more · sidebar.navigation.new' });+ expect(within(more).getByText('sidebar.navigation.new')).toBeTruthy();++ openMore();+ const item = screen.getByRole('menuitem', { name: /Newcomer/ });+ expect(within(item).getByText('sidebar.navigation.new')).toBeTruthy();+ fireEvent.keyDown(item, { key: 'Escape' });+ expect(screen.queryByText('sidebar.navigation.new')).toBeNull();+ expect(screen.getByRole('button', { name: 'sidebar.navigation.more' })).toBeTruthy();+ });++ it('waits for the account before deciding which plugins are new', () => {+ authMock.owner = null;+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ const view = renderNav();+ expect(localStorage.getItem('sidebar-navigation:apps:v1')).toBeNull();+ authMock.owner = 'owner-1';+ view.rerender(+ <MainViewHistoryProvider>+ <MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarTopNav section="all" />+ </MemoryRouter>+ </MainViewHistoryProvider>,+ );+ expect(screen.getByRole('button', { name: '站点' })).toBeTruthy();+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual(['app:xd-sites']);+ });++ it('marks the narrow rail More button while a new plugin waits there', () => {+ localStorage.setItem('sidebar-navigation:apps:v1', JSON.stringify({ 'owner-1': { known: [], unseen: [] } }));+ navigationTesting.resetArrivals();+ mainViewsMock.routeCapable = [NEWCOMER];+ mainViewsMock.sidebarVisible = [NEWCOMER];+ render(+ <MainViewHistoryProvider>+ <MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarRailNavigation renderSearch={() => null} />+ </MemoryRouter>+ </MainViewHistoryProvider>,+ );+ expect(screen.queryByRole('button', { name: 'Newcomer' })).toBeNull();+ expect(screen.getByRole('button', { name: 'sidebar.navigation.more · sidebar.navigation.new' })).toBeTruthy();+ });++ it('shows each account its own navigation layout', () => {+ setSidebarNavigationPrefs('owner-2', {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations'],+ });+ const view = renderNav();+ expect(screen.getByRole('button', { name: 'sidebar.tabs.plugins' })).toBeTruthy();+ authMock.owner = 'owner-2';+ view.rerender(+ <MainViewHistoryProvider>+ <MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarTopNav section="all" />+ </MemoryRouter>+ </MainViewHistoryProvider>,+ );+ expect(screen.queryByRole('button', { name: 'sidebar.tabs.plugins' })).toBeNull();+ expect(screen.getByRole('button', { name: 'ccAgent.layout.automations' })).toBeTruthy();+ });++ it('defers the first run while the installed roster is still empty', () => {+ installedMock.ghosts = [];+ mainViewsMock.routeCapable = [SITES];+ mainViewsMock.sidebarVisible = [SITES];+ renderNav();+ expect(localStorage.getItem('sidebar-navigation:apps:v1')).toBeNull();+ expect(getSidebarNavigationPrefs(OWNER).appsAtTop).toEqual([]);+ });++ it('starts a fresh Customize draft when the account changes while it is open', () => {+ setSidebarNavigationPrefs('owner-2', {+ order: ['automations', 'plugins', 'bots', 'search'],+ visible: ['automations', 'search'],+ });+ const view = renderNav();+ openMore();+ fireEvent.click(screen.getByRole('menuitem', { name: 'sidebar.navigation.customize.title' }));+ // Account A unchecks Plugins in the draft, then the account switches before Done.+ fireEvent.click(screen.getByRole('checkbox', { name: 'sidebar.navigation.items.plugins' }));+ authMock.owner = 'owner-2';+ view.rerender(+ <MainViewHistoryProvider>+ <MemoryRouter initialEntries={['/cc-agent']}>+ <SidebarTopNav section="all" />+ </MemoryRouter>+ </MainViewHistoryProvider>,+ );+ expect(screen.getByRole('checkbox', { name: 'sidebar.navigation.items.bots' }).getAttribute('aria-checked'))+ .toBe('false');+ fireEvent.click(screen.getByRole('button', { name: 'sidebar.navigation.customize.done' }));+ expect(getSidebarNavigationPrefs('owner-2').visible).toEqual(['automations', 'search']);+ expect(getSidebarNavigationPrefs(OWNER).visible).toEqual(['automations', 'plugins', 'bots', 'search']);+ });+});diff --git a/apps/desktop/src/renderer/components/sidebar/sidebarNavigationPrefs.ts b/apps/desktop/src/renderer/components/sidebar/sidebarNavigationPrefs.tsnew file mode 100644index 0000000000..40246eb5dc--- /dev/null+++ b/apps/desktop/src/renderer/components/sidebar/sidebarNavigationPrefs.ts@@ -0,0 +1,397 @@+import { useSyncExternalStore } from 'react';+import { Bot, Plug, Search, Timer, type LucideIcon } from 'lucide-react';++import { readSidebarOwnerStorage, writeSidebarOwnerStorage } from '@/lib/sidebarOwnerStorage';++/** Stable built-in entries only; installed app entries keep their own visibility settings. */+export type SidebarNavigationItemId = 'automations' | 'plugins' | 'bots' | 'search';++export const SIDEBAR_NAVIGATION_ITEMS: readonly SidebarNavigationItemId[] = [+ 'automations',+ 'plugins',+ 'bots',+ 'search',+];++/** One icon per built-in entry, shared by the sidebar rows, the rail, More and Customize. */+export const SIDEBAR_NAVIGATION_ITEM_ICONS: Record<SidebarNavigationItemId, LucideIcon> = {+ automations: Timer,+ plugins: Plug,+ bots: Bot,+ search: Search,+};++export const DEFAULT_SIDEBAR_NAVIGATION_VISIBLE: readonly SidebarNavigationItemId[] = [+ 'automations',+ 'plugins',+ 'bots',+ 'search',+];++/**+ * Plugins with a main view join the same order as `app:<ghostId>`. Two settings+ * apply to them: the plugin's own "show in sidebar" switch (per-account main-view+ * store) decides whether it appears anywhere in the sidebar, More included; this+ * module only decides where. Plugins default to More; `appsAtTop` lists the ones+ * placed at the top level (checked in Customize, or already in the sidebar when this+ * first ran for the owner). Entries never placed in the order follow the built-ins.+ */+export type SidebarNavigationAppEntryId = `app:${string}`;+export type SidebarNavigationEntryId = SidebarNavigationItemId | SidebarNavigationAppEntryId;++const APP_ENTRY_PREFIX = 'app:';+const MAX_APP_ENTRY_LENGTH = APP_ENTRY_PREFIX.length + 128;++export function appEntryId(ghostId: string): SidebarNavigationAppEntryId {+ return `${APP_ENTRY_PREFIX}${ghostId}`;+}++export function ghostIdOfEntry(id: SidebarNavigationEntryId): string | null {+ return id.startsWith(APP_ENTRY_PREFIX) ? id.slice(APP_ENTRY_PREFIX.length) : null;+}++export function isBuiltInEntry(id: SidebarNavigationEntryId): id is SidebarNavigationItemId {+ return SIDEBAR_NAVIGATION_ITEMS.includes(id as SidebarNavigationItemId);+}++/**+ * Keep entries missing from an edited order (plugins whose own sidebar switch is+ * off right now) at their previous place: each one goes back right after the entry+ * that preceded it before, or first when nothing did.+ */+export function mergeAbsentOrderEntries(+ edited: readonly SidebarNavigationEntryId[],+ previous: readonly SidebarNavigationEntryId[],+): SidebarNavigationEntryId[] {+ const merged = [...edited];+ previous.forEach((id, index) => {+ if (merged.includes(id)) return;+ const anchor = previous+ .slice(0, index)+ .reverse()+ .find((before) => merged.includes(before));+ merged.splice(anchor === undefined ? 0 : merged.indexOf(anchor) + 1, 0, id);+ });+ return merged;+}++/** Saved order restricted to entries that exist now; unplaced plugins follow in their given order. */+export function resolveSidebarNavigationOrder(+ order: readonly SidebarNavigationEntryId[],+ ghostIds: readonly string[],+): SidebarNavigationEntryId[] {+ const installed = new Set(ghostIds);+ const placed = order.filter((id) => {+ const ghostId = ghostIdOfEntry(id);+ return ghostId === null || installed.has(ghostId);+ });+ return [...placed, ...ghostIds.map(appEntryId).filter((id) => !placed.includes(id))];+}++/** Per-account key; see sidebarOwnerStorage for the owner suffix and switch guard. */+const STORAGE_KEY = 'sidebar-navigation:v2';++export interface SidebarNavigationPrefs {+ order: SidebarNavigationEntryId[];+ /** Built-in entries shown at the top level; the rest live in More. */+ visible: SidebarNavigationItemId[];+ /** Plugin main views placed at the top level; every other sidebar plugin sits in More. */+ appsAtTop: SidebarNavigationAppEntryId[];+}++export type SidebarNavigationPrefsInput = Omit<SidebarNavigationPrefs, 'appsAtTop'> & {+ appsAtTop?: SidebarNavigationAppEntryId[];+};++/** Only explicit differences from the current product defaults are persisted. */+interface SidebarNavigationOverride {+ order?: SidebarNavigationEntryId[];+ /** Built-ins in either direction; plugin entries only ever as `true` (at the top level). */+ visibility?: Partial<Record<SidebarNavigationEntryId, boolean>>;+}++const defaultPrefs = (): SidebarNavigationPrefs => ({+ order: [...SIDEBAR_NAVIGATION_ITEMS],+ visible: [...DEFAULT_SIDEBAR_NAVIGATION_VISIBLE],+ appsAtTop: [],+});+const DEFAULT_SERVER_SNAPSHOT = defaultPrefs();++function validIds(value: unknown): SidebarNavigationItemId[] {+ return Array.isArray(value)+ ? [+ ...new Set(+ value.filter((id): id is SidebarNavigationItemId =>+ SIDEBAR_NAVIGATION_ITEMS.includes(id as SidebarNavigationItemId),+ ),+ ),+ ]+ : [];+}++function validOrder(value: unknown): SidebarNavigationEntryId[] {+ return Array.isArray(value)+ ? [+ ...new Set(+ value.filter(+ (id): id is SidebarNavigationEntryId =>+ typeof id === 'string' &&+ (isBuiltInEntry(id as SidebarNavigationEntryId) ||+ (id.startsWith(APP_ENTRY_PREFIX) &&+ id.length > APP_ENTRY_PREFIX.length &&+ id.length <= MAX_APP_ENTRY_LENGTH)),+ ),+ ),+ ]+ : [];+}++function validAppEntries(value: unknown): SidebarNavigationAppEntryId[] {+ return validOrder(value).filter((id): id is SidebarNavigationAppEntryId => !isBuiltInEntry(id));+}++function normalize(value: unknown): SidebarNavigationPrefs {+ const fallback = defaultPrefs();+ if (!value || typeof value !== 'object') return fallback;+ const candidate = value as { order?: unknown; visible?: unknown; appsAtTop?: unknown };+ const order = validOrder(candidate.order);+ return {+ order: [...order, ...fallback.order.filter((id) => !order.includes(id))],+ visible: Array.isArray(candidate.visible) ? validIds(candidate.visible) : fallback.visible,+ appsAtTop: validAppEntries(candidate.appsAtTop),+ };+}++function applyOverride(value: unknown): SidebarNavigationPrefs {+ const fallback = defaultPrefs();+ if (!value || typeof value !== 'object') return fallback;+ const override = value as SidebarNavigationOverride;+ const order = validOrder(override.order);+ const visibility = override.visibility ?? {};+ return {+ order: [...order, ...fallback.order.filter((id) => !order.includes(id))],+ visible: SIDEBAR_NAVIGATION_ITEMS.filter((id) => {+ const selected = visibility[id];+ return typeof selected === 'boolean'+ ? selected+ : DEFAULT_SIDEBAR_NAVIGATION_VISIBLE.includes(id);+ }),+ appsAtTop: validAppEntries(Object.keys(visibility)).filter((id) => visibility[id] === true),+ };+}++function toOverride(prefs: SidebarNavigationPrefs): SidebarNavigationOverride {+ const defaults = defaultPrefs();+ const override: SidebarNavigationOverride = {};+ if (+ prefs.order.length !== defaults.order.length ||+ prefs.order.some((id, index) => id !== defaults.order[index])+ ) {+ override.order = prefs.order;+ }+ const visibility: NonNullable<SidebarNavigationOverride['visibility']> = {};+ for (const id of SIDEBAR_NAVIGATION_ITEMS) {+ const selected = prefs.visible.includes(id);+ if (selected !== defaults.visible.includes(id)) visibility[id] = selected;+ }+ for (const id of prefs.appsAtTop) visibility[id] = true;+ if (Object.keys(visibility).length) override.visibility = visibility;+ return override;+}++/**+ * Preferences belong to the account, like the other sidebar layout settings:+ * each data owner keeps its own order, top-level entries and plugins in More.+ * Reads go through the owner guard (a synchronous Main check), so parsed values+ * are cached per owner and refreshed only on writes here or storage events from+ * other windows. Without an owner the product defaults apply and nothing is saved.+ */+const cache = new Map<string, SidebarNavigationPrefs>();+const listeners = new Set<() => void>();++function readPrefs(owner: string): SidebarNavigationPrefs {+ const raw = readSidebarOwnerStorage(STORAGE_KEY, owner);+ if (raw === null) return DEFAULT_SERVER_SNAPSHOT;+ try {+ return applyOverride(JSON.parse(raw));+ } catch {+ return DEFAULT_SERVER_SNAPSHOT;+ }+}++if (typeof window !== 'undefined') {+ window.addEventListener('storage', (event) => {+ if (event.key !== null && !event.key.startsWith(`${STORAGE_KEY}.owner.`)) return;+ cache.clear();+ listeners.forEach((listener) => listener());+ });+}++export function getSidebarNavigationPrefs(owner: string | null): SidebarNavigationPrefs {+ if (!owner) return DEFAULT_SERVER_SNAPSHOT;+ const cached = cache.get(owner);+ if (cached) return cached;+ const prefs = readPrefs(owner);+ cache.set(owner, prefs);+ return prefs;+}++export function subscribeSidebarNavigationPrefs(listener: () => void): () => void {+ listeners.add(listener);+ return () => listeners.delete(listener);+}++/** Returns whether the preferences reached storage, not just this window's cache. */+export function setSidebarNavigationPrefs(+ owner: string | null,+ prefs: SidebarNavigationPrefsInput,+): boolean {+ if (!owner) return false;+ const next = normalize(prefs);+ // Keep this window consistent even if the owner guard or storage refuses the write.+ cache.set(owner, next);+ const persisted = writeSidebarOwnerStorage(STORAGE_KEY, owner, JSON.stringify(toOverride(next)));+ listeners.forEach((listener) => listener());+ return persisted;+}++export function useSidebarNavigationPrefs(owner: string | null): SidebarNavigationPrefs {+ return useSyncExternalStore(+ subscribeSidebarNavigationPrefs,+ () => getSidebarNavigationPrefs(owner),+ () => DEFAULT_SERVER_SNAPSHOT,+ );+}++/* ------------------------------------------------------------------------- */+/* Plugin entries joining the sidebar */+/* ------------------------------------------------------------------------- */++/**+ * Plugins are installed per account, so arrivals are tracked per data owner:+ * `known` lists plugins that have been in the sidebar before, `unseen` the ones+ * placed into More on arrival that the user has not looked at yet ("New").+ */+interface SidebarAppArrivals {+ known: string[];+ unseen: string[];+}++const ARRIVALS_STORAGE_KEY = 'sidebar-navigation:apps:v1';+const EMPTY_UNSEEN: readonly string[] = [];++function readArrivals(): Record<string, SidebarAppArrivals> {+ try {+ const raw = JSON.parse(localStorage.getItem(ARRIVALS_STORAGE_KEY) ?? '{}') as unknown;+ if (!raw || typeof raw !== 'object') return {};+ const strings = (value: unknown) =>+ Array.isArray(value)+ ? [...new Set(value.filter((id): id is string => typeof id === 'string'))]+ : [];+ return Object.fromEntries(+ Object.entries(raw as Record<string, Partial<SidebarAppArrivals>>).map(([owner, record]) => [+ owner,+ { known: strings(record?.known), unseen: strings(record?.unseen) },+ ]),+ );+ } catch {+ return {};+ }+}++let arrivals = readArrivals();+const arrivalListeners = new Set<() => void>();++function writeArrivals(next: Record<string, SidebarAppArrivals>): void {+ arrivals = next;+ try {+ localStorage.setItem(ARRIVALS_STORAGE_KEY, JSON.stringify(next));+ } catch {+ // Keep this window consistent even if persistence is unavailable.+ }+ arrivalListeners.forEach((listener) => listener());+}++if (typeof window !== 'undefined') {+ window.addEventListener('storage', (event) => {+ if (event.key !== ARRIVALS_STORAGE_KEY) return;+ arrivals = readArrivals();+ arrivalListeners.forEach((listener) => listener());+ });+}++/**+ * Track plugins entering the sidebar so new ones carry a New tag. They need no+ * placement write: plugins default to More. The first run for an owner keeps the+ * plugins already in the sidebar at the top level, so nothing moves on upgrade.+ * Idempotent.+ */+export function reconcileSidebarAppArrivals(+ owner: string,+ ghostIds: readonly string[],+ rosterReady: boolean,+): void {+ // Main reports no plugins at all while an account switch settles, and every real+ // session carries at least the bundled ones. Until the installed roster is known,+ // record nothing: neither a baseline nor arrivals. Once it is, an empty sidebar is+ // a real baseline, so the owner's first sidebar plugin still starts in More.+ if (!rosterReady) return;+ const record = arrivals[owner];+ if (!record) {+ if (ghostIds.length > 0) {+ const prefs = getSidebarNavigationPrefs(owner);+ const kept = setSidebarNavigationPrefs(owner, {+ ...prefs,+ appsAtTop: [...new Set([...prefs.appsAtTop, ...ghostIds.map(appEntryId)])],+ });+ // Without the stored top-level placement a restart would move these plugins+ // into More; leave the first run to be retried instead of recording it.+ if (!kept) return;+ }+ writeArrivals({ ...arrivals, [owner]: { known: [...ghostIds], unseen: [] } });+ return;+ }+ const arrived = ghostIds.filter((id) => !record.known.includes(id));+ // A new plugin removed or switched off before it was seen is no longer news.+ const unseen = record.unseen.filter((id) => ghostIds.includes(id));+ if (arrived.length === 0 && unseen.length === record.unseen.length) return;+ writeArrivals({+ ...arrivals,+ [owner]: { known: [...record.known, ...arrived], unseen: [...unseen, ...arrived] },+ });+}++/** Plugins this owner has had in the sidebar, including ones whose switch is off now. */+export function getSidebarKnownApps(owner: string | null): readonly string[] {+ return owner ? (arrivals[owner]?.known ?? EMPTY_UNSEEN) : EMPTY_UNSEEN;+}++/** Opening More shows every new entry, so they stop being flagged. */+export function markSidebarAppArrivalsSeen(owner: string): void {+ const record = arrivals[owner];+ if (!record || record.unseen.length === 0) return;+ writeArrivals({ ...arrivals, [owner]: { ...record, unseen: [] } });+}++export function useSidebarUnseenApps(owner: string | null): readonly string[] {+ return useSyncExternalStore(+ (listener) => {+ arrivalListeners.add(listener);+ return () => arrivalListeners.delete(listener);+ },+ () => (owner ? (arrivals[owner]?.unseen ?? EMPTY_UNSEEN) : EMPTY_UNSEEN),+ () => EMPTY_UNSEEN,+ );+}++export const __testing = {+ /** Re-read arrivals from storage, as a fresh window would. */+ resetArrivals(): void {+ arrivals = readArrivals();+ arrivalListeners.clear();+ },+ /** Forget cached preferences, as a fresh window would. */+ resetPrefsCache(): void {+ cache.clear();+ },+};diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsxindex 0be0d2d026..a7be9828d8 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx@@ -37,9 +37,7 @@ import {Folder,Hammer,Loader2,- Plug,SquarePen,- Timer,Trash2,X,} from 'lucide-react';@@ -65,7 +63,7 @@ import {import { WORKLOUDER_CODEX_AGENT_SLOT_COUNT } from '../../../shared/workLouderCodex';import { setSessionOrdinalBadges } from './sidebar/sessionOrdinalBadges';import { useOwnTopNavScrollableRows, useSidebarCollapsedState } from '../feature-context';-import { SidebarTopNav } from '@/components/sidebar/SidebarTopNav';+import { SidebarRailNavigation, SidebarTopNav } from '@/components/sidebar/SidebarTopNav';import { SidebarFilterPopover } from './sidebar/SidebarFilterPopover';import { MainListScopeHeader } from './sidebar/MainListScopeHeader';import { SharedTasksSection } from '@/features/device-link/SharedTasksSection';@@ -96,10 +94,6 @@ import {} from '@/lib/worktreeRemovalWarning';import { useSessionRunningStatus } from '@/hooks/useSessionRunningStatus';import { useAttachedSessionIds } from '@/hooks/useAttachedSessionIds';-import { useActiveMainView } from '@/hooks/useActiveMainView';-import { useAnyGhostUnread } from '@/cindy-brain/ghostUnreadStore';-import { GhostPanelRestoreEntry } from '@/cindy-brain/GhostPanelRestoreEntry';-import { GhostMainViewNavEntries } from '@/components/sidebar/GhostMainViewNavEntries';import {BOT_GROUP_LANE_SESSION,botOwnedSessionNotificationTitle,@@ -418,8 +412,9 @@ export function CCAgentSidebarUpper() {const isCollapsed = useSidebarCollapsedState();// 展开态由本 Feature 在自己的列表滚动区里渲染顶部导航的可滚动段(自动任务 /// 插件 / 搜索 / 远程机器),shell 顶部只留固定的「新建」——列表上滚时这些行一起- // 滚走(2026-08-12 用户裁决,对齐 Codex)。rail 态没有该滚动区,交回 shell 整块渲染。- useOwnTopNavScrollableRows(!isCollapsed);+ // 滚走(2026-08-12 用户裁决,对齐 Codex)。rail 态由 CollapsedView 按同一份导航偏好+ // 整段渲染(含伙伴),shell 不再补 rail 伙伴图标。+ useOwnTopNavScrollableRows(true);// F-PJ-10:filter.status 决定后端 fetch 时是否带 ?status=archived|allconst hiddenProjects = useHiddenProjects();const { hiddenProjectKeys, initialSnapshot: sidebarSettingsSnapshot } = hiddenProjects;@@ -3974,15 +3969,6 @@ function CollapsedView({const handleNewCCS = useCallback(() => {navigate('/cc-agent/new', { state: makeGenericNewMakerRouteState(location.pathname) });}, [location.pathname, navigate]);- const handleNavScheduled = useCallback(() => {- navigate('/cc-agent/scheduled');- }, [navigate]);- const onScheduleMatch = useMatch('/cc-agent/scheduled');- // 主视图切换(Plugin / Skill 管理)——与展开态 SidebarTopNav 的管理入口同源:- // 命中 Plugin 或 Skill 视图时高亮。折叠 rail 之前漏了这颗按钮,现保持两态一致。- const { activeKey, navigateToView } = useActiveMainView();- // 插件未读聚合(badge 槽)——与展开态同源同语义。- const hasGhostUnread = useAnyGhostUnread();// 接管中的会话(/ctr)——面板行沿用 SessionStatusIcon 的 RadioTower 表达。const attachedSessionIds = useAttachedSessionIds();@@ -4011,37 +3997,24 @@ function CollapsedView({label={t('ccAgent.layout.new')}onClick={handleNewCCS}/>- {/* 自动化 rail 入口 —— 仅导航,不再显示未读 dot(与展开态 SidebarTopNav 一致,- 未读 / 运行状态由展开后的各 schedule 组头承载)。 */}- <SidebarIconButton- icon={Timer}- label={t('ccAgent.layout.automations')}- aria-label={t('ccAgent.layout.automations')}- aria-current={onScheduleMatch ? 'page' : undefined}- active={Boolean(onScheduleMatch)}- onClick={handleNavScheduled}- />- <GhostMainViewNavEntries variant="rail" />- {/* 插件 rail 入口 —— 未读绿点与展开态 SidebarTopNav 对称(同一聚合语义:- 任一插件有未读就点亮,静态不呼吸)。 */}- <SidebarIconButton- icon={Plug}- label={t('sidebar.tabs.plugins')}- active={activeKey === 'plugins'}- aria-current={activeKey === 'plugins' ? 'page' : undefined}- showDot={hasGhostUnread}- onClick={() => navigateToView('plugins')}- />- <GhostPanelRestoreEntry variant="rail" className={SIDEBAR_RAIL_ICON_BUTTON_CLASS} />- <ConversationSearchBox- navigate={navigate}- allKnownProjects={allSearchProjects}- allowedSessionIds={searchableSessionIds}- hiddenProjectKeys={hiddenProjectKeys}- projectFilterRequest={isCollapsed ? projectFilterRequest : null}- machineSelection={selectedMachineId}- searchDevices={searchDevices}- triggerClassName={SIDEBAR_RAIL_ICON_BUTTON_CLASS}+ {/* 自动化 / 插件 / 伙伴 / 搜索按「自定义」的顺序与勾选排列,未勾选项收进「更多」+ (与展开态 SidebarTopNav 同一份偏好)。搜索在 project-menu 锁定请求时临时出现。 */}+ <SidebarRailNavigation+ forceSearch={isCollapsed && projectFilterRequest != null}+ renderSearch={({ defaultOpen, onOpenChange }) => (+ <ConversationSearchBox+ navigate={navigate}+ allKnownProjects={allSearchProjects}+ allowedSessionIds={searchableSessionIds}+ hiddenProjectKeys={hiddenProjectKeys}+ projectFilterRequest={isCollapsed ? projectFilterRequest : null}+ machineSelection={selectedMachineId}+ searchDevices={searchDevices}+ triggerClassName={SIDEBAR_RAIL_ICON_BUTTON_CLASS}+ defaultOpen={defaultOpen}+ onOpenChange={onOpenChange}+ />+ )}/><div className="my-[7px] h-px w-[22px] shrink-0 bg-sidebar-border" aria-hidden />diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsxindex 4bf13a8f0f..e0bb3f5f4d 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsx@@ -653,6 +653,8 @@ export interface ConversationSearchBoxProps {triggerClassName?: string;/** Popover open 态变化上报(供 SidebarActionBar 的 openChildCount 守卫;含程序化打开)。 */onOpenChange?: (open: boolean) => void;+ /** 挂载即打开:rail 从「更多」打开未勾选的搜索时,图标随打开一起出现。 */+ defaultOpen?: boolean;}/**@@ -670,9 +672,10 @@ export function ConversationSearchBox({searchDevices = EMPTY_SEARCH_DEVICES,triggerClassName,onOpenChange,+ defaultOpen = false,}: ConversationSearchBoxProps) {const { t } = useTranslation();- const [open, setOpen] = useState(false);+ const [open, setOpen] = useState(defaultOpen);const inputRef = useRef<HTMLInputElement>(null);// search.reset 在 search 声明后才拿得到,但 handleResultChosen 需先于 search 定义(要作为diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarInlineSearch.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarInlineSearch.tsxindex e6a158d2eb..c2c00be9eb 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarInlineSearch.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarInlineSearch.tsx@@ -1,5 +1,5 @@/**- * SidebarInlineSearch —— SidebarTopNav 顶部导航列表末尾的「搜索」行。+ * SidebarInlineSearch —— SidebarTopNav 顶部导航中可排序的「搜索」行。* ---------------------------------------------------------------------------* 渲染为一条裸行(无外层 padding),融入 SidebarTopNav 的 gap-0.5 列表,与 新建/自动任务/* 插件等入口同款。两态一体、图标位置恒定:@@ -43,6 +43,8 @@ export interface SidebarInlineSearchProps {* 故一旦 query 非空就切回 cc-agent(同视图时宿主内部去重、为 no-op)。*/onSearchActive?: () => void;+ /** Let a search opened from More leave the sidebar again after focus moves away. */+ onFocusLeave?: () => void;}export function SidebarInlineSearch({@@ -50,6 +52,7 @@ export function SidebarInlineSearch({allKnownProjects,openSignal,onSearchActive,+ onFocusLeave,}: SidebarInlineSearchProps) {const { t } = useTranslation();const inputRef = useRef<HTMLInputElement>(null);@@ -121,6 +124,7 @@ export function SidebarInlineSearch({if (event.currentTarget.contains(event.relatedTarget as Node | null)) return;setFocusWithin(false);setForceOpen(false);+ if (!menuOpen) onFocusLeave?.();}}className={cn('flex h-8 w-full items-center gap-2.5 rounded-full border pl-3 transition-colors',diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 7b7390d505..2aa9fdcb56 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -5768,7 +5768,7 @@"configurationTitle": "Configuration","sidebarEntryTitle": "Sidebar entry","showInSidebar": "Show in sidebar",- "sidebarEntryDescription": "When turned on, “{{title}}” appears in the sidebar. Hiding it does not disable the plugin.",+ "sidebarEntryDescription": "When turned on, “{{title}}” appears in the sidebar, either at the top or under More — choose where in More → Customize. Hiding it does not disable the plugin.","iosSimulatorAutoOpenTitle": "Open the embedded Simulator panel automatically","iosSimulatorAutoOpenDescription": "Show the Simulator in the right sidebar after starting it or launching an app. When off, you can still open it manually; all other features are unchanged.","openTool": "View details for Tool {{name}}",@@ -7841,6 +7841,22 @@"issues": "Issues","bots": "Teammates"},+ "navigation": {+ "more": "More",+ "new": "New",+ "customize": {+ "title": "Customize",+ "done": "Done",+ "reset": "Reset to default",+ "reorder": "Reorder {{name}} with the up and down arrow keys"+ },+ "items": {+ "automations": "Automations",+ "plugins": "Plugins",+ "bots": "Teammates",+ "search": "Search"+ }+ },"user": {"settingsLink": "Settings, current user: {{name}}","settingsLinkBeta": "Settings, current user: {{name}}, Beta channel enabled",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 3d92b916c0..1a0265441a 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -5767,7 +5767,7 @@"configurationTitle": "設定","sidebarEntryTitle": "サイドバー項目","showInSidebar": "サイドバーに表示",- "sidebarEntryDescription": "オンにすると、サイドバーに「{{title}}」が表示されます。非表示にしてもプラグインは無効になりません。",+ "sidebarEntryDescription": "オンにすると、「{{title}}」がサイドバーに表示されます。最上部に置くか「その他」にまとめるかは「その他 → カスタマイズ」で変更できます。非表示にしてもプラグインは無効になりません。","iosSimulatorAutoOpenTitle": "内蔵シミュレータパネルを自動的に開く","iosSimulatorAutoOpenDescription": "シミュレータの起動時または App の起動後に、右側へシミュレータ画面を自動表示します。オフでも手動で開くことができ、ほかの機能には影響しません。","openTool": "Tool {{name}} の詳細を表示",@@ -7839,6 +7839,22 @@"issues": "問題","bots": "仲間"},+ "navigation": {+ "more": "その他",+ "new": "新着",+ "customize": {+ "title": "カスタマイズ",+ "done": "完了",+ "reset": "初期設定に戻す",+ "reorder": "上下矢印キーで{{name}}の順序を変更"+ },+ "items": {+ "automations": "自動化",+ "plugins": "プラグイン",+ "bots": "仲間",+ "search": "検索"+ }+ },"user": {"settingsLink": "設定, 現在のユーザー: {{name}}","settingsLinkBeta": "設定, 現在のユーザー: {{name}}, Beta チャンネル有効",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 4ff938f197..b3a55213f8 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -5767,7 +5767,7 @@"configurationTitle": "설정","sidebarEntryTitle": "사이드바 항목","showInSidebar": "사이드바에 표시",- "sidebarEntryDescription": "켜면 사이드바에 “{{title}}” 항목이 표시됩니다. 숨겨도 플러그인이 비활성화되지는 않습니다.",+ "sidebarEntryDescription": "켜면 “{{title}}” 항목이 사이드바에 표시됩니다. 맨 위에 둘지 “더 보기”에 넣을지는 “더 보기 → 사용자 지정”에서 바꿀 수 있습니다. 숨겨도 플러그인이 비활성화되지는 않습니다.","iosSimulatorAutoOpenTitle": "내장 시뮬레이터 패널 자동 열기","iosSimulatorAutoOpenDescription": "시뮬레이터를 시작하거나 App을 실행한 뒤 오른쪽에 시뮬레이터 화면을 자동으로 표시합니다. 꺼도 수동으로 열 수 있으며 다른 기능에는 영향을 주지 않습니다.","openTool": "Tool {{name}} 세부 정보 보기",@@ -7839,6 +7839,22 @@"issues": "이슈","bots": "동료"},+ "navigation": {+ "more": "더 보기",+ "new": "새 항목",+ "customize": {+ "title": "사용자 지정",+ "done": "완료",+ "reset": "기본값으로 복원",+ "reorder": "위아래 화살표 키로 {{name}} 순서 변경"+ },+ "items": {+ "automations": "자동화",+ "plugins": "플러그인",+ "bots": "동료",+ "search": "검색"+ }+ },"user": {"settingsLink": "설정, 현재 사용자: {{name}}","settingsLinkBeta": "설정, 현재 사용자: {{name}}, 베타 채널 활성화됨",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 004d3ff603..6a889fcce1 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -5767,7 +5767,7 @@"configurationTitle": "配置","sidebarEntryTitle": "侧边栏入口","showInSidebar": "显示在侧边栏",- "sidebarEntryDescription": "开启后,侧边栏会显示“{{title}}”。隐藏入口不会停用插件。",+ "sidebarEntryDescription": "开启后,“{{title}}”会出现在侧边栏,显示在最外层还是收进“更多”,可在“更多 → 自定义”里调整。隐藏入口不会停用插件。","iosSimulatorAutoOpenTitle": "自动打开内置模拟器面板","iosSimulatorAutoOpenDescription": "启动模拟器或打开 App 后,自动在右侧显示模拟器画面。关闭后仍可手动打开,其他功能不受影响。","openTool": "查看 Tool {{name}} 的详情",@@ -7839,6 +7839,17 @@"issues": "Issue","bots": "伙伴"},+ "navigation": {+ "more": "更多",+ "new": "新",+ "customize": {+ "title": "自定义",+ "done": "完成",+ "reset": "恢复默认",+ "reorder": "调整{{name}}顺序,按上下方向键"+ },+ "items": { "automations": "自动化", "plugins": "插件", "bots": "伙伴", "search": "搜索" }+ },"user": {"settingsLink": "设置,当前用户:{{name}}","settingsLinkBeta": "设置,当前用户:{{name}},Beta 测试渠道已开启",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 48693b1fcf..954d15eb68 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -5767,7 +5767,7 @@"configurationTitle": "配置","sidebarEntryTitle": "側邊欄入口","showInSidebar": "顯示在側邊欄",- "sidebarEntryDescription": "開啟後,側邊欄會顯示「{{title}}」。隱藏入口不會停用插件。",+ "sidebarEntryDescription": "開啟後,「{{title}}」會出現在側邊欄,顯示在最外層還是收進「更多」,可在「更多 → 自訂」中調整。隱藏入口不會停用插件。","iosSimulatorAutoOpenTitle": "自動開啟內建模擬器面板","iosSimulatorAutoOpenDescription": "啟動模擬器或開啟 App 後,自動在右側顯示模擬器畫面。關閉後仍可手動開啟,其他功能不受影響。","openTool": "檢視 Tool {{name}} 的詳情",@@ -7839,6 +7839,17 @@"issues": "Issue","bots": "夥伴"},+ "navigation": {+ "more": "更多",+ "new": "新",+ "customize": {+ "title": "自訂",+ "done": "完成",+ "reset": "恢復預設",+ "reorder": "調整{{name}}順序,按上下方向鍵"+ },+ "items": { "automations": "自動化", "plugins": "插件", "bots": "夥伴", "search": "搜尋" }+ },"user": {"settingsLink": "設定,當前使用者:{{name}}","settingsLinkBeta": "設定,當前使用者:{{name}},Beta 測試管道已開啟",diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.mdindex 2f1b75cad0..fa6c251192 100644--- a/docs/design-rules/design-inventory.md+++ b/docs/design-rules/design-inventory.md@@ -9,7 +9,7 @@本区块由 `scripts/design-inventory.mjs` 生成,请勿手改。重新生成:`pnpm design:inventory`;校验:`pnpm check:design-inventory`。-计数快照日期:2026-10-04。生成命令:`pnpm design:inventory`。裸颜色匹配与 `scripts/hardcoded-color-audit.mjs` 共用 `scripts/shared/hardcoded-color-match.mjs`(HEX / RGB / HSL / OKLCH 等字面通道),两者在共享 matcher 内统一排除纯语义包装、注释及 PR 编号;数值颜色函数还需位于样式属性、CSS 声明/函数或任意值语境,普通文案字符串里的颜色函数文本不计入;字面 fallback 仍计入——语义 token 消费与注释引用不是迁移债务;裸圆角为粗粒度(`rounded*` class、`border-radius:` 与 React style 对象的 `borderRadius:`)。Token 计数为样式源里 `var(--token)` / `hsl(var(--token)` 的去重 ID 数;Mobile 的 ThemeColors / typeScale 等 RN 属性不计入此列,不能将 0 解释为未使用 Token。+计数快照日期:2026-10-05。生成命令:`pnpm design:inventory`。裸颜色匹配与 `scripts/hardcoded-color-audit.mjs` 共用 `scripts/shared/hardcoded-color-match.mjs`(HEX / RGB / HSL / OKLCH 等字面通道),两者在共享 matcher 内统一排除纯语义包装、注释及 PR 编号;数值颜色函数还需位于样式属性、CSS 声明/函数或任意值语境,普通文案字符串里的颜色函数文本不计入;字面 fallback 仍计入——语义 token 消费与注释引用不是迁移债务;裸圆角为粗粒度(`rounded*` class、`border-radius:` 与 React style 对象的 `borderRadius:`)。Token 计数为样式源里 `var(--token)` / `hsl(var(--token)` 的去重 ID 数;Mobile 的 ThemeColors / typeScale 等 RN 属性不计入此列,不能将 0 解释为未使用 Token。登记 surface 数:52。平台包含 Desktop 与 Mobile;静态入口发现不表示已迁移或已实机验证。@@ -39,7 +39,7 @@| `desktop.plugins.app-main` | desktop | 插件主视图 | hash `/apps/:ghostId`(GhostMainViewFeatureLayout) | GhostMainViewFeatureLayout, GhostMainViewHost | apps/desktop/src/renderer/features/plugin/GhostMainViewFeatureLayout.tsx, apps/desktop/src/renderer/features/plugin/GhostMainViewHost.tsx | 0 | 0 | 0 || `desktop.plugins.installed` | desktop | 已装插件 | hash `/plugins`(GhostPluginPage) | AddMarketplaceDialog, GhostPluginDetailView, GhostPluginPage, MarketPluginDetailView, MyPublishesSection, PluginManagementLayout, PluginScopePicker, UpdateAllDialog | apps/desktop/src/renderer/features/plugin/AddMarketplaceDialog.tsx, apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx, apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx, apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx, apps/desktop/src/renderer/features/plugin/MyPublishesSection.tsx, apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx, apps/desktop/src/renderer/features/plugin/PluginScopePicker.tsx, apps/desktop/src/renderer/features/plugin/UpdateAllDialog.tsx, apps/desktop/src/renderer/features/plugin/plugin-motion.css | 28 | 0 | 48 || `desktop.settings` | desktop | 设置 | hash `/settings`(SettingsView;tab 含 general / personalization / providers / billing / usage / voice-input / im-bot / shortcuts / agent-island / import / remote-control / ghosts / builtin-tools / computer-use / help / about) | SettingsView | apps/desktop/src/renderer/components/settings/AboutSection.settings-search.ts, apps/desktop/src/renderer/components/settings/AboutSection.tsx, apps/desktop/src/renderer/components/settings/AccountDeletionSection.tsx, apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx, apps/desktop/src/renderer/components/settings/AgentIslandSection.settings-search.ts, apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx, apps/desktop/src/renderer/components/settings/AgentResourceSection.settings-search.ts, apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx, apps/desktop/src/renderer/components/settings/AppearanceSection.settings-search.ts, apps/desktop/src/renderer/components/settings/AppearanceSection.tsx, apps/desktop/src/renderer/components/settings/AuxiliaryModelSection.tsx, apps/desktop/src/renderer/components/settings/BetaChannelCell.tsx, apps/desktop/src/renderer/components/settings/BillingSettings.settings-search.ts, apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx, apps/desktop/src/renderer/components/settings/BrowserRealProfileSubsection.tsx, apps/desktop/src/renderer/components/settings/BuiltinToolsSection.settings-search.ts, apps/desktop/src/renderer/components/settings/BuiltinToolsSection.tsx, apps/desktop/src/renderer/components/settings/ChatEmbeddingCell.tsx, apps/desktop/src/renderer/components/settings/ChipMetricsSection.tsx, apps/desktop/src/renderer/components/settings/CindyMakeSection.settings-search.ts, apps/desktop/src/renderer/components/settings/CindyMakeSection.tsx, apps/desktop/src/renderer/components/settings/CollaborationSection.settings-search.ts, apps/desktop/src/renderer/components/settings/CollaborationSection.tsx, apps/desktop/src/renderer/components/settings/CompactionSection.tsx, apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsx, apps/desktop/src/renderer/components/settings/ComputerPermissionGuideWindow.tsx, apps/desktop/src/renderer/components/settings/ComputerPermissionRow.tsx, apps/desktop/src/renderer/components/settings/ComputerUseSection.settings-search.ts, apps/desktop/src/renderer/components/settings/ComputerUseSection.tsx, apps/desktop/src/renderer/components/settings/CustomProviderRuntimeFillOverlay.tsx, apps/desktop/src/renderer/components/settings/DefaultOverrideControls.tsx, apps/desktop/src/renderer/components/settings/DialogueDirectorySection.tsx, apps/desktop/src/renderer/components/settings/DingTalkBotSection.tsx, apps/desktop/src/renderer/components/settings/DiscordBotSection.tsx, apps/desktop/src/renderer/components/settings/DownloadMeter.tsx, apps/desktop/src/renderer/components/settings/ExperimentalSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotNotificationSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotSection.tsx, apps/desktop/src/renderer/components/settings/FontFamilyPicker.tsx, apps/desktop/src/renderer/components/settings/GeneralSettings.settings-search.ts, apps/desktop/src/renderer/components/settings/GenericGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/GitSafetySection.settings-search.ts, apps/desktop/src/renderer/components/settings/GitSafetySection.tsx, apps/desktop/src/renderer/components/settings/HarnessVersionMenuRow.tsx, apps/desktop/src/renderer/components/settings/HelpAssistantPanel.tsx, apps/desktop/src/renderer/components/settings/HelpSection.settings-search.ts, apps/desktop/src/renderer/components/settings/HelpSection.tsx, apps/desktop/src/renderer/components/settings/HelpThreadView.tsx, apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsx, apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx, apps/desktop/src/renderer/components/settings/ImBotSection.settings-search.ts, apps/desktop/src/renderer/components/settings/ImBotSection.tsx, apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx, apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx, apps/desktop/src/renderer/components/settings/ImLifecycleAnnouncementSection.tsx, apps/desktop/src/renderer/components/settings/InputDeviceConnectionStatus.tsx, apps/desktop/src/renderer/components/settings/JoyConGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/KeyboardShortcutsSection.settings-search.ts, apps/desktop/src/renderer/components/settings/KeyboardShortcutsSection.tsx, apps/desktop/src/renderer/components/settings/LanguageSection.tsx, apps/desktop/src/renderer/components/settings/LayoutResetControl.tsx, apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx, apps/desktop/src/renderer/components/settings/LlamaCppCandidates.tsx, apps/desktop/src/renderer/components/settings/LlamaCppProviderDetail.tsx, apps/desktop/src/renderer/components/settings/LocalModelDownloadUI.tsx, apps/desktop/src/renderer/components/settings/LocalOllamaInstall.tsx, apps/desktop/src/renderer/components/settings/LocalPackagingTag.tsx, apps/desktop/src/renderer/components/settings/LogoutSection.tsx, apps/desktop/src/renderer/components/settings/LspBetaCell.tsx, apps/desktop/src/renderer/components/settings/McpServerDialog.tsx, apps/desktop/src/renderer/components/settings/McpServersSection.tsx, apps/desktop/src/renderer/components/settings/MemorySection.tsx, apps/desktop/src/renderer/components/settings/MessageNavRailCell.tsx, apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx, apps/desktop/src/renderer/components/settings/ModelPriceOverrideDialog.tsx, apps/desktop/src/renderer/components/settings/MyDevicesPanel.tsx, apps/desktop/src/renderer/components/settings/NotificationSection.settings-search.ts, apps/desktop/src/renderer/components/settings/NotificationSection.tsx, apps/desktop/src/renderer/components/settings/OAuthDeviceCodeCard.tsx, apps/desktop/src/renderer/components/settings/OllamaProviderDetail.tsx, apps/desktop/src/renderer/components/settings/PersonalizationDetails.settings-search.ts, apps/desktop/src/renderer/components/settings/PersonalizationSettings.settings-search.ts, apps/desktop/src/renderer/components/settings/PiKernelVersionRow.tsx, apps/desktop/src/renderer/components/settings/PiPackagesSection.tsx, apps/desktop/src/renderer/components/settings/PlayStationGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/ProfileEditDialog.tsx, apps/desktop/src/renderer/components/settings/ProviderConnectionDialog.tsx, apps/desktop/src/renderer/components/settings/ProviderImportDialog.tsx, apps/desktop/src/renderer/components/settings/ProvidersSection.settings-search.ts, apps/desktop/src/renderer/components/settings/ProvidersSection.tsx, apps/desktop/src/renderer/components/settings/RemoteControlSection.settings-search.ts, apps/desktop/src/renderer/components/settings/RemoteControlSection.tsx, apps/desktop/src/renderer/components/settings/RemoteDesktopPermissions.tsx, apps/desktop/src/renderer/components/settings/RemoteDesktopSetting.tsx, apps/desktop/src/renderer/components/settings/RemoteHostDetail.tsx, apps/desktop/src/renderer/components/settings/RemoteSection.tsx, apps/desktop/src/renderer/components/settings/SessionImportSection.settings-search.ts, apps/desktop/src/renderer/components/settings/SessionImportSection.tsx, apps/desktop/src/renderer/components/settings/SessionRuntimeFallbackCell.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/settings/SettingsCatalogPanel.settings-search.ts, apps/desktop/src/renderer/components/settings/SettingsCatalogPanel.tsx, apps/desktop/src/renderer/components/settings/SettingsSearchBox.tsx, apps/desktop/src/renderer/components/settings/SettingsSearchNavigation.ts, apps/desktop/src/renderer/components/settings/SettingsSidebarNav.tsx, apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx, apps/desktop/src/renderer/components/settings/SettingsView.tsx, apps/desktop/src/renderer/components/settings/SharedTasks.settings-search.ts, apps/desktop/src/renderer/components/settings/SilentEncryptedRetryCell.tsx, apps/desktop/src/renderer/components/settings/SshKeySetupDialog.tsx, apps/desktop/src/renderer/components/settings/StorageManagementCard.settings-search.ts, apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx, apps/desktop/src/renderer/components/settings/StreamFadeSection.tsx, apps/desktop/src/renderer/components/settings/SubagentModelSection.settings-search.ts, apps/desktop/src/renderer/components/settings/SubagentModelSection.tsx, apps/desktop/src/renderer/components/settings/SwitchProGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx, apps/desktop/src/renderer/components/settings/TelegramBotSection.tsx, apps/desktop/src/renderer/components/settings/TelegramRemoteDevices.tsx, apps/desktop/src/renderer/components/settings/TerminalShellSection.tsx, apps/desktop/src/renderer/components/settings/TipsSection.settings-search.ts, apps/desktop/src/renderer/components/settings/TipsSection.tsx, apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx, apps/desktop/src/renderer/components/settings/UserProfileCard.tsx, apps/desktop/src/renderer/components/settings/UserPromptSection.tsx, apps/desktop/src/renderer/components/settings/VisionBridgeSection.settings-search.ts, apps/desktop/src/renderer/components/settings/VisionBridgeSection.tsx, apps/desktop/src/renderer/components/settings/VoiceInputSection.settings-search.ts, apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx, apps/desktop/src/renderer/components/settings/WallpaperSection.tsx, apps/desktop/src/renderer/components/settings/WechatBotSection.tsx, apps/desktop/src/renderer/components/settings/WecomBotSection.tsx, apps/desktop/src/renderer/components/settings/WindowBehaviorSection.settings-search.ts, apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeyboardLayout.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeycapGlyphs.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx, apps/desktop/src/renderer/components/settings/WorktreeRecycleCard.settings-search.ts, apps/desktop/src/renderer/components/settings/WorktreeRecycleCard.tsx, apps/desktop/src/renderer/components/settings/XUsageGuide.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadSettings.tsx, apps/desktop/src/renderer/components/settings/androidStatusPresentation.ts, apps/desktop/src/renderer/components/settings/billingVisibility.ts, apps/desktop/src/renderer/components/settings/browserOpenForLoginError.ts, apps/desktop/src/renderer/components/settings/cindyMakeVisibility.ts, apps/desktop/src/renderer/components/settings/computerPermissionFlow.ts, apps/desktop/src/renderer/components/settings/contacts/ContactDetailPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsImportDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsListPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsManagerDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsx, apps/desktop/src/renderer/components/settings/contacts/startContactsAiSession.ts, apps/desktop/src/renderer/components/settings/dialogueDirectoryDisplay.ts, apps/desktop/src/renderer/components/settings/dualSenseSilhouette.ts, apps/desktop/src/renderer/components/settings/feishuBotPresentation.ts, apps/desktop/src/renderer/components/settings/fontFamilyValue.ts, apps/desktop/src/renderer/components/settings/gamepadLayoutPrimitives.tsx, apps/desktop/src/renderer/components/settings/gamepadSilhouetteGeom.ts, apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts, apps/desktop/src/renderer/components/settings/imBotVisibility.ts, apps/desktop/src/renderer/components/settings/imDefaultSettingsLogic.ts, apps/desktop/src/renderer/components/settings/joyConSilhouette.ts, apps/desktop/src/renderer/components/settings/modelManagementPresentation.ts, apps/desktop/src/renderer/components/settings/modelManagementState.ts, apps/desktop/src/renderer/components/settings/myDevicesModel.ts, apps/desktop/src/renderer/components/settings/providerAssetModule.ts, apps/desktop/src/renderer/components/settings/realProfilePermissionGuide.ts, apps/desktop/src/renderer/components/settings/settingsSearchCatalog.ts, apps/desktop/src/renderer/components/settings/settingsSearchTypes.ts, apps/desktop/src/renderer/components/settings/switchProSilhouette.ts, apps/desktop/src/renderer/components/settings/ultimateC1Silhouette.ts, apps/desktop/src/renderer/components/settings/usage/UsageBarsTooltip.tsx, apps/desktop/src/renderer/components/settings/usage/UsageBreakdownTables.tsx, apps/desktop/src/renderer/components/settings/usage/UsageDeviceSelect.tsx, apps/desktop/src/renderer/components/settings/usage/UsageHistorySection.settings-search.ts, apps/desktop/src/renderer/components/settings/usage/UsageHistorySection.tsx, apps/desktop/src/renderer/components/settings/usage/UsageStatRow.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTokenBars.tsx, apps/desktop/src/renderer/components/settings/usage/formatUsagePercent.ts, apps/desktop/src/renderer/components/settings/usage/usageCharts.css, apps/desktop/src/renderer/components/settings/usage/usageHistoryColors.ts, apps/desktop/src/renderer/components/settings/usage/usageHistoryStats.ts, apps/desktop/src/renderer/components/settings/usageVisibility.ts, apps/desktop/src/renderer/components/settings/useProviderSubscriptionCard.ts, apps/desktop/src/renderer/components/settings/useSettingsSectionTarget.ts, apps/desktop/src/renderer/components/settings/wizardRecommend.ts, apps/desktop/src/renderer/components/settings/workLouderCodexCommandCopy.ts, apps/desktop/src/renderer/components/settings/xboxSeriesSilhouette.ts, apps/desktop/src/renderer/styles/sortable.css | 137 | 100 | 536 |-| `desktop.shell.main-layout` | desktop | 主窗口壳(标题栏 / 左右栏 / 内容区) | main BrowserWindow → renderer/index.tsx → main-entry.tsx → App → MainLayout (`#/` 受保护壳) | ChromeActions, DeviceSectionHeader, FeishuConflictDialogHost, GhostMediaLightboxHost, MainLayout, ProjectsSection, RightSidebar, RightSidebarShell, SessionShareImportWizard, Sidebar, UpdateNoticeDialog, WindowControls | apps/desktop/src/renderer/cindy-brain/GhostMediaLightboxHost.tsx, apps/desktop/src/renderer/components/UpdateNoticeDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialogHost.tsx, apps/desktop/src/renderer/components/layout/AppBadgeAttentionSync.tsx, apps/desktop/src/renderer/components/layout/BrowserWebviewPool.tsx, apps/desktop/src/renderer/components/layout/ChromeActions.tsx, apps/desktop/src/renderer/components/layout/ContentHeader.tsx, apps/desktop/src/renderer/components/layout/CredentialStoreBanner.tsx, apps/desktop/src/renderer/components/layout/FadeSwitcher.tsx, apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx, apps/desktop/src/renderer/components/layout/GlobalDropImportListener.tsx, apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx, apps/desktop/src/renderer/components/layout/MainLayout.tsx, apps/desktop/src/renderer/components/layout/RightSidebar.tsx, apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx, apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx, apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx, apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx, apps/desktop/src/renderer/components/layout/WallpaperVideo.tsx, apps/desktop/src/renderer/components/layout/chromeActionsGeometry.ts, apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts, apps/desktop/src/renderer/components/layout/railChromeActions.ts, apps/desktop/src/renderer/components/layout/windowDrag.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/sidebar/AccountSwitcherDialog.tsx, apps/desktop/src/renderer/components/sidebar/AttentionDot.tsx, apps/desktop/src/renderer/components/sidebar/DatabaseSizeWarningBanner.tsx, apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx, apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx, apps/desktop/src/renderer/components/sidebar/NavigationCountBadge.tsx, apps/desktop/src/renderer/components/sidebar/Sidebar.tsx, apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx, apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx, apps/desktop/src/renderer/components/sidebar/SortableList.tsx, apps/desktop/src/renderer/components/sidebar/UpdateBanner.tsx, apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx, apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx, apps/desktop/src/renderer/components/sidebar/VendorReadinessBadge.tsx, apps/desktop/src/renderer/components/sidebar/WorktreeBadge.tsx, apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx, apps/desktop/src/renderer/components/title-bar/MenuButton.tsx, apps/desktop/src/renderer/components/title-bar/WindowControls.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/DeviceSectionHeader.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx, apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx, apps/desktop/src/renderer/features/right-sidebar/EmptyState.tsx, apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBodyErrorBoundary.tsx, apps/desktop/src/renderer/features/right-sidebar/hooks/useBrowserWebview.ts, apps/desktop/src/renderer/features/right-sidebar/hooks/useNativePopupSurface.ts, apps/desktop/src/renderer/features/right-sidebar/iosSimulatorPluginAvailability.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserPartition.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserWebviewPool.ts, apps/desktop/src/renderer/features/right-sidebar/lib/detachedSidebarRouting.ts, apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts, apps/desktop/src/renderer/features/right-sidebar/lib/iosSimulatorFocusBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/lastTurnChangedFiles.ts, apps/desktop/src/renderer/features/right-sidebar/lib/nativePopupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBackgroundTasksTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBotWorkbenchTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarFileBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openRoutinesTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openSubagentsTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTerminalShortcut.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTurnReview.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupRouter.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/rsbBrowserBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarCommands.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarHostSession.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowProgressTree.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/chatTaskFocusIntent.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/workflowProgressModel.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/bot-workbench/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/CindyMakeTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.css, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/dropExternalFile.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/fileTreeImagePreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/iosSimulatorH264Decoder.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersAttentionIcon.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/actions.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/closeDecision.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/ResourceUsageBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/resource-usage.css, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/subscription.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/ImageDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/MarkdownDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/PlainUnifiedDiff.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/highlight.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/inlineDiff.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/useDiffHighlights.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/diffExpansionPreference.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/fileTree.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/gitApplyCommand.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/markdownPreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewSource.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/routines/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/ConversationStream.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/DetailView.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/RunList.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentToolCard.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentChangeFence.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentConversation.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentFormat.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/TerminalTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/lib/xtermPool.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/browserCommentEditorDraft.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/lib/parseOmnibox.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useBrowserComment.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useLocalHtmlAutoReload.ts, apps/desktop/src/renderer/features/right-sidebar/registry.ts, apps/desktop/src/renderer/features/right-sidebar/store.ts, apps/desktop/src/renderer/features/right-sidebar/types.ts, apps/desktop/src/renderer/layout/LayoutRoot.tsx, apps/desktop/src/renderer/layout/PanelDragController.tsx, apps/desktop/src/renderer/layout/PanelDragPrototype.tsx, apps/desktop/src/renderer/layout/collapsePrefs.ts, apps/desktop/src/renderer/layout/layoutDevTools.ts, apps/desktop/src/renderer/layout/panePlacement.tsx, apps/desktop/src/renderer/layout/paneWidths.tsx, apps/desktop/src/renderer/layout/panelMaximize.tsx, apps/desktop/src/renderer/styles/generated/tokens.css, apps/desktop/src/renderer/styles/globals.css | 142 | 46 | 227 |+| `desktop.shell.main-layout` | desktop | 主窗口壳(标题栏 / 左右栏 / 内容区) | main BrowserWindow → renderer/index.tsx → main-entry.tsx → App → MainLayout (`#/` 受保护壳) | ChromeActions, DeviceSectionHeader, FeishuConflictDialogHost, GhostMediaLightboxHost, MainLayout, ProjectsSection, RightSidebar, RightSidebarShell, SessionShareImportWizard, Sidebar, UpdateNoticeDialog, WindowControls | apps/desktop/src/renderer/cindy-brain/GhostMediaLightboxHost.tsx, apps/desktop/src/renderer/components/UpdateNoticeDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialogHost.tsx, apps/desktop/src/renderer/components/layout/AppBadgeAttentionSync.tsx, apps/desktop/src/renderer/components/layout/BrowserWebviewPool.tsx, apps/desktop/src/renderer/components/layout/ChromeActions.tsx, apps/desktop/src/renderer/components/layout/ContentHeader.tsx, apps/desktop/src/renderer/components/layout/CredentialStoreBanner.tsx, apps/desktop/src/renderer/components/layout/FadeSwitcher.tsx, apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx, apps/desktop/src/renderer/components/layout/GlobalDropImportListener.tsx, apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx, apps/desktop/src/renderer/components/layout/MainLayout.tsx, apps/desktop/src/renderer/components/layout/RightSidebar.tsx, apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx, apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx, apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx, apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx, apps/desktop/src/renderer/components/layout/WallpaperVideo.tsx, apps/desktop/src/renderer/components/layout/chromeActionsGeometry.ts, apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts, apps/desktop/src/renderer/components/layout/railChromeActions.ts, apps/desktop/src/renderer/components/layout/windowDrag.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/sidebar/AccountSwitcherDialog.tsx, apps/desktop/src/renderer/components/sidebar/AttentionDot.tsx, apps/desktop/src/renderer/components/sidebar/DatabaseSizeWarningBanner.tsx, apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx, apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx, apps/desktop/src/renderer/components/sidebar/NavigationCountBadge.tsx, apps/desktop/src/renderer/components/sidebar/Sidebar.tsx, apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx, apps/desktop/src/renderer/components/sidebar/SidebarNavigationCustomize.tsx, apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx, apps/desktop/src/renderer/components/sidebar/SortableList.tsx, apps/desktop/src/renderer/components/sidebar/UpdateBanner.tsx, apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx, apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx, apps/desktop/src/renderer/components/sidebar/VendorReadinessBadge.tsx, apps/desktop/src/renderer/components/sidebar/WorktreeBadge.tsx, apps/desktop/src/renderer/components/sidebar/sidebarNavigationPrefs.ts, apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx, apps/desktop/src/renderer/components/title-bar/MenuButton.tsx, apps/desktop/src/renderer/components/title-bar/WindowControls.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/DeviceSectionHeader.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx, apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx, apps/desktop/src/renderer/features/right-sidebar/EmptyState.tsx, apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBodyErrorBoundary.tsx, apps/desktop/src/renderer/features/right-sidebar/hooks/useBrowserWebview.ts, apps/desktop/src/renderer/features/right-sidebar/hooks/useNativePopupSurface.ts, apps/desktop/src/renderer/features/right-sidebar/iosSimulatorPluginAvailability.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserPartition.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserWebviewPool.ts, apps/desktop/src/renderer/features/right-sidebar/lib/detachedSidebarRouting.ts, apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts, apps/desktop/src/renderer/features/right-sidebar/lib/iosSimulatorFocusBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/lastTurnChangedFiles.ts, apps/desktop/src/renderer/features/right-sidebar/lib/nativePopupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBackgroundTasksTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBotWorkbenchTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarFileBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openRoutinesTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openSubagentsTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTerminalShortcut.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTurnReview.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupRouter.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/rsbBrowserBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarCommands.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarHostSession.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowProgressTree.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/chatTaskFocusIntent.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/workflowProgressModel.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/bot-workbench/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/CindyMakeTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.css, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/dropExternalFile.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/fileTreeImagePreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/iosSimulatorH264Decoder.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersAttentionIcon.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/actions.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/closeDecision.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/ResourceUsageBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/resource-usage.css, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/subscription.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/ImageDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/MarkdownDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/PlainUnifiedDiff.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/highlight.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/inlineDiff.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/useDiffHighlights.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/diffExpansionPreference.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/fileTree.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/gitApplyCommand.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/markdownPreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewSource.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/routines/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/ConversationStream.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/DetailView.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/RunList.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentToolCard.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentChangeFence.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentConversation.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentFormat.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/TerminalTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/lib/xtermPool.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/browserCommentEditorDraft.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/lib/parseOmnibox.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useBrowserComment.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useLocalHtmlAutoReload.ts, apps/desktop/src/renderer/features/right-sidebar/registry.ts, apps/desktop/src/renderer/features/right-sidebar/store.ts, apps/desktop/src/renderer/features/right-sidebar/types.ts, apps/desktop/src/renderer/layout/LayoutRoot.tsx, apps/desktop/src/renderer/layout/PanelDragController.tsx, apps/desktop/src/renderer/layout/PanelDragPrototype.tsx, apps/desktop/src/renderer/layout/collapsePrefs.ts, apps/desktop/src/renderer/layout/layoutDevTools.ts, apps/desktop/src/renderer/layout/panePlacement.tsx, apps/desktop/src/renderer/layout/paneWidths.tsx, apps/desktop/src/renderer/layout/panelMaximize.tsx, apps/desktop/src/renderer/styles/generated/tokens.css, apps/desktop/src/renderer/styles/globals.css | 144 | 46 | 233 || `desktop.skillhub.local` | desktop | SkillHub 本地技能 | hash `/skillhub/local` 及统一详情 `/skillhub/detail`(旧详情链接重定向) | InstallTargetPicker, PluginManagementLayout, SkillDetailLayout, SkillhubDetailRoute, SkillhubDetailView, SkillhubFeatureLayout, SkillhubHomeView, SkillhubLocalLayout, SkillhubMarketDetailView | apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubDetailRoute.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubDetailView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubFeatureLayout.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubLocalLayout.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubMarketDetailView.tsx, apps/desktop/src/renderer/features/skillhub/components/InstallTargetPicker.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillDetailLayout.tsx | 35 | 0 | 43 || `desktop.skillhub.market` | desktop | SkillHub 市场 | hash `/skillhub/market`(SkillhubMarketListView) | InstallTargetPicker, MarketCard, MarketInfoEditDialog, SkillhubMarketDetailView, SkillhubMarketListView, VisibilityEditorDialog | apps/desktop/src/renderer/features/skillhub/SkillhubMarketDetailView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubMarketListView.tsx, apps/desktop/src/renderer/features/skillhub/components/HomeMarketCard.tsx, apps/desktop/src/renderer/features/skillhub/components/InstallTargetPicker.tsx, apps/desktop/src/renderer/features/skillhub/components/LocalSkillControls.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketCard.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketInfoEditDialog.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketInstallStatus.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketListError.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketLocalSkills.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketPreviewTree.tsx, apps/desktop/src/renderer/features/skillhub/components/OfficialSkillBadge.tsx, apps/desktop/src/renderer/features/skillhub/components/PlatformTagSelector.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillCategoryFilterBar.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillDetailLayout.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillIcon.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillTagList.tsx, apps/desktop/src/renderer/features/skillhub/components/TeamScopePicker.tsx, apps/desktop/src/renderer/features/skillhub/components/VisibilityEditorDialog.tsx | 43 | 0 | 37 || `desktop.window.computer-permission-guide` | desktop | 电脑使用权限引导 | `?view=computer-permission-guide` → ComputerPermissionGuideWindow;backdrop 同文件 | ComputerPermissionBackdrop, ComputerPermissionGuideWindow | apps/desktop/src/main/computer-permission-guide/MacComputerPermissionGuideNativeHost.ts, apps/desktop/src/main/computer-permission-guide/placement.ts, apps/desktop/src/main/computer-permission-guide/request.ts, apps/desktop/src/main/computer-permission-guide/switch-target.ts, apps/desktop/src/main/computer-permission-guide/window.ts, apps/desktop/src/renderer/components/settings/ComputerPermissionGuideWindow.tsx | 7 | 2 | 9 |