mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-16 23:01:06 +02:00
feat(chat): add ActiveChatStreamRunner to persist streams across nav
This commit is contained in:
parent
204b3aa56c
commit
5c3aa72c1a
1 changed files with 29 additions and 0 deletions
29
surfsense_web/components/chat/active-chat-stream-runner.tsx
Normal file
29
surfsense_web/components/chat/active-chat-stream-runner.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { chatStreamStore } from "@/lib/chat/stream-engine/store";
|
||||
|
||||
/**
|
||||
* Persistent, render-null host for app-wide chat-stream lifecycle.
|
||||
*
|
||||
* Mounted in the workspace shell (``LayoutDataProvider``), it persists across
|
||||
* in-app navigation between workspace routes (``/new-chat`` -> ``/chats`` ->
|
||||
* ``/automations`` and doc-tab switches) and only unmounts on real teardown
|
||||
* (workspace change / app teardown). On that teardown it aborts the single
|
||||
* in-flight turn — this replaces the old chat-page unmount abort, which was
|
||||
* what killed streams on ordinary navigation.
|
||||
*
|
||||
* NOTE: the ``hitl-decision`` bridge and ``useChatSessionStateSync`` stay in
|
||||
* the chat page: both need the currently-viewed thread id (HITL resume can
|
||||
* only be triggered from the page's approval UI), which the shell-level runner
|
||||
* does not cleanly have.
|
||||
*/
|
||||
export function ActiveChatStreamRunner() {
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
chatStreamStore.abortActive();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue