Clear deeplinks after use (#5128)
This commit is contained in:
@@ -28,6 +28,7 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => {
|
|||||||
|
|
||||||
const messagesRef = useRef(messages);
|
const messagesRef = useRef(messages);
|
||||||
const isCreatingRecipeRef = useRef(false);
|
const isCreatingRecipeRef = useRef(false);
|
||||||
|
const hasCheckedRecipeRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
messagesRef.current = messages;
|
messagesRef.current = messages;
|
||||||
@@ -56,6 +57,7 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => {
|
|||||||
setRecipeAccepted(false);
|
setRecipeAccepted(false);
|
||||||
setIsParameterModalOpen(false);
|
setIsParameterModalOpen(false);
|
||||||
setIsRecipeWarningModalOpen(false);
|
setIsRecipeWarningModalOpen(false);
|
||||||
|
hasCheckedRecipeRef.current = false; // Reset check flag for new recipe
|
||||||
|
|
||||||
chatContext.setChat({
|
chatContext.setChat({
|
||||||
...chatContext.chat,
|
...chatContext.chat,
|
||||||
@@ -77,14 +79,23 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const checkRecipeAcceptance = async () => {
|
const checkRecipeAcceptance = async () => {
|
||||||
|
// Only check once per recipe load
|
||||||
|
if (hasCheckedRecipeRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalRecipe) {
|
if (finalRecipe) {
|
||||||
|
hasCheckedRecipeRef.current = true;
|
||||||
|
|
||||||
// If the recipe comes from session metadata (not from navigation state),
|
// 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
|
// 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) {
|
if (isFromSessionMetadata) {
|
||||||
// Recipe loaded from session metadata should be automatically accepted
|
// Recipe loaded from session metadata should be automatically accepted
|
||||||
setRecipeAccepted(true);
|
setRecipeAccepted(true);
|
||||||
|
setIsRecipeWarningModalOpen(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +121,7 @@ export const useRecipeManager = (chat: ChatType, recipe?: Recipe | null) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
checkRecipeAcceptance();
|
checkRecipeAcceptance();
|
||||||
}, [finalRecipe, recipe]);
|
}, [finalRecipe, recipe, chat.messages.length]);
|
||||||
|
|
||||||
// Filter parameters to only show valid ones that are actually used in the recipe
|
// Filter parameters to only show valid ones that are actually used in the recipe
|
||||||
const filteredParameters = useMemo(() => {
|
const filteredParameters = useMemo(() => {
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ app.on('open-url', async (_event, url) => {
|
|||||||
recipeDeeplink || undefined,
|
recipeDeeplink || undefined,
|
||||||
scheduledJobId || undefined
|
scheduledJobId || undefined
|
||||||
);
|
);
|
||||||
|
windowDeeplinkURL = null;
|
||||||
return; // Skip the rest of the handler
|
return; // Skip the rest of the handler
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,6 +367,7 @@ app.on('open-url', async (_event, url) => {
|
|||||||
} else if (parsedUrl.hostname === 'sessions') {
|
} else if (parsedUrl.hostname === 'sessions') {
|
||||||
firstOpenWindow.webContents.send('open-shared-session', pendingDeepLink);
|
firstOpenWindow.webContents.send('open-shared-session', pendingDeepLink);
|
||||||
}
|
}
|
||||||
|
pendingDeepLink = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user