---
id: portfolio.ds.chat
name: "Chat"
type: component
status: active
relations: [{"type":"composes","target":"portfolio.ds.homepage-hero"},{"type":"composes","target":"portfolio.ds.chat-message-list"},{"type":"composes","target":"portfolio.ds.chat-composer"},{"type":"supersedes","target":"portfolio.ds.chat-old"},{"type":"uses_token","target":"portfolio.ds.primitive-scale"},{"type":"uses_token","target":"portfolio.ds.focus-interaction-states"}]
sources: ["packages/design-system/src/components/Chat.astro","apps/portfolio-site/src/design-system/docs/chat.astro","apps/portfolio-site/src/lib/designSystemRegistry.ts","packages/design-system/src/components/chat-controller.ts","packages/design-system/src/components/chat-contract.ts","apps/portfolio-site/src/components/DummyChat.astro","apps/portfolio-site/src/components/routes/HomeRoute.astro"]
catalog: ["apps/portfolio-site/src/design-system/docs/chat.astro"]
previews: ["apps/portfolio-site/src/design-system/docs/chat.astro"]
---
# Chat

## Purpose
The conversation composition used by the Homepage and catalog previews.

## Contract
- In the catalog, Chat is a child of Templates > Chat Page Template below the separator. Chat Message List and Chat Composer remain its direct menu children.
- Homepage Hero is the first child of the scroll surface, before Chat Message List. Its optional `heroQuestion` text comes from the host; the catalog uses the Hero default. It stays outside the live log and conversation history, including after sending or resetting. Chat Composer remains in its own overlay.
- Chat has no usable composer until a host attaches an adapter. The cloud homepage uses the same-origin Digital Twin endpoint. Normal dev and catalog examples use a deterministic fixture; the authenticated localhost preview attaches the private backend to its selected surface. A non-cloud static homepage has no adapter. Chat neither selects a provider nor substitutes a demo reply.
- A host can supply localized starter questions and a group label through `suggestions`. Chat Message List renders them outside the live log. They are disabled until an adapter is available; activating one sends its label through the same flow as a typed question. The group is hidden once the conversation starts and returns on reset to an empty conversation.
- A successful reply may supply three related follow-up questions. The latest group appears below the answer, outside the live log. Sending any question dismisses the group. Generating suggestions never sends them; only a chosen label enters the transcript, as an ordinary user message.
- A host may set `replyPresentation.linkPaths` to opt into formatted assistant answers. Only the first validated text block is formatted; the remaining source labels, user text and history stay literal. Without this option, replies stay plain.
- An application may provide visible copy in the optional `composer-status` slot or associate a visible description outside the Composer with Text Input through `inputDescriptionId`. HomeRoute leaves `inputDescriptionId` unset, and the catalog preview renders no product notice.
- Chat measures the live dock so messages remain reachable above the overlaid Composer.
- Dock resizing does not follow the bottom while the input is focused. This keeps the reading position stable while a draft grows; send and answer-start scrolling retain their explicit behavior.
- When the mobile keyboard shrinks the conversation viewport at the end of a conversation, keep the last message visible above Composer. Opening or resizing the keyboard while reading earlier messages preserves the reading position. This is a viewport adjustment, not a follow-on-every-keystroke rule.
- HomeRoute opts in to visual viewport fitting for the focused input. Chat does not resize the page shell for pinch zoom, change the scroll owner or clear the draft.
- Standard Chat and Chat Page Template previews mount one empty conversation fixture. They do not expose page-content variants.
- Registers the canonical `ds-chat` element backed by `ChatElement`. Request validation, adapter injection, history, optional host-configured loading time, answer-start scroll, retry, cancellation and disposal remain shared behavior.
- Chat owns a full-height internal scroll surface. Hero receives the measured Composer height through its arrow inset prop. An empty transcript adds no second bottom clearance. Once messages or suggestions appear, the scroll surface reserves the dock height plus `--primitive-space-12` so they remain reachable above Composer.
- Without an adapter/JavaScript any supplied messages remain readable and sending remains disabled. No model, provider key or project knowledge is built into the component.
- The scroll surface reserves the height released by the template Header (`--header-container-scroll-offset`) above the messages. Each pixel of scrolling moves the messages one pixel on screen, even while the Header changes height. The scroll range and clearance above the Composer stay stable. Standalone Chat has no Header and uses zero top padding.
- Props, states and abstract Preview content retain the conversation contract; spacing follows the owner-requested refinements. Parent previews must not invent product copy or override child-owned layout and states.

## Use
- Inspect and refine the canonical conversation UI in the standard Design System Preview.
- Reuse the existing adapter protocol without making paid requests from a component Preview.

## Do Not Use
- Do not embed a provider, knowledge source or hard-coded product copy inside Chat.
- Do not fork global tokens or treat archived acceptance as verification of the current component.
- Do not duplicate Header's shared child components or global primitives as part of the chat-specific branch.

## Accessibility
- Preserve the original native semantics, accessible names, keyboard behavior, disabled/read-only states and Reduced Motion rules.
- Physical mobile keyboard and assistive-technology behavior still require separate review.

## Verification
- Check available Preview states, wrapping and geometry.
- Test template composition, send/pending/reply, cancellation/retry, long history and scroll without duplicate initialization.
- Validate registry routes, child imports, Essence graph and production build.

## Enabled Profile Records
- Registry ID: chat.
- Canonical route: /design-system/chat/.
- Media: no new source or delivery assets.
- Release scope: Homepage and Design System integration.
