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