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) <noreply@anthropic.com>
This commit is contained in:
parent
e47cc89b75
commit
743eddfbd1
@ -84,6 +84,13 @@ export function useAgents(connected: Ref<boolean>) {
|
|||||||
_allowedAgentIds.value = data.allowedAgents;
|
_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'
|
// Restore mode: URL ?mode= > sessionStorage > default 'private'
|
||||||
const urlParams = new URLSearchParams(window.location.hash.split('?')[1] || '');
|
const urlParams = new URLSearchParams(window.location.hash.split('?')[1] || '');
|
||||||
const urlMode = urlParams.get('mode');
|
const urlMode = urlParams.get('mode');
|
||||||
@ -107,8 +114,10 @@ export function useAgents(connected: Ref<boolean>) {
|
|||||||
selectedAgent.value = urlAgent as string;
|
selectedAgent.value = urlAgent as string;
|
||||||
} else if (isSavedAgentAllowed) {
|
} else if (isSavedAgentAllowed) {
|
||||||
selectedAgent.value = savedAgent as string;
|
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<void> {
|
async function fetchAgentModels(): Promise<void> {
|
||||||
|
|||||||
@ -46,6 +46,9 @@ export function useAgentSocket(
|
|||||||
updateFromServer(data);
|
updateFromServer(data);
|
||||||
if (data.session_id) chatStore.sessionKey = data.session_id;
|
if (data.session_id) chatStore.sessionKey = data.session_id;
|
||||||
else if (data.sessionId) chatStore.sessionKey = data.sessionId;
|
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
|
// assay session info — store session ID for reconnect
|
||||||
|
|||||||
Reference in New Issue
Block a user