fix: append the recipe prompt when start recipe in a session (#2599)
This commit is contained in:
@@ -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 */}
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user