@@ -487,6 +487,59 @@ it.layer(NodeServices.layer)("server settings", (it) => {
487487 } ) . pipe ( Effect . provide ( makeServerSettingsLayer ( ) ) ) ,
488488 ) ;
489489
490+ it . effect ( "folds a legacy in-config enabled flag into the envelope on load" , ( ) =>
491+ Effect . gen ( function * ( ) {
492+ const serverConfig = yield * ServerConfig . ServerConfig ;
493+ const fileSystem = yield * FileSystem . FileSystem ;
494+ const serverSettings = yield * ServerSettingsModule . ServerSettingsService ;
495+ // Old settings files can carry both flags with conflicting values.
496+ // The explicit false must win so a user's disable sticks.
497+ yield * fileSystem . writeFileString (
498+ serverConfig . settingsPath ,
499+ '{"providerInstances":{"grok":{"driver":"grok","enabled":true,"config":{"enabled":false}},"codex_work":{"driver":"codex","config":{"enabled":true,"homePath":"~/.codex"}}}}' ,
500+ ) ;
501+
502+ const settings = yield * serverSettings . getSettings ;
503+
504+ const grokId = ProviderInstanceId . make ( "grok" ) ;
505+ const codexWorkId = ProviderInstanceId . make ( "codex_work" ) ;
506+ assert . deepEqual ( settings . providerInstances [ grokId ] , {
507+ driver : ProviderDriverKind . make ( "grok" ) ,
508+ enabled : false ,
509+ config : { } ,
510+ } ) ;
511+ // A lone in-config flag is lifted to the envelope and stripped.
512+ assert . deepEqual ( settings . providerInstances [ codexWorkId ] , {
513+ driver : ProviderDriverKind . make ( "codex" ) ,
514+ enabled : true ,
515+ config : { homePath : "~/.codex" } ,
516+ } ) ;
517+ } ) . pipe ( Effect . provide ( makeServerSettingsLayer ( ) ) ) ,
518+ ) ;
519+
520+ it . effect ( "folds in-config enabled flags arriving through updates" , ( ) =>
521+ Effect . gen ( function * ( ) {
522+ const serverSettings = yield * ServerSettingsModule . ServerSettingsService ;
523+ const grokId = ProviderInstanceId . make ( "grok" ) ;
524+
525+ const next = yield * serverSettings . updateSettings ( {
526+ providerInstances : {
527+ [ grokId ] : {
528+ driver : ProviderDriverKind . make ( "grok" ) ,
529+ enabled : true ,
530+ config : { enabled : false , binaryPath : "/opt/grok" } ,
531+ } ,
532+ } ,
533+ } ) ;
534+
535+ assert . deepEqual ( next . providerInstances [ grokId ] , {
536+ driver : ProviderDriverKind . make ( "grok" ) ,
537+ enabled : false ,
538+ config : { binaryPath : "/opt/grok" } ,
539+ } ) ;
540+ } ) . pipe ( Effect . provide ( makeServerSettingsLayer ( ) ) ) ,
541+ ) ;
542+
490543 it . effect ( "trims provider path settings when updates are applied" , ( ) =>
491544 Effect . gen ( function * ( ) {
492545 const serverSettings = yield * ServerSettingsModule . ServerSettingsService ;
@@ -524,7 +577,8 @@ it.layer(NodeServices.layer)("server settings", (it) => {
524577 launchArgs : "" ,
525578 } ) ;
526579 assert . deepEqual ( next . providers . opencode , {
527- enabled : true ,
580+ // OpenCode is disabled by default; this update only touches paths.
581+ enabled : false ,
528582 binaryPath : "/opt/homebrew/bin/opencode" ,
529583 serverUrl : "http://127.0.0.1:4096" ,
530584 serverPassword : "secret-password" ,
0 commit comments