Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix: 诊断预填保留原草稿的全部字段
Dasha5c72bc9a761
diff --git a/apps/desktop/src/renderer/components/chat/__tests__/ErrorLocalization.test.tsx b/apps/desktop/src/renderer/components/chat/__tests__/ErrorLocalization.test.tsxindex 722c810613..a4692a28be 100644--- a/apps/desktop/src/renderer/components/chat/__tests__/ErrorLocalization.test.tsx+++ b/apps/desktop/src/renderer/components/chat/__tests__/ErrorLocalization.test.tsx@@ -50,13 +50,14 @@ it('offers diagnosis after expanding details with a redacted prompt for the fail// 新建任务页已有未发送内容时,诊断预填只追加,不能丢掉用户的文字与附件。it('appends the diagnosis prompt to an unsent new-task draft instead of replacing it', () => {const attachment = { id: 'a1', name: 'note.txt', path: '/tmp/note.txt' } as never;- saveDraft(NEW_MAKER_DRAFT_KEY, { text: plainTextToTiptapDoc('我写到一半的内容'), attachments: [attachment] });+ saveDraft(NEW_MAKER_DRAFT_KEY, { text: plainTextToTiptapDoc('我写到一半的内容'), attachments: [attachment], pendingGhostId: 'plugin-1' });prefillErrorDiagnosisDraft('请帮我诊断这个错误');const draft = getDraft(NEW_MAKER_DRAFT_KEY)!;const text = JSON.stringify(draft.text);expect(text.indexOf('我写到一半的内容')).toBeGreaterThanOrEqual(0);expect(text.indexOf('请帮我诊断这个错误')).toBeGreaterThan(text.indexOf('我写到一半的内容'));expect(draft.attachments).toHaveLength(1);+ expect(draft.pendingGhostId).toBe('plugin-1');clearDraft(NEW_MAKER_DRAFT_KEY);});diff --git a/apps/desktop/src/renderer/lib/errorDiagnosisPrompt.ts b/apps/desktop/src/renderer/lib/errorDiagnosisPrompt.tsindex c6ccf553be..ed41229170 100644--- a/apps/desktop/src/renderer/lib/errorDiagnosisPrompt.ts+++ b/apps/desktop/src/renderer/lib/errorDiagnosisPrompt.ts@@ -32,19 +32,26 @@ export function buildErrorDiagnosisPrompt(}/**- * 新建任务页已有未发送的内容时不覆盖:诊断提示追加在原文之后,附件与浏览器评论原样保留。- * 草稿为空时与其他预填入口一致,整体写入。+ * 新建任务页已有未发送的内容时不覆盖:以原草稿为底整体保留(附件、浏览器评论、插件交接、+ * 旧版引用等全部字段),只把诊断提示追加在正文之后。草稿为空时与其他预填入口一致,整体写入。*/export function prefillErrorDiagnosisDraft(prompt: string): void {const existing = getDraft(NEW_MAKER_DRAFT_KEY);const added = plainTextToTiptapDoc(prompt);const existingContent = existing?.text?.content ?? [];- saveDraft(NEW_MAKER_DRAFT_KEY, {- ...(existing?.browserComments?.length ? { browserComments: existing.browserComments } : {}),- text: existingContent.length > 0- ? { ...added, content: [...existingContent, ...(added.content ?? [])] }- : added,- attachments: existing?.attachments ?? [],- });+ const hasUnsent =+ existingContent.length > 0 ||+ (existing?.attachments.length ?? 0) > 0 ||+ (existing?.browserComments?.length ?? 0) > 0 ||+ (existing?.quotes?.length ?? 0) > 0;+ saveDraft(+ NEW_MAKER_DRAFT_KEY,+ existing && hasUnsent+ ? {+ ...existing,+ text: { ...added, content: [...existingContent, ...(added.content ?? [])] },+ }+ : { text: added, attachments: [] },+ );resetDraftWorkspaceTargets();}