← All proposals

Regenerate a suggestion

A recipe, not a component: one interactive story that composes the Suggestion Card (single choice), the Button and the PDS Compact Pagination.

Extends a PDS componentOpen in Storybook

proposals/RegenerateSuggestion/HANDOFF.md112 lines · View on GitHub

Handoff: Regenerate a suggestion (recipe)

Rewritten 2026-11-20 against v2.0.0-beta.21 to the lessons template. Facts checked against RegenerateSuggestion.stories.tsx, SuggestionCard.tsx and the package source at beta.21; nothing was checked by eye.

What and why

An agent's suggestion is not always right. This recipe shows how to let people ask for a different one (Regenerate) and still go back to earlier attempts (a pager), using the Suggestion Card's footer slots. 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. 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 request (2026-10-21).
  • Context: context.md

Exploration and decisions

  • A recipe, not a story of the card: it adds no prop or class to the Suggestion Card (it fills actionsStart and actionsEnd), and the same pattern would apply to other things an agent offers.
  • Regenerate is a secondary Button with the rotate icon in actionsStart, in its working state (isWorking, label "Regenerating") while the agent replies. The new set replaces the rows and the view jumps to it.
  • Browsing: once there is more than one set, the package PaginationCompact (pageControlType='static', itemsPerPage={1}, "1 of 2") sits in actionsEnd. Each set keeps its own selection.
  • The screen owns the sets, the selection and what Regenerate does. The sample's replies are scripted (a 1.2 second setTimeout, three headline sets that cycle: after the third, the first set repeats). One story: Interactive.

Full list: decisions.md.

API

None, recipe: no props, types or defaults of its own. The composition is below.

Variants and states shown by the one story: one set (no pager); regenerating (Regenerate in its working state, disabled); two or more sets (pager shown, each set with its own selected radio); Suggestion Card pending, accepted (statusLabel "Done") and dismissed (statusLabel "Dismissed").

What it composes and how

  • Suggestion Card (type='choice', title, description, state, statusLabel, actionsStart, actionsEnd), with SuggestionChoice rows (selectionType='radio', one name per set). See its handoff.
  • actionsStart: three Buttons, in order: Use selected (variant='primary', displayType='icon-start', iconName='check'), Regenerate (variant='secondary', iconName='rotate', isWorking, label "Regenerate" or "Regenerating"), Dismiss (variant='subtle').
  • actionsEnd: the package PaginationCompact (currentPage, onPageChange, itemsPerPage={1}, pageControlType='static', totalItemCount), only when there is more than one set.
  • The story's state (story-only; L9): pages, page, picked (one selection per set), isRegenerating, state, HEADLINE_SETS, the 1.2 second delay.

Tokens used

None, recipe: no CSS of its own, no --pds-* token used by the recipe (the Suggestion Card, Button and Pagination bring their own). Custom CSS variables: none. Net-new classes: none. Raw values kept: none.

Impact

From impact.md: no existing PDS component is reached and no --pds-* token is redefined. No other proposal depends on this recipe.

Reused vs net-new

  • Reused, from the package (beta.21): Button (isWorking, disableWhenWorking; the story imports the local copy ../_base/Button/Button, which the port replaces with the package one), PaginationCompact.
  • Reused, from another proposal: SuggestionCard and SuggestionChoice (ready-for-dev).
  • Net-new: none, recipe. See custom.md.

Accessibility

