Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): absorb the workbench write-chain cleanup rejection on failure (#5344)
billythegod0f018241768f
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.tsindex fdb87e5184..280218cd7e 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.ts@@ -185,6 +185,41 @@ describe('bot workbench judgments', () => {});});+describe('bot workbench write-chain failure hygiene', () => {+ it('absorbs the cleanup promise rejection when a write fails and keeps the chain usable', async () => {+ root = await mkdtemp(path.join(os.tmpdir(), 'bot-workbench-'));+ const proj = path.join(root, 'proj');+ await mkdir(proj);+ await addBotWorkbenchDirectory(root, 'bot-1', proj, new Date('2026-10-01T01:00:00.000Z'));++ // 把 workbench.json 换成目录 → 下一次 mutate 的 rename 失败。+ const file = path.join(botProfileDir(root, 'bot-1'), 'workbench.json');+ await rm(file);+ await mkdir(file);++ const rejections: unknown[] = [];+ const onUnhandled = (reason: unknown) => rejections.push(reason);+ process.on('unhandledRejection', onUnhandled);+ try {+ // 第二次添加走同一条写链:run 本身按预期 reject(调用方拿到失败)。+ await expect(+ addBotWorkbenchDirectory(root, 'bot-1', proj, new Date('2026-10-01T02:00:00.000Z')),+ ).rejects.toThrow();+ await new Promise((resolve) => setImmediate(resolve));+ // finally 派生的 cleanup promise 不得产生进程级 unhandledRejection。+ expect(rejections).toEqual([]);+ } finally {+ process.off('unhandledRejection', onUnhandled);+ }++ // 写链未被失败污染:恢复文件后同一 bot 的下一次写入正常。+ await rm(file, { recursive: true });+ expect(await addBotWorkbenchDirectory(root, 'bot-1', proj, new Date('2026-10-01T03:00:00.000Z'))).toEqual({ ok: true });+ const state = await readBotWorkbenchState(root, 'bot-1');+ expect(state.directories[0]).toBe(path.resolve(proj));+ });+});+describe('bot workbench directory removal normalization', () => {it('removes a handed-over project addressed by an equivalent, differently-spelled path', async () => {// 回归:add 存 path.resolve 后的路径, remove 曾按原始串比较 —— 尾分隔符、diff --git a/apps/desktop/src/main/maker-ipc/botWorkbenchService.ts b/apps/desktop/src/main/maker-ipc/botWorkbenchService.tsindex 42455ce504..84e008b1ca 100644--- a/apps/desktop/src/main/maker-ipc/botWorkbenchService.ts+++ b/apps/desktop/src/main/maker-ipc/botWorkbenchService.ts@@ -159,9 +159,12 @@ function mutate<T>(return result;});writeChains.set(key, run);+ // finally 派生的 promise 会继承 run 的 rejection 且无人接住 —— 磁盘错误/+ // 写入中途 bot home 被删时升级为进程级 unhandledRejection。cleanup 照跑,+ // rejection 在此吸收(调用方已拿到原始 run 的失败)。void run.finally(() => {if (writeChains.get(key) === run) writeChains.delete(key);- });+ }).catch(() => undefined);return run;}