Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): hide Orca worker sessions from full session list (#4400)
Yecheng Fub4677742c567
diff --git a/apps/mobile/app/devices/[deviceId].tsx b/apps/mobile/app/devices/[deviceId].tsxindex 81ce6e2691..9969cb5714 100644--- a/apps/mobile/app/devices/[deviceId].tsx+++ b/apps/mobile/app/devices/[deviceId].tsx@@ -72,7 +72,7 @@ import {shouldReplaceListWithSearchResults,} from '@/session/conversationSearch';import { useConversationSearch } from '@/session/useConversationSearch';-import { sessionMatchesProjectDir } from '@/session/mobileHome';+import { selectVisibleDeviceSessions, sessionMatchesProjectDir } from '@/session/mobileHome';import { HomeSessionRow } from '@/session/HomeSurface';import { RenameSessionModal } from '@/session/RenameSessionModal';import { SessionOptionsPresenter } from '@/session/SessionOptionsExpoSheet';@@ -176,12 +176,13 @@ function DeviceDetailScreenContent() {// filter 必须 memo:裸 filter 每次渲染都产新数组,会让下游全部 [sessions, ...] 依赖的// useMemo 逐 emit 失效,派生链(索引 → sections → 全列表行)整体重建(2026-07-18// 重渲染风暴)。store 层已保证 allSessions 引用在内容未变时稳定,这里不能亲手打破。- const sessions = useMemo(() => allSessions.filter((s) =>- // 用展示用 canonicalDeviceId(设备归并结果)匹配,与首页项目卡一致 —— 被认领的 stale 会话也能显示,- // 数量与卡片相符。deviceLinkDeviceId 仍是物理路由 key(openSession / patch 用它),不参与此处判断。- (s.canonicalDeviceId ?? s.deviceLinkDeviceId) === deviceId- && (!projectWorkingDir || sessionMatchesProjectDir(s.workingDir, projectWorkingDir))),- [allSessions, deviceId, projectWorkingDir]);+ // 列表隐藏 Orca worker 子会话(本期不支持进 worker 聊天);Lead + 普通会话保留。仅 mobile 侧过滤。+ // 与首页卡片口径对齐:首页已 exclude worker,「查看全部 N 条」不能再把它们露出来。+ // 用展示用 canonicalDeviceId(设备归并结果)匹配 —— 被认领的 stale 会话也能显示,数量与卡片相符。+ const sessions = useMemo(+ () => selectVisibleDeviceSessions(allSessions, deviceId, projectWorkingDir),+ [allSessions, deviceId, projectWorkingDir],+ );const messageVersion = useRemoteMessageVersion();const storeVersion = useRemoteSessionStoreVersion();const [statusFilter, setStatusFilter] = useState<RemoteSessionStatusFilter>(diff --git a/apps/mobile/src/__tests__/orcaCollab.test.ts b/apps/mobile/src/__tests__/orcaCollab.test.tsindex aac4775e71..47636c8411 100644--- a/apps/mobile/src/__tests__/orcaCollab.test.ts+++ b/apps/mobile/src/__tests__/orcaCollab.test.ts@@ -7,7 +7,7 @@ import {classifyOrcaDispatchTool,parseOrcaWorkerReport,} from '@/session/orcaCollab';-import { excludeOrcaWorkerSessions } from '@/session/mobileHome';+import { excludeOrcaWorkerSessions, selectVisibleDeviceSessions } from '@/session/mobileHome';import { normalizeRemoteMessages } from '@/session/messageNormalize';import type { RemoteMessage, RemoteSession } from '@/session/types';@@ -208,6 +208,61 @@ describe('excludeOrcaWorkerSessions', () => {});});+describe('selectVisibleDeviceSessions', () => {+ it('drops workers and keeps lead/normal rows in the same device and project', () => {+ const rows = selectVisibleDeviceSessions([+ session({+ id: 'lead',+ orcaRole: 'lead',+ deviceLinkDeviceId: 'dev-a',+ workingDir: '/repo/cindy',+ }),+ session({+ id: 'worker',+ orcaRole: 'worker',+ deviceLinkDeviceId: 'dev-a',+ workingDir: '/repo/cindy',+ }),+ session({+ id: 'other-device',+ orcaRole: null,+ deviceLinkDeviceId: 'dev-b',+ workingDir: '/repo/cindy',+ }),+ session({+ id: 'other-project',+ orcaRole: null,+ deviceLinkDeviceId: 'dev-a',+ workingDir: '/repo/infra',+ }),+ session({+ id: 'canonical-match',+ orcaRole: null,+ canonicalDeviceId: 'dev-a',+ deviceLinkDeviceId: 'stale-id',+ workingDir: '/repo/cindy',+ }),+ ], 'dev-a', '/repo/cindy');+ expect(rows.map((item) => item.id)).toEqual(['lead', 'canonical-match']);+ });++ it('keeps all non-worker rows for a device when no project dir is set', () => {+ const rows = selectVisibleDeviceSessions([+ session({ id: 'keep', orcaRole: null, deviceLinkDeviceId: 'dev-a', workingDir: '/repo/one' }),+ session({ id: 'worker', orcaRole: 'worker', deviceLinkDeviceId: 'dev-a', workingDir: '/repo/one' }),+ session({ id: 'other', orcaRole: 'lead', deviceLinkDeviceId: 'dev-b', workingDir: '/repo/one' }),+ ], 'dev-a');+ expect(rows.map((item) => item.id)).toEqual(['keep']);+ });++ it('feeds the derived rows into the device/project list sections', () => {+ const detail = readFileSync(resolve(process.cwd(), 'app/devices/[deviceId].tsx'), 'utf8');+ expect(detail).toContain('selectVisibleDeviceSessions(allSessions, deviceId, projectWorkingDir)');+ expect(detail).toContain('buildRemoteSessionSections(sessions,');+ expect(detail).toContain('summarizeRemoteSessionOverview(sessions,');+ });+});+describe('MessageRenderer wires the orca card', () => {it('routes message items carrying an orcaCard to OrcaCollabCard', () => {const source = readFileSync(resolve(process.cwd(), 'src/session/MessageRenderer.tsx'), 'utf8');diff --git a/apps/mobile/src/session/mobileHome.ts b/apps/mobile/src/session/mobileHome.tsindex 3740b13a00..20431f5d4a 100644--- a/apps/mobile/src/session/mobileHome.ts+++ b/apps/mobile/src/session/mobileHome.ts@@ -4,6 +4,7 @@ import { mobilePresentationLocalizer } from '@/i18n/presentationLocalizer';import { localizeRemoteSessionListItem } from '@/session/sessionList';import {buildMobileHomePresentation as buildMobileHomePresentationShared,+ sessionMatchesProjectDir,type MobileHomeSessionLike,type MobileHomeNoDeviceContext,type MobileHomeOptions,@@ -101,3 +102,19 @@ export function excludeOrcaWorkerSessions<T extends Pick<RemoteSession, 'orcaRol): T[] {return sessions.filter((session) => session.orcaRole !== 'worker');}++/**+ * 设备/项目「查看全部」列表的会话派生:先丢掉 Orca worker,再按规范设备 id 与项目目录收口。+ * 结果必须直接喂给该页的 sections / 计数,不能只在别处调用 helper。+ */+export function selectVisibleDeviceSessions<+ T extends Pick<RemoteSession, 'orcaRole' | 'canonicalDeviceId' | 'deviceLinkDeviceId' | 'workingDir'>,+>(+ sessions: readonly T[],+ deviceId: string,+ projectWorkingDir?: string | null,+): T[] {+ return excludeOrcaWorkerSessions(sessions).filter((session) =>+ (session.canonicalDeviceId ?? session.deviceLinkDeviceId) === deviceId+ && (!projectWorkingDir || sessionMatchesProjectDir(session.workingDir, projectWorkingDir)));+}