← All proposals

Chain of Thought

A collapsible list.

Net-new componentOpen in Storybook

proposals/ChainOfThought/HANDOFF.md169 lines · View on GitHub

Handoff: ChainOfThought

Rewritten 2026-11-20 against v2.0.0-beta.21 to the lessons template. Props, defaults, classes and tokens were checked against ChainOfThought.tsx, chain-of-thought.css and the stories as they are now. Nothing here was checked by eye in a session, and the a11y panel was not run.

What and why

A user needs to see what an agent did, and open it up when they want the detail: its reasoning, a web search, tool calls, or plain progress. PDS has nothing for this. This proposal is a collapsible record: a summary line (a Thinking State with a chevron, such as "Thought for 4 seconds") over a list of steps. Each step is a EventLogItem: an optional status icon, a label, quiet secondary text, optional expandable detail, and a slot for any content under it (a log block, file tags, a table). The list itself is a Event Log without the rail.

Chain of Thought builds on two other proposals. It renders the summary with ThinkingState (shipped in PDS beta.18; imported from the package, so there is nothing to port for it), its body is a Event Log and its rows are EventLogItem (../EventLog/HANDOFF.md, written 2026-10-16; AgentStep was renamed to EventLogItem). Event Log and EventLogItem must port with it; the row's API is in that handoff.

  • Figma / Jira: none. Sources were designer screenshots: a tool-call log, a reasoning-and-tools trace, and an agent investigating a failed build.
  • Context: context.md

