Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 平铺时回落手动排序并补上来源标签
Dash37d89cde44b5
diff --git a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.tsindex e79b66d154..f01adcdaa3 100644--- a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts+++ b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts@@ -199,6 +199,23 @@ describe('远程机器切换入口并入 SidebarTopNav(置顶段上方,固定不}});+ it('关项目分组时 hook 把 manual 回落到 recency', () => {+ const hookSource = read('features', 'cc-agent', 'hooks', 'useSidebarFilter.ts');+ expect(hookSource).toContain('nextSortByAfterGroupByChange');+ expect(hookSource).toContain('const nextSort = nextSortByAfterGroupByChange(next, current)');+ });++ it('列表行也接收来源标签(平铺时项目会话不再丢项目名)', () => {+ const entryListSource = read('features', 'cc-agent', 'sidebar', 'SessionEntryList.tsx');+ expect(entryListSource).toContain('sourceLabel={sourceLabelMap?.get(entry.session.id)}');+ expect(entryListSource.match(/sourceLabel=\{sourceLabelMap\?\.get\(entry\.session\.id\)\}/g)).toHaveLength(+ 2,+ );+ const cardSource = read('features', 'cc-agent', 'sidebar', 'SessionCard.tsx');+ expect(cardSource).toContain('sourceLabel,');+ expect(cardSource).toContain('{sourceLabel ? (');+ });+// 2026-08-12 用户裁决:筛选各维度选中后菜单不关闭(常要连调几项);排序与显示// 模式仍选完即关(一次一个决定)。it('筛选维度选中后保持菜单打开,排序 / 显示模式仍选完即关', () => {diff --git a/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts b/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.tsindex 7eea1e8668..0feb4a9259 100644--- a/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts+++ b/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts@@ -52,6 +52,11 @@ describe('Projects sidebar section', () => {expect(projectsSectionSource).toContain('const allGroupsCollapsed = hasVisibleProjectGroups',);+ // 平铺时来源标签要覆盖从项目摊出来的会话,不能只喂 dialogues。+ expect(projectsSectionSource).toContain('flattenedSessionsForSourceLabels');+ expect(projectsSectionSource).toContain(+ '[...projects.flatMap((project) => project.sessions), ...dialogues]',+ );});// 2026-08-12 用户裁决:段头「新建项目」按钮暂时移除(同一动作在新任务页的工作diff --git a/apps/desktop/src/renderer/__tests__/useSidebarFilter.test.ts b/apps/desktop/src/renderer/__tests__/useSidebarFilter.test.tsindex 0c22bff23d..572c564250 100644--- a/apps/desktop/src/renderer/__tests__/useSidebarFilter.test.ts+++ b/apps/desktop/src/renderer/__tests__/useSidebarFilter.test.ts@@ -42,6 +42,7 @@ import {nextTaskInfoAfterToggle,persistManualProjectOrder,nextProjectsAfterToggle,+ nextSortByAfterGroupByChange,includeProjectInFilter,removeProjectsFromFilter,gcProjectsAgainstActive,@@ -268,6 +269,15 @@ describe('loadSortBy', () => {});});+describe('nextSortByAfterGroupByChange', () => {+ it('flat + manual 回落到 recency;其它组合保持', () => {+ expect(nextSortByAfterGroupByChange('flat', 'manual')).toBe('recency');+ expect(nextSortByAfterGroupByChange('flat', 'priority')).toBe('priority');+ expect(nextSortByAfterGroupByChange('flat', 'recency')).toBe('recency');+ expect(nextSortByAfterGroupByChange('project', 'manual')).toBe('manual');+ });+});+describe('taskInfoFields(任务行右侧信息复选)', () => {beforeEach(() => installMemoryLocalStorage());afterEach(() => uninstallLocalStorage());diff --git a/apps/desktop/src/renderer/components/settings/__tests__/AppearanceSection.accessibility.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/AppearanceSection.accessibility.test.tsxindex 036f1c8e66..ad60d11b05 100644--- a/apps/desktop/src/renderer/components/settings/__tests__/AppearanceSection.accessibility.test.tsx+++ b/apps/desktop/src/renderer/components/settings/__tests__/AppearanceSection.accessibility.test.tsx@@ -41,6 +41,7 @@ vi.mock('@/hooks/useFontSettings', async (importOriginal) => ({vi.mock('@/hooks/useSidebarCardMode', () => ({useSidebarCardMode: () => ({ mode: 'text', setMode: vi.fn() }),+ useSidebarMainViewMode: () => ({ mode: 'list', setMode: vi.fn() }),}));vi.mock('@/themes/local-themes', () => ({diff --git a/apps/desktop/src/renderer/features/cc-agent/hooks/helpers/sidebarFilterCore.ts b/apps/desktop/src/renderer/features/cc-agent/hooks/helpers/sidebarFilterCore.tsindex 27a40728f4..84f4f44250 100644--- a/apps/desktop/src/renderer/features/cc-agent/hooks/helpers/sidebarFilterCore.ts+++ b/apps/desktop/src/renderer/features/cc-agent/hooks/helpers/sidebarFilterCore.ts@@ -61,6 +61,14 @@ export type FilterLastActivity = 'all' | '1d' | '3d' | '7d' | '30d';* (侧边栏重设计裁决:alphabetic 与 time(旧「最早优先」)已删除,存量值回退到* recency——时间排序只保留最近优先一档。) */export type FilterSortBy = 'recency' | 'manual' | 'priority';++/** 切到平铺时,手动排序失去项目行载体,回落到按时间;其它档位保持。 */+export function nextSortByAfterGroupByChange(+ groupBy: FilterGroupBy,+ sortBy: FilterSortBy,+): FilterSortBy {+ return groupBy === 'flat' && sortBy === 'manual' ? 'recency' : sortBy;+}/*** 任务行右侧信息项(复选)。存储数组的顺序 = 用户勾选先后(nextTaskInfoAfterToggle* 按序追加),列表行据此渲染(2026-08-12 用户裁决);菜单里四个选项的排列另有固定顺序。diff --git a/apps/desktop/src/renderer/features/cc-agent/hooks/useSidebarFilter.ts b/apps/desktop/src/renderer/features/cc-agent/hooks/useSidebarFilter.tsindex 5c305959c7..a00f994f72 100644--- a/apps/desktop/src/renderer/features/cc-agent/hooks/useSidebarFilter.ts+++ b/apps/desktop/src/renderer/features/cc-agent/hooks/useSidebarFilter.ts@@ -74,6 +74,7 @@ import {persistManualProjectOrder,persistManualPinnedOrder,nextProjectsAfterToggle,+ nextSortByAfterGroupByChange,includeProjectInFilter,removeProjectsFromFilter,gcProjectsAgainstActive,@@ -459,6 +460,14 @@ export function useSidebarFilter(const setGroupBy = useCallback((next: FilterGroupBy) => {setGroupByState(next);persistGroupBy(next);+ // 手动排序只对项目行有意义。切到平铺后菜单不再露出该档,若仍保留+ // sortBy=manual,渲染层会继续按它禁用设备分组,菜单却显示「按时间」。+ setSortByState((current) => {+ const nextSort = nextSortByAfterGroupByChange(next, current);+ if (nextSort === current) return current;+ persistSortBy(nextSort);+ return nextSort;+ });}, []);const setGroupDialogue = useCallback((next: boolean) => {diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsxindex f98f33ce1a..c01f7ec297 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx@@ -148,6 +148,7 @@ export function SessionCard({onMoveSession,projectOptions = [],matchIndices,+ sourceLabel,variant = 'card',isFirst = false,hideBottomDivider = false,@@ -773,6 +774,18 @@ export function SessionCard({}/>)}+ {sourceLabel ? (+ <span+ className={cn(+ 'min-w-0 truncate text-11 font-normal',+ isActive+ ? 'text-sidebar-item-active-foreground/70'+ : 'text-[var(--cmd-palette-item-meta)]',+ )}+ >+ {sourceLabel}+ </span>+ ) : null}</div>)}</div>diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsxindex 277eb31a5d..f9882c1a05 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsx@@ -138,6 +138,7 @@ export function SessionEntryRows({variant="list"isFirst={showFirstDivider && index === 0}hideBottomDivider={nextHighlighted}+ sourceLabel={sourceLabelMap?.get(entry.session.id)}/>) : (<SessionItemdiff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsxindex 825ef55e5e..fac64d4362 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx@@ -522,10 +522,19 @@ export function ProjectsSection({? t('ccAgent.sidebar.foldAll.collapseDevices'): t('ccAgent.sidebar.foldAll.expandAll');const FoldIcon = foldState === 'expand-all' ? ChevronsUpDown : ChevronsDownUp;- // 散排对话 hover 时右侧的来源标签(与时间排序视图同口径):全部标成「对话」。+ // 散排行的来源标签:平铺时项目会话也要标项目名,不能只喂 dialogues。+ const flattenedSessionsForSourceLabels = useMemo(() => {+ if (filter.groupBy === 'project') return dialogues;+ return [...projects.flatMap((project) => project.sessions), ...dialogues];+ }, [filter.groupBy, projects, dialogues]);const dialogueSourceLabelMap = useMemo(- () => buildSessionSourceLabelMap(dialogues, allKnownProjects, t('ccAgent.sidebar.dialogues')),- [dialogues, allKnownProjects, t],+ () =>+ buildSessionSourceLabelMap(+ flattenedSessionsForSourceLabels,+ allKnownProjects,+ t('ccAgent.sidebar.dialogues'),+ ),+ [flattenedSessionsForSourceLabels, allKnownProjects, t],);// F-PJ-10:即使 projects 因 filter 收窄到空,也要保留段头供用户切回 Filter。