@@ -570,6 +570,36 @@ describe('draftMessages', async () => {
570570 } )
571571} )
572572
573+ describe ( 'devSessionWatchConfig' , ( ) => {
574+ test ( 'returns undefined for extension experience (watch everything)' , async ( ) => {
575+ const extensionInstance = await testUIExtension ( { type : 'ui_extension' } )
576+ expect ( extensionInstance . devSessionWatchConfig ) . toBeUndefined ( )
577+ } )
578+
579+ test ( 'returns empty paths for configuration experience (watch nothing)' , async ( ) => {
580+ const extensionInstance = await testAppConfigExtensions ( )
581+ expect ( extensionInstance . devSessionWatchConfig ) . toEqual ( { paths : [ ] } )
582+ } )
583+
584+ test ( 'delegates to specification devSessionWatchConfig when defined' , async ( ) => {
585+ const config = functionConfiguration ( )
586+ config . build = {
587+ watch : 'src/**/*.rs' ,
588+ wasm_opt : true ,
589+ }
590+ const extensionInstance = await testFunctionExtension ( { config, dir : '/tmp/my-function' } )
591+ const watchConfig = extensionInstance . devSessionWatchConfig
592+ expect ( watchConfig ) . toBeDefined ( )
593+ expect ( watchConfig ! . paths ) . toContain ( joinPath ( '/tmp/my-function' , 'src/**/*.rs' ) )
594+ } )
595+
596+ test ( 'returns undefined for function extension without build.watch' , async ( ) => {
597+ const config = functionConfiguration ( )
598+ const extensionInstance = await testFunctionExtension ( { config} )
599+ expect ( extensionInstance . devSessionWatchConfig ) . toBeUndefined ( )
600+ } )
601+ } )
602+
573603describe ( 'watchedFiles' , async ( ) => {
574604 test ( 'returns files based on devSessionWatchPaths when defined' , async ( ) => {
575605 await inTemporaryDirectory ( async ( tmpDir ) => {
@@ -607,6 +637,58 @@ describe('watchedFiles', async () => {
607637 } )
608638 } )
609639
640+ test ( 'respects custom ignore paths from devSessionWatchConfig' , async ( ) => {
641+ await inTemporaryDirectory ( async ( tmpDir ) => {
642+ // Given - create an extension with a spec that defines custom ignore paths
643+ const config = functionConfiguration ( )
644+ config . build = {
645+ watch : '**/*' ,
646+ wasm_opt : true ,
647+ }
648+ const extensionInstance = await testFunctionExtension ( {
649+ config,
650+ dir : tmpDir ,
651+ } )
652+
653+ // Override devSessionWatchConfig to include ignore paths
654+ vi . spyOn ( extensionInstance , 'devSessionWatchConfig' , 'get' ) . mockReturnValue ( {
655+ paths : [ joinPath ( tmpDir , '**/*' ) ] ,
656+ ignore : [ '**/ignored-dir/**' ] ,
657+ } )
658+
659+ // Create files - one in a normal dir, one in the ignored dir
660+ const srcDir = joinPath ( tmpDir , 'src' )
661+ const ignoredDir = joinPath ( tmpDir , 'ignored-dir' )
662+ await mkdir ( srcDir )
663+ await mkdir ( ignoredDir )
664+ await writeFile ( joinPath ( srcDir , 'index.js' ) , 'code' )
665+ await writeFile ( joinPath ( ignoredDir , 'should-be-ignored.js' ) , 'ignored' )
666+
667+ // When
668+ const watchedFiles = extensionInstance . watchedFiles ( )
669+
670+ // Then
671+ expect ( watchedFiles ) . toContain ( joinPath ( srcDir , 'index.js' ) )
672+ expect ( watchedFiles ) . not . toContain ( joinPath ( ignoredDir , 'should-be-ignored.js' ) )
673+ } )
674+ } )
675+
676+ test ( 'returns empty watched files for configuration extensions' , async ( ) => {
677+ await inTemporaryDirectory ( async ( tmpDir ) => {
678+ // Given
679+ const extensionInstance = await testAppConfigExtensions ( false , tmpDir )
680+
681+ // Create files that should not be watched
682+ await writeFile ( joinPath ( tmpDir , 'some-file.ts' ) , 'code' )
683+
684+ // When
685+ const watchedFiles = extensionInstance . watchedFiles ( )
686+
687+ // Then - configuration extensions default to empty paths, so no files watched
688+ expect ( watchedFiles ) . toHaveLength ( 0 )
689+ } )
690+ } )
691+
610692 test ( 'returns all files when devSessionWatchPaths is undefined' , async ( ) => {
611693 await inTemporaryDirectory ( async ( tmpDir ) => {
612694 // Given
0 commit comments