From 99cfc6c91e2ff371d9c5fd6864e83823f8a1641b Mon Sep 17 00:00:00 2001 From: xintaofei Date: Wed, 11 Mar 2026 14:06:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BC=9A=E8=AF=9D=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E4=B8=AD=E7=9A=84=E6=80=9D=E8=80=83=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/message/message-list-view.tsx | 10 +++++++++- src/i18n/messages/ar.json | 6 +++--- src/i18n/messages/de.json | 6 +++--- src/i18n/messages/en.json | 6 +++--- src/i18n/messages/es.json | 6 +++--- src/i18n/messages/fr.json | 6 +++--- src/i18n/messages/ja.json | 6 +++--- src/i18n/messages/ko.json | 6 +++--- src/i18n/messages/pt.json | 6 +++--- src/i18n/messages/zh-CN.json | 6 +++--- src/i18n/messages/zh-TW.json | 6 +++--- src/lib/adapters/ai-elements-adapter.ts | 18 +++++++++++++++--- 12 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/components/message/message-list-view.tsx b/src/components/message/message-list-view.tsx index b9cbf70..936f91f 100644 --- a/src/components/message/message-list-view.tsx +++ b/src/components/message/message-list-view.tsx @@ -169,7 +169,15 @@ export function MessageListView({ const { threadItems, nonStreamingAdapted } = useMemo(() => { const allTurns = timelineTurns.map((item) => item.turn) - const allAdapted = adaptMessageTurns(allTurns, adapterText) + const streamingIndices = new Set() + timelineTurns.forEach((item, i) => { + if (item.phase === "streaming") streamingIndices.add(i) + }) + const allAdapted = adaptMessageTurns( + allTurns, + adapterText, + streamingIndices.size > 0 ? streamingIndices : undefined + ) // Collect non-streaming adapted messages for plan extraction const nonStreaming = allAdapted.filter( diff --git a/src/i18n/messages/ar.json b/src/i18n/messages/ar.json index 3ead831..27bb466 100644 --- a/src/i18n/messages/ar.json +++ b/src/i18n/messages/ar.json @@ -1185,9 +1185,9 @@ "running": "قيد التشغيل" }, "reasoning": { - "thinking": "جارٍ التفكير...", - "thoughtForFewSeconds": "فكر لبضع ثوانٍ", - "thoughtForSeconds": "فكر لمدة {duration} ثانية" + "thinking": "جارٍ التفكير", + "thoughtForFewSeconds": "تفكير", + "thoughtForSeconds": "تفكير" }, "messageList": { "attachedResources": "الموارد المرفقة", diff --git a/src/i18n/messages/de.json b/src/i18n/messages/de.json index c4be6a4..8a7a168 100644 --- a/src/i18n/messages/de.json +++ b/src/i18n/messages/de.json @@ -1185,9 +1185,9 @@ "running": "Läuft" }, "reasoning": { - "thinking": "Denkt nach...", - "thoughtForFewSeconds": "Dachte einige Sekunden nach", - "thoughtForSeconds": "Dachte {duration} Sekunden nach" + "thinking": "Denkt nach", + "thoughtForFewSeconds": "Nachgedacht", + "thoughtForSeconds": "Nachgedacht" }, "messageList": { "attachedResources": "Angehängte Ressourcen", diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index 522d506..5cab814 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -1185,9 +1185,9 @@ "running": "Running" }, "reasoning": { - "thinking": "Thinking...", - "thoughtForFewSeconds": "Thought for a few seconds", - "thoughtForSeconds": "Thought for {duration} seconds" + "thinking": "Thinking", + "thoughtForFewSeconds": "Thought", + "thoughtForSeconds": "Thought" }, "messageList": { "attachedResources": "Attached resources", diff --git a/src/i18n/messages/es.json b/src/i18n/messages/es.json index 4051655..ef5d4b7 100644 --- a/src/i18n/messages/es.json +++ b/src/i18n/messages/es.json @@ -1185,9 +1185,9 @@ "running": "En ejecución" }, "reasoning": { - "thinking": "Pensando...", - "thoughtForFewSeconds": "Pensó durante unos segundos", - "thoughtForSeconds": "Pensó durante {duration} segundos" + "thinking": "Pensando", + "thoughtForFewSeconds": "Pensamiento", + "thoughtForSeconds": "Pensamiento" }, "messageList": { "attachedResources": "Recursos adjuntos", diff --git a/src/i18n/messages/fr.json b/src/i18n/messages/fr.json index 7821cf1..8f6627b 100644 --- a/src/i18n/messages/fr.json +++ b/src/i18n/messages/fr.json @@ -1185,9 +1185,9 @@ "running": "En cours" }, "reasoning": { - "thinking": "Réflexion...", - "thoughtForFewSeconds": "A réfléchi pendant quelques secondes", - "thoughtForSeconds": "A réfléchi pendant {duration} secondes" + "thinking": "Réflexion", + "thoughtForFewSeconds": "Réflexion", + "thoughtForSeconds": "Réflexion" }, "messageList": { "attachedResources": "Ressources jointes", diff --git a/src/i18n/messages/ja.json b/src/i18n/messages/ja.json index e1caf1f..8d16e5a 100644 --- a/src/i18n/messages/ja.json +++ b/src/i18n/messages/ja.json @@ -1185,9 +1185,9 @@ "running": "実行中" }, "reasoning": { - "thinking": "考え中...", - "thoughtForFewSeconds": "数秒間考えました", - "thoughtForSeconds": "{duration} 秒間考えました" + "thinking": "考え中", + "thoughtForFewSeconds": "考えた", + "thoughtForSeconds": "考えた" }, "messageList": { "attachedResources": "添付リソース", diff --git a/src/i18n/messages/ko.json b/src/i18n/messages/ko.json index e4126fa..b0a675a 100644 --- a/src/i18n/messages/ko.json +++ b/src/i18n/messages/ko.json @@ -1185,9 +1185,9 @@ "running": "실행 중" }, "reasoning": { - "thinking": "생각 중...", - "thoughtForFewSeconds": "몇 초 동안 생각했습니다", - "thoughtForSeconds": "{duration}초 동안 생각했습니다" + "thinking": "생각 중", + "thoughtForFewSeconds": "생각함", + "thoughtForSeconds": "생각함" }, "messageList": { "attachedResources": "첨부된 리소스", diff --git a/src/i18n/messages/pt.json b/src/i18n/messages/pt.json index a102831..91a31c5 100644 --- a/src/i18n/messages/pt.json +++ b/src/i18n/messages/pt.json @@ -1185,9 +1185,9 @@ "running": "Em execução" }, "reasoning": { - "thinking": "Pensando...", - "thoughtForFewSeconds": "Pensou por alguns segundos", - "thoughtForSeconds": "Pensou por {duration} segundos" + "thinking": "Pensando", + "thoughtForFewSeconds": "Pensamento", + "thoughtForSeconds": "Pensamento" }, "messageList": { "attachedResources": "Recursos anexados", diff --git a/src/i18n/messages/zh-CN.json b/src/i18n/messages/zh-CN.json index 4ed763a..ebdfe4b 100644 --- a/src/i18n/messages/zh-CN.json +++ b/src/i18n/messages/zh-CN.json @@ -1185,9 +1185,9 @@ "running": "运行中" }, "reasoning": { - "thinking": "思考中...", - "thoughtForFewSeconds": "思考了几秒", - "thoughtForSeconds": "思考了 {duration} 秒" + "thinking": "思考中", + "thoughtForFewSeconds": "思考", + "thoughtForSeconds": "思考" }, "messageList": { "attachedResources": "附加资源", diff --git a/src/i18n/messages/zh-TW.json b/src/i18n/messages/zh-TW.json index a9b9e47..4d2ef2d 100644 --- a/src/i18n/messages/zh-TW.json +++ b/src/i18n/messages/zh-TW.json @@ -1185,9 +1185,9 @@ "running": "執行中" }, "reasoning": { - "thinking": "思考中...", - "thoughtForFewSeconds": "思考了幾秒", - "thoughtForSeconds": "思考了 {duration} 秒" + "thinking": "思考中", + "thoughtForFewSeconds": "思考", + "thoughtForSeconds": "思考" }, "messageList": { "attachedResources": "附加資源", diff --git a/src/lib/adapters/ai-elements-adapter.ts b/src/lib/adapters/ai-elements-adapter.ts index af45b58..717afc4 100644 --- a/src/lib/adapters/ai-elements-adapter.ts +++ b/src/lib/adapters/ai-elements-adapter.ts @@ -603,7 +603,8 @@ function buildToolResultMap( */ export function adaptMessageTurn( turn: MessageTurn, - text: AdapterMessageText + text: AdapterMessageText, + isStreaming: boolean = false ): AdaptedMessage { const adaptedContent: AdaptedContentPart[] = [] const resultMap = buildToolResultMap(turn.blocks) @@ -703,6 +704,14 @@ export function adaptMessageTurn( } } + // Mark the last reasoning block as streaming if the turn is actively streaming + if (isStreaming) { + const last = adaptedContent[adaptedContent.length - 1] + if (last?.type === "reasoning") { + last.isStreaming = true + } + } + const userSplit = turn.role === "user" ? splitUserTextAndResources(adaptedContent, text.attachedResources) @@ -730,9 +739,12 @@ export function adaptMessageTurn( */ export function adaptMessageTurns( turns: MessageTurn[], - text: AdapterMessageText + text: AdapterMessageText, + streamingIndices?: Set ): AdaptedMessage[] { - return turns.map((turn) => adaptMessageTurn(turn, text)) + return turns.map((turn, i) => + adaptMessageTurn(turn, text, streamingIndices?.has(i) ?? false) + ) } /**