Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 保留排队标注图片地址

DavidShen51e3c36d91d2
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/normalizeAttachmentsTemp.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/normalizeAttachmentsTemp.test.ts
index f508410704..ac0cd515a4 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/normalizeAttachmentsTemp.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/normalizeAttachmentsTemp.test.ts
@@ -220,6 +220,32 @@ describe('inline attachment temporary files', () => {
expect(downloadToFile).not.toHaveBeenCalled();
});
+ it('keeps queued annotated images on their burned image URL', async () => {
+ const burnedUrl = 'xdt-image://queued-annotated/annotated.png';
+ const originalPath = path.join(tempRoot.value, 'original.png');
+ await fs.writeFile(originalPath, Buffer.from([0x89, 0x50, 0x4e, 0x47]));
+ const item = {
+ clientId: 'queued-annotated-image',
+ files: [{
+ category: 'image',
+ ext: '.png',
+ path: originalPath,
+ url: burnedUrl,
+ mimeType: 'image/png',
+ annotated: true,
+ }],
+ };
+
+ const materialized = await materializeQueuedOssAttachmentsDeferred(
+ 'queued-annotated-image',
+ item,
+ );
+
+ expect(materialized.item).toBe(item);
+ expect(ingestMedia).not.toHaveBeenCalled();
+ expect(downloadToFile).not.toHaveBeenCalled();
+ });
+
it('writes private bytes and removes them even before Maker owns the session', async () => {
const sessionId = 'reviewer-session';
const normalized = await normalizeUserMessage(sessionId, {
diff --git a/apps/desktop/src/main/maker-ipc/normalizeAttachments.ts b/apps/desktop/src/main/maker-ipc/normalizeAttachments.ts
index 303105d41a..a3e35891b1 100644
--- a/apps/desktop/src/main/maker-ipc/normalizeAttachments.ts
+++ b/apps/desktop/src/main/maker-ipc/normalizeAttachments.ts
@@ -418,6 +418,7 @@ type SerializedFileLike = {
type?: unknown;
category?: unknown;
ext?: unknown;
+ annotated?: unknown;
};
function isQueuedImageFile(file: SerializedFileLike): boolean {
@@ -460,6 +461,10 @@ function needsImageMaterialize(v: unknown): v is string {
function queuedFileMaterializeRef(file: SerializedFileLike): string | null {
if (isOssRefField(file.url)) return file.url;
+ // 标注图的 url 是烧录位图,path 仍是原始磁盘图;本地队列必须继续使用 url。
+ if (file.annotated === true && typeof file.url === 'string' && file.url.length > 0) {
+ return null;
+ }
if (isOssRefField(file.path)) return file.path;
if (!isQueuedImageFile(file)) return null;
if (isLocalImagePathField(file.url)) return file.url;