@@ -540,8 +540,6 @@ export namespace Session {
540540 for ( const part of userParts ) {
541541 await updatePart ( part )
542542 }
543- // mark session as updated since a message has been added to it
544- await update ( input . sessionID , ( _draft ) => { } )
545543
546544 if ( isLocked ( input . sessionID ) ) {
547545 return new Promise ( ( resolve ) => {
@@ -566,6 +564,7 @@ export namespace Session {
566564 const [ preserve , remove ] = splitWhen ( msgs , ( x ) => x . info . id === messageID )
567565 msgs = preserve
568566 for ( const msg of remove ) {
567+ if ( msg . info . id === userMsg . id ) continue
569568 await Storage . remove ( `session/message/${ input . sessionID } /${ msg . info . id } ` )
570569 await Bus . publish ( MessageV2 . Event . Removed , { sessionID : input . sessionID , messageID : msg . info . id } )
571570 }
@@ -577,11 +576,15 @@ export namespace Session {
577576 for ( const part of removeParts ) {
578577 await Storage . remove ( `session/part/${ input . sessionID } /${ last . info . id } /${ part . id } ` )
579578 await Bus . publish ( MessageV2 . Event . PartRemoved , {
579+ sessionID : input . sessionID ,
580580 messageID : last . info . id ,
581581 partID : part . id ,
582582 } )
583583 }
584584 }
585+ await update ( input . sessionID , ( draft ) => {
586+ draft . revert = undefined
587+ } )
585588 }
586589
587590 const previous = msgs . filter ( ( x ) => x . info . role === "assistant" ) . at ( - 1 ) ?. info as MessageV2 . Assistant
0 commit comments