Spaces:
Sleeping
Sleeping
Update web/src/components/Message.tsx
Browse files
web/src/components/Message.tsx
CHANGED
|
@@ -3,6 +3,10 @@ import React, { useMemo, useState } from "react";
|
|
| 3 |
import { Button } from "./ui/button";
|
| 4 |
import ReactMarkdown from "react-markdown";
|
| 5 |
import remarkGfm from "remark-gfm";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
import {
|
| 8 |
Copy,
|
|
@@ -241,6 +245,13 @@ export function Message({
|
|
| 241 |
|
| 242 |
const hasRefs = !!(message.references && message.references.length > 0);
|
| 243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
return (
|
| 245 |
<div
|
| 246 |
className={`flex gap-2 ${
|
|
@@ -301,6 +312,46 @@ export function Message({
|
|
| 301 |
${isUser && !showSenderInfo ? "bg-primary text-primary-foreground" : "bg-muted"}
|
| 302 |
`}
|
| 303 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
{renderBubbleContent()}
|
| 305 |
|
| 306 |
{/* ✅ Restore "left-bottom small reference box" */}
|
|
|
|
| 3 |
import { Button } from "./ui/button";
|
| 4 |
import ReactMarkdown from "react-markdown";
|
| 5 |
import remarkGfm from "remark-gfm";
|
| 6 |
+
import pdfIcon from "../assets/file-icons/pdf.png";
|
| 7 |
+
import pptIcon from "../assets/file-icons/ppt.png";
|
| 8 |
+
import otherIcon from "../assets/file-icons/other_format.png";
|
| 9 |
+
|
| 10 |
|
| 11 |
import {
|
| 12 |
Copy,
|
|
|
|
| 245 |
|
| 246 |
const hasRefs = !!(message.references && message.references.length > 0);
|
| 247 |
|
| 248 |
+
const attachments = (message as any).attachments as
|
| 249 |
+
| Array<{ name: string; kind: string; size: number; fileType?: string }>
|
| 250 |
+
| undefined;
|
| 251 |
+
|
| 252 |
+
const hasAttachments = !!(attachments && attachments.length);
|
| 253 |
+
|
| 254 |
+
|
| 255 |
return (
|
| 256 |
<div
|
| 257 |
className={`flex gap-2 ${
|
|
|
|
| 312 |
${isUser && !showSenderInfo ? "bg-primary text-primary-foreground" : "bg-muted"}
|
| 313 |
`}
|
| 314 |
>
|
| 315 |
+
{/* ✅ Attachments shown “with” the message */}
|
| 316 |
+
{hasAttachments && (
|
| 317 |
+
<div className="mb-3 flex flex-wrap gap-2">
|
| 318 |
+
{attachments!.map((a, idx) => {
|
| 319 |
+
const icon = a.kind === "pdf" ? pdfIcon : a.kind === "ppt" ? pptIcon : otherIcon;
|
| 320 |
+
const label =
|
| 321 |
+
a.kind === "pdf"
|
| 322 |
+
? "PDF"
|
| 323 |
+
: a.kind === "ppt"
|
| 324 |
+
? "Presentation"
|
| 325 |
+
: a.kind === "doc"
|
| 326 |
+
? "Document"
|
| 327 |
+
: a.kind === "image"
|
| 328 |
+
? "Image"
|
| 329 |
+
: "File";
|
| 330 |
+
|
| 331 |
+
return (
|
| 332 |
+
<div
|
| 333 |
+
key={`${a.name}-${idx}`}
|
| 334 |
+
className="
|
| 335 |
+
inline-flex items-center gap-2
|
| 336 |
+
rounded-xl border border-border
|
| 337 |
+
bg-background/70 dark:bg-background/30
|
| 338 |
+
px-2 py-1
|
| 339 |
+
shadow-sm
|
| 340 |
+
max-w-full
|
| 341 |
+
"
|
| 342 |
+
title={a.name}
|
| 343 |
+
>
|
| 344 |
+
<img src={icon} alt={a.name} className="h-6 w-6 object-contain" draggable={false} />
|
| 345 |
+
<div className="min-w-0">
|
| 346 |
+
<div className="text-xs font-medium truncate max-w-[320px]">{a.name}</div>
|
| 347 |
+
<div className="text-[11px] text-muted-foreground">{label}</div>
|
| 348 |
+
</div>
|
| 349 |
+
</div>
|
| 350 |
+
);
|
| 351 |
+
})}
|
| 352 |
+
</div>
|
| 353 |
+
)}
|
| 354 |
+
|
| 355 |
{renderBubbleContent()}
|
| 356 |
|
| 357 |
{/* ✅ Restore "left-bottom small reference box" */}
|