fix(tui): copy compaction summary as last message (#56055)

This commit is contained in:
Victor Navarro
2026-10-16 14:22:53 +02:00
committed by GitHub
Unverified
parent b0d762154c
commit bd902fcb46
+11 -12
View File
@@ -1141,7 +1141,7 @@ export function Session(props: {
},
run: () => {
const lastAssistantMessage = messagesBeforeRevert().findLast(
(msg): msg is SessionMessageAssistant => msg.type === "assistant",
(msg) => msg.type === "assistant" || (msg.type === "compaction" && msg.status === "completed" && msg.summary.trim() !== ""),
)
if (!lastAssistantMessage) {
toast.show({ message: "No assistant messages found", variant: "error" })
@@ -1149,17 +1149,16 @@ export function Session(props: {
return
}
const textParts = lastAssistantMessage.content.filter((part) => part.type === "text")
if (textParts.length === 0) {
toast.show({ message: "No text parts found in last assistant message", variant: "error" })
dialog.clear()
return
}
const text = textParts
.map((part) => part.text)
.join("\n")
.trim()
const text =
lastAssistantMessage.type === "assistant"
? lastAssistantMessage.content
.filter((part) => part.type === "text")
.map((part) => part.text)
.join("\n")
.trim()
: lastAssistantMessage.type === "compaction" && lastAssistantMessage.status === "completed"
? lastAssistantMessage.summary.trim()
: ""
if (!text) {
toast.show({
message: "No text content found in last assistant message",