@@ -37,6 +37,7 @@ import * as SDK from '../../core/sdk/sdk.js';
3737import * as Bindings from '../../models/bindings/bindings.js' ;
3838import * as Persistence from '../../models/persistence/persistence.js' ;
3939import * as Workspace from '../../models/workspace/workspace.js' ;
40+ import * as FloatingButton from '../../ui/components/floating_button/floating_button.js' ;
4041import * as IconButton from '../../ui/components/icon_button/icon_button.js' ;
4142import * as UI from '../../ui/legacy/legacy.js' ;
4243import * as VisualLogging from '../../ui/visual_logging/visual_logging.js' ;
@@ -1375,6 +1376,7 @@ export class NavigatorSourceTreeElement extends UI.TreeOutline.TreeElement {
13751376 readonly node : NavigatorUISourceCodeTreeNode ;
13761377 private readonly navigatorView : NavigatorView ;
13771378 uiSourceCodeInternal : Workspace . UISourceCode . UISourceCode ;
1379+ private aiButtonContainer ?: HTMLElement ;
13781380
13791381 constructor (
13801382 navigatorView : NavigatorView , uiSourceCode : Workspace . UISourceCode . UISourceCode , title : string ,
@@ -1425,6 +1427,28 @@ export class NavigatorSourceTreeElement extends UI.TreeOutline.TreeElement {
14251427 UI . ARIAUtils . setLabel ( this . listItemElement , `${ this . uiSourceCodeInternal . name ( ) } , ${ this . nodeType } ` ) ;
14261428 }
14271429
1430+ private createAiButton ( ) : void {
1431+ if ( ! UI . ActionRegistry . ActionRegistry . instance ( ) . hasAction ( 'drjones.sources-floating-button' ) ) {
1432+ return ;
1433+ }
1434+ const action = UI . ActionRegistry . ActionRegistry . instance ( ) . getAction ( 'drjones.sources-floating-button' ) ;
1435+ if ( ! this . aiButtonContainer ) {
1436+ this . aiButtonContainer = this . listItemElement . createChild ( 'span' , 'ai-button-container' ) ;
1437+ const floatingButton = new FloatingButton . FloatingButton . FloatingButton ( {
1438+ iconName : 'smart-assistant' ,
1439+ } ) ;
1440+ floatingButton . addEventListener ( 'click' , ev => {
1441+ ev . stopPropagation ( ) ;
1442+ this . navigatorView . sourceSelected ( this . uiSourceCode , false ) ;
1443+ void action . execute ( ) ;
1444+ } , { capture : true } ) ;
1445+ floatingButton . addEventListener ( 'mousedown' , ev => {
1446+ ev . stopPropagation ( ) ;
1447+ } , { capture : true } ) ;
1448+ this . aiButtonContainer . appendChild ( floatingButton ) ;
1449+ }
1450+ }
1451+
14281452 get uiSourceCode ( ) : Workspace . UISourceCode . UISourceCode {
14291453 return this . uiSourceCodeInternal ;
14301454 }
@@ -1434,6 +1458,7 @@ export class NavigatorSourceTreeElement extends UI.TreeOutline.TreeElement {
14341458 this . listItemElement . addEventListener ( 'click' , this . onclick . bind ( this ) , false ) ;
14351459 this . listItemElement . addEventListener ( 'contextmenu' , this . handleContextMenuEvent . bind ( this ) , false ) ;
14361460 this . listItemElement . addEventListener ( 'dragstart' , this . ondragstart . bind ( this ) , false ) ;
1461+ this . createAiButton ( ) ;
14371462 }
14381463
14391464 private shouldRenameOnMouseDown ( ) : boolean {
0 commit comments