diff --git a/src/components/sessions/SessionMessageItem.tsx b/src/components/sessions/SessionMessageItem.tsx index 7189a048b..88035b830 100644 --- a/src/components/sessions/SessionMessageItem.tsx +++ b/src/components/sessions/SessionMessageItem.tsx @@ -1,5 +1,5 @@ -import { memo } from "react"; -import { Copy } from "lucide-react"; +import { memo, useState } from "react"; +import { ChevronDown, ChevronUp, Copy } from "lucide-react"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/button"; @@ -17,6 +17,9 @@ import { highlightText, } from "./utils"; +const COLLAPSE_THRESHOLD = 3000; +const COLLAPSED_LENGTH = 1500; + interface SessionMessageItemProps { message: SessionMessage; isActive: boolean; @@ -31,6 +34,13 @@ export const SessionMessageItem = memo(function SessionMessageItem({ onCopy, }: SessionMessageItemProps) { const { t } = useTranslation(); + const [expanded, setExpanded] = useState(false); + + const isLong = message.content.length > COLLAPSE_THRESHOLD; + const displayContent = + isLong && !expanded + ? message.content.slice(0, COLLAPSED_LENGTH) + "…" + : message.content; return (
{searchQuery - ? highlightText(message.content, searchQuery) - : message.content} + ? highlightText(displayContent, searchQuery) + : displayContent}
+ {isLong && ( + + )}
); }); diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 714606148..f25b83bc3 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -725,7 +725,9 @@ "copyCommand": "Copy Command", "copyMessage": "Copy Message", "messageCopied": "Message copied", - "conversationHistory": "Conversation History" + "conversationHistory": "Conversation History", + "expandContent": "Expand full content", + "collapseContent": "Collapse" }, "console": { "providerSwitchReceived": "Received provider switch event:", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index cd3ffdada..9380eb2c0 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -725,7 +725,9 @@ "copyCommand": "コマンドをコピー", "copyMessage": "メッセージをコピー", "messageCopied": "メッセージがコピーされました", - "conversationHistory": "会話履歴" + "conversationHistory": "会話履歴", + "expandContent": "全文を表示", + "collapseContent": "折りたたむ" }, "console": { "providerSwitchReceived": "プロバイダー切り替えイベントを受信:", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 1e7afe320..cb32835e1 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -725,7 +725,9 @@ "copyCommand": "复制命令", "copyMessage": "复制消息", "messageCopied": "已复制消息内容", - "conversationHistory": "对话记录" + "conversationHistory": "对话记录", + "expandContent": "展开完整内容", + "collapseContent": "收起" }, "console": { "providerSwitchReceived": "收到供应商切换事件:",