@@ -17,6 +17,7 @@ const hoisted = vi.hoisted(() => ({
1717
1818vi . mock ( "../../plugins/runtime.js" , ( ) => ( {
1919 getActivePluginRegistry : ( ) => hoisted . activeRegistry ,
20+ getActivePluginSessionExtensionRegistry : ( ) => hoisted . activeRegistry ,
2021 requireActivePluginRegistry : ( ) => hoisted . activeRegistry ,
2122} ) ) ;
2223vi . mock ( "../../config/sessions/session-accessor.js" , async ( importOriginal ) => ( {
@@ -25,6 +26,7 @@ vi.mock("../../config/sessions/session-accessor.js", async (importOriginal) => (
2526} ) ) ;
2627
2728const { sessionCatalogHandlers } = await import ( "./session-catalog.js" ) ;
29+ const { listActiveSessionCatalogs } = await import ( "../../plugins/session-catalog-active.js" ) ;
2830
2931function provider (
3032 id : string ,
@@ -121,6 +123,52 @@ describe("session catalog Gateway HOME isolation", () => {
121123 ) ;
122124 } ) ;
123125
126+ it ( "binds HOME isolation into the internal read-only catalog facade" , async ( ) => {
127+ const localHost = {
128+ hostId : "gateway:local" ,
129+ label : "Local" ,
130+ kind : "gateway" as const ,
131+ connected : true ,
132+ sessions : [ ] ,
133+ } ;
134+ const list = vi . fn ( async ( request : { allowProcessHomeFallback ?: boolean } ) =>
135+ request . allowProcessHomeFallback === false ? [ ] : [ localHost ] ,
136+ ) ;
137+ const read = vi . fn ( async ( request : Parameters < SessionCatalogProvider [ "read" ] > [ 0 ] ) => {
138+ if ( request . allowProcessHomeFallback === false ) {
139+ throw new Error ( "local Test sessions are unavailable in isolated state" ) ;
140+ }
141+ return { hostId : request . hostId , threadId : request . threadId , items : [ ] } ;
142+ } ) ;
143+ hoisted . activeRegistry . sessionCatalogs = [ { provider : provider ( "test" , { list, read } ) } ] ;
144+
145+ await withProfile ( undefined , async ( ) => {
146+ const [ catalog ] = listActiveSessionCatalogs ( ) ;
147+ expect ( catalog ?. processHomeFallbackAllowed ) . toBe ( true ) ;
148+ await expect ( catalog ?. list ( { } ) ) . resolves . toEqual ( [ localHost ] ) ;
149+ await expect (
150+ catalog ?. read ( { hostId : "gateway:local" , threadId : "known-thread" } ) ,
151+ ) . resolves . toMatchObject ( { threadId : "known-thread" } ) ;
152+ } ) ;
153+ await withProfile ( "dev" , async ( ) => {
154+ const [ catalog ] = listActiveSessionCatalogs ( ) ;
155+ expect ( catalog ?. processHomeFallbackAllowed ) . toBe ( false ) ;
156+ await expect ( catalog ?. list ( { } ) ) . resolves . toEqual ( [ ] ) ;
157+ await expect (
158+ catalog ?. read ( { hostId : "gateway:local" , threadId : "known-thread" } ) ,
159+ ) . rejects . toThrow ( "local Test sessions are unavailable in isolated state" ) ;
160+ } ) ;
161+
162+ expect ( list . mock . calls . map ( ( [ request ] ) => request . allowProcessHomeFallback ) ) . toEqual ( [
163+ true ,
164+ false ,
165+ ] ) ;
166+ expect ( read . mock . calls . map ( ( [ request ] ) => request . allowProcessHomeFallback ) ) . toEqual ( [
167+ true ,
168+ false ,
169+ ] ) ;
170+ } ) ;
171+
124172 it . each ( [
125173 [ "continue" , "continueSession" , { } ] ,
126174 [ "archive" , "archive" , { confirmNoOtherRunner : true } ] ,
0 commit comments