diff --git a/ui/desktop/src/hooks/useRecipeManager.ts b/ui/desktop/src/hooks/useRecipeManager.ts index 5abf9f47df29..07cc8723c6f4 100644 --- a/ui/desktop/src/hooks/useRecipeManager.ts +++ b/ui/desktop/src/hooks/useRecipeManager.ts @@ -26,6 +26,7 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => { const messagesRef = useRef(messages); const isCreatingRecipeRef = useRef(false); + const hasCheckedRecipeRef = useRef(false); useEffect(() => { messagesRef.current = messages; @@ -54,6 +55,7 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => { setRecipeAccepted(false); setIsParameterModalOpen(false); setIsRecipeWarningModalOpen(false); + hasCheckedRecipeRef.current = false; // Reset check flag for new recipe chatContext.setChat({ ...chatContext.chat, @@ -75,14 +77,23 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => { useEffect(() => { const checkRecipeAcceptance = async () => { + // Only check once per recipe load + if (hasCheckedRecipeRef.current) { + return; + } + if (finalRecipe) { + hasCheckedRecipeRef.current = true; + // If the recipe comes from session metadata (not from navigation state), // it means it was already accepted in a previous session, so auto-accept it - const isFromSessionMetadata = !recipe && finalRecipe; + const hasMessages = chat.messages.length > 0; + const isFromSessionMetadata = !recipe && finalRecipe && hasMessages; if (isFromSessionMetadata) { // Recipe loaded from session metadata should be automatically accepted setRecipeAccepted(true); + setIsRecipeWarningModalOpen(false); return; } @@ -108,7 +119,7 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => { }; checkRecipeAcceptance(); - }, [finalRecipe, recipe]); + }, [finalRecipe, recipe, chat.messages.length]); // Filter parameters to only show valid ones that are actually used in the recipe const filteredParameters = useMemo(() => { diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index e827bf800187..f32d57340ee9 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -346,6 +346,7 @@ app.on('open-url', async (_event, url) => { recipeDeeplink || undefined, scheduledJobId || undefined ); + windowDeeplinkURL = null; return; // Skip the rest of the handler } @@ -366,6 +367,7 @@ app.on('open-url', async (_event, url) => { } else if (parsedUrl.hostname === 'sessions') { firstOpenWindow.webContents.send('open-shared-session', pendingDeepLink); } + pendingDeepLink = null; } });