From ed57a0331ab9c98c132f6a94853530f2186c4766 Mon Sep 17 00:00:00 2001 From: Storme-bit Date: Sun, 19 Apr 2026 00:26:48 -0700 Subject: [PATCH] documentation update --- packages/chat-client/src/App.jsx | 10 +++------- packages/chat-client/src/hooks/useChat.js | 9 +++++---- packages/chat-client/src/hooks/useSession.js | 3 ++- packages/orchestration-service/src/services/qdrant.js | 3 +++ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/chat-client/src/App.jsx b/packages/chat-client/src/App.jsx index 50a59d7..0a34a62 100644 --- a/packages/chat-client/src/App.jsx +++ b/packages/chat-client/src/App.jsx @@ -99,13 +99,11 @@ export default function App() { // Home: create session, navigate to chat, then send after a tick function handleHomeSend(text) { - createSession(); + const newSession = createSession(); // ← capture the returned session setViewHistory(prev => [...prev, 'home']); setView('chat'); setLeftOpen(true); - setTimeout(() => { - sendMessage(text, selectedModel, null); - }, 50); + sendMessage(text, selectedModel, null, newSession); // ← pass directly, no setTimeout needed } function handleNewProjectChat(text) { @@ -120,9 +118,7 @@ export default function App() { setViewHistory(prev => [...prev, view]); setView('chat'); setLeftOpen(true); - setTimeout(() => { - sendMessage(text, selectedModel, activeProject?.id ?? null); - }, 50); + sendMessage(text, selectedModel, activeProject?.id ?? null, newSession); // ← direct, no timeout } const canGoBack = view !== 'home'; diff --git a/packages/chat-client/src/hooks/useChat.js b/packages/chat-client/src/hooks/useChat.js index 694904f..9b812b1 100644 --- a/packages/chat-client/src/hooks/useChat.js +++ b/packages/chat-client/src/hooks/useChat.js @@ -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)); } }, diff --git a/packages/chat-client/src/hooks/useSession.js b/packages/chat-client/src/hooks/useSession.js index 4e78ff9..2abec44 100644 --- a/packages/chat-client/src/hooks/useSession.js +++ b/packages/chat-client/src/hooks/useSession.js @@ -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 }, []); diff --git a/packages/orchestration-service/src/services/qdrant.js b/packages/orchestration-service/src/services/qdrant.js index c39217d..fa0444f 100644 --- a/packages/orchestration-service/src/services/qdrant.js +++ b/packages/orchestration-service/src/services/qdrant.js @@ -15,6 +15,9 @@ async function searchEpisodes( vector, {limit = ORCHESTRATION.RECENT_EPISODE_LIM body.filter = { must: [{key: 'sessionId', match: {value: sessionId} }] }; } + console.log('[qdrant] searchEpisodes filter:', JSON.stringify(body.filter)); + console.log('[qdrant] projectSessionIds:', projectSessionIds); + const res = await fetch ( `${BASE_URL}/collections/${COLLECTIONS.EPISODES}/points/search`, {