@@ -7,7 +7,9 @@ import { createModelSelection } from "@t3tools/shared/model";
77import { resolveProjectSettings } from "@t3tools/shared/projectSettings" ;
88import { useNavigate } from "@tanstack/react-router" ;
99
10+ import { mergeEnvironmentSettings } from "../../hooks/useSettings" ;
1011import {
12+ defaultModelSelectionsAreMixed ,
1113 getCustomModelOptionsByInstance ,
1214 resolveEffectiveDefaultModelSelection ,
1315} from "../../modelSelection" ;
@@ -48,7 +50,7 @@ function isWorktreeSubmodules(value: string | null): value is WorktreeSubmodules
4850}
4951
5052export function ProjectDefaultsSettings ( { category } : { category : ProjectSettingsCategory } ) {
51- const { scope, target, connectedEnvironments } = useSettingsScope ( ) ;
53+ const { scope, target, targets , connectedEnvironments } = useSettingsScope ( ) ;
5254 const settings = useScopedSettings ( ) ;
5355 const updateSettings = useUpdateScopedSettings ( ) ;
5456 const navigate = useNavigate ( ) ;
@@ -76,7 +78,15 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
7678 selection ?. model ,
7779 ) ;
7880 const activeEntry = entries . find ( ( entry ) => entry . instanceId === selection ?. instanceId ) ;
79- const mixedModel = useScopedSettingsMixed ( [ "defaultModelSelection" ] ) ;
81+ const mixedModel = defaultModelSelectionsAreMixed (
82+ targets . map ( ( candidate ) => ( {
83+ settings : mergeEnvironmentSettings ( candidate . settings , settings ) ,
84+ providers : providersByEnvironment . get ( candidate . environmentId ) ?? EMPTY_SERVER_PROVIDERS ,
85+ } ) ) ,
86+ ) ;
87+ const automaticModel =
88+ targets . length > 0 &&
89+ targets . every ( ( candidate ) => candidate . settings . defaultModelSelection === null ) ;
8090 const mixedFallback = useScopedSettingsMixed ( [ "fallbackModelSelection" ] ) ;
8191 const fallbackSelection = settings . fallbackModelSelection ?? selection ;
8292 const fallbackModelOptions = getCustomModelOptionsByInstance (
@@ -99,6 +109,9 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
99109 : null ;
100110
101111 const modelDisabledReason = useScopedModelDisabledReason ( settings , entries ) ;
112+ const effortDisabledReason = selection
113+ ? modelDisabledReason ( selection . instanceId , selection . model )
114+ : null ;
102115
103116 const setModel = ( value : ModelSelection | null ) => {
104117 const reason = value ? modelDisabledReason ( value . instanceId , value . model ) : null ;
@@ -119,13 +132,15 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
119132 description = {
120133 isProjectScope
121134 ? "Model for new threads in this project."
122- : ! unavailable &&
123- ! mixedModel &&
124- modelSource !== "project" &&
125- settings . defaultModelSelection === null
135+ : ! unavailable && modelSource !== "project" && automaticModel
126136 ? "Default model for new threads, selected automatically. Projects can override it."
127137 : "Default model for new threads. Projects can override it."
128138 }
139+ status = {
140+ mixedModel
141+ ? `${ automaticModel ? "Automatic defaults differ." : "Defaults differ." } Select one environment or choose a shared model to edit effort.`
142+ : effortDisabledReason
143+ }
129144 resetAction = {
130145 settings . defaultModelSelection !== null ? (
131146 < SettingResetButton label = "default model" onClick = { ( ) => setModel ( null ) } />
@@ -142,7 +157,9 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
142157 instanceEntries = { entries }
143158 modelOptionsByInstance = { modelOptions }
144159 triggerClassName = { SETTINGS_PICKER_TRIGGER_CLASSNAME }
145- { ...( mixedModel ? { triggerLabel : "Mixed" } : { } ) }
160+ { ...( mixedModel
161+ ? { triggerLabel : automaticModel ? "Automatic (mixed)" : "Mixed" }
162+ : { } ) }
146163 getModelDisabledReason = { modelDisabledReason }
147164 onOpenProviderSetup = { ( instanceId ) => {
148165 if ( representative )
@@ -155,7 +172,7 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
155172 setModel ( createModelSelection ( instanceId , model ) )
156173 }
157174 />
158- { ! mixedModel ? (
175+ { ! mixedModel && ! effortDisabledReason ? (
159176 < TraitsPicker
160177 provider = { activeEntry . driverKind }
161178 models = { activeEntry . models }
@@ -171,7 +188,9 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
171188 ) : null }
172189 </ div >
173190 ) : (
174- < span className = "text-sm text-muted-foreground" > No providers available</ span >
191+ < span className = "text-sm text-muted-foreground" >
192+ { mixedModel ? "Mixed" : "No providers available" }
193+ </ span >
175194 )
176195 }
177196 />
0 commit comments