@@ -807,4 +807,47 @@ describe('useSlashCompletion', () => {
807807 } ) ;
808808 } ) ;
809809 } ) ;
810+
811+ it ( 'should not call shared callbacks when disabled' , ( ) => {
812+ const mockSetSuggestions = vi . fn ( ) ;
813+ const mockSetIsLoadingSuggestions = vi . fn ( ) ;
814+ const mockSetIsPerfectMatch = vi . fn ( ) ;
815+
816+ const slashCommands = [
817+ createTestCommand ( {
818+ name : 'help' ,
819+ description : 'Show help' ,
820+ } ) ,
821+ ] ;
822+
823+ const { rerender } = renderHook (
824+ ( { enabled, query } ) =>
825+ useSlashCompletion ( {
826+ enabled,
827+ query,
828+ slashCommands,
829+ commandContext : mockCommandContext ,
830+ setSuggestions : mockSetSuggestions ,
831+ setIsLoadingSuggestions : mockSetIsLoadingSuggestions ,
832+ setIsPerfectMatch : mockSetIsPerfectMatch ,
833+ } ) ,
834+ {
835+ initialProps : { enabled : false , query : '@src/file' } ,
836+ } ,
837+ ) ;
838+
839+ // Clear any initial calls
840+ mockSetSuggestions . mockClear ( ) ;
841+ mockSetIsLoadingSuggestions . mockClear ( ) ;
842+ mockSetIsPerfectMatch . mockClear ( ) ;
843+
844+ // Change query while disabled (simulating @ completion typing)
845+ rerender ( { enabled : false , query : '@src/file.ts' } ) ;
846+ rerender ( { enabled : false , query : '@src/file.tsx' } ) ;
847+
848+ // Should not have called shared callbacks during @ completion typing
849+ expect ( mockSetSuggestions ) . not . toHaveBeenCalled ( ) ;
850+ expect ( mockSetIsLoadingSuggestions ) . not . toHaveBeenCalled ( ) ;
851+ expect ( mockSetIsPerfectMatch ) . not . toHaveBeenCalled ( ) ;
852+ } ) ;
810853} ) ;
0 commit comments