DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix: restore active turn on page refresh (P1-8)
unknownb611c2b11c0f
diff --git a/deeptutor/api/routers/unified_ws.py b/deeptutor/api/routers/unified_ws.pyindex cb9376f56..93c136fd7 100644--- a/deeptutor/api/routers/unified_ws.py+++ b/deeptutor/api/routers/unified_ws.py@@ -159,6 +159,25 @@ async def unified_websocket(ws: WebSocket) -> None:await subscribe_session(session_id, after_seq=int(msg.get("after_seq") or 0))continue+ if msg_type == "check_active_turn":+ session_id = str(msg.get("session_id") or "").strip()+ if not session_id:+ await safe_send({"type": "error", "content": "Missing session_id."})+ continue+ from deeptutor.services.session import get_turn_runtime_manager++ runtime = get_turn_runtime_manager()+ active_turn = await runtime.store.get_active_turn(session_id)+ if active_turn:+ await safe_send({+ "type": "active_turn_info",+ "turn_id": active_turn["id"],+ "status": active_turn.get("status", "running"),+ })+ else:+ await safe_send({"type": "active_turn_info", "turn_id": "", "status": "none"})+ continue+if msg_type == "resume_from":turn_id = str(msg.get("turn_id") or "").strip()if not turn_id:diff --git a/web/app/(workspace)/learning/[bookId]/page.tsx b/web/app/(workspace)/learning/[bookId]/page.tsxindex 6ffbd3f2c..d95b216df 100644--- a/web/app/(workspace)/learning/[bookId]/page.tsx+++ b/web/app/(workspace)/learning/[bookId]/page.tsx@@ -103,15 +103,11 @@ export default function LearningBookPage() {setConnecting(false);setError(null);reconnectAttemptsRef.current = 0;+ // Check for existing active turn before starting a new onews.send(JSON.stringify({- type: "start_turn",+ type: "check_active_turn",session_id: params.bookId,- capability: "guided_learning",- content: "Start learning",- book_references: [{ book_id: params.bookId, page_ids: [] }],- config: {},}));- setWaitingForLLM(true);};ws.onmessage = (event) => {@@ -158,6 +154,30 @@ export default function LearningBookPage() {}return;}+ if (evt.type === "active_turn_info") {+ const info = evt as unknown as { turn_id: string; status: string };+ if (info.turn_id && info.status === "running") {+ // Resume existing turn+ currentTurnRef.current = info.turn_id;+ wsRef.current?.send(JSON.stringify({+ type: "subscribe_session",+ session_id: params.bookId,+ }));+ setWaitingForLLM(true);+ } else {+ // No active turn — start a new one+ wsRef.current?.send(JSON.stringify({+ type: "start_turn",+ session_id: params.bookId,+ capability: "guided_learning",+ content: "Start learning",+ book_references: [{ book_id: params.bookId, page_ids: [] }],+ config: {},+ }));+ setWaitingForLLM(true);+ }+ return;+ }if (evt.type === "stage_start") {setWaitingForLLM(false);currentStageRef.current = evt.stage;