Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(attachments): fill in all media fields on content parts

Steven Enamakel2f37904cae93
diff --git a/app/src/features/voiceNotes/voiceNoteApi.ts b/app/src/features/voiceNotes/voiceNoteApi.ts
index 9068f23f48..3370471c91 100644
--- a/app/src/features/voiceNotes/voiceNoteApi.ts
+++ b/app/src/features/voiceNotes/voiceNoteApi.ts
@@ -63,7 +63,22 @@ export async function voiceNoteContentPart(
durationMs,
waveform,
pushToTalk: false,
- media: { opaqueId: noteId, kind: 'audio', contentType, durationMs, sizeBytes: blob.size },
+ media: {
+ opaqueId: noteId,
+ kind: 'audio',
+ contentType,
+ durationMs,
+ sizeBytes: blob.size,
+ codec: null,
+ fileName: null,
+ height: null,
+ localCachePath: null,
+ path: null,
+ platformMessageId: null,
+ transcribed: false,
+ url: null,
+ width: null,
+ },
},
};
}
diff --git a/app/src/lib/attachments.ts b/app/src/lib/attachments.ts
index 8ab5f80f02..52823b8238 100644
--- a/app/src/lib/attachments.ts
+++ b/app/src/lib/attachments.ts
@@ -323,10 +323,33 @@ export function attachmentsToParts(attachments: Attachment[]): ContentPart[] {
contentType: a.mimeType,
fileName: a.file.name,
sizeBytes: a.originalSizeBytes,
+ codec: null,
+ durationMs: null,
+ height: null,
+ localCachePath: null,
+ path: null,
+ platformMessageId: null,
+ transcribed: false,
+ width: null,
+ };
+ if (a.kind === 'image') {
+ return { kind: 'image', altText: null, caption: null, media: { ...media, kind: 'image' } };
+ }
+ if (a.kind === 'video') {
+ return {
+ kind: 'video',
+ caption: null,
+ durationMs: null,
+ thumbnail: null,
+ media: { ...media, kind: 'video' },
+ };
+ }
+ return {
+ kind: 'file',
+ fileName: a.file.name,
+ caption: null,
+ media: { ...media, kind: 'document' },
};
- if (a.kind === 'image') return { kind: 'image', media: { ...media, kind: 'image' } };
- if (a.kind === 'video') return { kind: 'video', media: { ...media, kind: 'video' } };
- return { kind: 'file', fileName: a.file.name, media: { ...media, kind: 'document' } };
});
}
diff --git a/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx b/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
index e46cc2efa5..9c318bc8a4 100644
--- a/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
+++ b/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
@@ -884,7 +884,22 @@ describe('ChatRuntimeProvider — dedupe, proactive resolution, mid-turn invaria
{
kind: 'file' as const,
fileName: 'archive.zip',
- media: { url: 'data:application/zip;name=archive.zip;base64,AQID' },
+ caption: null,
+ media: {
+ kind: 'document',
+ url: 'data:application/zip;name=archive.zip;base64,AQID',
+ contentType: null,
+ fileName: 'archive.zip',
+ sizeBytes: null,
+ codec: null,
+ durationMs: null,
+ height: null,
+ localCachePath: null,
+ path: null,
+ platformMessageId: null,
+ transcribed: false,
+ width: null,
+ },
},
];
const durable =
diff --git a/app/src/services/chatWire.test.ts b/app/src/services/chatWire.test.ts
index 829411994c..7f04486020 100644
--- a/app/src/services/chatWire.test.ts
+++ b/app/src/services/chatWire.test.ts
@@ -55,6 +55,7 @@ describe('chatWire', () => {
input_tokens: 10,
output_tokens: 5,
cached_input_tokens: 2,
+ context_tokens: 0,
context_window: 1000,
cost_usd: null,
cost_source: 'unknown',
diff --git a/app/src/store/queueSlice.test.ts b/app/src/store/queueSlice.test.ts
index ada62a3395..652c9dc33b 100644
--- a/app/src/store/queueSlice.test.ts
+++ b/app/src/store/queueSlice.test.ts
@@ -220,7 +220,23 @@ describe('clipQueuePreview', () => {
describe('clipQueuePreview with typed attachments', () => {
const file = (name?: string) => ({
kind: 'file' as const,
- media: { url: 'data:application/pdf;base64,AAA', fileName: name },
+ fileName: name ?? null,
+ caption: null,
+ media: {
+ kind: 'document' as const,
+ url: 'data:application/pdf;base64,AAA',
+ fileName: name ?? null,
+ contentType: null,
+ sizeBytes: null,
+ codec: null,
+ durationMs: null,
+ height: null,
+ localCachePath: null,
+ path: null,
+ platformMessageId: null,
+ transcribed: false,
+ width: null,
+ },
});
it('uses the caption when there is one', () => {