fix: initial prompt not filled in after accepting new recipe (#3637)

This commit is contained in:
Zane
2025-07-31 10:49:28 -07:00
committed by GitHub
parent f1907abacb
commit b5e73c4c89
5 changed files with 40 additions and 27 deletions
+16
View File
@@ -75,6 +75,8 @@ interface ChatInputProps {
setIsGoosehintsModalOpen?: (isOpen: boolean) => void;
disableAnimation?: boolean;
recipeConfig?: Recipe | null;
recipeAccepted?: boolean;
initialPrompt?: string;
}
export default function ChatInput({
@@ -95,6 +97,8 @@ export default function ChatInput({
sessionCosts,
setIsGoosehintsModalOpen,
recipeConfig,
recipeAccepted,
initialPrompt,
}: ChatInputProps) {
const [_value, setValue] = useState(initialValue);
const [displayValue, setDisplayValue] = useState(initialValue); // For immediate visual feedback
@@ -200,6 +204,18 @@ export default function ChatInput({
setHasUserTyped(false);
}, [initialValue]); // Keep only initialValue as a dependency
// Handle recipe prompt updates
useEffect(() => {
// If recipe is accepted and we have an initial prompt, and no messages yet, set the prompt
if (recipeAccepted && initialPrompt && messages.length === 0 && !displayValue.trim()) {
setDisplayValue(initialPrompt);
setValue(initialPrompt);
setTimeout(() => {
textAreaRef.current?.focus();
}, 0);
}
}, [recipeAccepted, initialPrompt, messages.length, displayValue]);
// Draft functionality - load draft if no initial value or recipe
useEffect(() => {
// Reset draft loaded flag when context changes