-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Load recipe deeplinks in single window when app is closed #4048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
220561f
3f8f56b
7c61d48
ec86bbc
a66656d
03edb04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't follow the logic here. in what scenario is this going to be triggered? there was a recipe, the user went to the hub ...
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment to help but yeah basically if they decide to start a new chat from home/hub after loading a recipe for whatever reason it should clear the current recipe and start a new chat. Basically anytime a chat is started from hub/home it should be a fresh chat regardless of the scenario.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's probably the best we can do at this point, yeah. I guess right now if you restart a session that was started by a recipe, this doesn't actually have the recipe stuff in it anymore? /cc @lifeizhou-ap
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah its always worked like that where the recipe details are lost when resuming a session, we'd need to add the recipe to the session metadata if we wanted to do that. |
||
| // 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, | ||
| }; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should probably be/use a constant seeing that we have 'New Chat' already 4 times |
||
| 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(() => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noticed some local debug code that wasn't needed