MCPcopy Create free account
hub / github.com/Roy3838/Observer / dispatchWindowEventIfNeeded

Method dispatchWindowEventIfNeeded

app/src/utils/logging.ts:208–343  ·  view source on GitHub ↗

* Dispatch window events based on logType - unified event system * Logger is the single source of truth; events are notifications

(entry: LogEntry)

Source from the content-addressed store, hash-verified

206 * Logger is the single source of truth; events are notifications
207 */
208 private dispatchWindowEventIfNeeded(entry: LogEntry): void {
209 const logType = entry.details?.logType;
210 if (!logType) return;
211
212 try {
213 switch (logType) {
214 case 'agent-status-changed':
215 window.dispatchEvent(
216 new CustomEvent('agentStatusChanged', {
217 detail: entry.details.content
218 })
219 );
220 break;
221
222 case 'iteration-start':
223 window.dispatchEvent(
224 new CustomEvent('agentIterationStart', {
225 detail: {
226 agentId: entry.source,
227 intervalMs: entry.details.content?.intervalMs,
228 iterationStartTime: entry.details.content?.iterationStartTime,
229 iterationId: entry.details.iterationId
230 }
231 })
232 );
233 break;
234
235 case 'iteration-end':
236 case 'iteration-skipped':
237 // These are logged but don't need immediate UI events
238 // UI can track completion through log listener
239 break;
240
241 case 'stream-start':
242 window.dispatchEvent(
243 new CustomEvent('agentStreamStart', {
244 detail: {
245 agentId: entry.source,
246 iterationId: entry.details.iterationId
247 }
248 })
249 );
250 break;
251
252 case 'stream-chunk':
253 window.dispatchEvent(
254 new CustomEvent('agentResponseChunk', {
255 detail: {
256 agentId: entry.source,
257 chunk: entry.details.content?.chunk,
258 iterationId: entry.details.iterationId
259 }
260 })
261 );
262 break;
263
264 case 'thinking-chunk':
265 window.dispatchEvent(

Callers 1

notifyListenersMethod · 0.95

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected