From b089151d63b93a7c9d61180bb5114aefd98bf0b3 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 4 May 2026 12:29:10 -0700 Subject: [PATCH 1/2] feat(mothership): restore attachment previews on draft and add video support --- .../components/chat-message-attachments.tsx | 23 +++++++++++++++---- .../components/attached-files-list.tsx | 13 +++++++++-- .../home/components/user-input/user-input.tsx | 3 +++ .../[workspaceId]/home/hooks/use-chat.ts | 5 ++-- .../user-input/hooks/use-file-attachments.ts | 5 +++- .../lib/copilot/chat/attachment-preview.ts | 9 ++++++++ apps/sim/lib/copilot/chat/display-message.ts | 5 ++-- 7 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 apps/sim/lib/copilot/chat/attachment-preview.ts diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/chat-message-attachments.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/chat-message-attachments.tsx index e39d3a0dd37..00d02b1b19d 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/chat-message-attachments.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/chat-message-attachments.tsx @@ -30,13 +30,26 @@ export function ChatMessageAttachments(props: { )} > {attachments.map((att) => { - const isImage = att.media_type.startsWith('image/') - return isImage && att.previewUrl ? ( + if (!att.previewUrl) { + return ( + + ) + } + const isVideo = att.media_type.startsWith('video/') + return (
- {att.filename} + {isVideo ? ( +
- ) : ( - ) })} diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list.tsx index 6046107e6d6..2ea1c66d082 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list.tsx @@ -22,7 +22,8 @@ export const AttachedFilesList = React.memo(function AttachedFilesList({ return (
{attachedFiles.map((file) => { - const isImage = file.type.startsWith('image/') + const isVideo = file.type.startsWith('video/') + const hasPreview = Boolean(file.previewUrl) return ( @@ -30,7 +31,15 @@ export const AttachedFilesList = React.memo(function AttachedFilesList({ className='group relative h-[56px] w-[56px] flex-shrink-0 cursor-pointer overflow-hidden rounded-[8px] border border-[var(--border-1)] bg-[var(--surface-5)] hover:bg-[var(--surface-4)]' onClick={() => onFileClick(file)} > - {isImage && file.previewUrl ? ( + {hasPreview && isVideo ? ( +