← All proposals

Chat with an agent

A recipe, not a component: one interactive story that composes the existing proposals into a chat with an agent, from the empty state to a conversation.

Extends a PDS componentOpen in Storybook

proposals/ChatWithAgent/HANDOFF.md199 lines · View on GitHub

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 Content story of Chat Panel. It is the whole chat experience, not the panel, so it lives here next to Event 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 aboveField slot. 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 hasScrollToLatest and hasContentFade, 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) is false, 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 package IdentityBlock with isAgent, agentLabel='Agent', primaryText='Zappy', secondaryText='Pantheon AI'.
  • header with headerInset='none': a summary row (package StatusIndicator type='warning' "3 awaiting review" with an arrowRight icon), two context rows (EventLogItem size='xs': "Reading: entire site" with globe, and "Editing:" with pen, a package Tag and a subtle package Button "Add page"), and a package SegmentedButton (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)

  • variant default on the empty state, compact in the footer; the footer one takes focus when it appears (textareaProps.autoFocus).
  • actionsStart: an icon-only MenuButton (iconName='plus', iconOnly, size='s', label='Add', one menu item "Add photos & files").
  • actionsEnd: a Select with variant='bare' as the model picker (label='Model'), an IconButton for voice (microphoneLines), and Send, an IconButton with iconName='paperPlane', variant='primary' and isWorking while the agent works.
  • fieldHeader: ChatAttachment chips for dropped files. onFilesDrop and dropLabel are 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 ChainOfThought with expandWhenActive and isActive while working, label "Working..." while running, then one finished label such as "Thought for 4s" (no showTimer or time once finished, since 2026-11-20). Its steps are EventLogItems with status active for the current one and done for earlier ones, some with secondaryText. The package ThinkingState is rendered inside ChainOfThought.
  • The reply sits under it. A reply that proposes changes ends with a SuggestionCard (state pending / accepted / dismissed, statusLabel) whose child is the Code diff recipe (CodeDiffSample, story-only helper). Accept, Refine and Dismiss are Buttons in actionsStart; after Accept the FeedbackBar is in actionsEnd; after Dismiss, an Undo Button is in actionsEnd and takes focus.
  • Replies 2 and 3 (the commit and the multidev) get a FeedbackBar underneath. 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 hidden role='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 an IconButton with ariaLabel='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 (with isAgent and agentLabel), 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) and MenuButton (_base/MenuButton). The port uses the package ones.
  • Reused, from other proposals (all ready-for-dev except where noted; each handoff is ../<Name>/HANDOFF.md): ChainOfThought, ChatAttachment, Composer, ChatMessage (and ChatMessageList), ChatPanel, the Code diff recipe, EventLog (EventLogItem), FeedbackBar, Icon (adds microphoneLines), IconButton (variant='primary' and isWorking are Send; tagged in-progress, so Send is not ready), Select (variant='bare'), SuggestionCard (its type='changes' default; the choice type is not used here).
  • Net-new: none, recipe. See custom.md.
  • ContentDiff is 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 has ariaLabel='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 its statusLabel.
  • Dropped files have a drop overlay label (dropLabel), and each chip has a removeLabel ("Remove <name>").
  • The Chain of Thought is native details/summary (from its proposal). The Scroll to latest button has scrollToLatestLabel.
  • Gap in the story: the Chat Panel's built-in close button is on by default (hasCloseButton = true in ChatPanel.tsx) and the story passes no closeButtonLabel or onClose, 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 it closeButtonLabel and onClose, in the story.
  • If full screen returns, use the PDS FullScreenOverlay for 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-right on chat-with-agent-story__frame, story-only; a real drawer owns its own elevation).
  • The frame is height: 100vh with width: fit-content and margin-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-inset from 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:

  1. Full-width Segmented Button (story CSS stretches .pds-segmented-button, __track and __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.
  2. Neutral Tag color (--tag-bg and --tag-fg set to the badge-silver-muted tokens; the CSS comment calls it a trial). The package Tag has 13 muted colors (the story passes tagColor='slate') and no neutral one named as such. Recommendation: drop the override and use a package color (stone or slate); which looks right is not checked by eye.
  3. 24px "Add page" Button (--button-height: var(--pds-spacing-xl)). The package Button's smallest size is xs, 28px (--pds-spacing-button-height-xs is 1.75rem). Recommendation: drop the override and keep size='xs'.
  4. Empty-state heading in xl and a pds-copy-xs description in the secondary color (story CSS; VerticalEmptyState has no heading size prop, and its heading is 2xl). Recommendation: drop the override and use the package look.
  5. Send is an IconButton with variant='primary' and isWorking, and the model picker is a Select with variant='bare'. Neither exists in the package at beta.21 (IconButton variants there are standard, reverse, critical, no isWorking; the Select has no variant). Their shapes are decided in their own handoffs, and the IconButton proposal is in-progress. Recommendation: copy whatever shape those ship with; the screen composition does not depend on the names.
  6. onFilesDrop and dropLabel on 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.
  7. microphoneLines icon is new (Icon proposal). Recommendation: the Icon handoff's own plan (add a registry entry), not this recipe.
  8. The recipe relies on the Chat Panel's hasCloseButton default (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.md has the recommended order; IconButton must land before Send works), then keep the story and Usage page as documentation of the composition. For a recipe, keep tags: ['!manifest'] on the story if its variants are not useful alone; do not put !manifest on 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.