DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix: resolve code review blockers - was_running check before deletion and temp ID resolution
WeDonee35fbd41b753
diff --git a/deeptutor/services/session/sqlite_store.py b/deeptutor/services/session/sqlite_store.pyindex 68a5f877f..95eae0adf 100644--- a/deeptutor/services/session/sqlite_store.py+++ b/deeptutor/services/session/sqlite_store.py@@ -686,15 +686,6 @@ class SQLiteSessionStore:(session_id, int(message_id)),).fetchone()- attachment_ids: list[str] = []- for m in [msg, paired_msg]:- if m is not None:- atts = _json_loads(m["attachments_json"], [])- for att in atts:- aid = att.get("id") or att.get("attachment_id")- if aid:- attachment_ids.append(aid)-user_msg = msg if role == "user" else paired_msgturn_id = Nonewas_running = False@@ -713,8 +704,22 @@ class SQLiteSessionStore:if turn_row is not None:turn_id = turn_row["id"]was_running = turn_row["status"] == "running"- conn.execute("DELETE FROM turn_events WHERE turn_id = ?", (turn_id,))- conn.execute("DELETE FROM turns WHERE id = ?", (turn_id,))++ if was_running:+ return {"deleted": False, "attachment_ids": [], "turn_id": turn_id, "was_running": True}++ attachment_ids: list[str] = []+ for m in [msg, paired_msg]:+ if m is not None:+ atts = _json_loads(m["attachments_json"], [])+ for att in atts:+ aid = att.get("id") or att.get("attachment_id")+ if aid:+ attachment_ids.append(aid)++ if turn_id is not None:+ conn.execute("DELETE FROM turn_events WHERE turn_id = ?", (turn_id,))+ conn.execute("DELETE FROM turns WHERE id = ?", (turn_id,))ids_to_delete = [int(message_id)]if paired_msg is not None:diff --git a/web/context/UnifiedChatContext.tsx b/web/context/UnifiedChatContext.tsxindex b0b60d8c5..0649ba626 100644--- a/web/context/UnifiedChatContext.tsx+++ b/web/context/UnifiedChatContext.tsx@@ -1264,14 +1264,28 @@ export function UnifiedChatProvider({const session = currentState.sessions[key];if (!session || !session.sessionId) return;if (session.isStreaming) return;+ let effectiveId = messageId;+ if (messageId < 0) {+ const origIdx = session.messages.findIndex((m) => m.id === messageId);+ if (origIdx === -1) return;+ try {+ await loadSession(session.sessionId);+ } catch {+ return;+ }+ const refreshed = stateRef.current.sessions[key];+ const realId = refreshed?.messages[origIdx]?.id;+ if (realId == null || realId < 0) return;+ effectiveId = realId;+ }try {- await deleteMessage(session.sessionId, messageId);- dispatch({ type: "DELETE_TURN", key, messageId });+ await deleteMessage(session.sessionId, effectiveId);+ dispatch({ type: "DELETE_TURN", key, messageId: effectiveId });} catch (err) {console.error("Failed to delete turn:", err);}},- [],+ [loadSession],);const value: ChatContextValue = {