diff --git a/frontend/src/routes/_auth.chat.$chatId.tsx b/frontend/src/routes/_auth.chat.$chatId.tsx
index c30799001..606b6b0c5 100644
--- a/frontend/src/routes/_auth.chat.$chatId.tsx
+++ b/frontend/src/routes/_auth.chat.$chatId.tsx
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState, useCallback } from "react";
import { createFileRoute } from "@tanstack/react-router";
-import { AsteriskIcon, Check, Copy, UserIcon, ChevronDown, SquarePenIcon } from "lucide-react";
+import { AsteriskIcon, Check, Copy, UserIcon, ChevronDown, Bot, SquarePenIcon } from "lucide-react";
import ChatBox from "@/components/ChatBox";
import { useOpenAI } from "@/ai/useOpenAi";
import { useLocalState } from "@/state/useLocalState";
@@ -18,6 +18,23 @@ export const Route = createFileRoute("/_auth/chat/$chatId")({
component: ChatComponent
});
+// Custom hook for copy to clipboard functionality
+function useCopyToClipboard(text: string) {
+ const [isCopied, setIsCopied] = useState(false);
+
+ const handleCopy = useCallback(async () => {
+ try {
+ await navigator.clipboard.writeText(text);
+ setIsCopied(true);
+ setTimeout(() => setIsCopied(false), 2000);
+ } catch (error) {
+ console.error("Failed to copy text: ", error);
+ }
+ }, [text]);
+
+ return { isCopied, handleCopy };
+}
+
function UserMessage({ text, chatId }: { text: string; chatId: string }) {
return (
@@ -42,18 +59,8 @@ function SystemMessage({
loading?: boolean;
chatId: string;
}) {
- const [isCopied, setIsCopied] = useState(false);
-
- const handleCopy = useCallback(async () => {
- try {
- const textWithoutThinking = stripThinkingTags(text);
- await navigator.clipboard.writeText(textWithoutThinking);
- setIsCopied(true);
- setTimeout(() => setIsCopied(false), 2000);
- } catch (error) {
- console.error("Failed to copy text: ", error);
- }
- }, [text]);
+ const textWithoutThinking = stripThinkingTags(text);
+ const { isCopied, handleCopy } = useCopyToClipboard(textWithoutThinking);
return (
@@ -78,6 +85,68 @@ function SystemMessage({
);
}
+function SystemPromptMessage({ text }: { text: string }) {
+ const [isExpanded, setIsExpanded] = useState(false);
+ const { isCopied, handleCopy } = useCopyToClipboard(text);
+
+ return (
+
+
+
+
+
+
+
+ System Prompt
+
+
+ {isExpanded ? (
+ <>
+ {text}
+ {text.length > 100 && (
+ <>
+ {" "}
+
+ >
+ )}
+ >
+ ) : (
+ <>
+ {text.length > 100 ? text.slice(0, 100) : text}
+ {text.length > 100 && (
+ <>
+ {"... "}
+
+ >
+ )}
+ >
+ )}
+
+
+
+
+
+ );
+}
+
function ChatComponent() {
const { chatId } = Route.useParams();
const {
@@ -640,23 +709,20 @@ END OF INSTRUCTIONS`;
- {/* Show user and assistant messages, excluding system messages */}
- {localChat.messages
- ?.filter((message) => message.role !== "system")
- .map((message, index) => (
-
- {message.role === "user" && (
-
- )}
- {message.role === "assistant" && (
-
- )}
-
- ))}
+ {/* Show all messages including system messages */}
+ {localChat.messages?.map((message, index) => (
+
+ {message.role === "system" && }
+ {message.role === "user" && }
+ {message.role === "assistant" && (
+
+ )}
+
+ ))}
{(currentStreamingMessage || isLoading) && (