From 743eddfbd1836d9b428041b3ab875b15843381b1 Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 31 Mar 2026 21:34:24 +0200 Subject: [PATCH] Fix agent selection + SM state for chat UI - agents.ts: fallback agent list when server sends none, auto-select default - useAgentSocket.ts: set connectionState=SYNCED + channelState=READY on assay ready signal, unlocks chat input Co-Authored-By: Claude Opus 4.6 (1M context) --- src/composables/agents.ts | 11 ++++++++++- src/composables/useAgentSocket.ts | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/composables/agents.ts b/src/composables/agents.ts index 537c917..8cc098a 100644 --- a/src/composables/agents.ts +++ b/src/composables/agents.ts @@ -84,6 +84,13 @@ export function useAgents(connected: Ref) { _allowedAgentIds.value = data.allowedAgents; } + // Fallback: if no agents from server, provide a default so chat UI works + if (allAgents.value.length === 0) { + allAgents.value = [{ id: 'assay', name: 'assay', promptPrice: null, completionPrice: null }]; + _allowedAgentIds.value = ['assay']; + _defaultAgent.value = 'assay'; + } + // Restore mode: URL ?mode= > sessionStorage > default 'private' const urlParams = new URLSearchParams(window.location.hash.split('?')[1] || ''); const urlMode = urlParams.get('mode'); @@ -107,8 +114,10 @@ export function useAgents(connected: Ref) { selectedAgent.value = urlAgent as string; } else if (isSavedAgentAllowed) { selectedAgent.value = savedAgent as string; + } else if (!selectedAgent.value && _defaultAgent.value) { + // Auto-select default agent so chat UI is immediately usable + selectedAgent.value = _defaultAgent.value; } - // else: leave selectedAgent empty — AgentsView shows agent picker } async function fetchAgentModels(): Promise { diff --git a/src/composables/useAgentSocket.ts b/src/composables/useAgentSocket.ts index 3d4490a..d10be36 100644 --- a/src/composables/useAgentSocket.ts +++ b/src/composables/useAgentSocket.ts @@ -46,6 +46,9 @@ export function useAgentSocket( updateFromServer(data); if (data.session_id) chatStore.sessionKey = data.session_id; else if (data.sessionId) chatStore.sessionKey = data.sessionId; + // Set SM states so chat UI is unlocked + chatStore.applyConnectionState('SYNCED'); + chatStore.applyChannelState('READY'); }, // assay session info — store session ID for reconnect