Skip to content
3 changes: 2 additions & 1 deletion ui/desktop/src/components/BaseChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export default function BaseChat({
onStreamFinish,
});

const recipe = session?.recipe;

useAutoSubmit({
sessionId,
session,
Expand Down Expand Up @@ -176,7 +178,6 @@ export default function BaseChat({
session,
});

const recipe = session?.recipe;
const { setProviderAndModel } = useModelAndProvider();

useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions ui/desktop/src/components/recipes/RecipesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default function RecipesView() {
setView('pair', {
disableAnimation: true,
resumeSessionId: session.id,
initialMessage: recipe.prompt ? { msg: recipe.prompt, images: [] } : undefined,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing the recipe prompt as initialMessage so it auto-submits using the existing Scenario 1 logic (same pattern as Hub) for ref see ui/desktop/src/components/Hub.tsx:63-67 where Hub does the same thing

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I understand. ?:undefined === ?? is what I meant

});
} catch (error) {
console.error('Failed to load recipe:', error);
Expand Down
22 changes: 16 additions & 6 deletions ui/desktop/src/hooks/useAutoSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export function useAutoSubmit({
);
}, [sessionId]);

const hasUnfilledParameters = useCallback((session: Session) => {
const recipe = session.recipe;
return recipe?.parameters && recipe.parameters.length > 0 && !session.user_recipe_values;
}, []);

// Auto-submit logic
useEffect(() => {
const currentSessionId = searchParams.get('resumeSessionId');
Expand All @@ -60,17 +65,18 @@ export function useAutoSubmit({
return;
}

// Don't submit if already streaming or loading
if (chatState !== ChatState.Idle) {
return;
}

// Scenario 1: New session with initial message from Hub
// Hub always creates new sessions, so message_count will be 0
if (initialMessage && session.message_count === 0 && messages.length === 0) {
hasAutoSubmittedRef.current = true;
handleSubmit(initialMessage);
clearInitialMessage();
if (!hasUnfilledParameters(session)) {
hasAutoSubmittedRef.current = true;
handleSubmit(initialMessage);
clearInitialMessage();
}
return;
}

Expand All @@ -87,8 +93,11 @@ export function useAutoSubmit({

// Scenario 3: Resume with shouldStartAgent (continue existing conversation)
if (shouldStartAgent) {
hasAutoSubmittedRef.current = true;
handleSubmit({ msg: '', images: [] });
if (!hasUnfilledParameters(session)) {
hasAutoSubmittedRef.current = true;
handleSubmit({ msg: '', images: [] });
}
return;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is duplicated and I think it belongs in the caller

Copy link
Copy Markdown
Collaborator Author

@Abhijay007 Abhijay007 Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, I will extract the parameter checking logic into a hasUnfilledParameters helper function to remove duplication between Scenario 1 and 3

Copy link
Copy Markdown
Collaborator Author

@Abhijay007 Abhijay007 Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, did you mean removing scenario 3?

}
}, [
session,
Expand All @@ -99,6 +108,7 @@ export function useAutoSubmit({
messages.length,
chatState,
clearInitialMessage,
hasUnfilledParameters,
]);

return {
Expand Down