Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 回收远程队列编辑图片缓存
DavidShen7af8787342a5
diff --git a/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.ts b/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.tsindex 946c758788..14b186b418 100644--- a/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.ts+++ b/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.ts@@ -504,6 +504,57 @@ describe('renderer input queue facade', () => {expect(saved).toBe(true);});+ it('recycles an ordinary controller image after a remote queue edit is accepted', async () => {+ const sid = `remote-image-${Math.random().toString(36).slice(2, 8)}`;+ const deviceId = 'dev-remote-image';+ const item = queued('q-remote-image', 'ordinary remote image edit');+ const sourceUrl = 'xdt-image://session/ordinary-source.png';+ const source: AttachedFile = {+ id: 'remote-image',+ name: 'ordinary-source.png',+ path: 'C:\\images\\ordinary-source.png',+ ext: 'png',+ size: 123,+ category: 'image',+ mimeType: 'image/png',+ url: sourceUrl,+ };+ makerChatStore.initGlobalListeners();+ projectionHandler?.(projection(sid, { pendingQueue: [item] }));+ remoteProjectsStore.setDeviceSessions(deviceId, 'Remote Mac', [{ id: sid } as never]);+ remoteInvoke.mockImplementation(async (_deviceId, channel, args) => {+ expect(channel).toBe('maker:input:update-content');+ const replacement = args[2] as AgentInputQueuedMessage;+ return projection(sid, {+ pendingQueue: [+ {+ ...replacement,+ files: (replacement.files ?? []).map((file) => ({+ ...file,+ path: 'C:\\remote-cache\\ordinary.png',+ url: 'xdt-image://remote/ordinary.png',+ })),+ },+ ],+ });+ });++ const saved = await makerChatStore.updateQueueItemContent(sid, item.clientId, {+ content: {+ text: item.text,+ mentions: [],+ hasQuotes: false,+ agentReferences: [],+ pastedTextRanges: [],+ slashCommandRanges: [],+ },+ files: [source],+ });++ expect(saved).toBe(true);+ expect(cleanupCachedImages).toHaveBeenCalledWith([sourceUrl]);+ });+it('recycles a newly annotated remote queue edit source only after acceptance', async () => {const sid = `remote-annotation-${Math.random().toString(36).slice(2, 8)}`;const deviceId = 'dev-remote-annotation';diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 66a2a64b6c..28fdebd9b0 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -13722,25 +13722,22 @@ function cleanupAcceptedQueueEditMaterializationSources(editedFiles: readonly AttachedFile[],preparedFiles: readonly AttachedFile[],acceptedFiles: readonly AttachedFile[],+ remoteMediaSession: boolean,): void {const queuedUrls = new Set(queuedFiles.map((file) => file.url).filter(Boolean));const retainedUrls = new Set(- [...preparedFiles, ...acceptedFiles].flatMap((file) =>+ (remoteMediaSession ? acceptedFiles : [...preparedFiles, ...acceptedFiles]).flatMap((file) =>[file.url, file.annotationSourceUrl].filter((url): url is string => Boolean(url)),),);- const preparedById = new Map(preparedFiles.map((file) => [file.id, file]));const removedSourceUrls = [...new Set(editedFiles.flatMap((file) => {- const prepared = preparedById.get(file.id);if (file.cacheUrlShared === true ||!file.url?.startsWith('xdt-image://') ||queuedUrls.has(file.url) ||- retainedUrls.has(file.url) ||- prepared?.annotated !== true ||- prepared.url === file.url+ retainedUrls.has(file.url)) {return [];}@@ -13814,9 +13811,10 @@ async function updateQueueItemContent(if (!queuedFile || queuedFile.url !== file.url || queuedFile.path !== file.path) return file;return { ...file, cacheUrlShared: undefined, stagedPathShared: undefined };});+ const remoteMediaSession = isRemoteMediaSession(sessionId);const preparedFiles =(await materializeAnnotatedAttachmentsForSend(filesForMaterialization, sessionId, {- stripAnnotationMeta: isRemoteMediaSession(sessionId),+ stripAnnotationMeta: remoteMediaSession,})) ?? [];const textUnchanged = content.text === queued.text;@@ -13912,6 +13910,7 @@ async function updateQueueItemContent(files,preparedFiles,accepted.files ?? [],+ remoteMediaSession,);} else {cleanupUnacceptedQueueEditMaterialization(files, preparedFiles);