@@ -15,8 +15,6 @@ import {
1515 getAppModelOptionsForInstance ,
1616 resolveAppModelSelectionForInstance ,
1717 resolveAppModelSelectionState ,
18- resolvePlanAgentHealPatch ,
19- withoutPlanAgentSelection ,
2018} from "./modelSelection" ;
2119
2220function provider ( input : {
@@ -865,81 +863,44 @@ describe("instance-scoped model selection", () => {
865863 } ) ;
866864} ) ;
867865
868- describe ( "withoutPlanAgentSelection " , ( ) => {
869- const instance = ProviderInstanceId . make ( "opencode" ) ;
866+ describe ( "resolveAppModelSelectionState with the opencode plan agent " , ( ) => {
867+ const instanceId = ProviderInstanceId . make ( "opencode" ) ;
870868 const model = "opencode/gpt-5.4" ;
871-
872- it ( "drops a stored plan agent option" , ( ) => {
873- const selection = createModelSelection ( instance , model , [
874- { id : "variant" , value : "high" } ,
869+ const opencode : ServerProvider = {
870+ ...provider ( { provider : ProviderDriverKind . make ( "opencode" ) , instanceId : "opencode" } ) ,
871+ models : [
872+ {
873+ slug : model ,
874+ name : model ,
875+ isCustom : false ,
876+ capabilities : {
877+ optionDescriptors : [
878+ {
879+ id : "agent" ,
880+ label : "Agent" ,
881+ type : "select" ,
882+ options : [
883+ { id : "build" , label : "Build" , isDefault : true } ,
884+ { id : "plan" , label : "Plan" } ,
885+ ] ,
886+ currentValue : "build" ,
887+ } ,
888+ ] ,
889+ } ,
890+ } ,
891+ ] ,
892+ } ;
893+ const settings : UnifiedSettings = {
894+ ...DEFAULT_UNIFIED_SETTINGS ,
895+ planModeEnabled : false ,
896+ textGenerationModelSelection : createModelSelection ( instanceId , model , [
875897 { id : "agent" , value : "plan" } ,
876- ] ) ;
877- expect ( withoutPlanAgentSelection ( selection ) ) . toEqual (
878- createModelSelection ( instance , model , [ { id : "variant" , value : "high" } ] ) ,
879- ) ;
880- } ) ;
881-
882- it ( "keeps non-plan agent options" , ( ) => {
883- const selection = createModelSelection ( instance , model , [ { id : "agent" , value : "build" } ] ) ;
884- expect ( withoutPlanAgentSelection ( selection ) ) . toBe ( selection ) ;
885- } ) ;
886-
887- it ( "omits options entirely when plan was the only stored option" , ( ) => {
888- const selection = createModelSelection ( instance , model , [ { id : "agent" , value : "plan" } ] ) ;
889- expect ( withoutPlanAgentSelection ( selection ) ) . toEqual ( { instanceId : instance , model } ) ;
890- } ) ;
891-
892- it ( "returns null and undefined selections unchanged" , ( ) => {
893- expect ( withoutPlanAgentSelection ( null ) ) . toBeNull ( ) ;
894- expect ( withoutPlanAgentSelection ( undefined ) ) . toBeUndefined ( ) ;
895- } ) ;
896- } ) ;
897-
898- describe ( "resolvePlanAgentHealPatch" , ( ) => {
899- const instance = ProviderInstanceId . make ( "opencode" ) ;
900- const model = "opencode/gpt-5.4" ;
901- const healed = createModelSelection ( instance , model , [ { id : "variant" , value : "high" } ] ) ;
902- const storedPlan = createModelSelection ( instance , model , [
903- { id : "variant" , value : "high" } ,
904- { id : "agent" , value : "plan" } ,
905- ] ) ;
906- const nullPatch = {
907- planModeEnabled : true ,
908- textGenerationModelSelection : storedPlan ,
909- sourceControlWriterModelSelection : null ,
898+ ] ) ,
910899 } ;
911900
912- it ( "returns null when plan mode is on" , ( ) => {
913- expect ( resolvePlanAgentHealPatch ( nullPatch ) ) . toBeNull ( ) ;
914- } ) ;
915-
916- it ( "returns null when nothing needs healing" , ( ) => {
917- expect (
918- resolvePlanAgentHealPatch ( {
919- planModeEnabled : false ,
920- textGenerationModelSelection : healed ,
921- sourceControlWriterModelSelection : null ,
922- } ) ,
923- ) . toBeNull ( ) ;
924- } ) ;
925-
926- it ( "patches the stored text generation selection to drop the plan agent" , ( ) => {
927- expect (
928- resolvePlanAgentHealPatch ( {
929- planModeEnabled : false ,
930- textGenerationModelSelection : storedPlan ,
931- sourceControlWriterModelSelection : null ,
932- } ) ,
933- ) . toEqual ( { textGenerationModelSelection : healed } ) ;
934- } ) ;
935-
936- it ( "patches a stored source control writer selection that uses the plan agent" , ( ) => {
937- expect (
938- resolvePlanAgentHealPatch ( {
939- planModeEnabled : false ,
940- textGenerationModelSelection : healed ,
941- sourceControlWriterModelSelection : storedPlan ,
942- } ) ,
943- ) . toEqual ( { sourceControlWriterModelSelection : healed } ) ;
901+ it ( "keeps a stored plan agent this device did not pick" , ( ) => {
902+ expect ( resolveAppModelSelectionState ( settings , [ opencode ] ) ) . toEqual (
903+ createModelSelection ( instanceId , model , [ { id : "agent" , value : "plan" } ] ) ,
904+ ) ;
944905 } ) ;
945906} ) ;
0 commit comments