@@ -2025,14 +2025,28 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
20252025 await this . diffViewProvider . revertChanges ( ) // closes diff view
20262026 }
20272027
2028- // if last message is a partial we need to update and save it
2029- const lastMessage = this . clineMessages . at ( - 1 )
2030-
2031- if ( lastMessage && lastMessage . partial ) {
2032- // lastMessage.ts = Date.now() DO NOT update ts since it is used as a key for virtuoso list
2033- lastMessage . partial = false
2034- // instead of streaming partialMessage events, we do a save and post like normal to persist to disk
2035- console . log ( "updating partial message" , lastMessage )
2028+ // Remove partial streaming messages (text and reasoning) when stream is aborted
2029+ // to match main branch behavior where interrupted streaming text doesn't persist
2030+ while ( this . clineMessages . length > 0 ) {
2031+ const lastMessage = this . clineMessages [ this . clineMessages . length - 1 ]
2032+
2033+ if ( lastMessage && lastMessage . partial ) {
2034+ // Remove partial text and reasoning messages that were being streamed
2035+ if (
2036+ lastMessage . type === "say" &&
2037+ ( lastMessage . say === "text" || lastMessage . say === "reasoning" )
2038+ ) {
2039+ this . clineMessages . pop ( )
2040+ console . log ( `[abortStream] removed partial ${ lastMessage . say } message` )
2041+ continue
2042+ }
2043+
2044+ // For other partial messages (like tool asks), finalize them instead of removing
2045+ lastMessage . partial = false
2046+ console . log ( `[abortStream] finalized partial ${ lastMessage . type } message` )
2047+ }
2048+
2049+ break
20362050 }
20372051
20382052 // Update `api_req_started` to have cancelled and cost, so that
0 commit comments