修复会话消息中的思考状态显示不正确
This commit is contained in:
@@ -169,7 +169,15 @@ export function MessageListView({
|
|||||||
|
|
||||||
const { threadItems, nonStreamingAdapted } = useMemo(() => {
|
const { threadItems, nonStreamingAdapted } = useMemo(() => {
|
||||||
const allTurns = timelineTurns.map((item) => item.turn)
|
const allTurns = timelineTurns.map((item) => item.turn)
|
||||||
const allAdapted = adaptMessageTurns(allTurns, adapterText)
|
const streamingIndices = new Set<number>()
|
||||||
|
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
|
// Collect non-streaming adapted messages for plan extraction
|
||||||
const nonStreaming = allAdapted.filter(
|
const nonStreaming = allAdapted.filter(
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "قيد التشغيل"
|
"running": "قيد التشغيل"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "جارٍ التفكير...",
|
"thinking": "جارٍ التفكير",
|
||||||
"thoughtForFewSeconds": "فكر لبضع ثوانٍ",
|
"thoughtForFewSeconds": "تفكير",
|
||||||
"thoughtForSeconds": "فكر لمدة {duration} ثانية"
|
"thoughtForSeconds": "تفكير"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "الموارد المرفقة",
|
"attachedResources": "الموارد المرفقة",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "Läuft"
|
"running": "Läuft"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "Denkt nach...",
|
"thinking": "Denkt nach",
|
||||||
"thoughtForFewSeconds": "Dachte einige Sekunden nach",
|
"thoughtForFewSeconds": "Nachgedacht",
|
||||||
"thoughtForSeconds": "Dachte {duration} Sekunden nach"
|
"thoughtForSeconds": "Nachgedacht"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "Angehängte Ressourcen",
|
"attachedResources": "Angehängte Ressourcen",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "Running"
|
"running": "Running"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "Thinking...",
|
"thinking": "Thinking",
|
||||||
"thoughtForFewSeconds": "Thought for a few seconds",
|
"thoughtForFewSeconds": "Thought",
|
||||||
"thoughtForSeconds": "Thought for {duration} seconds"
|
"thoughtForSeconds": "Thought"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "Attached resources",
|
"attachedResources": "Attached resources",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "En ejecución"
|
"running": "En ejecución"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "Pensando...",
|
"thinking": "Pensando",
|
||||||
"thoughtForFewSeconds": "Pensó durante unos segundos",
|
"thoughtForFewSeconds": "Pensamiento",
|
||||||
"thoughtForSeconds": "Pensó durante {duration} segundos"
|
"thoughtForSeconds": "Pensamiento"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "Recursos adjuntos",
|
"attachedResources": "Recursos adjuntos",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "En cours"
|
"running": "En cours"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "Réflexion...",
|
"thinking": "Réflexion",
|
||||||
"thoughtForFewSeconds": "A réfléchi pendant quelques secondes",
|
"thoughtForFewSeconds": "Réflexion",
|
||||||
"thoughtForSeconds": "A réfléchi pendant {duration} secondes"
|
"thoughtForSeconds": "Réflexion"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "Ressources jointes",
|
"attachedResources": "Ressources jointes",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "実行中"
|
"running": "実行中"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "考え中...",
|
"thinking": "考え中",
|
||||||
"thoughtForFewSeconds": "数秒間考えました",
|
"thoughtForFewSeconds": "考えた",
|
||||||
"thoughtForSeconds": "{duration} 秒間考えました"
|
"thoughtForSeconds": "考えた"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "添付リソース",
|
"attachedResources": "添付リソース",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "실행 중"
|
"running": "실행 중"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "생각 중...",
|
"thinking": "생각 중",
|
||||||
"thoughtForFewSeconds": "몇 초 동안 생각했습니다",
|
"thoughtForFewSeconds": "생각함",
|
||||||
"thoughtForSeconds": "{duration}초 동안 생각했습니다"
|
"thoughtForSeconds": "생각함"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "첨부된 리소스",
|
"attachedResources": "첨부된 리소스",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "Em execução"
|
"running": "Em execução"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "Pensando...",
|
"thinking": "Pensando",
|
||||||
"thoughtForFewSeconds": "Pensou por alguns segundos",
|
"thoughtForFewSeconds": "Pensamento",
|
||||||
"thoughtForSeconds": "Pensou por {duration} segundos"
|
"thoughtForSeconds": "Pensamento"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "Recursos anexados",
|
"attachedResources": "Recursos anexados",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "运行中"
|
"running": "运行中"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "思考中...",
|
"thinking": "思考中",
|
||||||
"thoughtForFewSeconds": "思考了几秒",
|
"thoughtForFewSeconds": "思考",
|
||||||
"thoughtForSeconds": "思考了 {duration} 秒"
|
"thoughtForSeconds": "思考"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "附加资源",
|
"attachedResources": "附加资源",
|
||||||
|
|||||||
@@ -1185,9 +1185,9 @@
|
|||||||
"running": "執行中"
|
"running": "執行中"
|
||||||
},
|
},
|
||||||
"reasoning": {
|
"reasoning": {
|
||||||
"thinking": "思考中...",
|
"thinking": "思考中",
|
||||||
"thoughtForFewSeconds": "思考了幾秒",
|
"thoughtForFewSeconds": "思考",
|
||||||
"thoughtForSeconds": "思考了 {duration} 秒"
|
"thoughtForSeconds": "思考"
|
||||||
},
|
},
|
||||||
"messageList": {
|
"messageList": {
|
||||||
"attachedResources": "附加資源",
|
"attachedResources": "附加資源",
|
||||||
|
|||||||
@@ -603,7 +603,8 @@ function buildToolResultMap(
|
|||||||
*/
|
*/
|
||||||
export function adaptMessageTurn(
|
export function adaptMessageTurn(
|
||||||
turn: MessageTurn,
|
turn: MessageTurn,
|
||||||
text: AdapterMessageText
|
text: AdapterMessageText,
|
||||||
|
isStreaming: boolean = false
|
||||||
): AdaptedMessage {
|
): AdaptedMessage {
|
||||||
const adaptedContent: AdaptedContentPart[] = []
|
const adaptedContent: AdaptedContentPart[] = []
|
||||||
const resultMap = buildToolResultMap(turn.blocks)
|
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 =
|
const userSplit =
|
||||||
turn.role === "user"
|
turn.role === "user"
|
||||||
? splitUserTextAndResources(adaptedContent, text.attachedResources)
|
? splitUserTextAndResources(adaptedContent, text.attachedResources)
|
||||||
@@ -730,9 +739,12 @@ export function adaptMessageTurn(
|
|||||||
*/
|
*/
|
||||||
export function adaptMessageTurns(
|
export function adaptMessageTurns(
|
||||||
turns: MessageTurn[],
|
turns: MessageTurn[],
|
||||||
text: AdapterMessageText
|
text: AdapterMessageText,
|
||||||
|
streamingIndices?: Set<number>
|
||||||
): AdaptedMessage[] {
|
): AdaptedMessage[] {
|
||||||
return turns.map((turn) => adaptMessageTurn(turn, text))
|
return turns.map((turn, i) =>
|
||||||
|
adaptMessageTurn(turn, text, streamingIndices?.has(i) ?? false)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user