优化claude code系统消息显示
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { memo, useCallback, useEffect, useMemo, useRef } from "react"
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { useConversationRuntime } from "@/contexts/conversation-runtime-context"
|
||||
import { ContentPartsRenderer } from "./content-parts-renderer"
|
||||
import {
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
MessageThreadScrollButton,
|
||||
} from "@/components/ai-elements/message-thread"
|
||||
import { Message, MessageContent } from "@/components/ai-elements/message"
|
||||
import { Loader2 } from "lucide-react"
|
||||
import { ChevronDown, ChevronRight, Info, Loader2 } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import {
|
||||
buildPlanKey,
|
||||
@@ -68,6 +68,41 @@ type ThreadRenderItem =
|
||||
kind: "typing"
|
||||
}
|
||||
|
||||
const CollapsibleSystemMessage = memo(function CollapsibleSystemMessage({
|
||||
group,
|
||||
}: {
|
||||
group: ResolvedMessageGroup
|
||||
}) {
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
const t = useTranslations("Folder.chat.messageList")
|
||||
|
||||
return (
|
||||
<div className="border rounded-md text-sm border-yellow-500/30 bg-yellow-500/5">
|
||||
<button
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
className="flex items-center gap-2 w-full px-3 py-2.5 text-left hover:bg-yellow-500/10 transition-colors"
|
||||
>
|
||||
{expanded ? (
|
||||
<ChevronDown className="h-3.5 w-3.5 shrink-0 text-yellow-600 dark:text-yellow-500" />
|
||||
) : (
|
||||
<ChevronRight className="h-3.5 w-3.5 shrink-0 text-yellow-600 dark:text-yellow-500" />
|
||||
)}
|
||||
<Info className="h-3.5 w-3.5 shrink-0 text-yellow-600 dark:text-yellow-500" />
|
||||
<span className="font-medium text-yellow-700 dark:text-yellow-400">
|
||||
{t("systemMessage")}
|
||||
</span>
|
||||
</button>
|
||||
{expanded && (
|
||||
<div className="px-3 pb-3 border-t border-yellow-500/20">
|
||||
<div className="text-sm text-muted-foreground mt-2.5 max-h-96 overflow-auto">
|
||||
<ContentPartsRenderer parts={group.parts} role={group.role} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
const HistoricalMessageGroup = memo(function HistoricalMessageGroup({
|
||||
group,
|
||||
dimmed = false,
|
||||
@@ -77,6 +112,10 @@ const HistoricalMessageGroup = memo(function HistoricalMessageGroup({
|
||||
dimmed?: boolean
|
||||
showStats?: boolean
|
||||
}) {
|
||||
if (group.role === "system") {
|
||||
return <CollapsibleSystemMessage group={group} />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={dimmed ? "opacity-70" : undefined}>
|
||||
<Message from={group.role}>
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "الموارد المرفقة",
|
||||
"loading": "جارٍ التحميل...",
|
||||
"error": "خطأ: {message}",
|
||||
"emptyConversation": "لا توجد رسائل في هذه المحادثة."
|
||||
"emptyConversation": "لا توجد رسائل في هذه المحادثة.",
|
||||
"systemMessage": "رسالة النظام"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "جارٍ التفكير...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "Angehängte Ressourcen",
|
||||
"loading": "Lädt...",
|
||||
"error": "Fehler: {message}",
|
||||
"emptyConversation": "Keine Nachrichten in dieser Unterhaltung."
|
||||
"emptyConversation": "Keine Nachrichten in dieser Unterhaltung.",
|
||||
"systemMessage": "Systemnachricht"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "Denkt nach...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "Attached resources",
|
||||
"loading": "Loading...",
|
||||
"error": "Error: {message}",
|
||||
"emptyConversation": "No messages in this conversation."
|
||||
"emptyConversation": "No messages in this conversation.",
|
||||
"systemMessage": "System message"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "Thinking...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "Recursos adjuntos",
|
||||
"loading": "Cargando...",
|
||||
"error": "Error del chat: {message}",
|
||||
"emptyConversation": "No hay mensajes en esta conversación."
|
||||
"emptyConversation": "No hay mensajes en esta conversación.",
|
||||
"systemMessage": "Mensaje del sistema"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "Pensando...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "Ressources jointes",
|
||||
"loading": "Chargement...",
|
||||
"error": "Erreur : {message}",
|
||||
"emptyConversation": "Aucun message dans cette conversation."
|
||||
"emptyConversation": "Aucun message dans cette conversation.",
|
||||
"systemMessage": "Message système"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "Réflexion...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "添付リソース",
|
||||
"loading": "読み込み中...",
|
||||
"error": "エラー: {message}",
|
||||
"emptyConversation": "この会話にはメッセージがありません。"
|
||||
"emptyConversation": "この会話にはメッセージがありません。",
|
||||
"systemMessage": "システムメッセージ"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "考え中...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "첨부된 리소스",
|
||||
"loading": "불러오는 중...",
|
||||
"error": "오류: {message}",
|
||||
"emptyConversation": "이 대화에는 메시지가 없습니다."
|
||||
"emptyConversation": "이 대화에는 메시지가 없습니다.",
|
||||
"systemMessage": "시스템 메시지"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "생각 중...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "Recursos anexados",
|
||||
"loading": "Carregando...",
|
||||
"error": "Erro: {message}",
|
||||
"emptyConversation": "Nenhuma mensagem nesta conversa."
|
||||
"emptyConversation": "Nenhuma mensagem nesta conversa.",
|
||||
"systemMessage": "Mensagem do sistema"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "Pensando...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "附加资源",
|
||||
"loading": "加载中...",
|
||||
"error": "错误:{message}",
|
||||
"emptyConversation": "当前会话暂无消息。"
|
||||
"emptyConversation": "当前会话暂无消息。",
|
||||
"systemMessage": "系统消息"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "思考中...",
|
||||
|
||||
@@ -1445,7 +1445,8 @@
|
||||
"attachedResources": "附加資源",
|
||||
"loading": "載入中...",
|
||||
"error": "錯誤:{message}",
|
||||
"emptyConversation": "目前會話暫無訊息。"
|
||||
"emptyConversation": "目前會話暫無訊息。",
|
||||
"systemMessage": "系統訊息"
|
||||
},
|
||||
"liveTurnStats": {
|
||||
"thinking": "思考中...",
|
||||
|
||||
Reference in New Issue
Block a user