Skip to content

Elements

Every <aparte-*> custom element, generated from the source. Attributes, events and descriptions come from the components’ JSDoc; this page can’t drift from the code.

AparteChat - The Shell

The container element for a chat. Wrap a <aparte-chat-viewport> and a <aparte-composer> in it and it lays them out as a flex column — the viewport grows and scrolls, the composer sits below. Provide your own children for full control (custom composer, extra buttons), or leave it empty and it fills in a sensible default composition. Uses Light DOM for global CSS styling.

Being a component (not a bare <div>), it also owns behaviour a wrapper div can’t: with center-empty, it watches its own viewport and keeps the composer centered as a welcome state until the first message, then slides to the normal layout — no external JavaScript.

Presentational only: it does NOT wire a transport/client. Attach an AparteClient, or handle aparte-send yourself, as with the primitives. Size the element via CSS (a height, or let it fill a sized parent).

AttributeDescription
placeholderPlaceholder for the composer input (default composition)
disabledDisables the composer
center-emptyCenter the composer as a welcome state until the first message, then slide to the normal layout
PropertyTypeDescription
viewport (readonly)AparteChatViewport | nullThe message viewport (yours or the default), or null before connect.
composer (readonly)AparteComposer | nullThe composer (yours or the default), or null before connect.

AparteChatViewport - The Core

Container component with smart scroll, streaming, and segment support. Uses Light DOM for global CSS styling.

