mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-09-01 21:25:58 +08:00
### Summary In agent **Explore**, asking a model and switching to another session (chat box) while the answer was still streaming caused the streaming answer to be rendered inside the session the user had just switched to. **Root cause.** The Explore page mounts `SessionChat` once per canvas; `useSendAgentMessage` therefore keeps one SSE `answerList` and one `derivedMessages` list shared by every session. The effect that folds streamed frames into the message list (`web/src/pages/agent/chat/use-send-agent-message.ts`) appended unconditionally, so after a session switch the in-flight frames of session A were written into the message list of the currently displayed session B. The global `sendLoading` also made the last assistant message of session B show a streaming indicator. **Fix.** Every agent SSE frame already carries the `session_id` it belongs to (see the frame contract in `internal/agent/canvas/runner.go`), so ownership is known on the client: - `useSendAgentMessage` accepts an optional `activeSessionId` (the session the page is currently displaying) and skips the streamed-answer append when the stream's `session_id` differs from it. It also exposes `streamSessionId` so callers can scope streaming UI. - The Explore hook (`use-send-session-message.ts`) passes the URL session id as `activeSessionId`. - `session-chat.tsx` shows the per-message streaming loading state only when the in-flight stream belongs to the displayed session. Behavior after the fix: switching sessions mid-answer keeps each session's message list clean; switching back to the streaming session resumes rendering the answer there; the answer is still persisted to its own session by the backend. Canvas debug chat and shared-agent chat are unchanged (they pass no `activeSessionId`, so the gate is inactive). **Verification.** Reproduced in the browser (dev services): asked for a long essay in session A, switched to session B mid-stream — pre-fix, session B showed session A's growing essay (~27k chars); post-fix, session B shows only its own history while the stream keeps running (confirmed by switching back and watching it continue in A). `jest src/pages/agent` passes (12 suites / 79 tests); `tsc --noEmit` shows no new errors in the touched files (remaining errors are pre-existing on main). --------- Co-authored-by: euvre <euvre@users.noreply.github.com>
Install front-end dependencies
npm install
Launch front-end
npm run dev
The following output confirms a successful launch of the system:
Login to RAGFlow web UI
Open your browser and navigate to:
http://localhost:9222 or http://[YOUR_MACHINE_IP]:9222
Replace [YOUR_MACHINE_IP] with your actual machine IP address (e.g., http://192.168.1.49:9222).
Login to RAGFlow web admin UI
Open your browser and navigate to:
http://localhost:9222/admin or http://[YOUR_MACHINE_IP]:9222/admin
Replace [YOUR_MACHINE_IP] with your actual machine IP address (e.g., http://192.168.1.49:9222/admin).
Shutdown front-end
Ctrl + C or
kill -f "umi dev"