Handoff: Chat with an agent (recipe)
Rewritten 2026-11-20 against v2.0.0-beta.21 to the lessons template. Facts checked against ChatWithAgent.stories.tsx, chat-with-agent-story.css and the current proposals it composes; nothing was checked by eye.
What and why
The pieces of an AI chat (Chat Panel, Composer, Chat Message, Chain of Thought, Suggestion Card, Code Diff, Feedback Bar and more) are proposed one by one. This recipe shows them working together, from the empty state to a conversation, so the flow can be judged and the parts can be put together the same way. It is a recipe, not a component: a story and a Usage page that compose existing components. It has no API, class, token or CSS of its own that needs porting. There is nothing to port beyond the components it uses (below). The engineer copies the composition and keeps the story as documentation.
- Figma / Jira: none. Source: the designer's chat reference screenshots and direction (2026-10-19). The wording and the scripted replies are made-up samples.
- Context:
context.md
Exploration and decisions
- A recipe, moved out of Chat Panel. It started as the
With Sample Contentstory of Chat Panel. It is the whole chat experience, not the panel, so it lives here next toEvent log with agent. - The sample is scripted. Three exchanges repeat (a dependency check ending in a Suggestion Card with a Code Diff, a commit, a multidev), plus a fourth reply to Refine. Steps tick every 0.9 seconds (
STEP_MS) and the thanks text fades back to the thumbs after 4.5 seconds (THANKS_MS). All timing and state live in the story, because the screen owns them, not a component. - Refine uses the Composer's
aboveFieldslot. Context the next message applies to: a bar above the input reading "Refining: 2 changes (composer.json, pantheon.yml)" with a dismiss button. A branch bar that follows the agent's work was considered and not built (passive; the header already shows context). - Full screen and history removed. The expand button, full-screen layout and conversation list were dropped (designer: not needed for now). The chat is the drawer only. If full screen returns, use the PDS
FullScreenOverlay. - Scrolling is the Chat Panel's. The story's own scroll-to-end code was replaced by
hasScrollToLatestandhasContentFade, so the view follows the end only while the person is at the end. - Helper text and the Review dot are off.
SHOW_HELPER_TEXT(a story-only constant) isfalse, and Review has no dot.
API
None, recipe: no props, no types, no defaults of its own. The composition is below. The recipe's inputs are the props of the components it composes, so port those first.
Variants and states shown by the one story (Interactive): empty state (default-size Composer, no footer); conversation (compact Composer in the footer); agent working (Chain of Thought open, Send in isWorking); agent done (Chain of Thought collapsed, "Thought for N seconds"); Suggestion Card pending, accepted and dismissed; Refine active (context bar above the input); files dropped (chips in the Composer's fieldHeader); feedback given (thanks text, then thumbs with the choice pressed).
What it composes and how
One Chat Panel docked as a drawer (size='m', the default).
Chat Panel (ChatPanel, proposal)
title: the packageIdentityBlockwithisAgent,agentLabel='Agent',primaryText='Zappy',secondaryText='Pantheon AI'.headerwithheaderInset='none': a summary row (packageStatusIndicatortype='warning'"3 awaiting review" with anarrowRighticon), two context rows (EventLogItemsize='xs': "Reading: entire site" withglobe, and "Editing:" withpen, a packageTagand a subtle packageButton"Add page"), and a packageSegmentedButton(Compose / Chat / Review,size='m',defaultValue='chat'). Only Chat is built; the Chat Panel does not know about the switch.footer: absent on the empty state; the compact Composer once there is a conversation.onFilesDrop+dropLabel,hasScrollToLatest+scrollToLatestLabel,hasContentFade. Not passed:hasCloseButton,closeButtonLabel,onClose(see Decisions and open questions).
Empty state: package VerticalEmptyState (image is the messages icon at 4xl, imageHeight='auto', headingLevel='h2', a message node), with the default-size Composer in the same centered group (a flex column, gap xl).
Composer (Composer, proposal; the same story-only SampleComposer in both places)
variantdefault on the empty state,compactin the footer; the footer one takes focus when it appears (textareaProps.autoFocus).actionsStart: an icon-onlyMenuButton(iconName='plus',iconOnly,size='s',label='Add', one menu item "Add photos & files").actionsEnd: aSelectwithvariant='bare'as the model picker (label='Model'), anIconButtonfor voice (microphoneLines), and Send, anIconButtonwithiconName='paperPlane',variant='primary'andisWorkingwhile the agent works.fieldHeader:ChatAttachmentchips for dropped files.onFilesDropanddropLabelare given to the Composer as well as the Chat Panel.aboveField: the Refine context bar (below).- Enter sends, Shift+Enter adds a line (
textareaProps.onKeyDown).
The agent's turn (ChatMessageList of ChatMessages; the user's message is sender='user', label='You'; the agent's is label='Zappy')
- A
ChainOfThoughtwithexpandWhenActiveandisActivewhile working,label"Working..." while running, then one finished label such as "Thought for 4s" (noshowTimerortimeonce finished, since 2026-11-20). Its steps areEventLogItems withstatusactivefor the current one anddonefor earlier ones, some withsecondaryText. The packageThinkingStateis rendered insideChainOfThought. - The reply sits under it. A reply that proposes changes ends with a
SuggestionCard(statepending / accepted / dismissed,statusLabel) whose child is the Code diff recipe (CodeDiffSample, story-only helper). Accept, Refine and Dismiss areButtons inactionsStart; after Accept theFeedbackBaris inactionsEnd; after Dismiss, an UndoButtonis inactionsEndand takes focus. - Replies 2 and 3 (the commit and the multidev) get a
FeedbackBarunderneath. The reply with a Suggestion Card has its feedback in the card instead. The thanks text (statusLabel) replaces the thumbs for a few seconds, then the thumbs return with the choice pressed.
Screen decisions the recipe makes
- The input moves from the empty state to the footer on the first send.
- Chain of Thought is open while working and collapsed when done.
- Refine puts the context bar in
aboveField, moves focus to the input and announces "Refining <title>" in a visually hiddenrole='status'region next to the Composer. Sending clears the bar, adds a "(Refining: <title>)" line to the user's message, and the agent replies with a narrowed Suggestion Card. Dismissing the bar is anIconButtonwithariaLabel='Stop refining'. - Which replies get thumbs, and the timing of the thanks text.
What the screen owns (not a component): the turns and the script, step timing, the model choice, the dropped files, the Refine state, the Suggestion Card's accepted/dismissed state, the feedback choice and thanks timing, and moving focus.
Story-only (do not port; L9): SampleChat, SampleComposer, SampleFeedback, SampleSuggestion, RefineContext, SCRIPTS, MODELS, VIEWS, SHOW_HELPER_TEXT, HELPER_TEXT, STEP_MS, THANKS_MS, the scripted wording, and chat-with-agent-story.css (the frame with the drawer shadow, the summary and rows spacing, the rule above the view switch, the empty-state group, the reply spacing, the Refine bar). CodeDiffSample is the story-only helper of the Code diff recipe.
Tokens used
From chat-with-agent-story.css as it is now. The recipe has no component CSS, so these are story-only layout, not for porting:
--pds-border-width-default--pds-color-badge-silver-muted-background--pds-color-badge-silver-muted-foreground--pds-color-border-default-secondary--pds-color-foreground-default--pds-color-foreground-default-secondary--pds-color-surface-default-secondary--pds-elevation-drawer-right--pds-spacing-2xl--pds-spacing-2xs--pds-spacing-s--pds-spacing-xl--pds-spacing-xs--pds-typography-size-xl
Also read, not defined: --chat-panel-inset (the Chat Panel's own variable, used for the story's header rows). Overridden, not defined: --button-height, --tag-bg, --tag-fg (other components' variables). The badge-silver-muted tokens are package tokens and exist in the light and dark token files at beta.21; the Badge proposal itself was retired, so only the tokens matter here. Net-new classes: none. Raw values kept: none. Token check not rerun in this pass.
Impact
From impact.md:
- Nothing reaches existing components. Its CSS is scoped to its own
chat-with-agent-story__*classes. - Opt-in overrides only inside the story: Empty State heading and text, Segmented Button width, Icon margin, Button height, Tag colors.
- Does not redefine any
--pds-*token. - No other proposal imports or uses it.
- It depends on the components below, and changes to them change what the story shows.
Reused vs net-new
- Reused, from the PDS package (beta.21):
FlexContainer,IdentityBlock(withisAgentandagentLabel),SegmentedButton,StatusIndicator,Tag,ThinkingState(inside Chain of Thought),VerticalEmptyState, and, behind the story's local copies,Button(_base/Button, used for Add page, Accept, Refine, Dismiss and Undo) andMenuButton(_base/MenuButton). The port uses the package ones. - Reused, from other proposals (all
ready-for-devexcept where noted; each handoff is../<Name>/HANDOFF.md): ChainOfThought, ChatAttachment, Composer, ChatMessage (andChatMessageList), ChatPanel, the Code diff recipe, EventLog (EventLogItem), FeedbackBar, Icon (addsmicrophoneLines), IconButton (variant='primary'andisWorkingare Send; taggedin-progress, so Send is not ready), Select (variant='bare'), SuggestionCard (itstype='changes'default; thechoicetype is not used here). - Net-new: none, recipe. See
custom.md. ContentDiffis not used by this recipe (the story uses only the Code diff recipe).
Accessibility
a11y panel not run; light and dark not checked by eye; keyboard and focus not tested in a browser. What the code does:
- Keyboard and focus come from the components. Enter sends, Shift+Enter adds a line (
textareaProps.onKeyDown). - On the first send the input moves to the footer and takes focus (
autoFocus). - Refine moves focus to the input. The context bar is announced through a visually hidden
role='status'region ("Refining <title>"); its dismiss button hasariaLabel='Stop refining'. - After Dismiss on a Suggestion Card, focus moves to Undo; after Undo, to Dismiss.
- The Feedback Bar has a group label (
groupLabel) and thumb labels (upLabel,downLabel: "Rate this response", "Good response", "Bad response"); the thanks text is itsstatusLabel. - Dropped files have a drop overlay label (
dropLabel), and each chip has aremoveLabel("Remove <name>"). - The Chain of Thought is native
details/summary(from its proposal). The Scroll to latest button hasscrollToLatestLabel. - Gap in the story: the Chat Panel's built-in close button is on by default (
hasCloseButton = trueinChatPanel.tsx) and the story passes nocloseButtonLabeloronClose, so the button renders without a name or handler. Not checked in a browser.
Decisions and open questions
Each carries a recommendation (the designer decides).
- Is the Compose / Chat / Review switch meant to change the content? Only Chat is built. Recommendation: leave it as a screen decision; the Chat Panel stays unaware of it.
- Story-only overrides of other components (the next four are also in "Expect to change"). Recommendation for each: drop it from the recipe and use the package component as it is.
- The Chat Panel's close button in this story. Recommendation: pass
hasCloseButton={false}, or give itcloseButtonLabelandonClose, in the story. - If full screen returns, use the PDS
FullScreenOverlayfor the overlay and a link or route for the embedded page. - Sample wording, scripts and timings are made up, and the story is not checked in dark.
Extension or new component
None, recipe: not a component, so there is no L1 question. It does use the extension pattern where PDS shipped it: the avatar label on the title is the package IdentityBlock with isAgent and agentLabel, not a new agent component.
Footprint
- The recipe draws nothing outside its own box. The one outside-the-box element is the story's frame shadow (
--pds-elevation-drawer-rightonchat-with-agent-story__frame, story-only; a real drawer owns its own elevation). - The frame is
height: 100vhwithwidth: fit-contentandmargin-inline-start: auto; the Chat Panel scrolls inside it. A parent that does not give the Chat Panel a fixed height will not get the pinned header/footer and inner scroll. Not checked in another parent. - The header rows use
--chat-panel-insetfrom the Chat Panel; a copy that drops the Chat Panel loses that padding. - The empty-state group uses
min-height: 100%and a block-start padding that offsets the Chat Panel's content-fade padding (calc(var(--pds-spacing-2xl) - var(--pds-spacing-s))). That coupling to the fade is story-only. - Component-level footprint (the Chain of Thought, the Suggestion Card's Code Diff, the Feedback Bar's thanks text) belongs to each component's handoff. Next-to-neighbors check: not done in this pass.
Dark mode and per-size values
None, recipe: no values of its own to tune per size. The story's CSS uses one size and no per-theme override; it relies on tokens that switch with the theme. Token values at beta.21, from the package token files (light / dark):
| Token | Light | Dark |
|---|---|---|
--pds-color-surface-default-secondary (summary row) |
oklch(0.9731 0 0) |
oklch(0.2520 0 0) |
--pds-color-border-default-secondary (rule above the switch) |
oklch(0.8761 0 0) |
oklch(0.3329 0 0) |
--pds-color-foreground-default-secondary (empty-state text) |
oklch(0.4778 0.0020 247.87) |
oklch(0.8452 0 0) |
--pds-color-badge-silver-muted-background (Tag trial) |
oklch(0.9430 0 0) |
oklch(0.3329 0 0) |
--pds-color-badge-silver-muted-foreground (Tag trial) |
oklch(0.3211 0 0) |
oklch(0.8452 0 0) |
--pds-elevation-drawer-right (frame) |
-4px 0px 16px 0px rgba(0, 0, 0, 0.08) |
-2px 0px 32px 0px rgba(0, 0, 0, 0.8), -1px 0px 0px 0px rgba(255, 255, 255, 0.12) |
Not checked by eye in either theme. Per-size values of the composed components are in their own handoffs.
Expect to change
Each is a choice in this recipe that the engineer or the PDS team may undo. Recommended answers:
- Full-width Segmented Button (story CSS stretches
.pds-segmented-button,__trackand__option; the package component has no width prop). Recommendation: drop the override; if the design needs full width, ask for a full-width option on Segmented Button as its own request, not through this recipe. - Neutral Tag color (
--tag-bgand--tag-fgset to thebadge-silver-mutedtokens; the CSS comment calls it a trial). The package Tag has 13 muted colors (the story passestagColor='slate') and no neutral one named as such. Recommendation: drop the override and use a package color (stoneorslate); which looks right is not checked by eye. - 24px "Add page" Button (
--button-height: var(--pds-spacing-xl)). The package Button's smallest size isxs, 28px (--pds-spacing-button-height-xsis1.75rem). Recommendation: drop the override and keepsize='xs'. - Empty-state heading in
xland apds-copy-xsdescription in the secondary color (story CSS;VerticalEmptyStatehas no heading size prop, and its heading is2xl). Recommendation: drop the override and use the package look. - Send is an
IconButtonwithvariant='primary'andisWorking, and the model picker is aSelectwithvariant='bare'. Neither exists in the package at beta.21 (IconButton variants there arestandard,reverse,critical, noisWorking; theSelecthas novariant). Their shapes are decided in their own handoffs, and the IconButton proposal isin-progress. Recommendation: copy whatever shape those ship with; the screen composition does not depend on the names. onFilesDropanddropLabelon both the Chat Panel and the Composer, with the same handler. Recommendation: keep; the panel takes drops anywhere, the composer takes drops on the field.microphoneLinesicon is new (Icon proposal). Recommendation: the Icon handoff's own plan (add a registry entry), not this recipe.- The recipe relies on the Chat Panel's
hasCloseButtondefault (on). Recommendation: see the Chat Panel handoff; default off is the toolkit convention (L2).
Not an issue: screen-reader text in the recipe is top-level props (agentLabel, groupLabel, upLabel, downLabel, statusLabel, removeLabel, scrollToLatestLabel, dropLabel) or a sibling status region, never inside another prop's object (L3).
Target-version check
Checked against .pds-reference/src at v2.0.0-beta.21 (the package installed is 2.0.0-beta.21). CHANGELOG.mdx has no entry for any chat component.
| Item | In beta.21? |
|---|---|
IdentityBlock isAgent, agentLabel |
yes |
ThinkingState |
yes |
Button isWorking, disableWhenWorking, displayType, sizes xs to l |
yes |
MenuButton iconOnly, sizes xs, s, m |
yes |
Tag isRemovable, removeLabel, tagColor (includes slate, stone), sizes xs, s, m |
yes |
SegmentedButton size s, m, l |
yes |
StatusIndicator type (incl. warning) |
yes |
VerticalEmptyState fillHeight, headingLevel, image, imageHeight, message |
yes |
Icons paperPlane, plus, pen, globe, arrowRight, xmark, messages, check, rotate, fileDiff |
yes |
Icon microphoneLines |
no (new; in the Icon proposal) |
IconButton variant='primary', isWorking |
no (variants are standard, reverse, critical) |
Select variant='bare' |
no |
ChatPanel, Composer, ChatMessage, ChatMessageList, ChainOfThought, ChatAttachment, EventLogItem, FeedbackBar, SuggestionCard |
no (proposals) |
--pds-color-badge-silver-muted-*, --pds-elevation-drawer-right |
yes (light and dark token files) |
Port notes
- Nothing to generate and no folder in
pds-toolkit-react. Port the components above first (../../docs/PORT-ORDER.mdhas the recommended order; IconButton must land before Send works), then keep the story and Usage page as documentation of the composition. For a recipe, keeptags: ['!manifest']on the story if its variants are not useful alone; do not put!manifeston the.mdx<Meta>. - The engineer copies the composition: the props and slots above, and the screen decisions. The scripts, timers and sample text are story-only.
- Swap the story's local copies (
../_base/Button,../_base/MenuButton,../Icon/Icon) for the package ones.
Preview
npm run storybook, then Recipes/Chat with an agent (story Interactive; Usage page Usage). Figma: none.