Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
修复会话移动锁死和计划草稿残留
nothingyuancando370c98b9867a
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex 95e0adef4c..3309b96d04 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@ -357,6 +357,12 @@ describe('local-db:sessions:update handler wiring', () => {expect(h.closeSession).toHaveBeenCalledWith('codex-local');});+ it('does not reacquire the route lock for a combined workingDir and status patch', async () => {+ await invokeUpdate('codex-local', { workingDir: '/new/dir', status: 'active' });++ expect(h.routeLock).toHaveBeenCalledTimes(1);+ });+it('does nothing for remote sessions', async () => {await invokeUpdate('cc-remote', { workingDir: '/new/dir' });expect(h.relocate).not.toHaveBeenCalled();diff --git a/apps/desktop/src/main/localDb/ipc/sessions.ts b/apps/desktop/src/main/localDb/ipc/sessions.tsindex 63dc27cde0..66d017adf9 100644--- a/apps/desktop/src/main/localDb/ipc/sessions.ts+++ b/apps/desktop/src/main/localDb/ipc/sessions.ts@@ -110,8 +110,9 @@ async function withStatusWriteLock<T>(sessionId: string,status: unknown,task: () => Promise<T>,+ alreadyLocked = false,): Promise<T> {- if (status === undefined) return task();+ if (status === undefined || alreadyLocked) return task();return withSessionRouteLock(sessionId, task);}@@ -1456,7 +1457,12 @@ export function registerSessionIpc(// 先记号后写库,代价只是写库失败时该会话本进程内不再自动起名 —— 用户毕竟确实// 按下过保存,这个方向的偏差是安全的。if (typeof p.title === 'string') noteUserTitleWritten(sid);- await withStatusWriteLock(sid, p.status, () => writeSessionPatch(db, sid, setObj, p.status));+ await withStatusWriteLock(+ sid,+ p.status,+ () => writeSessionPatch(db, sid, setObj, p.status),+ p.workingDir !== undefined,+ );// session-git-pr-context:/clear 经此处写 clearedAt——边界之前的消息对用户// 不可见,PR 引用同步重算(fire-and-forget,内部按 clearedAt/rewindAt 过滤)。if (p.clearedAt !== undefined) {diff --git a/apps/desktop/src/renderer/__tests__/planModeComposerCommand.test.ts b/apps/desktop/src/renderer/__tests__/planModeComposerCommand.test.tsindex 8510a59b5a..0218380a1d 100644--- a/apps/desktop/src/renderer/__tests__/planModeComposerCommand.test.ts+++ b/apps/desktop/src/renderer/__tests__/planModeComposerCommand.test.ts@@ -99,5 +99,6 @@ describe('/plan composer command', () => {expect(planModeComposerDraftText(true, editorText, storedText)).toBe(editorText);expect(planModeComposerDraftText(false, null, storedText)).toBe(storedText);expect(planModeComposerDraftText(true, null, storedText)).toBeNull();+ expect(planModeComposerDraftText(true, editorText, storedText, true)).toBeNull();});});diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsxindex c33a8e5f99..bf905ddeca 100644--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx@@ -5049,6 +5049,7 @@ export function ChatInput({editorOwnsSource,editorOwnsSource ? editor.getJSON() : null,existingDraft?.text,+ true,);if (editorOwnsSource) {planModeEntry?.onToggle(!planModeEntry.enabled);diff --git a/apps/desktop/src/renderer/components/new-chat/planModeComposerCommand.ts b/apps/desktop/src/renderer/components/new-chat/planModeComposerCommand.tsindex 8258a98a85..ee8636407a 100644--- a/apps/desktop/src/renderer/components/new-chat/planModeComposerCommand.ts+++ b/apps/desktop/src/renderer/components/new-chat/planModeComposerCommand.ts@@ -63,6 +63,8 @@ export function planModeComposerDraftText(editorOwnsSource: boolean,editorText: JSONContent | null | undefined,storedText: JSONContent | null | undefined,+ consumedCommand = false,): JSONContent | null {+ if (consumedCommand) return null;return (editorOwnsSource ? editorText : storedText) ?? null;}