fix(session): persist interrupted streamed text

pull/17441/head
Kit Langton 2026-03-13 23:36:31 -04:00
parent 2d6d788db5
commit ce8e9b1d84
1 changed files with 10 additions and 1 deletions

View File

@ -48,8 +48,8 @@ export namespace SessionProcessor {
needsCompaction = false
const shouldBreak = (await Config.get()).experimental?.continue_loop_on_deny !== true
while (true) {
try {
let currentText: MessageV2.TextPart | undefined
try {
let reasoningMap: Record<string, MessageV2.ReasoningPart> = {}
const stream = await LLM.stream(streamInput)
@ -385,6 +385,15 @@ export namespace SessionProcessor {
SessionStatus.set(input.sessionID, { type: "idle" })
}
}
if (currentText) {
currentText.text = currentText.text.trimEnd()
currentText.time = {
start: currentText.time?.start ?? Date.now(),
end: Date.now(),
}
await Session.updatePart(currentText)
currentText = undefined
}
if (snapshot) {
const patch = await Snapshot.patch(snapshot)
if (patch.files.length) {