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