From 7c5f139d90de2aa9da8f21cb339e29611597c107 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 05:58:15 +0000 Subject: [PATCH 1/4] feat: implement inline system message display with truncation and expand - Add SystemPromptMessage component with Bot icon and "System Prompt" label - Show truncated text (100 chars) with "..." and expand/collapse functionality - Include copy button with same pattern as assistant messages (hover reveal) - Remove system message filter to allow inline rendering - System messages now appear naturally at top of chat - Styled with muted background to distinguish from regular messages Resolves #98 Co-authored-by: AnthonyRonning --- frontend/src/routes/_auth.chat.$chatId.tsx | 88 +++++++++++++++++----- 1 file changed, 70 insertions(+), 18 deletions(-) diff --git a/frontend/src/routes/_auth.chat.$chatId.tsx b/frontend/src/routes/_auth.chat.$chatId.tsx index c30799001..04b4637eb 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, ChevronRight, SquarePenIcon } from "lucide-react"; import ChatBox from "@/components/ChatBox"; import { useOpenAI } from "@/ai/useOpenAi"; import { useLocalState } from "@/state/useLocalState"; @@ -78,6 +78,63 @@ function SystemMessage({ ); } +function SystemPromptMessage({ text }: { text: string }) { + const [isExpanded, setIsExpanded] = useState(false); + 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]); + + const truncatedText = text.length > 100 ? text.slice(0, 100) + "..." : text; + + return ( +
+
+
+ +
+
+
+ System Prompt +
+
{isExpanded ? text : truncatedText}
+
+ {text.length > 100 && ( + + )} + +
+
+
+
+ ); +} + function ChatComponent() { const { chatId } = Route.useParams(); const { @@ -640,23 +697,18 @@ 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) && (
Date: Tue, 10 Jun 2025 06:15:25 +0000 Subject: [PATCH 2/4] fix: improve system prompt copy button layout and styling - Move copy button outside flex container to prevent overlap with expand/collapse button - Change icon size from h-3 w-3 to h-4 w-4 to match assistant message styling - Add -mb-2 margin and remove extra h-auto p-1 classes for consistent positioning - Copy button now appears identical to assistant message version Co-authored-by: AnthonyRonning --- frontend/src/routes/_auth.chat.$chatId.tsx | 36 ++++++++++------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/frontend/src/routes/_auth.chat.$chatId.tsx b/frontend/src/routes/_auth.chat.$chatId.tsx index 04b4637eb..8b023377a 100644 --- a/frontend/src/routes/_auth.chat.$chatId.tsx +++ b/frontend/src/routes/_auth.chat.$chatId.tsx @@ -105,30 +105,28 @@ function SystemPromptMessage({ text }: { text: string }) { System Prompt
{isExpanded ? text : truncatedText}
-
- {text.length > 100 && ( - - )} + {text.length > 100 && ( -
+ )} +
From a8a58dd6efcb81815dc9ad72075de807462c26e4 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 06:27:29 +0000 Subject: [PATCH 3/4] feat: make system prompt expand/collapse inline with text - Replace separate "Show more" button with inline text links - Text now shows "... see more" and "show less" inline with content - Remove unused ChevronRight import - Maintains all existing functionality and copy button behavior Co-authored-by: AnthonyRonning --- frontend/src/routes/_auth.chat.$chatId.tsx | 51 ++++++++++++++-------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/frontend/src/routes/_auth.chat.$chatId.tsx b/frontend/src/routes/_auth.chat.$chatId.tsx index 8b023377a..483667c96 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, Bot, ChevronRight, 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"; @@ -92,8 +92,6 @@ function SystemPromptMessage({ text }: { text: string }) { } }, [text]); - const truncatedText = text.length > 100 ? text.slice(0, 100) + "..." : text; - return (
@@ -104,20 +102,39 @@ function SystemPromptMessage({ text }: { text: string }) {
System Prompt
-
{isExpanded ? text : truncatedText}
- {text.length > 100 && ( - - )} +
+ {isExpanded ? ( + <> + {text} + {text.length > 100 && ( + <> + {" "} + + + )} + + ) : ( + <> + {text.length > 100 ? text.slice(0, 100) : text} + {text.length > 100 && ( + <> + {"... "} + + + )} + + )} +