@@ -383,6 +383,47 @@ it.layer(layerTest)("CodexDriver", (it) => {
383383 ) ,
384384 ) ;
385385
386+ it . effect . skipIf ( windowsHost ) (
387+ "uses an environment CODEX_HOME as the instance's shared home" ,
388+ ( ) =>
389+ Effect . gen ( function * ( ) {
390+ const fs = yield * FileSystem . FileSystem ;
391+ const tempDir = yield * fs
392+ . makeTempDirectoryScoped ( { prefix : "t3-codex-driver-" } )
393+ . pipe ( Effect . flatMap ( ( directory ) => fs . realPath ( directory ) ) ) ;
394+
395+ const instances = yield * Effect . forEach ( [ "work" , "personal" ] , ( account ) =>
396+ Effect . gen ( function * ( ) {
397+ const codexHome = NodePath . join ( tempDir , `codex-${ account } ` ) ;
398+ const binaryPath = NodePath . join ( codexHome , "packages" , "standalone" , "bin" , "codex" ) ;
399+ yield * fs . makeDirectory ( NodePath . dirname ( binaryPath ) , { recursive : true } ) ;
400+ yield * fs . writeFileString ( binaryPath , "#!/bin/sh\n" ) ;
401+ yield * fs . chmod ( binaryPath , 0o755 ) ;
402+ const instance = yield * CodexDriver . create ( {
403+ instanceId : ProviderInstanceId . make ( `codex-${ account } ` ) ,
404+ displayName : account ,
405+ enabled : false ,
406+ environment : [ { name : "CODEX_HOME" , value : codexHome , sensitive : false } ] ,
407+ config : { ...CodexDriver . defaultConfig ( ) , binaryPath } ,
408+ } ) ;
409+ return {
410+ codexHome,
411+ continuationKey : instance . continuationIdentity . continuationKey ,
412+ update : ( yield * instance . snapshot . resolveMaintenance ( ) ) . update ,
413+ } ;
414+ } ) ,
415+ ) ;
416+
417+ for ( const { codexHome, continuationKey, update } of instances ) {
418+ expect ( continuationKey ) . toBe ( `codex:home:${ codexHome } ` ) ;
419+ expect ( update ?. env ) . toEqual ( { CODEX_HOME : codexHome } ) ;
420+ }
421+ } ) . pipe (
422+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ,
423+ Effect . scoped ,
424+ ) ,
425+ ) ;
426+
386427 for ( const fixture of [
387428 {
388429 name : "leaves mise npm-backend installations manual-only" ,
0 commit comments