Streaming Partial streams
Partial streams
connectPartialStream is for sources where a single row grows over time, like token-streamed assistant replies.
Use connectPartialStream when a single row grows over time. The canonical case: an assistant chat row whose content field accumulates token by token; tokens and latencyMs updated each chunk.
Signature
function connectPartialStream<
TRow extends Record<string, unknown> & { id: string },
>(
grid: GridLike<TRow>,
stream: AsyncIterable<Partial<TRow>>,
options: PartialStreamOptions,
): StreamConnection;
interface PartialStreamOptions {
rowId: string;
}Each yielded Partial<TRow> is merged into the row keyed by options.rowId via applyTransaction.update. The row must already exist (call applyTransaction.add once before connecting, or seed it through your engine state).
Recipe — chat completion
import { connectPartialStream } from "@pretable/stream-adapter";
// Seed the row first.
grid.applyTransaction({
add: [
{ id: "msg-001", role: "assistant", content: "", tokens: 0, latencyMs: 0 },
],
});
connectPartialStream<ChatRow>(
grid,
openai.responses.stream({ model: "gpt-5", input: prompt }),
{ rowId: "msg-001" },
);Each chunk's Partial<ChatRow> (whatever fields it carries — typically content deltas accumulated client-side) is merged into the seeded row. The grid's selection, scroll position, and focus state stay anchored to that row across every patch.
Lifecycle
Same as connectElementStream — done resolves when the iterator finishes, dispose() stops consuming early.
When you have raw JSON
If your source emits raw JSON strings (e.g. a single object whose keys arrive over time), pipe through parsePartialStream first. See Parsers →.