diff --git a/ai-hub/app/api/routes/sessions.py b/ai-hub/app/api/routes/sessions.py index f9f2455..ee7276c 100644 --- a/ai-hub/app/api/routes/sessions.py +++ b/ai-hub/app/api/routes/sessions.py @@ -298,6 +298,7 @@ """ import uuid from datetime import datetime + from sqlalchemy.orm.attributes import flag_modified session = db.query(models.Session).filter( models.Session.id == session_id, @@ -315,6 +316,8 @@ new_node_ids = set(request.node_ids) detached_nodes = old_node_ids - new_node_ids + print(f"[DEBUG] AttachNodes Request for {session_id} - Old: {old_node_ids}, New: {new_node_ids}, Detaching: {detached_nodes}") + session.attached_node_ids = list(request.node_ids) # Initialize sync status for new nodes @@ -337,6 +340,8 @@ sync_status.pop(nid, None) session.node_sync_status = sync_status + flag_modified(session, "attached_node_ids") + flag_modified(session, "node_sync_status") db.commit() db.refresh(session) diff --git a/ui/client-app/src/pages/CodingAssistantPage.js b/ui/client-app/src/pages/CodingAssistantPage.js index 2df60d8..044d186 100644 --- a/ui/client-app/src/pages/CodingAssistantPage.js +++ b/ui/client-app/src/pages/CodingAssistantPage.js @@ -98,9 +98,12 @@ setIsInitiatingSync(true); try { await attachNodesToSession(sessionId, attachedNodeIds, syncConfig); - await fetchNodeInfo(); - // M3: Explicitly close the selector so the user sees the page status + // M3: Explicitly turn off the editing mesh ref and modal BEFORE fetching + // so the server's newly saved attached nodes replace the user checkboxes immediately + isEditingMeshRef.current = false; setShowNodeSelector(false); + + await fetchNodeInfo(); } catch (err) { alert(`Sync Error: ${err.message}`); } finally {