diff --git a/dashboard/src/api/index.js b/dashboard/src/api/index.js index 69241cd..15f3a2e 100644 --- a/dashboard/src/api/index.js +++ b/dashboard/src/api/index.js @@ -283,10 +283,22 @@ export function createRoomWS(roomId, callbacks = {}) { } }, sendMessage: (content, userId = 'user', userName = 'User') => { - ws.send(JSON.stringify({ action: 'send_message', content, user_id: userId, user_name: userName })) + const send = () => { + if (ws.readyState === WebSocket.OPEN) { + ws.send(JSON.stringify({ action: 'send_message', content, user_id: userId, user_name: userName })) + } else if (ws.readyState === WebSocket.CONNECTING) { + // Wait for connection then retry + ws.addEventListener('open', () => { + ws.send(JSON.stringify({ action: 'send_message', content, user_id: userId, user_name: userName })) + }, { once: true }) + } + } + send() }, ping: () => { - ws.send(JSON.stringify({ action: 'ping' })) + if (ws.readyState === WebSocket.OPEN) { + ws.send(JSON.stringify({ action: 'ping' })) + } }, close: () => ws.close() } diff --git a/dashboard/src/views/AgentsView.vue b/dashboard/src/views/AgentsView.vue index 8e588ed..7279c37 100644 --- a/dashboard/src/views/AgentsView.vue +++ b/dashboard/src/views/AgentsView.vue @@ -33,6 +33,14 @@ +
{{ agent.system_prompt?.slice(0, 100) }}...