MCPcopy Index your code
hub / github.com/simstudioai/sim / emitTerminalIfMissing

Function emitTerminalIfMissing

apps/sim/app/api/copilot/chat/stream/route.ts:347–371  ·  view source on GitHub ↗
(
      status: MothershipStreamV1CompletionStatus,
      options?: { message?: string; code: string; reason?: string }
    )

Source from the content-addressed store, hash-verified

345 }
346
347 const emitTerminalIfMissing = (
348 status: MothershipStreamV1CompletionStatus,
349 options?: { message?: string; code: string; reason?: string }
350 ) => {
351 if (controllerClosed || sawTerminalEvent) {
352 return
353 }
354 for (const envelope of buildResumeTerminalEnvelopes({
355 streamId,
356 afterCursor: cursor,
357 status,
358 message: options?.message,
359 code: options?.code ?? 'resume_terminal',
360 reason: options?.reason,
361 requestId: currentRequestId,
362 })) {
363 if (!enqueueEvent(envelope)) {
364 break
365 }
366 cursor = envelope.stream.cursor ?? String(envelope.seq)
367 if (envelope.type === MothershipStreamV1EventType.complete) {
368 sawTerminalEvent = true
369 }
370 }
371 }
372
373 try {
374 enqueueComment('accepted')

Callers 1

startInnerFunction · 0.85

Calls 2

enqueueEventFunction · 0.85

Tested by

no test coverage detected