From f0aa9d528970de4ddd690df01f9f726caee8cd5b Mon Sep 17 00:00:00 2001 From: dawn <90008@klbr.net> Date: Wed, 18 Nov 2026 20:05:10 +0300 Subject: [PATCH] feat(web): attach and play audio and video clips Signed-off-by: dawn <90008@klbr.net> --- web/scripts/transcript.test.mjs | 9 ++- web/src/lib/chat/Chat.svelte | 32 +++++++++-- web/src/lib/chat/Clips.svelte | 95 +++++++++++++++++++++++++++++++ web/src/lib/chat/Composer.svelte | 50 +++++++++++++--- web/src/lib/chat/WorkSteps.svelte | 9 ++- web/src/lib/chat/attachments.ts | 41 ++++++++++++- web/src/lib/context.ts | 5 +- web/src/lib/transcript.svelte.ts | 9 ++- 8 files changed, 229 insertions(+), 21 deletions(-) create mode 100644 web/src/lib/chat/Clips.svelte diff --git a/web/scripts/transcript.test.mjs b/web/scripts/transcript.test.mjs index 73524d07c..47c54a08c 100644 --- a/web/scripts/transcript.test.mjs +++ b/web/scripts/transcript.test.mjs @@ -215,7 +215,7 @@ test('history shows file cards only from entry metadata and keeps label-like wor }; attached.content.push({ kind: 'image', - image: { reference: { url: '/image-one' } }, + image: { mime_type: 'image/png', reference: { url: '/image-one' } }, }); api.reset([literal, attached]); const transcript = new Transcript('session'); @@ -228,7 +228,12 @@ test('history shows file cards only from entry metadata and keeps label-like wor assert.equal(second.text, 'inspect [Image #1]'); assert.deepEqual(second.files, [{ name: 'report.pdf', size: 12 }]); assert.deepEqual(second.images, [ - { src: '/api/image-one', width: undefined, height: undefined }, + { + src: '/api/image-one', + width: undefined, + height: undefined, + mime: 'image/png', + }, ]); }); diff --git a/web/src/lib/chat/Chat.svelte b/web/src/lib/chat/Chat.svelte index 3cf0db2b7..b4397ba82 100644 --- a/web/src/lib/chat/Chat.svelte +++ b/web/src/lib/chat/Chat.svelte @@ -95,6 +95,7 @@ import { compose, drafts, finishNotes } from '../notes'; import { draftOf } from './drafts'; import { + clipKind, filenameParts, formatSize, type Attached, @@ -112,6 +113,7 @@ type Displayed, type Group, type Made, + type Picture, } from '../transcript.svelte'; import { traceLink } from '../tracelink.svelte'; import { @@ -121,6 +123,7 @@ import { VirtualList } from './virtual.svelte'; import Composer from './Composer.svelte'; import QueuePanel from './QueuePanel.svelte'; + import Clips from './Clips.svelte'; import ImageGallery from './ImageGallery.svelte'; import Markdown from './Markdown.svelte'; import Receipt from './Receipt.svelte'; @@ -1501,6 +1504,14 @@ )} {@const senderLabel = (group.from?.trim() || null) ?? (agentRole ? 'agent' : null)} + {@const pictures = group.images.filter( + (picture) => !clipKind(picture.mime), + )} + {@const clips = group.images.filter((picture) => + clipKind(picture.mime), + )} + {@const number = (picture: Picture) => + group.images.indexOf(picture) + 1}
{/if} {/if} - {#if group.images.length} + {#if pictures.length}
- + {#snippet children(open)} - {#each group.images as picture, index (index)} + {#each pictures as picture, index (index)} {@const thumb = thumbnailSource(picture)} Image #{index + 1}
{/if} + {#if clips.length} +
+ +
+ {/if} {#if group.files.length}