diff --git a/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx b/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx index f2007f1d..8c34209c 100644 --- a/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx +++ b/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx @@ -35,6 +35,7 @@ export function ChatConversation({ onDecline, onEditMessage, onDeleteMessage, + onOpenFile, onSubmit, composerRef, }: { @@ -58,6 +59,7 @@ export function ChatConversation({ onDecline: (approvalId: string) => void; onEditMessage: (messageId: string, bodyMd: string) => void; onDeleteMessage: (messageId: string) => void; + onOpenFile: (fileId: string) => void; onSubmit: (event: FormEvent) => void; composerRef: MutableRefObject; }) { @@ -87,6 +89,7 @@ export function ChatConversation({ onDecline={onDecline} onEditMessage={onEditMessage} onDeleteMessage={onDeleteMessage} + onOpenFile={onOpenFile} /> )} @@ -156,7 +159,6 @@ function ConversationHeader({ )} {!searchOpen && participants.length > 0 && } - ); diff --git a/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx b/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx index 2e090263..a6a9ed4c 100644 --- a/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx +++ b/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx @@ -23,6 +23,7 @@ export function ChatMessageRow({ canModify = false, onEdit, onDelete, + onOpenFile, }: { message: ChatMessageRecord; attachments: ChatAttachmentRecord[]; @@ -36,6 +37,7 @@ export function ChatMessageRow({ canModify?: boolean; onEdit?: (bodyMd: string) => void; onDelete?: () => void; + onOpenFile?: (fileId: string) => void; }) { const [editing, setEditing] = useState(false); const name = senderName(message, context); @@ -61,7 +63,7 @@ export function ChatMessageRow({ {message.editedAt && !deleted && (edited)} {canModify && !editing && ( - setEditing(true)} /> + setEditing(true)} /> )} @@ -98,7 +100,7 @@ export function ChatMessageRow({ {messageFiles.map((file) => { const attachment = attachments.find((item) => item.messageId === message.id && item.fileId === file.id); const handoff = bot && attachment?.transferType === "handoff"; - return ; + return onOpenFile(file.id) : null} />; })} )} @@ -173,7 +175,8 @@ function mentionLabel(mention: ChatMentionRecord, context: MessageContext): stri throw new Error("Message mention target type is unsupported."); } -function AttachmentCard({ file, handoff = false }: { file: FileObjectRecord; handoff?: boolean }) { +function AttachmentCard({ file, handoff = false, onOpen }: { file: FileObjectRecord; handoff?: boolean; onOpen: (() => void) | null }) { + const canOpen = onOpen !== null && file.scanState === "approved"; return (
{file.kind.toUpperCase()} ยท {file.sha256.slice(0, 8)}
- + {canOpen && } ); } diff --git a/AgentCompany-New/src/renderer/src/pages/chat/ChatThreadPanel.tsx b/AgentCompany-New/src/renderer/src/pages/chat/ChatThreadPanel.tsx index 0aa627a9..bc722acc 100644 --- a/AgentCompany-New/src/renderer/src/pages/chat/ChatThreadPanel.tsx +++ b/AgentCompany-New/src/renderer/src/pages/chat/ChatThreadPanel.tsx @@ -29,6 +29,7 @@ export function ChatThreadPanel({ onClose, onSubmit, onBoardSubmit, + onOpenFile, }: { thread: ChatThreadRecord; rootMessage: ChatMessageRecord | null; @@ -44,6 +45,7 @@ export function ChatThreadPanel({ onClose: () => void; onSubmit: (event: FormEvent) => void; onBoardSubmit: (event: FormEvent) => void; + onOpenFile: (fileId: string) => void; }) { return (