@@ -3,12 +3,13 @@ import { useQuery } from "@tanstack/react-query";
33import { ChevronDownIcon , PlusIcon , RotateCcwIcon , Undo2Icon , XIcon } from "lucide-react" ;
44import { type ReactNode , useCallback , useState } from "react" ;
55import {
6+ type ModelSlug ,
67 type ProviderKind ,
78 DEFAULT_GIT_TEXT_GENERATION_MODEL_BY_PROVIDER ,
89} from "@t3tools/contracts" ;
910import { getModelOptions , normalizeModelSlug } from "@t3tools/shared/model" ;
1011import {
11- getAppModelOptions ,
12+ getCustomModelOptionsByProvider ,
1213 getCustomModelsForProvider ,
1314 MAX_CUSTOM_MODEL_LENGTH ,
1415 MODEL_PROVIDER_SETTINGS ,
@@ -28,6 +29,7 @@ import {
2829} from "../components/ui/select" ;
2930import { SidebarTrigger } from "../components/ui/sidebar" ;
3031import { Switch } from "../components/ui/switch" ;
32+ import { ProviderModelPicker } from "../components/chat/ProviderModelPicker" ;
3133import { SidebarInset } from "../components/ui/sidebar" ;
3234import { Tooltip , TooltipPopup , TooltipTrigger } from "../components/ui/tooltip" ;
3335import { resolveAndPersistPreferredEditor } from "../editorPreferences" ;
@@ -219,20 +221,8 @@ function SettingsRouteView() {
219221
220222 const textGenProvider = settings . textGenerationProvider ;
221223 const textGenDefaultModel = DEFAULT_GIT_TEXT_GENERATION_MODEL_BY_PROVIDER [ textGenProvider ] ;
222- const gitTextGenerationModelOptions = getAppModelOptions (
223- textGenProvider ,
224- textGenProvider === "codex" ? settings . customCodexModels : settings . customClaudeModels ,
225- settings . textGenerationModel ,
226- ) ;
227- const currentGitTextGenerationModel =
228- settings . textGenerationModel ?? textGenDefaultModel ;
229- const defaultGitTextGenerationModel =
230- defaults . textGenerationModel ?? textGenDefaultModel ;
231- const isGitTextGenerationModelDirty =
232- currentGitTextGenerationModel !== defaultGitTextGenerationModel ;
233- const selectedGitTextGenerationModelLabel =
234- gitTextGenerationModelOptions . find ( ( option ) => option . slug === currentGitTextGenerationModel )
235- ?. name ?? currentGitTextGenerationModel ;
224+ const textGenModel = ( settings . textGenerationModel ?? textGenDefaultModel ) as ModelSlug ;
225+ const gitModelOptionsByProvider = getCustomModelOptionsByProvider ( settings ) ;
236226 const selectedCustomModelProviderSettings = MODEL_PROVIDER_SETTINGS . find (
237227 ( providerSettings ) => providerSettings . provider === selectedCustomModelProvider ,
238228 ) ! ;
@@ -267,7 +257,9 @@ function SettingsRouteView() {
267257 ...( settings . textGenerationProvider !== defaults . textGenerationProvider
268258 ? [ "Git writing provider" ]
269259 : [ ] ) ,
270- ...( isGitTextGenerationModelDirty ? [ "Git writing model" ] : [ ] ) ,
260+ ...( settings . textGenerationModel !== defaults . textGenerationModel
261+ ? [ "Git writing model" ]
262+ : [ ] ) ,
271263 ...( settings . customCodexModels . length > 0 || settings . customClaudeModels . length > 0
272264 ? [ "Custom models" ]
273265 : [ ] ) ,
@@ -608,81 +600,22 @@ function SettingsRouteView() {
608600 </ SettingsSection >
609601
610602 < SettingsSection title = "Models" >
611- < SettingsRow
612- title = "Git writing provider"
613- description = "Which AI provider to use for auto-generated git content."
614- control = {
615- < Select
616- value = { textGenProvider }
617- onValueChange = { ( value ) => {
618- if ( value === "codex" || value === "claudeAgent" ) {
619- updateSettings ( {
620- textGenerationProvider : value ,
621- textGenerationModel :
622- DEFAULT_GIT_TEXT_GENERATION_MODEL_BY_PROVIDER [ value ] ,
623- } ) ;
624- }
625- } }
626- >
627- < SelectTrigger
628- className = "w-full sm:w-52"
629- aria-label = "Git text generation provider"
630- >
631- < SelectValue >
632- { textGenProvider === "claudeAgent" ? "Claude" : "Codex" }
633- </ SelectValue >
634- </ SelectTrigger >
635- < SelectPopup align = "end" alignItemWithTrigger = { false } >
636- < SelectItem hideIndicator value = "codex" >
637- Codex
638- </ SelectItem >
639- < SelectItem hideIndicator value = "claudeAgent" >
640- Claude
641- </ SelectItem >
642- </ SelectPopup >
643- </ Select >
644- }
645- />
646-
647603 < SettingsRow
648604 title = "Git writing model"
649- description = "Model used for auto-generated git content."
650- resetAction = {
651- isGitTextGenerationModelDirty ? (
652- < SettingResetButton
653- label = "git writing model"
654- onClick = { ( ) =>
655- updateSettings ( {
656- textGenerationModel : defaults . textGenerationModel ,
657- } )
658- }
659- />
660- ) : null
661- }
605+ description = "Provider and model used for auto-generated git content."
662606 control = {
663- < Select
664- value = { currentGitTextGenerationModel }
665- onValueChange = { ( value ) => {
666- if ( ! value ) return ;
607+ < ProviderModelPicker
608+ provider = { textGenProvider }
609+ model = { textGenModel }
610+ lockedProvider = { null }
611+ modelOptionsByProvider = { gitModelOptionsByProvider }
612+ onProviderModelChange = { ( provider , model ) => {
667613 updateSettings ( {
668- textGenerationModel : value ,
614+ textGenerationProvider : provider ,
615+ textGenerationModel : model ,
669616 } ) ;
670617 } }
671- >
672- < SelectTrigger
673- className = "w-full sm:w-52"
674- aria-label = "Git text generation model"
675- >
676- < SelectValue > { selectedGitTextGenerationModelLabel } </ SelectValue >
677- </ SelectTrigger >
678- < SelectPopup align = "end" alignItemWithTrigger = { false } >
679- { gitTextGenerationModelOptions . map ( ( option ) => (
680- < SelectItem hideIndicator key = { option . slug } value = { option . slug } >
681- { option . name }
682- </ SelectItem >
683- ) ) }
684- </ SelectPopup >
685- </ Select >
618+ />
686619 }
687620 />
688621
0 commit comments