Exploration and decisions

  • variant: steps (default), reasoning, search and coding. It sets the body: steps is rows with status icons; reasoning is running text; search is a quiet query row with result rows (a bold title and the domain as secondary text) and a quiet "+N more" row; coding is rows with a bold verb, code-font secondary text and +/- diff counts. The rows are EventLogItem, so the body is the consumer's content.
  • Built on native <details>, not ExpansionPanel. ExpansionPanel is a bordered card with a space-between chevron. The references have a borderless, left-aligned summary with the chevron beside the label and a rule down the left of the steps.
  • The summary is rendered by Chain of Thought from label, isActive, time, showTimer and iconName, so the size hierarchy is enforced. The cost is that there is no custom summary.
  • expandWhenActive opens the list while isActive is true and closes it when the agent finishes. The first time the user opens or closes it, the automatic behavior stops for that instance.
  • size: s is a 14px summary over 12px rows; m is 16px over 14px. Rows read the size from the list (EventLog's size, or a pds-copy-* class on the reasoning list).
  • The body is a EventLog. Chain of Thought renders EventLog (no rail) for the list variants, so list semantics belong to the list and a step also works alone inline. It keeps its own rule down the left of the steps. Steps are children, not a data array.
  • Content under a step is a slot (children on EventLogItem), always visible and lined up with the label. detail stays for content that starts collapsed. In the example, a finished step keeps its output in detail (collapsed) and the active step shows its content open.
  • File tags under a step are PDS Tag (tagColor='slate', size='xs'), not Badge: they are objects, not status, and Tag can link and truncate.

API

ChainOfThought

Extends ComponentPropsWithoutRef<'div'>. Props are alphabetical.

Prop Type Default Purpose
children ReactNode none The body. EventLogItem components for the list variants (each is wrapped in a list item), or paragraphs for reasoning.
className string none Additional class names.
expandWhenActive boolean false Open while isActive is true and close when it turns false, until the user toggles it.
iconName AgenticIcon ('sparklesSolid' | 'zappy') none here; ThinkingState uses 'zappy' Icon before the summary label. The shared package type.
isActive boolean false Agent still working: shimmers the label and pulses the icon. Opposite of ThinkingState's default (state='active').
isOpen boolean false Initial open state only (uncontrolled).
label string required The always-visible line that toggles the list. For a finished run, the whole phrase with the duration ("Thought for 4s").
showTimer boolean false Show the live elapsed time. Only renders with time. For a live run only.
size 's' | 'm' 's' Size of the whole block.
time string none Live elapsed time while the agent works, formatted by the consumer. For a live run only.
variant 'coding' | 'reasoning' | 'search' | 'steps' 'steps' What the list shows.

Finished and live wording (changed 2026-11-20). A finished run is one label ("Thought for 4s") with showTimer off. time and showTimer are for a live run only (a ticking value, hidden from screen readers while active). This is how the shipped ThinkingState works (ThinkingState.tsx TSDoc on time). No prop was removed.

The row props (EventLogItem) are in ../EventLog/HANDOFF.md.

Variants and states: steps, reasoning, search and coding; sizes s and m; active, completed and expanded or collapsed; steps with detail, content, secondary text and diff counts; all four step statuses.

Tokens used

From chain-of-thought.css as it is now (type comes from the semantic pds-copy-* classes and from ThinkingState / EventLog, so there are no font-size tokens here):

  • --pds-animation-transition-rotation
  • --pds-border-radius-default
  • --pds-border-width-default
  • --pds-border-width-outline
  • --pds-color-border-default
  • --pds-color-foreground-default
  • --pds-color-foreground-default-secondary
  • --pds-color-interactive-focus
  • --pds-spacing-2xs
  • --pds-spacing-s
  • --pds-spacing-xs
  • --pds-typography-fw-medium
  • --pds-typography-fw-regular

EventLog and EventLogItem add the status and diff colors and the code font; see ../EventLog/HANDOFF.md. Custom variables here: --chain-of-thought-indent, --event-log-gap (set on the list). The earlier handoff also listed --pds-typography-ff-default, --pds-typography-lh-m, --pds-typography-size-s and --pds-typography-size-xs; the CSS no longer uses them (stale since the 2026-10-19 move to pds-copy-*).

Impact

From impact.md: nothing reaches existing PDS components; everything is scoped to pds-chain-of-thought. It depends on the package ThinkingState (shipped), Event Log, EventLogItem, the local Icon and Spinner (the active step uses a monochrome spinner). The example stories use the package's CodeBlock, Tag and FlexContainer.

Reused vs net-new

  • Reused: ThinkingState (summary), EventLog and EventLogItem (body), Icon, Spinner, and in the stories CodeBlock, Tag and FlexContainer.
  • Net-new: Chain of Thought (and, through its body, Event Log and EventLogItem; see their handoff). See custom.md.

Accessibility

  • The summary is a summary inside details, so Enter and Space toggle it natively, and it takes the visible focus ring (--pds-color-interactive-focus). The click handler calls preventDefault and mirrors the open state in React so the chevron rotates; keyboard toggling goes through that same click. Not checked with a keyboard in a session.
  • The summary contains the package ThinkingState, which has role='status'. A live region inside a toggle can announce the label again on a re-render while the agent is active. Not tested with a screen reader. Do not announce the summary twice: keep the label stable while active (change it only when the state changes) and let the details expanded or collapsed state come from the browser.
  • A finished summary is one label, so it reads as one phrase. Do not pass showTimer and time for a finished run: the time is a separate element and the number would be read apart from its label.
  • The list is an EventLog (an ol), so a screen reader announces the number of steps.
  • Each step's status is announced as visually-hidden text (labelStrings, translatable); the active spinner has its own label.
  • Shimmer and pulse on the summary stop under prefers-reduced-motion.
  • The a11y panel was clean on the Event log with agent story, which includes a Chain of Thought, in light (earlier note). It has not been run on the Chain of Thought stories, nor in dark. Run it in both before the port.

Decisions and open questions

Each has a recommended answer (a recommendation, not a decision).

  • Reasoning text. Plain paragraphs now; italic, links and markdown are not handled. Recommendation: leave it to the consumer's content; do not build markdown in.
  • Motion. Steps appear instantly when added. Recommendation: no animation for the first port; add one only if a screen asks.
  • Long lists. No max-height or scroll. Recommendation: no cap until a real screen has dozens of steps; then scroll the list, not the block.
  • Result favicons. Search results use a globe icon; the reference shows each site's favicon. Recommendation: a leading slot on EventLogItem later, not now.
  • "+7 more" is a plain quiet row. Recommendation: keep it plain; a link or button that expands the rest is a separate change.
  • Custom icon on a done step replaces the check, so completion shows only by color and hidden text. Recommendation: keep the hidden text and the color; no extra check.
  • Content when a step finishes. The consumer decides whether it collapses. Recommendation: keep it the consumer's call.
  • Not built: a larger, bolder step style and a header with a metadata line ("Investigation started..."), both from the investigation screenshot. Recommendation: leave out of this port.
  • Stopped runs. Should a stopped run pass through to the summary (stopped state)? Recommendation: yes, later, as a state-like addition once isActive is reconsidered; not needed for the first port.
  • The dark-mode shimmer question from ThinkingState is settled (text-clipped gradient, confirmed 2026-10-19); it applies here unchanged.
  • Convention questions (expandWhenActive, the isActive default, variant, isOpen) are under Expect to change.
  • Which one to use (2026-10-22): the Usage page opens with a TL;DR guide (Chain of Thought, Event Log or Timeline); Timeline is a sibling (../Timeline/HANDOFF.md). Docs only.

Extension or new component

New component, not an extension. The package has no collapsible record: ExpansionPanel is a bordered card with a space-between chevron and a divider (see the <details> decision above), ThinkingState is a non-interactive status line and Timeline is a vertical record people read in order. It reuses ThinkingState for the summary and the proposed EventLog / EventLogItem for the body, so what it adds is the toggle, the rule down the left and the four body variants.

Footprint

  • Nothing draws outside the box. The rule down the left is the list's own border-inline-start; the list is indented by margin-inline-start (--pds-spacing-2xs) and padding (--chain-of-thought-indent, --pds-spacing-s) inside the block.
  • The summary is inline-flex, so only the label, icon and chevron are the click target, not the full row. A parent that expects a full-width toggle will find a small one.
  • When closed, the block is only the summary line; when open, it grows by the list. There is no max-height or scroll, so a long list pushes content below it (open question below).
  • The summary focus ring is an outline, which a parent with overflow: hidden could clip at the edges.
  • Not checked next to neighbors by eye.

Dark mode and per-size values

There are no per-theme overrides: every color is a semantic token (--pds-color-foreground-default, --pds-color-foreground-default-secondary, --pds-color-border-default, --pds-color-interactive-focus), so dark follows the tokens. The left rule and the secondary text were not checked in dark in a session. The shimmer is ThinkingState's (text-clipped gradient, settled 2026-10-19).

Value s (default) m Source
Summary text (ThinkingState) s (14px) m (16px) size passed to ThinkingState
Rows and reasoning text xs (12px) s (14px) EventLog size, or pds-copy-* on reasoning
Chevron icon s s single size (Icon size='s')
Summary gap --pds-spacing-2xs --pds-spacing-2xs single size
List indent --pds-spacing-s --pds-spacing-s single size (--chain-of-thought-indent)
Row gap --pds-spacing-xs --pds-spacing-xs single size (--event-log-gap)
Reasoning paragraph gap --pds-spacing-s --pds-spacing-s single size

One visible change from the 2026-11-20 label change (for the designer to accept): the number in a finished summary ("4s" in "Thought for 4s") loses the smaller, quieter code-font style that ThinkingState's timer element has (thinking-state.css, .pds-thinking-state__time, line 29). It is now plain label text.

Expect to change

Each is a choice that breaks, or may break, a toolkit convention, with a recommended answer (recommendations, for the designer and engineer to confirm).

  • expandWhenActive and its "stops on the first toggle" ref. Behavior inside the API is not a toolkit pattern. Recommendation: keep it. It is the Autopilot behavior (open while working, collapse when done) and the screens rely on it; if the engineer drops it, the screen can drive isOpen with a key.
  • isActive defaults to false, the opposite of ThinkingState (state='active'). Recommendation: keep false. A record is usually finished, and the default-on state would shimmer every stored message; say so in the TSDoc.
  • variant changes markup as well as style (ol vs div for reasoning). Recommendation: keep one component with four variants; reasoning could later become plain children in the default list if the engineer wants a smaller API.
  • isOpen is initial only. Recommendation: rename to isDefaultOpen if the engineer wants the name to say so; otherwise keep (matches ExpansionPanel's isOpen).
  • Finished summary is one label. Changed 2026-11-20 to match ThinkingState; showTimer and time stay for a live run.
  • No custom summary. The summary is rendered from props so the size hierarchy holds. Recommendation: keep.

Target-version check

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

  • ThinkingState: exists (CHANGELOG beta.18). Its time TSDoc says a finished run goes in label; this proposal now does the same.
  • AgenticIcon ('zappy' | 'sparklesSolid'): exists and is exported from the package (src/libs/types/custom-types.tsx:6; also in the installed dist/libs/types/custom-types.d.ts). iconName now uses it. sparklesSolid and zappy are in generated-icon-data.ts.
  • ChainOfThought, EventLog, EventLogItem: not in the package.
  • angleDown, check, circleMinus: exist in the icon set.
  • Spinner: a package component exists (loading-indicators/Spinner); the local Spinner proposal's additions are what the step spinner needs (see ../Spinner/HANDOFF.md). Not re-verified here.
  • Nothing in the CHANGELOG up to beta.21 mentions a chain of thought or collapsible agent record.

Port notes

  • New components. Where they live is the engineer's call, but a reasonable home is src/components/ for Chain of Thought with Event Log beside it. Use npm run generate:component for each, then copy the files over.
  • ThinkingState has shipped (beta.18); port Event Log and EventLogItem, then Chain of Thought. Swap the local Icon wrapper and mergeClasses for the real ones, and port the Spinner proposal for the step spinner (ready: ../Spinner/HANDOFF.md). The order is in docs/PORT-ORDER.md.
  • AgenticIcon is imported from the package already; keep it.
  • The Slot story is story-only (the placeholders are SlotPlaceholder from _story-helpers); the engineer can drop it. Its second list is an example of real content.

Preview

npm run storybook, then Component Proposals/Chain of Thought (rows: Component Proposals/Event Log/Event Log Item).

Figma: https://www.figma.com/design/AMGWJbraJoi2PKWnxo29Ah/PDS-Proposals?node-id=374-45