Repository navigation
feat(fork-storybook): the Petal digest card in Storybook and the Figma kit - #395
Conversation
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>
NoahHendrickson
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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) returnsresolvePullRequestState(snapshot)synchronously whenpullRequest.snapshotis set. Whenbranchis null, it callsuseSharedPullRequestSummary(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 mirrorBotDigestAskCard's. After this PR,BotDigestAskCardis a pure pass-through: one hook, one helper call, then it copies every prop across.- The
botDigestAskTileexport, plus theLucideIconandPullRequestStatePresentationimports it pulled in. - The story's
presentation()helper and its separatedraft → {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
atandonPageprops 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
left a comment
There was a problem hiding this comment.
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
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>
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.tsxreads its data through hooks and could not render on its own.View split (no behaviour change)
apps/web/src/custom/bots/BotDigest.tsxnow exports presentational pieces that take plain props, the same wayForkSubagentCardViewandComposerLimitsTrayViewdo:BotDigestView: the vessel and its strip. Takes the status text, the hidden count withonShowDismissed, the asks' keys withatandonPagefor the pager, and the ask card aschildren.BotDigestAskCardView: the ask surface. Takes the question, detail, icon, tone class, links, actions andonDismiss.BotDigestAskActions: the answer buttons, then Reply.botDigestAskTile: the tile's icon and tone, from the pull request's state or the needs-input default.BotDigestAsksForandBotDigestAskCardstill 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.tsxrenders on thecomposersurface. It uses the realBotDigestLinkRowunder the story router, so the PR chips are the app's own. It has:Figma
The Petal digest component set is
251:10492, inside the doc frame251:10493on the Petal card page of the Basic UI kit. It has nineStatevariants that match the stories.PR state / *marks.composer/vessel,composer/prompt,base/border,base/foreground,base/muted-foreground,status/input,component/pr-*, and the radius tokens.micro/icon-microsizes, 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:changedpasses: format, lint, knip, typecheck, tests and react compiler.node .fork/lint-owned.mjsreports no blocking warnings.vp test run src/__fork_guards__ src/custom/bots: 116 files, all passing.glass_off) with no story errors. The only console error is a/.well-known/t3/environment404, 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)