MCPcopy
hub / github.com/CopilotKit/CopilotKit / markInterrupted

Function markInterrupted

packages/bot-slack/src/event-renderer.ts:542–573  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

540 await finalizeTurnStream();
541 },
542 async markInterrupted() {
543 // Idempotent. Mark BEFORE any await so subsequent subscriber
544 // callbacks (including the RUN_ERROR that AG-UI fires when we
545 // abort) see the flag and bail.
546 if (aborted) return;
547 aborted = true;
548 // Clear the native status; the interrupted marker (or the next turn) is
549 // the user-visible signal now.
550 if (statusMode) await clearStatus();
551 // Native turn stream: append the interrupted marker to the partial reply
552 // and finalize it.
553 if (nativeMode) {
554 if (turnStream && turnText.length > 0 && !turnFinalised) {
555 turnStream.append(turnText + INTERRUPTED_SUFFIX);
556 }
557 await finalizeTurnStream();
558 }
559 // Legacy per-message streams: append the marker and drain. Streams with
560 // no content yet are silently dropped (the bot never posted anything).
561 const tasks: Promise<void>[] = [];
562 for (const [id, stream] of Array.from(streams.entries())) {
563 const buf = buffers.get(id) ?? "";
564 if (buf.length > 0) {
565 stream.append(buf + INTERRUPTED_SUFFIX);
566 tasks.push(stream.finish());
567 }
568 streams.delete(id);
569 finalised.add(id);
570 }
571 buffers.clear();
572 await Promise.all(tasks);
573 },
574 };
575}

Callers 1

Calls 9

clearStatusFunction · 0.85
finalizeTurnStreamFunction · 0.85
entriesMethod · 0.80
appendMethod · 0.65
getMethod · 0.65
pushMethod · 0.65
finishMethod · 0.65
deleteMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…