Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(sidebar): 排除 Worker 空项目并修正活跃时间筛选 (#4679)
Dash2434a25e394d
diff --git a/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.ts b/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.tsindex 4e81c42f72..8a14589f68 100644--- a/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.ts+++ b/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.ts@@ -162,6 +162,8 @@ describe('touchUserSendInDb 广播 sessions:patched(device-link 项目归属收});it.each([+ { source: 'desktop', workspaceKind: 'project', remoteHostId: null, orcaRole: 'worker' },+ { source: 'plugin', workspaceKind: 'project', remoteHostId: null, orcaRole: 'worker' },{ source: 'scheduler', workspaceKind: 'project', remoteHostId: null },{ source: 'desktop', workspaceKind: 'dialogue', remoteHostId: null },{ source: 'desktop', workspaceKind: 'project', remoteHostId: 'ssh-host' },diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/recentWorkdirsDelete.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/recentWorkdirsDelete.test.tsindex 60ca5b51e0..de01947043 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/recentWorkdirsDelete.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/recentWorkdirsDelete.test.ts@@ -58,6 +58,7 @@ function createDb(): void {status TEXT NOT NULL DEFAULT 'active',workspace_kind TEXT NOT NULL DEFAULT 'project',remote_host_id TEXT,+ orca_role TEXT,agent_kind TEXT NOT NULL DEFAULT 'cc');`);@@ -231,17 +232,26 @@ describe('local-db:recent-workdirs:list exists probe', () => {expect(list[13]?.path).toBe('/not-mounted/project-0');});+ it('does not let hidden workers supply project agent-kind history', async () => {+ seed('/workspace/shared', 1_786_500_000_000);+ h.sqlite!.exec(`+ INSERT INTO sessions (id, working_dir, agent_kind, orca_role)+ VALUES ('ordinary', '/workspace/shared', 'cc', NULL),+ ('worker', '/workspace/shared', 'codex', 'worker');+ `);++ expect(await invoke('local-db:recent-workdirs:list')).toEqual([+ expect.objectContaining({ path: '/workspace/shared', knownAgentKinds: ['cc'] }),+ ]);+ });+it('retains agent-kind history after the last project session is soft-deleted', async () => {seed('/workspace/codex-only', 1_786_500_000_000);- h.sqlite!- .prepare(- `INSERT INTO sessions (id, working_dir, status, workspace_kind, remote_host_id, agent_kind)+ h.sqlite!.prepare(+ `INSERT INTO sessions (id, working_dir, status, workspace_kind, remote_host_id, agent_kind)VALUES (?, ?, 'active', 'project', NULL, 'codex')`,- )- .run('codex-session', '/workspace/codex-only');- h.sqlite!- .prepare("UPDATE sessions SET status = 'deleted' WHERE id = ?")- .run('codex-session');+ ).run('codex-session', '/workspace/codex-only');+ h.sqlite!.prepare("UPDATE sessions SET status = 'deleted' WHERE id = ?").run('codex-session');const list = (await invoke('local-db:recent-workdirs:list')) as Array<{path: string;diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex 964683cb31..ed2d94d283 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@ -772,6 +772,14 @@ describe('local-db:sessions:update handler wiring', () => {},);+ it('does not register a worker directory when its project target changes', async () => {+ h.sqlite!.prepare("UPDATE sessions SET orca_role = 'worker' WHERE id = ?").run('codex-local');++ await invokeUpdate('codex-local', { workingDir: '/worker/dir', workspaceKind: 'project' });++ expect(h.upsertRecentWorkdir).not.toHaveBeenCalled();+ });+it('suppresses the recent-project refresh after an owner switch', async () => {h.sqlite!.prepare("UPDATE sessions SET workspace_kind = 'project' WHERE id = ?").run('codex-local',diff --git a/apps/desktop/src/main/localDb/ipc/recentWorkdirs.ts b/apps/desktop/src/main/localDb/ipc/recentWorkdirs.tsindex 96d1ace715..1f2f5f9814 100644--- a/apps/desktop/src/main/localDb/ipc/recentWorkdirs.ts+++ b/apps/desktop/src/main/localDb/ipc/recentWorkdirs.ts@@ -13,14 +13,14 @@* 的放行依据;远程入口始终实时探测目录当前是否可访问。* - upsert 不暴露 IPC —— 由 main 内部在 session 创建、项目归属变更和发送消息时调用,* 避免 renderer 私自污染该表。生命周期与 session 解耦:归档 / 删除既不移除目录,- * 也不刷新最后活动时间;清空会话后仍按项目独立保存的时间筛选。+ * 也不刷新最后活动时间;未启用任务时间筛选时仍保留空项目。* - upsert 失败仅日志,不抛 —— 这是"用户体验增强"数据,不该挡住 session 创建主流程。*/import { stat } from 'node:fs/promises';import { BrowserWindow, ipcMain } from 'electron';-import { and, desc, eq, isNotNull, isNull, sql } from 'drizzle-orm';+import { and, desc, eq, isNotNull, isNull, ne, or, sql } from 'drizzle-orm';import type { DbClient } from '../client/DbClient.js';import { getDbClient } from '../client/current';@@ -157,6 +157,7 @@ export async function listRecentWorkdirs(client: DbClient = getDbClient()) {eq(sessions.workspaceKind, 'project'),isNull(sessions.remoteHostId),isNotNull(sessions.workingDir),+ or(isNull(sessions.orcaRole), ne(sessions.orcaRole, 'worker')),),);const knownKindsByPath = new Map<string, Set<string>>();diff --git a/apps/desktop/src/main/localDb/ipc/sessions.ts b/apps/desktop/src/main/localDb/ipc/sessions.tsindex 03ee45b1dd..4b147db09f 100644--- a/apps/desktop/src/main/localDb/ipc/sessions.ts+++ b/apps/desktop/src/main/localDb/ipc/sessions.ts@@ -69,7 +69,7 @@ import { upsertRecentWorkdir } from './recentWorkdirs';import { createLogger } from '../../logger';import {DESKTOP_VISIBLE_SESSION_SOURCES,- isRetainableProjectSessionSource,+ isRetainableProjectSession,} from '../../../shared/sessionSource.js';import {normalizeWorkingDirForProjectSettings,@@ -925,6 +925,7 @@ export async function touchUserSendInDb(id: string, atMs?: number): Promise<voidworkspaceKind: sessions.workspaceKind,remoteHostId: sessions.remoteHostId,source: sessions.source,+ orcaRole: sessions.orcaRole,}).from(sessions).where(and(eq(sessions.id, id), eq(sessions.userSendAt, ts)))@@ -954,7 +955,7 @@ export async function touchUserSendInDb(id: string, atMs?: number): Promise<voidrow.workspaceKind === 'project' &&row.workingDir &&!row.remoteHostId &&- isRetainableProjectSessionSource(row.source)+ isRetainableProjectSession(row)) {const projectDir = normalizeWorkingDirForProjectSettings(row.workingDir);const touched = await upsertRecentWorkdir(projectDir, ts, process.platform, dbClient);@@ -1404,7 +1405,12 @@ export function registerSessionIpc(// 路径写进去,后续 New Maker 项目下拉选中它时会丢失 host、按本机路径创建出一个// 错误的本地会话(指向本机不存在的同名目录)。在 host-aware 最近项目(给该表加// remote_host_id 列 + picker 区分 local/remote)落地前,remote 项目一律不进最近列表。- if (insertRow.workspaceKind === 'project' && insertRow.workingDir && !insertRow.remoteHostId) {+ if (+ insertRow.workspaceKind === 'project' &&+ insertRow.workingDir &&+ !insertRow.remoteHostId &&+ isRetainableProjectSession(insertRow)+ ) {void upsertRecentWorkdir(insertRow.workingDir, now);}// 订阅槽①旁路通知(fire-and-forget,动态 import 防环):意识旁听会话创建。@@ -1941,7 +1947,7 @@ export async function updateSessionInDb(row.workspaceKind === 'project' &&row.workingDir &&!row.remoteHostId &&- isRetainableProjectSessionSource(row.source)+ isRetainableProjectSession(row)) {const touched = await upsertRecentWorkdir(row.workingDir,diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 02468f305e..2a8cdce9e5 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -99,6 +99,7 @@ import {isAppSessionBoundaryPending,} from '../appSessionState.js';import { upsertRecentWorkdir } from '../localDb/ipc/recentWorkdirs.js';+import { isRetainableProjectSession } from '../../shared/sessionSource.js';import type { AgentMeta, Session as RendererSession } from '../../renderer/lib/ccAgent.types';import {deriveAutoTitleSeed,@@ -7424,7 +7425,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)// 项目根,而不是 auto-* 运行目录。worktreeStore 以同一预生成 sessionId// 保存了权威 baseRepo。先完成 best-effort upsert 再让 handler 广播 created,// 这样 renderer 收到广播重拉 recent 表时不会撞到写入竞态。- if (co.workspaceKind !== 'dialogue' && !co.remoteHostId) {+ if (+ co.workspaceKind !== 'dialogue' &&+ !co.remoteHostId &&+ isRetainableProjectSession({ source: 'desktop', orcaRole: co.orcaRole })+ ) {const recentProjectDir =worktreeStore.get(result.session.id)?.baseRepo ??getManagedWorktreeBasePath(co.workingDir) ??diff --git a/apps/desktop/src/renderer/__tests__/projectGrouping.test.ts b/apps/desktop/src/renderer/__tests__/projectGrouping.test.tsindex d365b78723..8cae419bf5 100644--- a/apps/desktop/src/renderer/__tests__/projectGrouping.test.ts+++ b/apps/desktop/src/renderer/__tests__/projectGrouping.test.ts@@ -28,6 +28,7 @@ import {pinnedSidebarEntryComparisonKey,} from '@/features/cc-agent/lib/pinnedSidebarOrder';import type { Session } from '@/lib/ccAgent.types';+import { findProjectRepresentativeKey } from '@/features/cc-agent/lib/sidebarProjectVisibility';/* ---------------- helpers ---------------- */@@ -323,7 +324,7 @@ describe('groupSessions', () => {expect(project.displayName).toBe('Newest alias');});- it('applies last-activity cutoff to persistent projects using lastUsedAt', () => {+ it('does not use directory registration time as matching task activity', () => {const projects = [{workingDir: '/workspace/old',@@ -342,8 +343,8 @@ describe('groupSessions', () => {projects,Date.parse('2026-08-01T00:00:00.000Z'),).map((project) => project.workingDir),- ).toEqual(['/workspace/recent']);- expect(filterPersistentLocalProjectsByLastActivity(projects, null)).toEqual(projects);+ ).toEqual([]);+ expect(filterPersistentLocalProjectsByLastActivity(projects, null)).toBe(projects);});it('distinguishes a truly empty project from a vendor-mismatched historical project', () => {@@ -398,9 +399,75 @@ describe('groupSessions', () => {persistentLocalProjects: activityFiltered,}).projects.filter((project) => persistentProjectMatchesVendor(project, 'codex'));- expect(visibleForCodex.map((project) => project.workingDir)).toEqual([- '/workspace/empty-recent',- ]);+ expect(visibleForCodex).toEqual([]);+ });++ it('retains projects introduced by matching tasks even when directory activity is old', () => {+ const persistent = [+ {+ workingDir: '/workspace/matching',+ lastUsedAt: '2026-01-01T00:00:00.000Z',+ knownAgentKinds: [],+ },+ {+ workingDir: '/workspace/empty',+ lastUsedAt: '2026-08-12T00:00:00.000Z',+ knownAgentKinds: [],+ },+ ];+ const task = s({ workingDir: '/workspace/matching', updatedAt: '2026-08-12T00:00:00.000Z' });+ const filtered = groupSessions([task], {+ persistentLocalProjects: filterPersistentLocalProjectsByLastActivity(+ persistent,+ Date.parse('2026-08-05T00:00:00.000Z'),+ ),+ });+ expect(filtered.projects.map((project) => project.workingDir)).toEqual(['/workspace/matching']);+ expect(filtered.projects[0]?.sessions).toEqual([task]);+ expect(+ groupSessions([], {+ persistentLocalProjects: filterPersistentLocalProjectsByLastActivity(persistent, null),+ }).projects,+ ).toHaveLength(2);+ });++ it.each([+ ['D:/Work/Repo', 'd:/work/repo'],+ ['//Server/Share/École', '//server/share/école'],+ ])('groups Windows case variants under an activity filter: %s', (first, second) => {+ const tasks = [+ s({ workingDir: first, updatedAt: '2026-08-12T00:00:00.000Z' }),+ s({ workingDir: second, updatedAt: '2026-08-11T00:00:00.000Z' }),+ ];+ const persistent = [+ { workingDir: first.toUpperCase(), lastUsedAt: tasks[0].updatedAt, knownAgentKinds: [] },+ ];+ const result = groupSessions(tasks, {+ localPlatform: 'win32',+ persistentLocalProjects: filterPersistentLocalProjectsByLastActivity(+ persistent,+ Date.parse('2026-08-05T00:00:00.000Z'),+ ),+ });+ expect(result.projects).toHaveLength(1);+ expect(result.projects[0].sessions).toEqual(tasks);+ expect(result.projects[0].workingDir).toBe(first);+ expect(+ findProjectRepresentativeKey(result.projects, `local:${first.toUpperCase()}`, 'win32'),+ ).toBe(result.projects[0].projectKey);+ });++ it('keeps POSIX casing and remote identities distinct without persistent seeds', () => {+ const result = groupSessions(+ [+ s({ workingDir: '/Work/Repo' }),+ s({ workingDir: '/work/repo' }),+ s({ workingDir: '/work/repo', remoteHostId: 'host-a' }),+ s({ workingDir: '/work/repo', remoteHostId: 'host-b' }),+ ],+ { localPlatform: 'linux' },+ );+ expect(result.projects).toHaveLength(4);});it('does not let an older session regress retained project activity', () => {diff --git a/apps/desktop/src/renderer/__tests__/sidebarProjectRestore.test.ts b/apps/desktop/src/renderer/__tests__/sidebarProjectRestore.test.tsindex 4b5351f42f..bd88a51291 100644--- a/apps/desktop/src/renderer/__tests__/sidebarProjectRestore.test.ts+++ b/apps/desktop/src/renderer/__tests__/sidebarProjectRestore.test.ts@@ -163,6 +163,35 @@ describe('collectRestorableProjectKeys', () => {).toBe(false);});+ it('continues into draft creation when a recent empty project cannot pass the activity filter', async () => {+ const keys = collectRestorableProjectKeys({+ sessions: [],+ persistentLocalProjects: [+ {+ workingDir: '/workspace/cindy',+ lastUsedAt: '2026-08-02T08:00:00.000Z',+ knownAgentKinds: [],+ },+ ],+ lastActivityCutoff: Date.parse('2026-08-01T00:00:00.000Z'),+ pinnedProjectKeys: new Set(),+ vendorPredicate: null,+ });+ const ensureProjectIncluded = vi.fn();++ await expect(+ restoreHiddenProjectIfPresent({+ projectKey: PROJECT_KEY,+ wasHiddenAtPickerOpen: true,+ setProjectHidden: vi.fn().mockResolvedValue(true),+ getCurrentProjectKeys: () => keys,+ ensureProjectIncluded,+ localPlatform: 'linux',+ }),+ ).resolves.toBe(false);+ expect(ensureProjectIncluded).not.toHaveBeenCalled();+ });+it('lets a pinned persistent project bypass activity and vendor filters', () => {const keys = collectRestorableProjectKeys({sessions: [],diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsxindex 22b595c629..63c2fb8f63 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx@@ -159,6 +159,7 @@ import {import { isOrcaWorkerSession, resolveSessionRoute } from '@/lib/orcaSessionIdentity';import {buildProjectKeyComparisonSet,+ findProjectRepresentativeKey,isProjectHidden,projectKeyComparisonSetHas,sidebarSessionsWithHiddenProjectsAsDialogues,@@ -1495,13 +1496,19 @@ function ExpandedView({if (isLoadingSessions) return; // 等首次加载完const targetDir = pendingFocus.workingDir;const targetKey = normalizeProjectKey(targetDir) ?? `local:${targetDir}`;- const exists = groupsWithPinnedProjects.projects.some((p) => p.projectKey === targetKey);- if (exists) {- collapse.expand(targetKey);+ const representativeKey = findProjectRepresentativeKey(+ groupsWithPinnedProjects.projects,+ targetKey,+ localPlatform,+ );+ if (representativeKey) {+ collapse.expand(representativeKey);// RAF 等 expand 触发的 re-render 完成 (project header DOM 在折叠态下已渲染,// 这里 RAF 主要给"刚 mount"的场景一帧时间让 querySelector 拿到节点)。requestAnimationFrame(() => {- const node = document.querySelector(`[data-project-workingdir="${CSS.escape(targetKey)}"]`);+ const node = document.querySelector(+ `[data-project-workingdir="${CSS.escape(representativeKey)}"]`,+ );if (node) node.scrollIntoView({ block: 'nearest', behavior: 'smooth' });});} else if (selectedMachineId !== MACHINE_ALL) {@@ -1521,6 +1528,7 @@ function ExpandedView({groupsWithPinnedProjects.projects,collapse,isLoadingSessions,+ localPlatform,selectedMachineId,t,]);diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.tsindex cf655a6b16..5d2f81d489 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts@@ -196,6 +196,7 @@ export function buildPersistentLocalProjects(for (const session of sessions) {if (session.workspaceKind === 'dialogue' ||+ isOrcaWorkerSession(session) ||session.remoteHostId != null ||session.deviceLinkDeviceId != null) {@@ -231,7 +232,9 @@ export function filterPersistentLocalProjectsByLastActivity(cutoffMs: number | null,): readonly PersistentLocalProject[] {if (cutoffMs === null) return projects;- return projects.filter((project) => toMs(project.lastUsedAt) >= cutoffMs);+ // With an activity filter, only matching tasks may introduce a project group.+ // A recently registered directory alone is not evidence of task activity.+ return [];}export function persistentProjectMatchesVendor(@@ -545,7 +548,7 @@ export function groupSessions(? sessions: sessions.filter((s) => s.pinnedAt == null);- const persistentRepresentativeByComparison = new Map<+ const localRepresentativeByComparison = new Map<string,{ projectKey: string; workingDir: string }>();@@ -554,8 +557,8 @@ export function groupSessions(if (!workingDir) continue;const projectKey = projectIdentityKey('local', workingDir, null);const comparisonKey = projectKeyComparisonKey(projectKey, localPlatform);- if (comparisonKey && !persistentRepresentativeByComparison.has(comparisonKey)) {- persistentRepresentativeByComparison.set(comparisonKey, { projectKey, workingDir });+ if (comparisonKey && !localRepresentativeByComparison.has(comparisonKey)) {+ localRepresentativeByComparison.set(comparisonKey, { projectKey, workingDir });}}@@ -615,11 +618,14 @@ export function groupSessions(if (scope === 'local') {const comparisonKey = projectKeyComparisonKey(projectKey, localPlatform);const representative = comparisonKey- ? persistentRepresentativeByComparison.get(comparisonKey)+ ? localRepresentativeByComparison.get(comparisonKey): undefined;if (representative) {projectKey = representative.projectKey;identityWorkingDir = representative.workingDir;+ } else if (comparisonKey) {+ // Filtered views have no persistent seeds; tasks still share path identity.+ localRepresentativeByComparison.set(comparisonKey, { projectKey, workingDir: dir });}}const arr = groups.get(projectKey);diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/sidebarProjectRestore.ts b/apps/desktop/src/renderer/features/cc-agent/lib/sidebarProjectRestore.tsindex 72a17710fc..c757460e87 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/sidebarProjectRestore.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/sidebarProjectRestore.ts@@ -3,6 +3,7 @@ import type { Session } from '@/lib/ccAgent.types';import { projectKeyComparisonKey } from '../../../../shared/projectKeys';import { sessionActivityMs } from './dateSessionGrouping';import {+ filterPersistentLocalProjectsByLastActivity,groupSessions,projectIdentityKeyForSession,type PersistentLocalProject,@@ -86,12 +87,10 @@ export function collectRestorableProjectKeys({lastActivityCutoff === null? vendorSessions: vendorSessions.filter((session) => sessionActivityMs(session) >= lastActivityCutoff);- const activityProjects =- lastActivityCutoff === null- ? vendorProjects- : vendorProjects.filter(- (project) => new Date(project.lastUsedAt).getTime() >= lastActivityCutoff,- );+ const activityProjects = filterPersistentLocalProjectsByLastActivity(+ vendorProjects,+ lastActivityCutoff,+ );const activityGroups = groupSessions(activitySessions, {includePinnedInProjects: true,persistentLocalProjects: activityProjects,diff --git a/apps/desktop/src/shared/__tests__/sessionSource.test.ts b/apps/desktop/src/shared/__tests__/sessionSource.test.tsindex 0e8b51e83a..b8f09ce3be 100644--- a/apps/desktop/src/shared/__tests__/sessionSource.test.ts+++ b/apps/desktop/src/shared/__tests__/sessionSource.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';-import { isRetainableProjectSessionSource } from '../sessionSource.js';+import { isRetainableProjectSession, isRetainableProjectSessionSource } from '../sessionSource.js';describe('isRetainableProjectSessionSource', () => {it.each(['desktop', 'plugin'] as const)('accepts the durable %s project source', (source) => {@@ -14,3 +14,20 @@ describe('isRetainableProjectSessionSource', () => {},);});++describe('isRetainableProjectSession', () => {+ it.each(['desktop', 'plugin'])(+ 'excludes %s workers but retains normal tasks and leads',+ (source) => {+ expect(isRetainableProjectSession({ source, orcaRole: 'worker' })).toBe(false);+ for (const orcaRole of [undefined, null, 'lead']) {+ expect(isRetainableProjectSession({ source, orcaRole })).toBe(true);+ }+ },+ );++ it.each([undefined, null, 'scheduler', 'bot', 'review', 'future-source'])(+ 'does not admit non-project source %j',+ (source) => expect(isRetainableProjectSession({ source })).toBe(false),+ );+});diff --git a/apps/desktop/src/shared/sessionSource.ts b/apps/desktop/src/shared/sessionSource.tsindex a754a279f5..5b2992a130 100644--- a/apps/desktop/src/shared/sessionSource.ts+++ b/apps/desktop/src/shared/sessionSource.ts@@ -28,8 +28,7 @@ export const RETAINABLE_PROJECT_SESSION_SOURCES = ['plugin',] as const satisfies readonly SessionSource[];-export type RetainableProjectSessionSource =- (typeof RETAINABLE_PROJECT_SESSION_SOURCES)[number];+export type RetainableProjectSessionSource = (typeof RETAINABLE_PROJECT_SESSION_SOURCES)[number];/** Fail closed for legacy/malformed rows whose source is missing or unknown. */export function isRetainableProjectSessionSource(@@ -38,6 +37,14 @@ export function isRetainableProjectSessionSource(return source === 'desktop' || source === 'plugin';}+/** Internal worker directories are execution inputs, not user project registrations. */+export function isRetainableProjectSession(session: {+ source?: unknown;+ orcaRole?: unknown;+}): boolean {+ return session.orcaRole !== 'worker' && isRetainableProjectSessionSource(session.source);+}+export function isReviewSessionSource(source: unknown): source is 'review' {return source === 'review';}