@@ -1277,7 +1277,7 @@ export namespace Config {
12771277 return yield * cachedGlobal
12781278 } )
12791279
1280- const install = Effect . fnUntraced ( function * ( dir : string ) {
1280+ const install = Effect . fn ( "Config.install" ) ( function * ( dir : string ) {
12811281 const pkg = path . join ( dir , "package.json" )
12821282 const gitignore = path . join ( dir , ".gitignore" )
12831283 const plugin = path . join ( dir , "node_modules" , "@opencode-ai" , "plugin" , "package.json" )
@@ -1345,7 +1345,7 @@ export namespace Config {
13451345 )
13461346 } )
13471347
1348- const loadInstanceState = Effect . fnUntraced ( function * ( ctx : InstanceContext ) {
1348+ const loadInstanceState = Effect . fn ( "Config.loadInstanceState" ) ( function * ( ctx : InstanceContext ) {
13491349 const auth = yield * authSvc . all ( ) . pipe ( Effect . orDie )
13501350
13511351 let result : Info = { }
@@ -1468,24 +1468,25 @@ export namespace Config {
14681468 log . debug ( "loaded custom config from OPENCODE_CONFIG_CONTENT" )
14691469 }
14701470
1471- const activeOrg = Option . getOrUndefined (
1472- yield * accountSvc . activeOrg ( ) . pipe ( Effect . catch ( ( ) => Effect . succeed ( Option . none ( ) ) ) ) ,
1471+ const activeAccount = Option . getOrUndefined (
1472+ yield * accountSvc . active ( ) . pipe ( Effect . catch ( ( ) => Effect . succeed ( Option . none ( ) ) ) ) ,
14731473 )
1474- if ( activeOrg ) {
1474+ if ( activeAccount ?. active_org_id ) {
1475+ const accountID = activeAccount . id
1476+ const orgID = activeAccount . active_org_id
1477+ const url = activeAccount . url
14751478 yield * Effect . gen ( function * ( ) {
14761479 const [ configOpt , tokenOpt ] = yield * Effect . all (
1477- [ accountSvc . config ( activeOrg . account . id , activeOrg . org . id ) , accountSvc . token ( activeOrg . account . id ) ] ,
1480+ [ accountSvc . config ( accountID , orgID ) , accountSvc . token ( accountID ) ] ,
14781481 { concurrency : 2 } ,
14791482 )
14801483 if ( Option . isSome ( tokenOpt ) ) {
14811484 process . env [ "OPENCODE_CONSOLE_TOKEN" ] = tokenOpt . value
14821485 yield * env . set ( "OPENCODE_CONSOLE_TOKEN" , tokenOpt . value )
14831486 }
14841487
1485- activeOrgName = activeOrg . org . name
1486-
14871488 if ( Option . isSome ( configOpt ) ) {
1488- const source = `${ activeOrg . account . url } /api/config`
1489+ const source = `${ url } /api/config`
14891490 const next = yield * loadConfig ( JSON . stringify ( configOpt . value ) , {
14901491 dir : path . dirname ( source ) ,
14911492 source,
@@ -1496,6 +1497,7 @@ export namespace Config {
14961497 yield * merge ( source , next , "global" )
14971498 }
14981499 } ) . pipe (
1500+ Effect . withSpan ( "Config.loadActiveOrgConfig" ) ,
14991501 Effect . catch ( ( err ) => {
15001502 log . debug ( "failed to fetch remote account config" , {
15011503 error : err instanceof Error ? err . message : String ( err ) ,
0 commit comments