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
@@ -14,6 +14,7 @@ import {
import { ChatSmart, Gear } from '../icons';
import { ViewOptions, View } from '../../App';
import { useChatContext } from '../../contexts/ChatContext';
import { DEFAULT_CHAT_TITLE } from '../../contexts/ChatContext';
interface SidebarProps {
onSelectSession: (sessionId: string) => void;
@@ -115,7 +116,7 @@ const AppSidebar: React.FC<SidebarProps> = ({ currentPath }) => {
if (
currentPath === '/pair' &&
chatContext?.chat?.title &&
chatContext.chat.title !== 'New Chat'
chatContext.chat.title !== DEFAULT_CHAT_TITLE
) {
titleBits.push(chatContext.chat.title);
} else if (currentPath !== '/' && currentItem) {
+3 -2
View File
@@ -30,6 +30,7 @@ import { ChatContextManagerProvider } from './context_management/ChatContextMana
import 'react-toastify/dist/ReactToastify.css';
import { ChatType } from '../types/chat';
import { DEFAULT_CHAT_TITLE } from '../contexts/ChatContext';
export default function Hub({
chat: _chat,
@@ -57,7 +58,7 @@ export default function Hub({
const newChatId = generateSessionId();
const newPairChat = {
id: newChatId, // This generates a unique ID each time
title: 'New Chat',
title: DEFAULT_CHAT_TITLE,
messages: [], // Always start with empty messages
messageHistoryIndex: 0,
recipeConfig: null, // Clear recipe for new chats from Hub
@@ -68,10 +69,10 @@ export default function Hub({
setPairChat(newPairChat);
// Navigate to pair page with the message to be submitted immediately
// No delay needed since we're updating state synchronously
setView('pair', {
disableAnimation: true,
initialMessage: combinedTextFromInput,
resetChat: true,
});
}
+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(() => {