From fdab049d58090eef85d5499c4e4483e2aa6fc295 Mon Sep 17 00:00:00 2001 From: Rayhan Noufal Arayilakath Date: Sat, 14 Mar 2026 14:46:52 -0500 Subject: [PATCH 1/2] fix(chat): correctly type thread and channel interface --- packages/chat/src/types.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/chat/src/types.ts b/packages/chat/src/types.ts index 3f95dd40..bd1f4d36 100644 --- a/packages/chat/src/types.ts +++ b/packages/chat/src/types.ts @@ -4,10 +4,12 @@ import type { Root } from "mdast"; import type { CardElement } from "./cards"; +import type { SerializedChannel } from "./channel"; import type { ChatElement } from "./jsx-runtime"; import type { Logger, LogLevel } from "./logger"; import type { Message } from "./message"; import type { ModalElement } from "./modals"; +import type { SerializedThread } from "./thread"; // ============================================================================= // Re-exports from extracted modules @@ -735,6 +737,9 @@ export interface Channel< * Empty iterable on threadless platforms. */ threads(): AsyncIterable>; + + /** Serialize this channel for persistence or cross-process transfer. */ + toJSON(): SerializedChannel; } /** @@ -940,6 +945,9 @@ export interface Thread, TRawMessage = unknown> */ subscribe(): Promise; + /** Serialize this thread for persistence or cross-process transfer. */ + toJSON(): SerializedThread; + /** * Unsubscribe from this thread. * From ca367a22aa4b576d090fb8f9bfd51da7eea8b10d Mon Sep 17 00:00:00 2001 From: Rayhan Noufal Arayilakath Date: Sat, 14 Mar 2026 14:52:54 -0500 Subject: [PATCH 2/2] fix(chat): nit make comment match `Message` comment for consistency --- packages/chat/src/types.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/chat/src/types.ts b/packages/chat/src/types.ts index bd1f4d36..1172ed67 100644 --- a/packages/chat/src/types.ts +++ b/packages/chat/src/types.ts @@ -738,7 +738,10 @@ export interface Channel< */ threads(): AsyncIterable>; - /** Serialize this channel for persistence or cross-process transfer. */ + /** + * Serialize the channel to a plain JSON object. + * Use this to pass channel data to external systems like workflow engines. + */ toJSON(): SerializedChannel; } @@ -945,7 +948,10 @@ export interface Thread, TRawMessage = unknown> */ subscribe(): Promise; - /** Serialize this thread for persistence or cross-process transfer. */ + /** + * Serialize the thread to a plain JSON object. + * Use this to pass thread data to external systems like workflow engines. + */ toJSON(): SerializedThread; /**