feat(web): sse event streaming and activity tracking

This commit is contained in:
Bohdan Triapitsyn
2025-12-24 03:25:52 +02:00
parent de0d7b698a
commit 6bcea3eb4d
2 changed files with 191 additions and 9 deletions
+13 -9
View File
@@ -407,7 +407,6 @@ export const useEventStream = () => {
break;
}
case 'openchamber:session-activity': {
if (!isDesktopRuntimeRef.current) break;
const sessionId = typeof props.sessionId === 'string' ? props.sessionId : null;
const phase = typeof props.phase === 'string' ? props.phase : null;
if (sessionId && (phase === 'idle' || phase === 'busy' || phase === 'cooldown')) {
@@ -804,16 +803,21 @@ export const useEventStream = () => {
completeStreamingMessage(sessionId, messageId);
// For web/vscode: trigger cooldown only when assistant message has finish === "stop"
// This matches the desktop backend logic in session_activity.rs
if (!isDesktopRuntimeRef.current) {
const rawCompletedSessionId = (message as { sessionID?: string }).sessionID;
const completedSessionId: string =
typeof rawCompletedSessionId === 'string' && rawCompletedSessionId.length > 0
? rawCompletedSessionId
: sessionId;
const finish = (message as { finish?: string }).finish;
if (finish === 'stop') {
const rawCompletedSessionId = (message as { sessionID?: string }).sessionID;
const completedSessionId: string =
typeof rawCompletedSessionId === 'string' && rawCompletedSessionId.length > 0
? rawCompletedSessionId
: sessionId;
const currentPhase = sessionActivityPhaseRef.current.get(completedSessionId);
if (currentPhase === 'busy') {
updateSessionActivityPhase(completedSessionId, 'cooldown');
const currentPhase = sessionActivityPhaseRef.current.get(completedSessionId);
if (currentPhase === 'busy') {
updateSessionActivityPhase(completedSessionId, 'cooldown');
}
}
}