Load recipe deeplinks in single window when app is closed (#4048)

This commit is contained in:
Zane
2025-08-13 14:52:33 -07:00
committed by GitHub
parent 1a58892948
commit 68dd3281f8
8 changed files with 123 additions and 53 deletions
+18 -1
View File
@@ -35,6 +35,7 @@ import 'react-toastify/dist/ReactToastify.css';
import { cn } from '../utils';
import { ChatType } from '../types/chat';
import { DEFAULT_CHAT_TITLE } from '../contexts/ChatContext';
export default function Pair({
chat,
@@ -80,6 +81,22 @@ export default function Pair({
// Handle initial message from hub page
useEffect(() => {
const messageFromHub = location.state?.initialMessage;
const resetChat = location.state?.resetChat;
// If we have a resetChat flag from Hub, clear any existing recipe config
// This scenario occurs when a user navigates from Hub to start a new chat,
// ensuring any previous recipe configuration is cleared for a fresh start
if (resetChat) {
const newChat: ChatType = {
...chat,
recipeConfig: null,
recipeParameters: null,
title: DEFAULT_CHAT_TITLE,
messages: [], // Clear messages for fresh start
messageHistoryIndex: 0,
};
setChat(newChat);
}
// Reset processing state when we have a new message from hub
if (messageFromHub) {
@@ -100,7 +117,7 @@ export default function Pair({
window.history.replaceState({}, '', '/pair');
}
}
}, [location.state, hasProcessedInitialInput, initialMessage, chat]);
}, [location.state, hasProcessedInitialInput, initialMessage, chat, setChat]);
// Auto-submit the initial message after it's been set and component is ready
useEffect(() => {