feat: broadcast pilot agent traces via WebSocket for live status on reconnect

Agent trace logs are now stored in-memory (pilotRunStore) and broadcast
through the existing /ws/crm-updates WebSocket channel. When a client
reconnects, it receives a pilot.catchup with all accumulated logs so the
user sees agent progress even after page reload. Three new WS event
types: pilot.trace, pilot.finished, pilot.catchup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-02-25 08:45:32 +07:00
parent b830f3728c
commit bf7f4ae933
6 changed files with 174 additions and 16 deletions

View File

@@ -373,6 +373,8 @@ const {
pushPilotNote,
refetchChatMessages,
refetchChatConversations,
handleRealtimePilotTrace,
handleRealtimePilotFinished,
destroyPilotWaveSurfer,
togglePilotLiveLogsExpanded,
} = pilotChat;
@@ -678,6 +680,8 @@ const { crmRealtimeState, startCrmRealtime, stopCrmRealtime } = useCrmRealtime({
// Refresh contacts to update sidebar preview (lastMessageText, lastAt, hasUnread)
void refetchContacts();
},
onPilotTrace: (log) => handleRealtimePilotTrace(log),
onPilotFinished: () => void handleRealtimePilotFinished(),
});
// ---------------------------------------------------------------------------