summaries chat client
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useCallback, useRef } from 'react';
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { streamMessage, updateSession } from '../api/orchestration';
|
||||
|
||||
export function useChat({ activeSession, appendMessage, updateLastMessage, refreshSessions }) {
|
||||
@@ -7,6 +7,18 @@ export function useChat({ activeSession, appendMessage, updateLastMessage, refre
|
||||
const [lastTokenCount, setLastTokenCount] = useState(0);
|
||||
const [lastModel, setLastModel] = useState(null);
|
||||
const cancelRef = useRef(null);
|
||||
const prevStreaming = React.useRef(false);
|
||||
const [summarising, setSummarising] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (prevStreaming.current && !streaming) {
|
||||
// Stream just finished — trigger the summarising indicator
|
||||
setSummarising(true);
|
||||
const t = setTimeout(() => setSummarising(false), 8000);
|
||||
return () => clearTimeout(t);
|
||||
}
|
||||
prevStreaming.current = streaming;
|
||||
}, [streaming]);
|
||||
|
||||
const sendMessage = useCallback(async (text, model, projectId = null, session=null) => {
|
||||
const targetSession = session ?? activeSession;
|
||||
|
||||
Reference in New Issue
Block a user