@@ -774,7 +774,7 @@ export class SettingsEditor2 extends EditorPane {
774
774
}
775
775
776
776
toggleAiSearch ( ) : void {
777
- if ( this . showAiResultsAction ) {
777
+ if ( this . searchInputActionBar && this . showAiResultsAction && this . searchInputActionBar . hasAction ( this . showAiResultsAction ) ) {
778
778
if ( ! this . showAiResultsAction . enabled ) {
779
779
aria . status ( localize ( 'noAiResults' , "No AI results available at this time." ) ) ;
780
780
}
@@ -1824,23 +1824,27 @@ export class SettingsEditor2 extends EditorPane {
1824
1824
return ;
1825
1825
}
1826
1826
1827
- // Kick off an AI search in the background. We purposely do not await it.
1828
1827
if ( this . aiSearchPromise ) {
1829
1828
this . aiSearchPromise . cancel ( ) ;
1830
1829
}
1831
- this . aiSearchPromise = createCancelablePromise ( token => {
1832
- return this . doAiSearch ( query , token ) . then ( ( results ) => {
1833
- if ( results && this . showAiResultsAction ) {
1834
- this . showAiResultsAction . enabled = true ;
1835
- this . showAiResultsAction . label = SHOW_AI_RESULTS_ENABLED_LABEL ;
1836
- this . renderResultCountMessages ( true ) ;
1837
- }
1838
- } ) . catch ( e => {
1839
- if ( ! isCancellationError ( e ) ) {
1840
- this . logService . trace ( 'Error during AI settings search:' , e ) ;
1841
- }
1830
+
1831
+ // Kick off an AI search in the background if the toggle is shown.
1832
+ // We purposely do not await it.
1833
+ if ( this . searchInputActionBar && this . showAiResultsAction && this . searchInputActionBar . hasAction ( this . showAiResultsAction ) ) {
1834
+ this . aiSearchPromise = createCancelablePromise ( token => {
1835
+ return this . doAiSearch ( query , token ) . then ( ( results ) => {
1836
+ if ( results && this . showAiResultsAction ) {
1837
+ this . showAiResultsAction . enabled = true ;
1838
+ this . showAiResultsAction . label = SHOW_AI_RESULTS_ENABLED_LABEL ;
1839
+ this . renderResultCountMessages ( true ) ;
1840
+ }
1841
+ } ) . catch ( e => {
1842
+ if ( ! isCancellationError ( e ) ) {
1843
+ this . logService . trace ( 'Error during AI settings search:' , e ) ;
1844
+ }
1845
+ } ) ;
1842
1846
} ) ;
1843
- } ) ;
1847
+ }
1844
1848
1845
1849
this . onDidFinishSearch ( expandResults , progressRunner ) ;
1846
1850
} ) ;
0 commit comments