fix: return pending_task_lane in session detail API response + debug logging

_build_session_detail was omitting pending_task_lane, is_branching, and
active_branch_id from the GET /ai-sessions/{id} response. The fields
existed on the schema and model but were never passed in the manual
constructor, so task lane state could never be restored on navigation.

Also adds console logging to AssistantChatPage selectChat flow to
diagnose message restoration, and fixes ScriptTemplateEditor stepper
dismiss firing during programmatic script_body updates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-28 21:44:04 +00:00
parent 4fa26149e6
commit 96602a6676
3 changed files with 16 additions and 4 deletions

View File

@@ -102,7 +102,9 @@ export default function AssistantChatPage() {
// Restore session from sessionStorage on mount (when URL has no session ID)
useEffect(() => {
console.log('[AssistantChat] Mount restore check — urlSessionId:', urlSessionId, 'activeChatId:', activeChatId)
if (!urlSessionId && activeChatId) {
console.log('[AssistantChat] Calling selectChat to restore:', activeChatId)
selectChat(activeChatId)
}
}, []) // eslint-disable-line react-hooks/exhaustive-deps
@@ -207,6 +209,7 @@ export default function AssistantChatPage() {
}
const selectChat = useCallback(async (chatId: string) => {
console.log('[AssistantChat] selectChat called with:', chatId)
setActiveChatId(chatId)
// Clear TaskLane when switching chats — will restore from backend if available
setShowTaskLane(false)
@@ -214,6 +217,7 @@ export default function AssistantChatPage() {
setActiveActions([])
try {
const detail = await aiSessionsApi.getSession(chatId)
console.log('[AssistantChat] getSession response — messages:', detail.conversation_messages?.length, 'pending_task_lane:', !!detail.pending_task_lane)
setMessages(
(detail.conversation_messages || []).map(m => ({
role: m.role as 'user' | 'assistant',
@@ -237,7 +241,8 @@ export default function AssistantChatPage() {
}
}
}
} catch {
} catch (err) {
console.error('[AssistantChat] Failed to load chat session:', err)
setMessages([])
}
}, [])