Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): 远程项目行去掉设备 ID,按设备分组时不再标注归属
Dashd789a3125013
diff --git a/apps/desktop/src/renderer/__tests__/remoteProjectIdentity.test.ts b/apps/desktop/src/renderer/__tests__/remoteProjectIdentity.test.tsindex b0411206ec..9488aa99d6 100644--- a/apps/desktop/src/renderer/__tests__/remoteProjectIdentity.test.ts+++ b/apps/desktop/src/renderer/__tests__/remoteProjectIdentity.test.ts@@ -1,6 +1,7 @@import { afterEach, describe, expect, it, vi } from 'vitest';import {+ collectAmbiguousDeviceNames,projectDisplayLabelWithMachine,resolveRemoteProjectMachineIdentity,} from '@/features/cc-agent/lib/remoteProjectIdentity';@@ -56,7 +57,9 @@ describe('resolveRemoteProjectMachineIdentity', () => {expect(resolveRemoteProjectMachineIdentity(remoteProject, [])?.displayLabel).toBe('gpu-box');});- it('shows a device-link friendly name and keeps the stable device id visible', () => {+ // 2026-08-12 用户裁决:设备 ID 是机器指纹哈希,对用户没有可读意义,默认不显示;+ // 只有两台设备撞名、光看名字分不出来时才附上消歧。+ it('shows only the device-link friendly name when the name is unambiguous', () => {const identity = resolveRemoteProjectMachineIdentity({scope: 'remote',@@ -66,6 +69,25 @@ describe('resolveRemoteProjectMachineIdentity', () => {},[],);+ expect(identity).toEqual({+ kind: 'device-link',+ label: 'Office Mac',+ detail: null,+ displayLabel: 'Office Mac',+ });+ });++ it('appends the device id only for names shared by more than one device', () => {+ const identity = resolveRemoteProjectMachineIdentity(+ {+ scope: 'remote',+ remoteHostId: null,+ deviceLinkDeviceId: 'device-123',+ deviceLinkDeviceName: 'Office Mac',+ },+ [],+ { ambiguousDeviceNames: new Set(['office mac']) },+ );expect(identity).toEqual({kind: 'device-link',label: 'Office Mac',@@ -74,6 +96,25 @@ describe('resolveRemoteProjectMachineIdentity', () => {});});+ it('falls back to the device id as the label when no device name resolved', () => {+ const identity = resolveRemoteProjectMachineIdentity(+ {+ scope: 'remote',+ remoteHostId: null,+ deviceLinkDeviceId: 'device-123',+ deviceLinkDeviceName: null,+ },+ [],+ );+ // 名字拿不到时 label 已经是 ID 本身,detail 不再重复一遍。+ expect(identity).toEqual({+ kind: 'device-link',+ label: 'device-123',+ detail: null,+ displayLabel: 'device-123',+ });+ });+it('does not add a machine identity to local projects', () => {expect(resolveRemoteProjectMachineIdentity(@@ -89,6 +130,48 @@ describe('resolveRemoteProjectMachineIdentity', () => {});});+describe('collectAmbiguousDeviceNames', () => {+ const project = (deviceLinkDeviceId: string | null, deviceLinkDeviceName: string | null) => ({+ deviceLinkDeviceId,+ deviceLinkDeviceName,+ });++ it('flags a name only when it maps to more than one device id', () => {+ const ambiguous = collectAmbiguousDeviceNames([+ project('device-a', 'Dash Macbook Pro'),+ project('device-b', 'Dash Macbook Pro'),+ project('device-c', 'Office Mac'),+ ]);+ expect(ambiguous.has('dash macbook pro')).toBe(true);+ expect(ambiguous.has('office mac')).toBe(false);+ });++ it('does not flag several projects that live on the same device', () => {+ const ambiguous = collectAmbiguousDeviceNames([+ project('device-a', 'Dash Macbook Pro'),+ project('device-a', 'Dash Macbook Pro'),+ ]);+ expect(ambiguous.size).toBe(0);+ });++ it('compares names case-insensitively and ignores surrounding whitespace', () => {+ const ambiguous = collectAmbiguousDeviceNames([+ project('device-a', ' Dash Macbook Pro'),+ project('device-b', 'dash macbook pro '),+ ]);+ expect([...ambiguous]).toEqual(['dash macbook pro']);+ });++ it('skips entries without a device id or without a resolved name', () => {+ const ambiguous = collectAmbiguousDeviceNames([+ project(null, 'Dash Macbook Pro'),+ project('device-b', null),+ project('device-c', ' '),+ ]);+ expect(ambiguous.size).toBe(0);+ });+});+describe('projectDisplayLabelWithMachine', () => {it('serializes the enriched identity for locked search filters', () => {expect(diff --git a/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.ts b/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.tsindex 5cb7783ad2..fef0b9194e 100644--- a/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.ts+++ b/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.ts@@ -4,8 +4,9 @@ import { resolve } from 'node:path';import { describe, expect, it } from 'vitest';const sidebarDir = resolve(__dirname, '..', 'features', 'cc-agent', 'sidebar');-const projectNodeSource = readFileSync(- resolve(sidebarDir, 'sections', 'ProjectNode.tsx'),+const projectNodeSource = readFileSync(resolve(sidebarDir, 'sections', 'ProjectNode.tsx'), 'utf8');+const projectsSectionSource = readFileSync(+ resolve(sidebarDir, 'sections', 'ProjectsSection.tsx'),'utf8',);const sessionItemSource = readFileSync(resolve(sidebarDir, 'SessionItem.tsx'), 'utf8');@@ -21,7 +22,9 @@ describe('sidebar remote project icon', () => {expect(projectNodeSource).toContain("import { RemoteProjectIcon } from '../RemoteProjectIcon'");expect(sessionItemSource).toContain("import { RemoteProjectIcon } from './RemoteProjectIcon'");expect(sessionCardSource).toContain("import { RemoteProjectIcon } from './RemoteProjectIcon'");- expect(sessionHeaderSource).toContain("import { RemoteProjectIcon } from './sidebar/RemoteProjectIcon'");+ expect(sessionHeaderSource).toContain(+ "import { RemoteProjectIcon } from './sidebar/RemoteProjectIcon'",+ );});it('maps device-link sessions to the device-link project icon and SSH sessions to the SSH project icon', () => {@@ -70,4 +73,16 @@ describe('sidebar remote project icon', () => {expect(sessionItemSource).not.toContain('<span className="min-w-0 flex-1 truncate">');expect(sessionCardSource).not.toContain("'min-w-0 flex-1 truncate'");});++ // 2026-08-12 用户裁决:按设备分组时列表已按设备切段、段头写着设备名,项目行不再+ // 重复标注归属;远程图标保留(表达「远程 + 连接状态」,不重复归属信息)。+ it('drops the per-row machine label while device grouping is active, keeping the remote icon', () => {+ expect(projectNodeSource).toContain('hideRemoteMachineLabel = false');+ expect(projectNodeSource).toContain(+ '{!isEditingName && remoteIdentity && !hideRemoteMachineLabel ? (',+ );+ // 远程图标的渲染条件不受该开关影响。+ expect(projectNodeSource).toMatch(/\{!isEditingName && isDeviceLink \? \(/);+ expect(projectsSectionSource).toContain('hideRemoteMachineLabel={deviceGroupingActive}');+ });});diff --git a/apps/desktop/src/renderer/features/cc-agent/hooks/useProjectGroups.ts b/apps/desktop/src/renderer/features/cc-agent/hooks/useProjectGroups.tsindex ec3e627e8c..297b2c0e24 100644--- a/apps/desktop/src/renderer/features/cc-agent/hooks/useProjectGroups.ts+++ b/apps/desktop/src/renderer/features/cc-agent/hooks/useProjectGroups.ts@@ -13,7 +13,10 @@ import { useMemo } from 'react';import type { Session } from '@/lib/ccAgent.types';import { useRemoteSshHosts } from '@/hooks/useRemoteSshHosts';import { groupSessions, type ProjectGroupsResult } from '../lib/projectGrouping';-import { resolveRemoteProjectMachineIdentity } from '../lib/remoteProjectIdentity';+import {+ collectAmbiguousDeviceNames,+ resolveRemoteProjectMachineIdentity,+} from '../lib/remoteProjectIdentity';export function useProjectGroups(sessions: readonly Session[],@@ -24,11 +27,15 @@ export function useProjectGroups(return useMemo(() => {const groups = groupSessions(sessions, { projectAliases, includePinnedInProjects });+ // 撞名判定要看全量项目(哪些设备名对应了多个 deviceId),所以先扫一遍再逐个富化。+ const ambiguousDeviceNames = collectAmbiguousDeviceNames(groups.projects);return {...groups,projects: groups.projects.map((project) => ({...project,- remoteMachineIdentity: resolveRemoteProjectMachineIdentity(project, sshHosts),+ remoteMachineIdentity: resolveRemoteProjectMachineIdentity(project, sshHosts, {+ ambiguousDeviceNames,+ }),})),};}, [sessions, projectAliases, includePinnedInProjects, sshHosts]);diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/remoteProjectIdentity.ts b/apps/desktop/src/renderer/features/cc-agent/lib/remoteProjectIdentity.tsindex 10045901e2..6a06585c8f 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/remoteProjectIdentity.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/remoteProjectIdentity.ts@@ -21,16 +21,65 @@ function joinIdentity(label: string, detail: string | null): string {return detail ? `${label} · ${detail}` : label;}+/** 设备名归一(比对同名用):去空白 + 小写。 */+function deviceNameKey(name: string): string {+ return name.trim().toLowerCase();+}++export interface ResolveRemoteProjectIdentityOptions {+ /**+ * 「同名但不同设备」的设备名集合(deviceNameKey 归一后)。+ * device-link 的设备 ID 是机器指纹哈希,对用户没有可读意义,默认**不显示**+ * (2026-08-12 用户裁决);只有两台设备撞名、光看名字分不出来时才附在名字后面消歧。+ */+ ambiguousDeviceNames?: ReadonlySet<string>;+}++/**+ * 从一批远程项目里找出需要显示设备 ID 消歧的设备名——同一个名字对应了两个以上+ * 不同 deviceId 时才算撞名。只统计真的有项目会渲染的设备:没有项目的同名设备不会+ * 在列表里出现,不构成用户看得见的歧义。+ */+export function collectAmbiguousDeviceNames(+ projects: readonly Pick<+ RemoteProjectIdentitySource,+ 'deviceLinkDeviceId' | 'deviceLinkDeviceName'+ >[],+): ReadonlySet<string> {+ const idsByName = new Map<string, Set<string>>();+ for (const project of projects) {+ const deviceId = project.deviceLinkDeviceId;+ const name = project.deviceLinkDeviceName?.trim();+ if (!deviceId || !name) continue;+ const key = deviceNameKey(name);+ const ids = idsByName.get(key);+ if (ids) ids.add(deviceId);+ else idsByName.set(key, new Set([deviceId]));+ }+ const ambiguous = new Set<string>();+ for (const [key, ids] of idsByName) {+ if (ids.size > 1) ambiguous.add(key);+ }+ return ambiguous;+}+/** 把项目持久化身份与当前 SSH registry 合并成稳定、可读的展示模型。 */export function resolveRemoteProjectMachineIdentity(project: Omit<RemoteProjectIdentitySource, 'remoteMachineIdentity'>,sshHosts: readonly RemoteHostSnapshot[],+ options?: ResolveRemoteProjectIdentityOptions,): RemoteProjectMachineIdentity | null {if (project.scope !== 'remote') return null;if (project.deviceLinkDeviceId) {- const name = project.deviceLinkDeviceName?.trim() || project.deviceLinkDeviceId;- const detail = name === project.deviceLinkDeviceId ? null : project.deviceLinkDeviceId;+ const resolvedName = project.deviceLinkDeviceName?.trim();+ const name = resolvedName || project.deviceLinkDeviceId;+ // 设备 ID 只在撞名时才露出来消歧(见 ResolveRemoteProjectIdentityOptions);+ // 名字都拿不到时 label 已经退化成 ID 本身,不再重复附一遍。+ const detail =+ resolvedName && options?.ambiguousDeviceNames?.has(deviceNameKey(resolvedName))+ ? project.deviceLinkDeviceId+ : null;return {kind: 'device-link',label: name,diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsxindex ea742fbe0b..9ff3436414 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx@@ -80,6 +80,13 @@ export interface ProjectNodeProps {selectedSessionIds?: ReadonlySet<string>;/** Sidebar 内容过滤态或时间升序排序下强制展示全部 session entry。 */disableSessionCollapse: boolean;+ /**+ * 隐藏标题右侧的远程机器标注(设备名 / SSH endpoint)。+ * 「按设备分组」开启时列表已经按设备切段、段头写着设备名,行内再标一遍是重复+ * (2026-08-12 用户裁决)。远程图标仍保留——它表达「这是远程项目 + 连接状态」,+ * 不重复归属信息。置顶区不受分组影响,照常显示。+ */+ hideRemoteMachineLabel?: boolean;onToggle: (projectKey: string) => void;/** Project pin is independent from conversation pin state. */isProjectPinned: boolean;@@ -124,6 +131,7 @@ export function ProjectNode({scheduleSessionIndex,selectedSessionIds,disableSessionCollapse,+ hideRemoteMachineLabel = false,onToggle,isProjectPinned,onToggleProjectPin,@@ -340,7 +348,8 @@ export function ProjectNode({<RemoteProjectIcon kind="ssh" className="text-[var(--folder-item-icon)]" /></Tip>) : null}- {!isEditingName && remoteIdentity ? (+ {/* 远程机器标注:按设备分组时段头已写明归属,行内不再重复(hideRemoteMachineLabel)。 */}+ {!isEditingName && remoteIdentity && !hideRemoteMachineLabel ? (<spantitle={remoteIdentity.displayLabel}className="max-w-[45%] shrink truncate text-11 text-[var(--cmd-palette-item-meta)]"diff --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 6f0d77f84f..070471739e 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@@ -453,6 +453,8 @@ export function ProjectsSection({scheduleSessionIndex={scheduleSessionIndex}selectedSessionIds={selectedSessionIds}disableSessionCollapse={disableSessionCollapse}+ // 按设备分段时段头已写明设备,行内不再重复标注归属(2026-08-12 用户裁决)。+ hideRemoteMachineLabel={deviceGroupingActive}onToggle={onToggleProject}isProjectPinned={false}onToggleProjectPin={onToggleProjectPin}diff --git a/docs/product-rules/sidebar-redesign-plan.md b/docs/product-rules/sidebar-redesign-plan.mdindex c624f6dc42..27bde09cb0 100644--- a/docs/product-rules/sidebar-redesign-plan.md+++ b/docs/product-rules/sidebar-redesign-plan.md@@ -41,6 +41,16 @@层级方向固定:设备 → 项目/对话组 → 任务。全关 = 纯平铺。+**远程项目的机器标注**(2026-08-12 用户裁决):++- device-link 项目行只显示**设备名**,不显示设备 ID——ID 是机器指纹哈希,对用户+ 没有可读意义。仅当两台设备**撞名**(同一名字对应多个 deviceId,只统计列表里+ 真的会渲染的项目)时,才在名字后附上 ID 消歧。SSH 项目的 `user@host[:port]`+ 不受影响(那是可读信息,不是哈希)。+- **按设备分组开启时,项目行不再标注所属设备**:列表已按设备切段、段头写着设备名,+ 行内重复标注只是挤占项目名宽度。远程图标保留(表达「远程 + 连接状态」,+ 不重复归属信息)。置顶区不受分组影响,照常显示。+**默认组合(定稿)**:按项目分组 + 按设备分组开、对话不归组——即项目行与散排对话按活动时间混排,这与手机版现状(#1303)一致。