Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge main into fix/4532-deleted-session-badge
Dante203e76dd547f
diff --cc apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex 8267a649c2,97514242c4..97434a5661--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@@ -29,8 -31,6 +31,7 @@@ const h = vi.hoisted(() => (client: null as { drizzle: ReturnType<typeof drizzle> } | null,sqlite: null as InstanceType<typeof import('better-sqlite3')> | null,handlers: new Map<string, (...args: unknown[]) => unknown>(),+ setBadgeCount: vi.fn(),- commitBotProfileDeletion: vi.fn(),relocate: vi.fn(async (): Promise<{ persistedSdkSessionId: string | null }> => ({persistedSdkSessionId: null,})),@@@ -99,12 -104,6 +105,10 @@@ vi.mock('@cindy/maker-core/pi-subagent-writePiSubagentDeletedTombstone: h.writePiSubagentDeletedTombstone,clearPiSubagentDeletedTombstone: h.clearPiSubagentDeletedTombstone,}));- vi.mock('../../botProfileDeletionStore.js', () => ({- commitBotProfileDeletion: h.commitBotProfileDeletion,- }));+vi.mock('../../../appSessionState', () => ({+ getActiveAppSession: () => ({ dataOwnerId: 'owner-a', generation: 1 }),++ ownerScopedUserDataPath: (...parts: string[]) => path.join(h.userDataDir!, ...parts),+}));vi.mock('../../../logger', () => ({createLogger: () => ({ debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }),}));@@@ -301,10 -325,10 +335,12 @@@ async function invokeCreate(body: Recor}beforeEach(() => {+ clearAllSessionAttention();+ setSessionOpeningModelAdmission(async body => body);vi.clearAllMocks();+ h.commitBotProfileDeletion.mockReset();h.relocate.mockImplementation(async () => ({ persistedSdkSessionId: null }));+ h.commitBotProfileDeletion.mockResolvedValue({ status: 'archived', sessionIds: [] });h.closeSession.mockClear();h.routeLock.mockImplementation(async (_sessionId, task) => task());h.upsertRecentWorkdir.mockImplementation(async () => true);diff --cc apps/desktop/src/main/localDb/ipc/sessions.tsindex 10dceb2936,8ee2ec9615..7efc084d7b--- a/apps/desktop/src/main/localDb/ipc/sessions.ts+++ b/apps/desktop/src/main/localDb/ipc/sessions.ts@@@ -2076,11 -2204,12 +2208,15 @@@ export async function patchSessionMetaIrow.summary = null;}cleanupSessionRuntimeForTerminalStatus(sessionId, patch.status);+ if (terminal) {+ const { closeSharedTaskForTask } = await import('../../device-link/sharedTaskRuntime.js');+ await closeSharedTaskForTask(sessionId, dbClient);+ }return sessionToCamel(row);});+ if (updated.status === 'deleted' && isOwnerScopeCurrent(ownerScope)) {+ clearSessionAttention(sessionId, 'explicit');+ }notifyAgentIslandSessionPatch(updated.id, {status: updated.status,title: updated.title,@@@ -2359,10 -2504,18 +2511,21 @@@ export async function deleteBotProfileAconst status = committed.status;const committedSessionIds = [...new Set(committed.sessionIds)];+ for (const closure of prepared) await finalizeSharedTaskClosure(dbClient, closure);++ // Bot profile deletion commits terminal task status through a dedicated+ // transaction, so it bypasses the ordinary session patch/status writers.+ // Close the corresponding shared task only after that durable transition;+ // closeSharedTaskForTask journals network failures and never revives the task.+ if (committedSessionIds.length > 0) {+ const { closeSharedTaskForTask } = await import('../../device-link/sharedTaskRuntime.js');+ for (const id of committedSessionIds) await closeSharedTaskForTask(id, dbClient);+ }+for (const id of committedSessionIds) {+ if (status === 'deleted' && isOwnerScopeCurrent(ownerScope)) {+ clearSessionAttention(id, 'explicit');+ }notifyAgentIslandSessionPatch(id, { status });broadcastSessionPatched(id, { status, source: 'desktop' }, ownerScope);notifyGhostSessionStatusChange(id, status, null);