+ {/* Uploaded files outside the message bubble */}
+
+
+ {/* Message content inside the bubble (only if there's text) */}
+ {cleanContent && (
+
+ ) => {
+ if (!href) {
+ return {children};
+ }
+
+ // Check if this link matches a citation
+ const citation = citationMap.get(href);
+ if (citation) {
+ return (
+
+ {children}
+
+ );
+ }
+
+ // Regular external link
+ return (
+
+ {children}
+
+ );
+ },
+ img: ({ src, alt }: React.ImgHTMLAttributes) => {
+ if (!src) return null;
+ if (typeof src !== "string") {
+ return (
+
+ );
+ }
+ let url = src;
+ if (src.startsWith("/mnt/")) {
+ url = resolveArtifactURL(src, thread_id);
+ }
+ return (
+
+
+
+ );
+ },
+ }}
+ >
+ {cleanContent}
+
+
+ )}
+
+ );
+ }
+
+ // Default rendering for non-human messages or human messages without files
return (