documentation update
This commit is contained in:
@@ -8,8 +8,9 @@ export function useChat({ activeSession, appendMessage, updateLastMessage, refre
|
||||
const [lastModel, setLastModel] = useState(null);
|
||||
const cancelRef = useRef(null);
|
||||
|
||||
const sendMessage = useCallback(async (text, model, projectId = null) => {
|
||||
if (!activeSession || !text.trim() || streaming) return;
|
||||
const sendMessage = useCallback(async (text, model, projectId = null, session=null) => {
|
||||
const targetSession = session ?? activeSession;
|
||||
if (!targetSession || !text.trim() || streaming) return;
|
||||
|
||||
setError(null);
|
||||
|
||||
@@ -32,7 +33,7 @@ export function useChat({ activeSession, appendMessage, updateLastMessage, refre
|
||||
|
||||
// 3. Open stream
|
||||
cancelRef.current = streamMessage(
|
||||
activeSession.external_id,
|
||||
targetSession.external_id,
|
||||
text,
|
||||
model,
|
||||
{
|
||||
@@ -59,7 +60,7 @@ export function useChat({ activeSession, appendMessage, updateLastMessage, refre
|
||||
|
||||
// Assign project after first message if one was set
|
||||
if (projectId) {
|
||||
updateSession(activeSession.external_id, { projectId })
|
||||
updateSession(targetSession.external_id, { projectId })
|
||||
.catch(err => console.warn('[useChat] Failed to assign project:', err.message));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -58,11 +58,12 @@ export function useSession() {
|
||||
const newSession = {
|
||||
external_id: uuidv4(),
|
||||
metadata: null,
|
||||
isNew: true, // flag so SessionList can style it differently
|
||||
isNew: true,
|
||||
};
|
||||
setSessions(prev => [newSession, ...prev]);
|
||||
setActiveSession(newSession);
|
||||
setMessages([]);
|
||||
return newSession
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user