mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
No more 500 error when jumping between conversations (Nested Runtimes) (#8902)
This commit is contained in:
parent
738ecd468c
commit
a1b3c0c7d6
@ -1,14 +1,22 @@
|
||||
import { useEffect } from "react";
|
||||
import { useConversationId } from "#/hooks/use-conversation-id";
|
||||
import { useUserConversation } from "./use-user-conversation";
|
||||
import OpenHands from "#/api/open-hands";
|
||||
|
||||
const FIVE_MINUTES = 1000 * 60 * 5;
|
||||
|
||||
export const useActiveConversation = () => {
|
||||
const { conversationId } = useConversationId();
|
||||
return useUserConversation(conversationId, (query) => {
|
||||
const userConversation = useUserConversation(conversationId, (query) => {
|
||||
if (query.state.data?.status === "STARTING") {
|
||||
return 2000; // 2 seconds
|
||||
}
|
||||
return FIVE_MINUTES;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const conversation = userConversation.data;
|
||||
OpenHands.setCurrentConversation(conversation || null);
|
||||
}, [conversationId, userConversation.isFetched]);
|
||||
return userConversation;
|
||||
};
|
||||
|
||||
@ -23,7 +23,6 @@ export const useUserConversation = (
|
||||
queryKey: ["user", "conversation", cid],
|
||||
queryFn: async () => {
|
||||
const conversation = await OpenHands.getConversation(cid!);
|
||||
OpenHands.setCurrentConversation(conversation);
|
||||
return conversation;
|
||||
},
|
||||
enabled: !!cid,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user