diff --git a/frontend/components/knowledge-dropdown.tsx b/frontend/components/knowledge-dropdown.tsx index 82581de8..88c61190 100644 --- a/frontend/components/knowledge-dropdown.tsx +++ b/frontend/components/knowledge-dropdown.tsx @@ -11,6 +11,7 @@ import { } from "lucide-react"; import { useRouter } from "next/navigation"; import { useEffect, useRef, useState } from "react"; +import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Dialog, @@ -294,6 +295,11 @@ export function KnowledgeDropdown({ window.dispatchEvent(new CustomEvent("knowledgeUpdated")); } else { console.error("Folder upload failed:", result.error); + if (response.status === 400) { + toast.error("Upload failed", { + description: result.error || "Bad request", + }); + } } } catch (error) { console.error("Folder upload error:", error); @@ -333,6 +339,11 @@ export function KnowledgeDropdown({ window.dispatchEvent(new CustomEvent("knowledgeUpdated")); } else { console.error("S3 upload failed:", result.error); + if (response.status === 400) { + toast.error("Upload failed", { + description: result.error || "Bad request", + }); + } } } catch (error) { console.error("S3 upload error:", error); diff --git a/frontend/components/markdown-wrapper.tsx b/frontend/components/markdown-wrapper.tsx new file mode 100644 index 00000000..98828f10 --- /dev/null +++ b/frontend/components/markdown-wrapper.tsx @@ -0,0 +1,43 @@ +"use client"; + +import React from "react"; + +// Type-safe wrapper that bypasses react-markdown typing issues +interface MarkdownWrapperProps { + children: string; + remarkPlugins?: any[]; + rehypePlugins?: any[]; + linkTarget?: string; + components?: any; +} + +const MarkdownWrapper: React.FC = ({ + children, + remarkPlugins, + rehypePlugins, + linkTarget, + components +}) => { + const [MarkdownComponent, setMarkdownComponent] = React.useState(null); + + React.useEffect(() => { + // Dynamically import react-markdown at runtime to avoid build-time type issues + import("react-markdown").then((mod) => { + setMarkdownComponent(() => mod.default); + }); + }, []); + + if (!MarkdownComponent) { + return
Loading markdown...
; + } + + return React.createElement(MarkdownComponent, { + remarkPlugins, + rehypePlugins, + linkTarget, + components, + children, + }); +}; + +export default MarkdownWrapper; \ No newline at end of file diff --git a/frontend/types/jsx.d.ts b/frontend/types/jsx.d.ts new file mode 100644 index 00000000..18ff18af --- /dev/null +++ b/frontend/types/jsx.d.ts @@ -0,0 +1,22 @@ +import React from 'react'; + +declare global { + namespace JSX { + interface IntrinsicElements { + [elemName: string]: any; + } + } +} + +declare module 'react-markdown' { + interface ReactMarkdownProps { + children: string; + remarkPlugins?: any[]; + rehypePlugins?: any[]; + linkTarget?: string; + components?: any; + } + + const ReactMarkdown: React.FC; + export default ReactMarkdown; +} \ No newline at end of file