Skip to content

feat(fork-storybook): the Petal digest card in Storybook and the Figma kit - #395

Merged
NoahHendrickson merged 4 commits into
customfrom
t3/petal-digest-storybook-figma
Nov 22, 2026
Merged

NoahHendrickson merged 4 commits into
customfrom
t3/petal-digest-storybook-figma

Conversation

@NoahHendrickson

@NoahHendrickson NoahHendrickson commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

The Petal digest card (the status strip, pager and ask card above a Petal's composer, from #372, #374 and #380) had no Storybook story and no Figma component, because BotDigest.tsx reads its data through hooks and could not render on its own.

View split (no behaviour change)

apps/web/src/custom/bots/BotDigest.tsx now exports presentational pieces that take plain props, the same way ForkSubagentCardView and ComposerLimitsTrayView do:

  • BotDigestView: the vessel and its strip. Takes the status text, the hidden count with onShowDismissed, the asks' keys with at and onPage for the pager, and the ask card as children.
  • BotDigestAskCardView: the ask surface. Takes the question, detail, icon, tone class, links, actions and onDismiss.
  • BotDigestAskActions: the answer buttons, then Reply.
  • botDigestAskTile: the tile's icon and tone, from the pull request's state or the needs-input default.

BotDigestAsksFor and BotDigestAskCard still own every hook and render these pieces. The DOM, classes, test ids and React keys (dots keyed by the ask's source, the card keyed by its item) are the same as before. Nothing else in the app changes. The fork-storybook manifest entry lists the new views.

Stories

apps/fork-storybook/stories/fork/PetalDigest.stories.tsx renders on the composer surface. It uses the real BotDigestLinkRow under the story router, so the PR chips are the app's own. It has:

  • a Playground with controls for status, hidden count, ask count, question, detail, tile tone and answers
  • Status only
  • Offered answers
  • Reply only (with the 2-line detail clamp)
  • Several asks (pager)
  • Pull request states (open, draft, merged, closed)
  • Dismissed hidden

Figma

The Petal digest component set is 251:10492, inside the doc frame 251:10493 on the Petal card page of the Basic UI kit. It has nine State variants that match the stories.

  • Built from kit parts: Button outline/ghost xs, Icon button ghost icon-xs, Icon sets (Size 16), and the PR state / * marks.
  • Bound colours and radii: composer/vessel, composer/prompt, base/border, base/foreground, base/muted-foreground, status/input, component/pr-*, and the radius tokens.
  • No new variables or modes. The tile's 14% wash and the dimmed pager dots use layer opacity over a bound fill instead.
  • Micro buttons: the kit has no micro / icon-micro sizes, so those buttons are ghost xs and icon-xs instances overridden to the app's 20px box.

Checked against the stories in Dark Neutral. Heights match to the pixel.

Verification

  • vp run check:changed passes: format, lint, knip, typecheck, tests and react compiler.
  • node .fork/lint-owned.mjs reports no blocking warnings.
  • vp test run src/__fork_guards__ src/custom/bots: 116 files, all passing.
  • The Storybook build succeeds. All seven stories render headless in Basic (Dark Neutral) and Flat Glass (glass_off) with no story errors. The only console error is a /.well-known/t3/environment 404, which existing stories also hit on a static host.

Review fixes: the story digest keeps its own dismissed asks, so Dismiss and Show N dismissed work. Asks are keyed by position, the Playground lists each ask once, and an empty digest draws nothing, as the app does. Checked in a built Storybook.

Reviewed with sol-loop: 2 rounds with gpt-6.2-sol on high. Sol verdict: approved


🤖 Signed: Claude Opus 5.5 (claude-opus-5-5) via Claude Code
🤖 Signed: Claude Opus 5.5 (claude-opus-5-5) via Claude Code (review-thread fixes)

Split BotDigest into presentational views (BotDigestView, BotDigestAskCardView,
BotDigestAskActions, botDigestAskTile) that the hook-owning components render
unchanged, and add Fork/Petal digest stories for each state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 22, 2026

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7e9e312f011aadabfd3e7b1a2632cef9b5d90574 against d3e5d91d1745590fb4ffb1b8f687075bd3b3b60a. The two findings are in the Storybook fixture. I checked the production render and handlers against the base and found no behavior regression in the extraction. The fixture checks and git diff --check ran locally.

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code quality review of 7e9e312f011aadabfd3e7b1a2632cef9b5d90574.

Splitting the vessel and strip out as BotDigestView is right: BotDigestAsksFor is bound to the file read, the conversation and local storage, so a story can't mount it. The ask card is a different case. Half of this split isn't needed, and dropping it would remove two exports, a pass-through wrapper and a fake-data path from the story.

1. Drop BotDigestAskCardView and botDigestAskTile. The story can render the real BotDigestAskCard.

BotDigestAskCard only needed splitting if its one hook, useBotPullRequestState, couldn't run in Storybook. It can:

  • useBotPullRequestState (BotPullRequestMark.tsx:20-45) returns resolvePullRequestState(snapshot) synchronously when pullRequest.snapshot is set. When branch is null, it calls useSharedPullRequestSummary(null, null), which asks for no data.
  • The story already builds that snapshot in links() (PetalDigest.stories.tsx:57-76).
  • The story already runs this hook in Storybook. BotDigestLinkRow → BotDigestPullRequestChip (BotDigestItem.tsx:127) calls it on the same objects. The PR states story works because of that.

So the story can do this:

const pullRequest = links(ask).pullRequests[0] ?? null;
<BotDigestAskCard pullRequest={pullRequest} environmentId={environmentId} … />

That removes:

  • BotDigestAskCardView, a second component whose seven props mirror BotDigestAskCard's. After this PR, BotDigestAskCard is a pure pass-through: one hook, one helper call, then it copies every prop across.
  • The botDigestAskTile export, plus the LucideIcon and PullRequestStatePresentation imports it pulled in.
  • The story's presentation() helper and its separate draft → {state: "open", isDraft} mapping (lines 38-42). Today the story works out the tile one way (presentation(kind)) and the PR chip another (the snapshot). The two could drift apart, and the tile is the part the Figma kit is checked against.

Doing this also stops the story from re-deriving app logic, which the manifest entry says stories must never do: "a story never copies the app markup it shows".

If there is a reason to keep the tile helper, it needs a better signature. botDigestAskTile(hasPullRequest: boolean, state: … | null) takes two arguments that overlap, and (false, someState) silently ignores the state. The caller in the story then has to write the null check twice (lines 88-91). The input should be one value, e.g. (pullRequest: { state: PullRequestStatePresentation | null } | null). Deleting the helper is still the better move.

2. The story's Digest copies the container's pager logic, so move the pager state into BotDigestView.

Digest (PetalDigest.stories.tsx:81-117) copies BotDigestAsksFor's page state and its clamp, Math.min(page, Math.max(0, asks.length - 1)), line for line (BotDigest.tsx:111,128). It also copies the view → card → link row → actions composition. Paging is pure view state: nothing outside the strip reads page, and BotDigestAsksFor is already keyed by the bot, so it resets per Petal.

If BotDigestView owned useState and the clamp, and took its card as children: (at: number) => ReactNode (or an renderAsk(at) prop):

  • The at and onPage props go away.
  • The clamp lives in one place, not two.
  • The story stops copying container logic and only supplies data.

Without this, the next pager change (wrap-around, keyboard paging, or reset on dismiss) has to be made in two places. The story copy won't fail when they drift; it will just keep showing the old behaviour.

3. Nit: .fork/customizations.yaml

The inserted line BotDigestAskActions, botDigestAskTile), marked @public because knip does not follow the is now much longer than the rest of the paragraph. Please re-wrap it. If you take finding 1, the list becomes BotDigestView, BotDigestAskCard, BotDigestAskActions.


BotDigestAskActions is a good extraction. The offered branch is now in one place, and its data-testids and keys are unchanged. File size is fine (408 lines).

Not approving: findings 1 and 2 meet the bar for a wrapper that adds indirection, and for copied logic the existing architecture already lets you avoid.

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of 7e9e312f011aadabfd3e7b1a2632cef9b5d90574.

The BotDigest.tsx view split looks behaviour-preserving. BotDigestAsksFor still keys the pager dots and the card by item.source. BotDigestAskActions renders the same buttons as before: an empty answers.map renders nothing, just like the old offered ? … : null. botDigestAskTile keeps the icon and tone fallbacks exactly as they were. I found no problems in the app code.

All four findings are in the new story file. One matters: the Playground repeats an ask. The other three are small.


🤖 Signed: Claude Opus 5.5 (claude-opus-5-5) via Claude Code

xxxxxxxxxxxxx and others added 3 commits November 22, 2026 11:23
The story digest keeps its own dismissed asks, so Dismiss and Show N dismissed
work; asks are keyed by position, the Playground pool lists each ask once, and
a digest with no asks and no status draws nothing, as in the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NoahHendrickson
NoahHendrickson merged commit a81fde1 into custom Nov 22, 2026
31 checks passed
@NoahHendrickson
NoahHendrickson deleted the t3/petal-digest-storybook-figma branch November 22, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants