@@ -712,6 +712,77 @@ describe("instance-scoped model selection", () => {
712712 ) . toEqual ( saved ) ;
713713 } ) ;
714714
715+ describe ( "composer model option precedence" , ( ) => {
716+ const instanceId = ProviderInstanceId . make ( "claudeAgent" ) ;
717+ const driver = ProviderDriverKind . make ( "claudeAgent" ) ;
718+ const base = provider ( { provider : driver , instanceId, models : [ "claude-opus-5-5" ] } ) ;
719+ const providers = [
720+ {
721+ ...base ,
722+ models : base . models . map ( ( model ) => ( {
723+ ...model ,
724+ capabilities : {
725+ optionDescriptors : [
726+ {
727+ id : "effort" ,
728+ label : "Effort" ,
729+ type : "select" as const ,
730+ options : [
731+ { id : "medium" , label : "Medium" , isDefault : true } ,
732+ { id : "high" , label : "High" } ,
733+ ] ,
734+ currentValue : "medium" ,
735+ } ,
736+ ] ,
737+ } ,
738+ } ) ) ,
739+ } ,
740+ ] ;
741+ const settingsDefault = createModelSelection ( instanceId , "claude-opus-5-5" , [
742+ { id : "effort" , value : "high" } ,
743+ ] ) ;
744+ const dispatchedSelection = (
745+ threadModelSelection : ReturnType < typeof createModelSelection > | null ,
746+ ) => {
747+ const state = deriveEffectiveComposerModelState ( {
748+ draft : null ,
749+ providers,
750+ selectedProvider : driver ,
751+ selectedInstanceId : instanceId ,
752+ threadModelSelection,
753+ projectModelSelection : settingsDefault ,
754+ settings : settingsWithProviderInstances ( ) ,
755+ } ) ;
756+ const dispatch = getComposerProviderState ( {
757+ provider : driver ,
758+ model : state . selectedModel ,
759+ models : providers [ 0 ] ! . models ,
760+ modelOptions : state . modelOptions ?. [ instanceId ] ,
761+ } ) ;
762+ return createModelSelection (
763+ instanceId ,
764+ state . selectedModel ,
765+ dispatch . modelOptionsForDispatch ,
766+ ) ;
767+ } ;
768+
769+ it ( "does not inherit settings options for an optionless existing thread" , ( ) => {
770+ const threadSelection = createModelSelection ( instanceId , "claude-opus-5-5" ) ;
771+ expect ( dispatchedSelection ( threadSelection ) ) . toEqual ( threadSelection ) ;
772+ } ) ;
773+
774+ it ( "keeps the options it was saved with" , ( ) => {
775+ const threadSelection = createModelSelection ( instanceId , "claude-opus-5-5" , [
776+ { id : "effort" , value : "medium" } ,
777+ ] ) ;
778+ expect ( dispatchedSelection ( threadSelection ) ) . toEqual ( threadSelection ) ;
779+ } ) ;
780+
781+ it ( "leaves the settings default's options in place before a thread exists" , ( ) => {
782+ expect ( dispatchedSelection ( null ) ) . toEqual ( settingsDefault ) ;
783+ } ) ;
784+ } ) ;
785+
715786 it ( "keeps a custom-instance draft model while dropping unsupported options" , ( ) => {
716787 const instanceId = ProviderInstanceId . make ( "claude_openrouter" ) ;
717788 const driver = ProviderDriverKind . make ( "claudeAgent" ) ;
0 commit comments