-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Abhijay007 <[email protected]>
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.
Pull request overview
This PR adds auto-submit functionality for recipes that have been accepted, allowing recipe prompts to be automatically submitted when a session is opened with a recipe but no existing messages.
Key changes:
- Added autoSubmit prop that flows from Pair.tsx through BaseChat.tsx to ChatInput.tsx
- Implemented logic to determine when auto-submission should occur based on recipe presence and conversation state
- Added useEffect in ChatInput to trigger submission when autoSubmit is true
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ui/desktop/src/components/Pair.tsx | Added useChatStream hook and logic to calculate shouldAutoSubmit based on recipe and message state |
| ui/desktop/src/components/BaseChat.tsx | Added autoSubmit prop to component signature and passed it to ChatInput; moved recipe variable declaration earlier |
| ui/desktop/src/components/ChatInput.tsx | Added autoSubmit prop and useEffect to automatically submit initialValue when autoSubmit is true |
| ui/desktop/src/components/Hub.tsx | Explicitly set autoSubmit={false} to maintain existing Hub behavior |
| } | ||
|
|
||
| export default function Pair({ setChat, sessionId, initialMessage }: PairProps) { | ||
| const { session } = useChatStream({ sessionId, onStreamFinish: () => {} }); |
Copilot
AI
Jan 4, 2026
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.
This creates a second instance of useChatStream for the same sessionId. BaseChat already calls useChatStream internally, so this duplicates the session loading logic and could cause unnecessary API calls. Remove this hook and pass the autoSubmit logic directly to BaseChat, or have BaseChat expose the session data needed for this calculation.
| const recipe = session?.recipe; | ||
| const hasMessages = (session?.conversation?.length ?? 0) > 0; |
Copilot
AI
Jan 4, 2026
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.
The autoSubmit condition may evaluate before the session is fully loaded, causing shouldAutoSubmit to be false initially and then never re-evaluate to true. Since session is loaded asynchronously, the initial render will have session as undefined, causing shouldAutoSubmit to be false. When session loads, the useMemo will recalculate, but by then didAutoSubmit might already be set to true by the ChatInput useEffect, preventing the actual submission.
| const recipe = session?.recipe; | |
| const hasMessages = (session?.conversation?.length ?? 0) > 0; | |
| if (!session) return undefined; | |
| const recipe = session.recipe; | |
| const hasMessages = (session.conversation?.length ?? 0) > 0; |
| useEffect(() => { | ||
| if (!!autoSubmit && !didAutoSubmit) { | ||
| setDidAutoSubmit(true); | ||
| performSubmit(initialValue); | ||
| } | ||
| }, [autoSubmit, didAutoSubmit, initialValue, performSubmit]); |
Copilot
AI
Jan 4, 2026
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.
The useEffect depends on performSubmit which is a useCallback with many dependencies. If any of those dependencies change, performSubmit gets recreated and this effect will re-run, potentially submitting multiple times even though didAutoSubmit is true. The effect runs before didAutoSubmit is set, so rapid dependency changes could cause race conditions. Consider using useRef for performSubmit or restructure to avoid including it in the dependency array.
| useEffect(() => { | |
| if (!!autoSubmit && !didAutoSubmit) { | |
| setDidAutoSubmit(true); | |
| performSubmit(initialValue); | |
| } | |
| }, [autoSubmit, didAutoSubmit, initialValue, performSubmit]); | |
| const performSubmitRef = useRef<typeof performSubmit | null>(null); | |
| useEffect(() => { | |
| performSubmitRef.current = performSubmit; | |
| }, [performSubmit]); | |
| useEffect(() => { | |
| if (!!autoSubmit && !didAutoSubmit) { | |
| setDidAutoSubmit(true); | |
| performSubmitRef.current?.(initialValue); | |
| } | |
| }, [autoSubmit, didAutoSubmit, initialValue]); |
closes #6087
Summary
Type of Change
AI Assistance
Testing
Screenshots/Demos (for UX changes)
Before:
After: