fix: append the recipe prompt when start recipe in a session (#2599)

This commit is contained in:
Lifei Zhou
2025-05-21 15:59:40 +10:00
committed by GitHub
parent 0dbf155a65
commit e317153380
2 changed files with 11 additions and 2 deletions
+9 -1
View File
@@ -97,6 +97,7 @@ function ChatContent({
const [droppedFiles, setDroppedFiles] = useState<string[]>([]); const [droppedFiles, setDroppedFiles] = useState<string[]>([]);
const scrollRef = useRef<ScrollAreaHandle>(null); const scrollRef = useRef<ScrollAreaHandle>(null);
const hasSentPromptRef = useRef(false);
const { const {
summaryContent, summaryContent,
@@ -278,6 +279,14 @@ function ChatContent({
} }
}, [messages]); }, [messages]);
useEffect(() => {
const prompt = recipeConfig?.prompt;
if (prompt && !hasSentPromptRef.current) {
append(prompt);
hasSentPromptRef.current = true;
}
}, [recipeConfig?.prompt, append]);
// Handle submit // Handle submit
const handleSubmit = (e: React.FormEvent) => { const handleSubmit = (e: React.FormEvent) => {
window.electron.startPowerSaveBlocker(); window.electron.startPowerSaveBlocker();
@@ -476,7 +485,6 @@ function ChatContent({
const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => { const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault(); e.preventDefault();
}; };
return ( return (
<div className="flex flex-col w-full h-screen items-center justify-center"> <div className="flex flex-col w-full h-screen items-center justify-center">
{/* Loader when generating recipe */} {/* Loader when generating recipe */}
+2 -1
View File
@@ -285,10 +285,11 @@ const windowMap = new Map<number, BrowserWindow>();
interface RecipeConfig { interface RecipeConfig {
id: string; id: string;
name: string; title: string;
description: string; description: string;
instructions: string; instructions: string;
activities: string[]; activities: string[];
prompt: string;
} }
const createChat = async ( const createChat = async (