File tree Expand file tree Collapse file tree 4 files changed +18
-7
lines changed
Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -102,18 +102,22 @@ export function useCreationWorkspace({
102102 getRuntimeString,
103103 } = useDraftWorkspaceSettings ( projectPath , branches , recommendedTrunk ) ;
104104
105+ // Project scope ID for reading send options at send time
106+ const projectScopeId = getProjectScopeId ( projectPath ) ;
107+
108+ // Read the user's preferred model for fallback (same source as ChatInput's preferredModel)
109+ const fallbackModel = readPersistedState < string | null > ( getModelKey ( projectScopeId ) , null ) ;
110+
105111 // Workspace name generation with debounce
106112 const workspaceNameState = useWorkspaceName ( {
107113 message,
108114 debounceMs : 500 ,
115+ fallbackModel : fallbackModel ?? undefined ,
109116 } ) ;
110117
111118 // Destructure name state functions for use in callbacks
112119 const { waitForGeneration } = workspaceNameState ;
113120
114- // Project scope ID for reading send options at send time
115- const projectScopeId = getProjectScopeId ( projectPath ) ;
116-
117121 // Load branches on mount
118122 useEffect ( ( ) => {
119123 // This can be created with an empty project path when the user is
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ export interface UseWorkspaceNameOptions {
66 message : string ;
77 /** Debounce delay in milliseconds (default: 500) */
88 debounceMs ?: number ;
9+ /** Model to use if preferred small models aren't available */
10+ fallbackModel ?: string ;
911}
1012
1113/** State and actions for workspace name generation, suitable for passing to components */
@@ -37,7 +39,7 @@ export interface UseWorkspaceNameReturn extends WorkspaceNameState {
3739 * auto-generation resumes.
3840 */
3941export function useWorkspaceName ( options : UseWorkspaceNameOptions ) : UseWorkspaceNameReturn {
40- const { message, debounceMs = 500 } = options ;
42+ const { message, debounceMs = 500 , fallbackModel } = options ;
4143 const { api } = useAPI ( ) ;
4244
4345 const [ generatedName , setGeneratedName ] = useState ( "" ) ;
@@ -103,6 +105,7 @@ export function useWorkspaceName(options: UseWorkspaceNameOptions): UseWorkspace
103105 try {
104106 const result = await api . nameGeneration . generate ( {
105107 message : forMessage ,
108+ fallbackModel,
106109 } ) ;
107110
108111 // Check if this request is still current (wasn't cancelled)
@@ -141,7 +144,7 @@ export function useWorkspaceName(options: UseWorkspaceNameOptions): UseWorkspace
141144 }
142145 }
143146 } ,
144- [ api ]
147+ [ api , fallbackModel ]
145148 ) ;
146149
147150 // Debounced generation effect
Original file line number Diff line number Diff line change @@ -278,6 +278,8 @@ export const nameGeneration = {
278278 generate : {
279279 input : z . object ( {
280280 message : z . string ( ) ,
281+ /** Model to use if preferred small models (Haiku, GPT-Mini) aren't available */
282+ fallbackModel : z . string ( ) . optional ( ) ,
281283 } ) ,
282284 output : ResultSchema (
283285 z . object ( {
Original file line number Diff line number Diff line change @@ -174,13 +174,15 @@ export const router = (authToken?: string) => {
174174 . input ( schemas . nameGeneration . generate . input )
175175 . output ( schemas . nameGeneration . generate . output )
176176 . handler ( async ( { context, input } ) => {
177- const model = await getPreferredNameModel ( context . aiService ) ;
177+ // Prefer small/fast models, fall back to user's configured model
178+ const model =
179+ ( await getPreferredNameModel ( context . aiService ) ) ?? input . fallbackModel ;
178180 if ( ! model ) {
179181 return {
180182 success : false ,
181183 error : {
182184 type : "unknown" as const ,
183- raw : "No model available for name generation. Configure an API key for Anthropic or OpenAI. " ,
185+ raw : "No model available for name generation." ,
184186 } ,
185187 } ;
186188 }
You can’t perform that action at this time.
0 commit comments