a11y panel not run; light and dark not checked by eye; keyboard not tested in a browser. What the code does:

  • Regenerate is a real button. While it works it is disabled (the package Button's disableWhenWorking defaults to true) and its label changes to "Regenerating". The package Button sets no aria-busy.
  • The pager is PaginationCompact in static mode: a nav named by a visually hidden heading, previous and next buttons with labels, and the visible text "1 of 2" with a visually hidden "Page" before it. (The old handoff said the text was "Page 1 of 2"; only "1 of 2" is visible.)
  • The Suggestion Card's result line sits in a role='status' region and is read when the card is accepted or dismissed. Nothing announces a change of set: the rows are replaced and the pager text changes, but no status text says so.
  • Focus: not handled. A disabled button can lose focus while working; where focus goes after the new set arrives is not managed in the story. Not tested.
  • Not checked: whether the choice rows are non-interactive after the card is accepted or dismissed.

Decisions and open questions

Each carries a recommendation (the designer decides).

  • Is the footer the right place for the pager, or should it sit in the header at the right of the title? That would need a header slot on the card. Recommendation: keep it in the footer (actionsEnd); the card stays unchanged and the recipe is the only thing that knows about the pager.
  • Should the change of set be announced (for example "Set 2 of 2")? Recommendation: yes. Add a visually hidden role='status' text owned by the screen, the way the Chat with an agent recipe announces "Refining <title>", and keep focus on the Regenerate or the pager button that was used.
  • Does an accepted card keep the pager, so the history can still be browsed? Facts: the Suggestion Card hides actionsStart when resolved but still renders actionsEnd, and the story always passes the pager when there is more than one set, so the pager stays after Accept and Dismiss. The story does not record which set was accepted. Recommendation: keep the pager after Accept so history can be read, but show which set was accepted (the screen's state), and do not let Regenerate run on a resolved card.
  • What does Regenerate do on a dismissed or accepted card? In the story the buttons go away with the state (actionsStart is not rendered when resolved). Recommendation: nothing; Regenerate is a pending-state action only. If Undo exists (as in the Chat with an agent recipe), Regenerate returns with the pending state.

Extension or new component

None, recipe: not a component, no L1 question. It adds nothing to the Suggestion Card, the Button or the Pagination; it uses their existing slots and props.

Footprint

  • The recipe draws nothing outside its box.
  • Both footer slots live in the Suggestion Card's actions row: actionsStart at the start and actionsEnd at the end, and the row wraps on a narrow card (per suggestion-card.css). Three buttons plus the pager are the widest case; how it wraps was not checked.
  • The pager's nav is labelled by a fixed id (pagination-compact) in the package, so two pagers on one page would share a heading id. Not checked in a browser.
  • Next-to-neighbors check: not done.

Dark mode and per-size values

None, recipe: no values of its own. Single size: the Suggestion Card's default button size (xs) is set on each footer Button by the story (buttonSize was removed 2026-11-20); the pager has no size prop. No per-theme override; everything comes from the composed components' tokens. Not checked by eye in either theme.

Expect to change

Recommended answers, so the engineer can agree quickly:

  1. A Button label that changes while working ("Regenerate" to "Regenerating", plus isWorking). The Button keeps its label in one text node and puts the spinner in a separate slot, so page translation is not at risk. Recommendation: keep; the spinner already shows the state, so the label change is optional.
  2. Pager state in the screen, not the card (pages, page, picked). Recommendation: keep; this is the point of the recipe.
  3. PaginationCompact for sets ("1 of 2" is read as pages, not as "attempts"). Recommendation: keep the package component; if the wording matters, use labelStrings (it takes of, page, next, previous) rather than a new component.
  4. No announcement of a set change (above). Recommendation: add the status text; screen-reader text stays a top-level string owned by the screen (L3), never inside another component's props.
  5. Looping sample sets (HEADLINE_SETS repeats after three). Story-only; the engineer drops it.

Target-version check

Checked against .pds-reference/src at v2.0.0-beta.21.

Item In beta.21?
Button isWorking, disableWhenWorking, displayType='icon-start', variant primary, secondary, subtle yes (Button.tsx); subtle is also used by the Chat with an agent recipe
PaginationCompact currentPage, itemsPerPage, onPageChange, totalItemCount, pageControlType (dropdown, input, static), labelStrings yes
Icon rotate, check yes
SuggestionCard, SuggestionChoice no (proposal)

CHANGELOG.mdx has no entry about a regenerate pattern.

Port notes

Nothing to port. Port the Suggestion Card (and its dependencies, see docs/PORT-ORDER.md), then copy the composition from the story. The recipe uses the package's Button and PaginationCompact as they are. Swap the story's local Button copy for the package one. For a recipe, keep tags: ['!manifest'] on the story if its variants are not useful alone, and do not put it on the .mdx <Meta>.

Preview

npm run storybook, story Recipes / Regenerate a suggestion (Interactive; Usage page Usage). Figma: none.