Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(new-task): 残留清理固定账号库;离开新建页时完成待执行的空草稿删除
Dashf4e68feb07d6
diff --git a/apps/desktop/src/main/localDb/provisionalSessions.ts b/apps/desktop/src/main/localDb/provisionalSessions.tsindex 9f610b5f93..b27b54f9dd 100644--- a/apps/desktop/src/main/localDb/provisionalSessions.ts+++ b/apps/desktop/src/main/localDb/provisionalSessions.ts@@ -171,8 +171,8 @@ export function forgetProvisionalSession(sessionId: string): boolean {*/export async function deleteUnsentSessionRow(sessionId: string,+ db = getDbClient().drizzle,): Promise<{ workspaceKind: string | null; workingDir: string | null } | null> {- const db = getDbClient().drizzle;const [row] = await db.select({workspaceKind: sessions.workspaceKind,@@ -217,19 +217,25 @@ export async function sweepLeftoverProvisionalSessions(now = Date.now()): Promisif (!owner) return [];let run = sweeps.get(owner);if (!run) {- run = sweepOwner(now);+ run = sweepOwner(owner, now);sweeps.set(owner, run);}return run;}-async function sweepOwner(now: number): Promise<string[]> {+async function sweepOwner(owner: object, now: number): Promise<string[]> {const pending = [...loadLeftovers()];if (pending.length === 0) return [];+ // The whole sweep stays on this account's database; if the account changes mid-way,+ // the rest is kept for later instead of being checked against another account.const db = getDbClient().drizzle;const keep: Entry[] = [];const removed: string[] = [];- for (const entry of pending) {+ for (const [index, entry] of pending.entries()) {+ if (getCurrentDbClientSnapshot() !== owner) {+ keep.push(...pending.slice(index));+ break;+ }try {const [row] = await db.select({ id: sessions.id })@@ -240,7 +246,11 @@ async function sweepOwner(now: number): Promise<string[]> {if (now - entry.createdAt < FOREIGN_ENTRY_TTL_MS) keep.push(entry);continue;}- const deleted = await deleteUnsentSessionRow(entry.id);+ if (getCurrentDbClientSnapshot() !== owner) {+ keep.push(...pending.slice(index));+ break;+ }+ const deleted = await deleteUnsentSessionRow(entry.id, db);if (deleted) {removed.push(entry.id);onLeftoverSwept?.(entry.id);diff --git a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsxindex 5892123e28..0d6c78b366 100644--- a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx@@ -2184,8 +2184,14 @@ export function NewMakerDraftRoute() {});return () => {unsubscribe();- if (provisionalEmptyTimerRef.current) clearTimeout(provisionalEmptyTimerRef.current);+ const pendingEmptyCheck = provisionalEmptyTimerRef.current;+ if (pendingEmptyCheck) clearTimeout(pendingEmptyCheck);provisionalEmptyTimerRef.current = null;+ // Leaving the page while an empty-input delete is still pending: nothing will notify us+ // again, so finish it now rather than leave an empty task behind.+ if (pendingEmptyCheck && provisionalDraftTaskId() && !getComposerDraftPresence(NEW_MAKER_DRAFT_KEY)) {+ void discardProvisionalDraftTask();+ }};}, [armProvisionalEmptyCheck, refreshProvisionalTitle]);// 草稿里影响任务本身的设置变了:按新设置重建(不再适合提前建任务就删掉)。