The error segment — a failure, rendered in the conversation
Error segment
A failure card inside the turn that produced it, rather than a toast somewhere else on the page — so the reader can see which question failed.
A segment is data, not an element — it has no tag and dispatches nothing. This one is
AparteErrorSegment, and it is the object you push into a bubble; something else draws it.
Example
Section titled “Example”{ id: 's1', type: 'error', content: 'The model did not answer.', details: 'HTTP 429 — rate limited. Retrying in 20s.',}Discriminated by type: 'error'.
| Field | Type | Required | Description |
|---|---|---|---|
content | string | yes | |
details | string | — | |
stack | string | — |
Shared by every segment
Section titled “Shared by every segment”From AparteSegmentBase, which is also what a segment type of your own extends.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique segment identifier |
type | string | yes | Segment type discriminator |
isStreaming | boolean | — | Whether segment is currently being streamed |
messageId | string | — | Id of the message this segment belongs to. Stamped on insertion. |
index | number | — | Position in the owning message’s segments[], maintained across insertions and removals. |
meta | Record<string, unknown> & { aparte?: AparteSegmentTiming } | — | Extras the producer of the segment knows — token counts, cost, compute device — plus aparte, the one sub-object core writes. More |
Notes on individual fields
Section titled “Notes on individual fields”Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Who emits it
Section titled “Who emits it”An app pushes one with addSegment() on the viewport, or a parser produces it while a
reply streams. Core stamps its identity and timing on insert, so an emitted segment does not
have to carry them.
Who draws it
Section titled “Who draws it”A built-in renderer draws this one, from packages/core/src/renderers/segments/error.ts. It installs itself the first time a
segment of this type needs it, so a chat renders it with no setup.
Replace it with your own for this config only:
import { registerSegmentRenderer } from '@aparte/core';import type { AparteErrorSegment } from '@aparte/core';
registerSegmentRenderer({ type: 'error', render: (segment: AparteErrorSegment) => { const el = document.createElement('div'); el.textContent = JSON.stringify(segment); return el; },});See Customization for the whole renderer seam, and bring your own loop for emitting segments yourself.