AttributeDescription
scroll-threshold
max-rendered-bubbles
max-messages
MethodDescription
configure(config: AparteViewportConfig): voidConfigure viewport with options
appendToken(messageId: string, chunk: string): voidAppend a token chunk to a message’s content (simple text streaming)
appendToSegment(messageId: string, segmentId: string, chunk: string): voidAppend content to a specific segment within a message
addSegment(segment: AparteSegment): voidAdd a new segment. Two calling conventions are accepted: - addSegment(segment) — AparteClient’s 1-arg “operate on the current (head) message” convention (also what a wrapper host installs); - addSegment(messageId, segment) — explicit standalone form. The first argument’s type disambiguates (string = messageId, object = segment), so a raw viewport driven by AparteClient no longer drops text (the args used to bind one position short, creating a phantom message).
addSegment(messageId: string, segment: AparteSegment): void
addSegment(messageIdOrSegment: string | AparteSegment, maybeSegment?: AparteSegment): void
updateSegment(segmentId: string, updates: Partial<AparteSegment>): voidUpdate a segment. updateSegment(segmentId, updates) (1-arg client convention → current message) or updateSegment(messageId, segmentId, updates) (explicit). Disambiguated by arity: the 3rd arg is absent and the 2nd is the updates object in the 1-arg form.
updateSegment(messageId: string, segmentId: string, updates: Partial<AparteSegment>): void
updateSegment(a: string, b: string | Partial<AparteSegment>, c?: Partial<AparteSegment>): void
removeSegment(segmentId: string): voidRemove a segment. removeSegment(segmentId) (1-arg client convention → current message) or removeSegment(messageId, segmentId) (explicit).
removeSegment(messageId: string, segmentId: string): void
removeSegment(a: string, b?: string): void
startSegment(messageId: string, segment: AparteSegment): voidStart a new streaming segment (e.g., thinking or code block) Creates the segment and marks it as streaming
completeSegment(messageId: string, segmentId: string): voidComplete a streaming segment
setUsage(messageId: string, usage: AparteUsage): voidPersist token usage on a message and propagate to the live bubble so the perf chip (tokens/sec) renders in the action bar.
completeMessage(messageId: string): voidMark a message as finished streaming
updateMessage(messageId: string, updates: Partial<AparteMessage>): voidAtomic update for a message by ID Supports updating content, status, segments, and other metadata
addMessage(message: AparteMessage): voidAdd a complete message to the message registry.
appendMessage(message: AparteMessage): voidAppend a new message and create its bubble in the DOM. Implements the same contract as the Angular wrapper’s appendMessage(), making aparte-chat-viewport a fully standalone target for aparte-client. When _frameworkManagedDOM is true, only the internal repo is updated — the framework owns the DOM and will create the bubble element itself.
updateLastMessage(content: string, options?: { append?: boolean }): voidUpdate the last message content, optionally appending. Implements the same contract as the Angular wrapper’s updateLastMessage(),’ making aparte-chat-viewport a fully standalone streaming target for aparte-client.
addBranch(messageId: string): voidAdd a new sibling branch to an assistant message (retry flow). Creates a new empty assistant message as a sibling of messageId under the same parent, switches the active branch to it, and re-renders the active path.
addSiblingOf(existingId: string, newMessage: AparteMessage): string | nullAdd a new message relative to existingId, switch to it, and re-render. Role-aware semantics: - existingId is an assistant message → create a sibling (same parent), so the active path replaces the old response with the new one. - existingId is a user message → create a child of that message, so the user message stays on the active path and the new response follows it. Returns the new message’s ID, or null if existingId is not found.
navigateBranch(messageId: string, direction: 'prev' | 'next'): voidNavigate to the previous or next sibling branch of a message. Triggers a full re-render of the active path.
truncateResponsesAfter(userMessageId: string): voidRemove ALL responses to a user message (every child branch) and set head back to userMessageId. Cleaner than truncateFrom for edit flows: it discards stale sibling branches so the regenerated response starts alone.
truncateFrom(messageId: string): voidRemove all messages from messageId onwards (inclusive) from state and DOM. Used by edit to truncate history before re-generating.
getMessage(messageId: string): AparteMessage | undefinedGet a message by ID
getMessages(): AparteMessage[]
exportTree(): ExportedMessageRepositoryExport the full conversation tree (all branches, not just the active path). The returned snapshot can be persisted and restored via importTree().
importTree(tree: ExportedMessageRepository): voidImport a previously-exported tree snapshot, restoring the full branch topology and the active head. Replaces any existing repo content. Always calls _reRenderActivePath(): - In native DOM mode: rebuilds bubble elements. - In framework-managed mode: skips DOM manipulation but dispatches aparte-path-changed with sibling metadata so the wrapper can update branch arrows on already-rendered bubbles.
clearAll(): voidClear all messages and remove all bubble elements from the DOM. Also dispatches a aparte-reset-done event. In framework-managed mode the DOM is owned by the host framework (Angular
clearMessages(): voidClear all messages
setMessages(messages: AparteMessage[]): voidReplace the entire message list in one shot. Used when switching conversations: clears existing repo + DOM, then appends each message. In framework-managed mode the framework re-renders the bubble DOM itself; we only update the internal repo (used by aparte-client to build chat history).
scrollToBottom(): voidScroll to bottom of viewport
resetSpacer(): voidReset the bottom spacer to 0 height immediately and freeze it for 350 ms so the host-app layout transition (e.g. flex: 0→1 animation) does not trigger a premature recalculation with mid-animation geometry. Call before a full messages swap.
setAutoScroll(enabled: boolean): voidEnable or disable auto-scroll
setFrameworkManagedDOM(managed: boolean): voidSignal that a framework (e.g. Angular) manages the bubble DOM. When true, branch navigation dispatches aparte-path-changed without clearing/rebuilding the messages wrapper — the framework re-renders instead.
requestSmoothScroll(): voidRequest that the next auto-scroll triggered by a DOM mutation uses smooth behaviour instead of instant. Call this just before adding a user message bubble so the viewport animates down rather than jumping. Resets automatically after the first auto-scroll fires.
EventDescription
aparte-segment-update
aparte-reset-done
aparte-path-changed
AttributeDescription
placeholderForwarded to aparte-composer-input via event
disabledDisables the whole composer
targetID of the target element
PropertyTypeDescription
value (readonly)string
streaming (readonly)boolean
disabled (readonly)boolean
submitOnEnter (readonly)booleanWhen false, Shift+Enter submits and a bare Enter inserts a newline — the inverse of the default. Driven by the submit-on-enter attribute.
attachments (readonly)File[]
placeholder (readonly)string
targetId (readonly)string | null
panelActive (readonly)boolean
MethodDescription
getState(): AparteComposerStateSnapshot of the composer’s observable state. Pair with the aparte-composer-change DOM event to drive a custom send button or footer control that lives outside the composer package:
setValue(value: string): void
addAttachments(files: FileList | File[]): void
removeAttachment(file: File): void
clearAttachments(): void
showPanel(panel: HTMLElement, options?: { submitEnabled?: boolean; onSubmit?: () => void }): voidInject a panel into the composer, hiding the text input. The send button calls onSubmit when clicked.
hidePanel(): voidRemove the panel and restore the text input.
setPanelSubmitEnabled(enabled: boolean): voidUpdate the send button enabled state while a panel is active.
submit(): voidSubmit the current value. Called by aparte-composer-send or programmatically.
cancel(): voidCancel the current streaming response.
reset(): voidReset the composer to its initial state. Clears value, attachments, and hides any active panel. Call this when switching conversations.
focus(): voidFocus the input primitive inside this composer.
EventDescription
aparte-sendFired when a message is submitted
aparte-cancel
aparte-composer-change

AparteChatBubble - The Render

Message component supporting both simple content and rich segments. Uses Light DOM for global CSS styling.

AttributeDescription
role
data-role
content
timestamp
message-id
streaming
name
MethodDescription
appendToken(chunk: string): voidAppend a token chunk (for streaming)
setContent(content: string): voidSet content directly
getContent(): stringGet current content
setSegments(segments: AparteSegment[]): voidSet segments for rich content
addSegment(segment: AparteSegment): voidAdd a segment
updateSegment(segmentId: string, updates: Partial<AparteSegment>): voidUpdate a specific segment
appendToSegment(segmentId: string, content: string): voidAppend content to a segment
getSegments(): AparteSegment[]Get all segments
removeSegment(segmentId: string): voidRemove a segment by id (e.g. to discard a transient waiting indicator)
setAttachments(attachments: AparteAttachment[]): voidSet attachments (chips shown above message content, user role only)
setUsage(usage: AparteUsage | null | undefined): voidSet token usage + timing for this message (assistant only). Renders the info (“i”) action in the action bar; clicking it opens the app-owned stats popover (aparte-message-info).
setSiblings(count: number, index: number): voidUpdate the branch picker UI for tree-based navigation. The viewport calls this after a branch switch or re-render. Prev/Next clicks dispatch aparte-branch-navigate (bubbles: true) so the viewport can handle the actual tree switch.
updateMessage(updates: Partial<AparteMessage>): voidAtomic update for the message
EventDescription
aparte-attachment-preview
aparte-branch-navigate
aparte-action
aparte-retry
aparte-feedback
aparte-message-info
aparte-edit
AttributeDescription
visible
text
MethodDescription
show(): voidShow the typing indicator
hide(): voidHide the typing indicator
toggle(): voidToggle visibility
isVisible(): booleanCheck if visible
AttributeDescription
active-id
PropertyTypeDescription
conversationsAparteConversationListItem[]Set the list of conversations to display. Triggers a re-render.
AttributeDescription
iconIcon key for AparteConfig.getIcon(), or raw SVG/HTML starting with <
labelAccessible label (also used as tooltip)
disabledDisables the button
EventDescription
aparte-action-clickBubbles up when the button is clicked detail: { actionId: string, composer: AparteComposer | null }
SlotDescription
defaultOptional: override button content entirely
AttributeDescription
acceptMIME types / extensions passed to the file input (e.g. “image/*,.pdf”)
multipleAllow multiple file selection (default: true)
disabled
EventDescription
aparte-attachment-preview
AttributeDescription
placeholderPlaceholder text (fallback: reads from aparte-composer)
max-heightMax height in px before scroll (default: 200)
min-heightMin height in px. When omitted, the stylesheet’s min-height governs (44px in aparte.css) — so themes can resize the editor in pure CSS without being fought by an inline height.
disabled
MethodDescription
getValue(): string
setValue(value: string): void
clear(): void
focus(): void
blur(): void
focusEnd(): voidFocus the editor and place the caret at the very end of its content.
EventDescription
aparte-composer-submit

AparteOptgroup

Option group element for aparte-select dropdown.

AttributeDescription
labelGroup label
collapsibleAllow collapse/expand
collapsedCollapsed state
loading
PropertyTypeDescription
labelstring
collapsible (readonly)boolean
collapsedboolean
loadingboolean
EventDescription
aparte-optgroup-toggle

AparteOption

Option element for aparte-select dropdown.

AttributeDescription
valueOption value
disabledDisabled state
selectedSelected state
data-status
PropertyTypeDescription
valuestring
label (readonly)string
disabledboolean
selectedboolean

AparteProgressSpinner

Circular progress spinner web component.

  • Indeterminate (no value attribute): continuous rotation animation
  • Determinate (value="0–100"): fills the arc proportionally
AttributeDescription
valueProgress percentage 0–100 (omit for indeterminate)
AttributeDescription
value
placeholder
disabled
grouped
searchable
open
PropertyTypeDescription
valuestring
openboolean
EventDescription
aparte-select-open
aparte-select-close
aparte-select-change