-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: add auto submit for recipes that have been accepted #6325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b715b68
6463529
7c54209
950f6cb
668ad80
1f338f3
b725b7e
03d9055
69a79aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'); | ||
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
@@ -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; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code is duplicated and I think it belongs in the caller
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, did you mean removing scenario 3? |
||
| } | ||
| }, [ | ||
| session, | ||
|
|
@@ -99,6 +108,7 @@ export function useAutoSubmit({ | |
| messages.length, | ||
| chatState, | ||
| clearInitialMessage, | ||
| hasUnfilledParameters, | ||
| ]); | ||
|
|
||
| return { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
There was a problem hiding this comment.
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
initialMessageso it auto-submits using the existing Scenario 1 logic (same pattern as Hub) for ref seeui/desktop/src/components/Hub.tsx:63-67where Hub does the same thingThere was a problem hiding this comment.
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