Transcript Seed Messages (channels/transcript-messages.ts)

OpenBot · app/src/components/channels/transcript-messages.ts · typescript · MIT
chat, voice, tag:ag-ui, tag:state

Manages placeholder user messages shown while a new channel joins, preserving the user's turn until the runtime replaces messages. Reuse for chat transcript seeding logic.

// Source: https://github.com/CopilotKit/OpenBot | License: MIT | Copyright 2026 CopilotKit
// Provided via justclaw.it.com; keep this notice with the code.
import type { Message } from "@ag-ui/core";

/**
 * What a transcript shows while a brand-new channel is still joining.
 *
 * NOT DECIDED ON `messages.length`: the runtime replaces its messages wholesale, so the seed would
 * be dropped on the first assistant token with the person's own turn already gone. A role rather
 * than an id, because the agent's copy and the restored copy each mint their own.
 */
export function transcriptMessages(
  messages: readonly Message[],
  seed: Message | null,
): readonly Message[] {
  if (seed === null) {
    return messages;
  }
  if (messages.some((message) => message.role === "user")) {
    return

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key