mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-01 20:03:30 +02:00
Simplify chat session state hook and disable send button when blocked
This commit is contained in:
parent
22ead877fa
commit
17f8c993df
2 changed files with 22 additions and 13 deletions
|
|
@ -5,6 +5,10 @@ import type { ChatSessionState } from "@/contracts/types/chat-session-state.type
|
|||
|
||||
const ELECTRIC_URL = process.env.NEXT_PUBLIC_ELECTRIC_URL || "http://localhost:5133";
|
||||
|
||||
/**
|
||||
* Hook to get live chat session state for collaboration.
|
||||
* Tracks which user the AI is currently responding to.
|
||||
*/
|
||||
export function useChatSessionState(threadId: number | null) {
|
||||
const { data, isLoading, isError, error } = useShape<ChatSessionState>({
|
||||
url: `${ELECTRIC_URL}/v1/shape`,
|
||||
|
|
@ -12,8 +16,6 @@ export function useChatSessionState(threadId: number | null) {
|
|||
table: "chat_session_state",
|
||||
where: `thread_id = ${threadId}`,
|
||||
},
|
||||
// Skip fetching if no threadId
|
||||
...(threadId ? {} : { url: undefined as unknown as string }),
|
||||
});
|
||||
|
||||
const sessionState = data?.[0] ?? null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue