@@ -166,6 +166,34 @@ export class ModifiedFilesTracker {
166166 return messageId . startsWith ( 'modified-files-' ) ? messageId . replace ( 'modified-files-' , '' ) : messageId ;
167167 }
168168
169+ private renderUndoAllButton ( chatItem : ChatItem ) : void {
170+ let undoAllMessageId : String ;
171+ const contentWrapper = this . collapsibleContent . render . querySelector ( '.mynah-collapsible-content-label-content-wrapper' ) ;
172+ if ( contentWrapper == null || chatItem . buttons == null ) return ;
173+
174+ if ( chatItem . messageId !== undefined && chatItem . messageId !== null && chatItem . messageId !== '' ) {
175+ undoAllMessageId = this . getOriginalMessageId ( chatItem . messageId ) ;
176+ } else {
177+ return ;
178+ }
179+
180+ const buttonsWrapper = new ChatItemButtonsWrapper ( {
181+ tabId : this . props . tabId ,
182+ classNames : [ 'mynah-modified-files-undo-all-buttons' ] ,
183+ formItems : null ,
184+ buttons : chatItem . buttons ,
185+ onActionClick : action => {
186+ MynahUIGlobalEvents . getInstance ( ) . dispatch ( MynahEventNames . BODY_ACTION_CLICKED , {
187+ tabId : this . props . tabId ,
188+ messageId : undoAllMessageId ,
189+ actionId : action . id ,
190+ actionText : action . text
191+ } ) ;
192+ }
193+ } ) ;
194+ contentWrapper . appendChild ( buttonsWrapper . render ) ;
195+ }
196+
169197 private updateTitleText ( chatItem : ChatItem ) : void {
170198 // check if chatItem
171199 if ( chatItem . title !== undefined && chatItem . title !== '' ) {
@@ -180,6 +208,10 @@ export class ModifiedFilesTracker {
180208 // Store the current chatItem for button handling
181209 this . props . chatItem = chatItem ;
182210 this . renderModifiedFiles ( chatItem . header . fileList , chatItem . messageId ) ;
211+ } else if ( chatItem . buttons != null && Array . isArray ( chatItem . buttons ) && chatItem . buttons . length > 0 ) {
212+ // Handle case where only buttons (like undo all) are provided without fileList
213+ this . props . chatItem = chatItem ;
214+ this . renderUndoAllButton ( chatItem ) ;
183215 }
184216 }
185217
0 commit comments