Repository navigation
docs(storybook): state the real app path for every product story - #1477
Merged
Merged
Conversation
Astro-Han
force-pushed
the
docs/storybook-annotate-reachable-paths
branch
5 times, most recently
from
July 25, 2026 14:56
19f0a18 to
59aa262
Compare
Astro-Han
changed the base branch from
refactor/onboarding-remove-quick-chat-clone
to
main
July 25, 2026 15:13
The Storybook baseline contract asserts that sidebar and command/search stories do not import the desktop app shell, but it matched the bare string `app-shell` anywhere in the file. That also rejects prose that merely names `app-shell.tsx` as the file a story's real path runs through, which is documentation, not a dependency. Match `from '…app-shell…'` instead, so the assertion enforces the rule it states.
Storybook is where pixel work happens, so its stories get treated as ground truth for what the product looks like. That only holds if every story is a state a real user can reach. Two findings in #1433 — a 135px hero offset and a broken vertical centring — were measured against a story that composed a state the app never renders, and neither reproduced in the built app. Annotate every `Product/*` story with a `// Real path:` comment tracing how a user gets there, and give each file the fidelity convention that says why. Where a story deliberately arranges several states side by side for review, say so, so the arrangement is not mistaken for one screen. Prose on purpose: the value is that someone traced the path and wrote it down. Refs #1433
Guards the annotations added in the previous commit: every `export const X: Story` in a `Product/*`-titled story file must carry a `// Real path:` comment, and every such file must carry the fidelity convention. `Primitives/*` and `Design System/*` stories are exempt — they demonstrate a component's states, not a product surface, and there is no user path to a Button variant. Refs #1433
…the guard Three-way review of the annotation PR found the convention certifying things it had not checked. The onboarding stories mounted the hero inside `maxWidth: 720; padding: 48px 32px` — a frame the app never renders. The hero actually lands in ChatView's empty slot wrapped in `.maka-onboarding-surface`, and that class plus two `:has(.maka-firstrun)` rules own its height, padding and alignment. None of those cascaded in the story, so its geometry was its own scaffolding — which is precisely how #1433 produced a 135px offset and a centring bug that neither reproduced in the built app. The story now uses the app's class chain; measured in Storybook, both cascade rules apply for the first time. `CommandPaletteEmpty` claimed "⌘K in a context that offers no commands". No such context exists — `buildCommandList` always emits 新建对话 first, and the palette's empty branch says so in its own copy ("没有匹配的命令 / 换个关键词"). It is now `CommandPaletteNoMatch`, entered through a query, which is the state a user can actually reach. That one annotation was written, reviewed and merged as confidently as the other 123, and the contract passed it — so the contract now says what it does: story-reachable-path-contract → story-annotation-contract with a header that leads on the limit ("it cannot check the sentence is TRUE — only a reviewer following the call chain can"). Two escape hatches close with it: `satisfies Story` exports were invisible to the export scan, and a fixture object with a `title` field above `meta` would have exempted a whole file. The third test asserted `length >= 0`, which no input can fail; it now demonstrates the exemption is load-bearing instead. Repo-root lookup moves to the one `findRepoRoot` the neighbouring contract already had, replacing a fixed `../../../../..` chain that resolves to `/` if the build output moves. `app-shell.stories.tsx` told readers the hero appears whenever `sessions.length === 0`. Removing the ready_empty panel narrowed that gate to unfinished setup, so a configured user with no sessions now lands on EmptyHome — the sibling PR invalidated an annotation the annotation PR never touched. The convention itself moves to apps/desktop/stories/FIDELITY.md. It had shipped as a ~10-line block pasted into every product story file and drifted on day one: 17 byte-identical copies plus an older wording in app-shell.stories.tsx, with the contract only grepping for the literal string "FIDELITY CONVENTION". Each file now points at the doc, and the doc says what the copies did not — the frame matters, not just the component. Refs #1433
Two files claimed real paths to states the app cannot produce — the failure #1433 exists to stop, reintroduced by the PR that documents it. The permission prompt built each request by hand, and four of the combinations do not occur. `preToolUse` is the only thing that assigns a category and reason, and running it over the fixtures gives: ShellDangerous rm -rf node_modules dist && npm ci -> fs_destructive FsDestructive git clean -fdx -> shell_unsafe WebFetch category web_read -> reason custom maka_computer -> remember false The two shell commands were attached to each other's labels. WebFetch had reason `network`, which only `network_send` produces — `categoryToReason` has no `web_read` arm, so that prompt actually renders the generic copy. `makeRequest` now asks `preToolUse` for category, reason and args, and throws when the mode does not prompt at all; the only real input left is the session's permission mode, which matters because `custom_tool` prompts under `explore` and nowhere else, so CustomReason names the Deep Research session it needs. `ExpiredRequest` is deleted. It showed an 11-minute request, but the UI calls a request expired after 10 minutes while the runtime cancels it after 5 and the resulting tool_result dequeues the prompt. Nobody has ever seen that state. The threshold mismatch is a real defect and gets its own change; it does not get a fake screenshot in the meantime. Three of four capability-audit-strip stories rendered blank. The strip reports by exception and returns null when its four issue counts are zero, which is what the fixture factory defaults them to, so SkillsFocusHealthy, AutomationsFocusHealthy and Empty were empty panels under sentences describing a summary the component no longer writes. The state they named is "the strip is not on the page". Only WithRisks survives, in the element the strip is actually a child of rather than a 720px box with the E2E animation-pause attribute on it.
The frame here claimed to be the app's chain "class for class" and was not. It nested `.mainColumn` outside `.maka-panel-detail` where the app nests it inside, and dropped `.maka-detail-with-artifacts`, ChatView's 32px `header.maka-chat-header`, and the scroll viewport — about 32px of vertical offset, the same order as the 135px error that started #1433. Writing the chain out by hand was the original mistake one level down. Only the part that cannot be imported is written out now: app-shell.tsx owns the three outer wrappers and stories may not import it. Everything from `<main>` inward is the real ChatView in its empty state, with the hero passed through `emptyOverride` the way chat-message-surface.tsx passes it. There is no hand-written chain left to drift.
Every assertion selects files by meta title prefix, so a file whose
title cannot be read fell into no bucket and was skipped by all of them
— while stopping a new story from skipping the convention is the test's
only job. `metaTitle` reads a string literal, so `title:
`Product/${SECTION}`` or a title constant was enough to opt out, and the
`>= 15` tripwire only catches mass failure. Every file must now land in
a known bucket. Verified by planting a template-literal title: the new
assertion fails, the old ones stayed green.
`findRepoRoot` was duplicated into the annotation contract's helper
rather than shared; storybook-baseline-contract now imports the same
`REPO_ROOT`. And its app-shell import guard matched any specifier
containing the string, including leaves like `app-shell-command-actions`
— importing the command-list builder would make command-search.stories
more faithful, not less. Anchored to the shell module itself.
Each section now names the mistake that produced it: a hand-copied wrapper chain drifts like a hand-copied convention block, a hardcoded classifier result is an assertion rather than a demonstration, and a component that returns null in its healthy state has no story to tell about being absent.
…catch
Fresh-eye review found the first batch of `// Real path:` sentences
already carrying the failure they exist to prevent — a story annotated
with a state the app does not render.
- `capability-audit-strip` claimed its frame was the element the strip is
a direct child of "on both hosts". It is the skills host only. The
plan-reminder page mounts the strip inside `.maka-plan-shell
.agents-inner-view-clamp`, capped at `min(100%, 1024px)` with no
`.maka-module-main` ancestor, so `module-shell.css`'s `:has(> …)` third
grid row never applies there. Width measurements taken against this
story do not transfer to that page, and the annotation now says so.
- `CommandPaletteDisabledCommand` hand-built a `thread-search:blocked`
row into the base command list and rendered it with no query.
`buildCommandList` never emits a disabled command; the only disabled
row comes from `buildContentSearchCommands`, after a query of at least
two code points. `CommandPaletteContentSearchBlocked` already shows
that state through the real builder, so the story and its fixture go.
- `EmptyHome` named the zero-session path, but `ComposedShell` always
projects one active session across sidebar, header and composer. The
chat surface it shows is right; the sentence now scopes itself to it.
`storyExports` matched `export const X: Story =` plus, only in files
containing `satisfies Story`, `export const X = {`. No file in either
root contains `satisfies Story`, so that branch could never run while
`export const X = makeStory()` passed unseen. CSF already defines every
named export as a story, so match that — a mutation adding an
unannotated untyped export now fails where it used to pass. The scan
also covers `.stories.ts`, which `.storybook/main.ts` loads and this
only globbed as `.tsx`.
The contract enumerated the export spellings it knew and skipped the
rest, so an export it could not parse was silently exempt and the test
passed because it did not understand. It has now been wrong twice the
same way: first `export const X: Story =` plus a `satisfies Story`
branch no file in either root could trigger, then a bare
`^export const` that missed `export { X }`, `export function X()` and
anything indented. CSF defines every named export as a story, so an
open recognizer can never be complete.
Close it. `storyExports` recognizes the one form every story in both
roots uses, and a new assertion fails on any other top-level export
with a message saying to use the standard form or widen the contract
deliberately. Reality growing a new spelling is now red, not exempt.
The scanned file set had the same shape of problem one level up:
`STORY_ROOTS` and `STORY_EXTENSIONS` were hand-copied from
`.storybook/main.ts`, so a third glob there would put a whole directory
outside every assertion in this file. They are now checked against the
config — the same rule FIDELITY.md already states for story frames,
applied to the test that enforces it.
Verified by mutation: `export { X }`, `export function X()`, an
indented `export const`, and an added Storybook glob each pass on the
previous version and fail on this one.
Round 5 found the derivation commit stopped one step short. `preToolUse` gives these stories their category and reason, but it does not look at the arguments — and `OfficeDocumentEdit` was still asserting `operation: 'replaceText'`, which the tool's own Zod schema rejects before the permission engine is ever asked (office-document-tool.ts takes create | add | set | remove). The dialog renders the operation verbatim, so the story showed a prompt line the app cannot produce, plus `elementType` and `index`, both `add`-only. Now `set` on a real selector, verified against the schema itself. FIDELITY.md says both halves out loud: classification is not validation. `scans exactly what Storybook loads` did not scan exactly what Storybook loads. It picked the entries it recognized out of `main.ts` — the same fail-open the export check one test up exists to prevent. A `**/*.csf.tsx` glob would have loaded a directory of stories that no assertion in the file ever sees, and nothing would have gone red. It now reads every entry of the `stories` array and fails on any it cannot classify. Three mutations confirm: an unknown naming convention, an unknown entry form, and an uncovered root are each red, and the untouched config is green. `capability-audit-strip`'s frame had one child. The interesting thing about that frame is a row assignment — `:has(> .maka-capability-audit-strip)` adds a third `auto` row (module-shell.css) because the strip once landed in the `1fr` row and collapsed to ~0 height — and a lone child sits in row 1 under either rule, so the story could neither show that fix nor regress it. It has the two siblings now, as explicit stand-ins.
Astro-Han
force-pushed
the
docs/storybook-annotate-reachable-paths
branch
from
July 25, 2026 15:14
59aa262 to
16ee914
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Storybook is where pixel work happens, so its stories get treated as ground truth for what the product looks like. That only holds if every story is a state a real user can reach.
#1433 has two findings that came from a story the app never renders — a 135px hero offset and a broken vertical centring. Neither reproduced in the built app. The story wasn't wrong about the component; it was wrong about the product, and the comparison built on it was worthless.
This makes the reachability explicit rather than assumed:
Product/*story gets a// Real path:comment tracing how a user gets there — 124 stories across 18 files.apps/desktop/stories/FIDELITY.md, with each story file carrying a two-line pointer.Primitives/*andDesign System/*are exempt — they demonstrate a component's states, not a product surface, and there is no user path to a Button variant.What the first review round changed
An independent subagent, Codex and Kimi K3 all reviewed the first three commits. They converged on the same objection, and it was right: the contract checked that a sentence existed, not that it was true, while its name and framing claimed otherwise. Two of them found the proof in the PR itself.
The onboarding stories still had the exact defect the PR exists to prevent. They mounted the hero inside
maxWidth: 720; padding: 48px 32px— a frame the app never renders. The hero actually lands in ChatView's empty slot wrapped in.maka-onboarding-surface, and that class plus two:has(.maka-firstrun)rules own its height, padding and alignment. None of them cascaded in the story, so its geometry was its own scaffolding. The story now uses the app's class chain; measured in Storybook, both cascade rules apply for the first time. This alone is why the annotations were worth writing — the convention only surfaced it because someone had to state the path and check it.One annotation was simply false.
CommandPaletteEmptyclaimed "⌘K in a context that offers no commands". No such context exists:buildCommandListalways emits 新建对话 first, and the palette's empty branch says so in its own copy ("没有匹配的命令 / 换个关键词"). It is nowCommandPaletteNoMatch, entered through a query. It was written, reviewed and merged as confidently as the other 123, and the contract passed it.So the contract now says what it does:
story-reachable-path-contract→story-annotation-contract, with a header that leads on the limit: it cannot check the sentence is TRUE — only a reviewer following the call chain can.satisfies Storyexports were invisible to the export scan, and a fixture object with atitlefield abovemetawould have exempted a whole file. Both verified by planting them and watching the test fail.length >= 0, which no input can fail. It now demonstrates the exemption is load-bearing instead.findRepoRootthe neighbouring contract already had, replacing a fixed../../../../..chain that resolves to/if the build output moves.The convention had drifted on day one. It shipped as a ~10-line block pasted into every product story file: 17 byte-identical copies plus an older wording already in
app-shell.stories.tsx, with the contract only grepping for the literal string. One doc now, pointers everywhere else.The sibling PR invalidated an annotation this one never touched.
app-shell.stories.tsxtold readers the hero appears wheneversessions.length === 0; #1476 narrowed that gate to unfinished setup, so a configured user with no sessions now lands onEmptyHome.One incidental fix, in its own commit first: the Storybook baseline contract asserted that sidebar and command/search stories don't import the app shell, but matched the bare string
app-shellanywhere in the file — which also rejects prose namingapp-shell.tsxas the file a path runs through. It now matches the import specifier.What the second round changed
Same three reviewers on the result (Kimi on K3-256K this time). They found the same class of defect again, in three new places — which is the honest headline here: stating a path is easy to do confidently and wrong, and only running the authority catches it.
Two more stories claimed states the app cannot produce.
permission-dialog.stories.tsxhand-wrotecategoryandreasonfor every request, and runningpreToolUseover the fixtures shows four of them are impossible:rm -rf node_modules dist && npm ciclassifies asfs_destructive, notshell_unsafe;git clean -fdxis the reverse — the two shell stories had each other's commands; WebFetch isweb_read, whose reason falls through tocustombecausecategoryToReasonhas noweb_readarm; andmaka_computernever allows remember-for-turn.makeRequestnow derives all of it frompreToolUseand throws when the mode does not prompt at all, so an impossible fixture fails visibly instead of rendering a screen that does not exist.CustomReasonhad to name its session, becausecustom_toolprompts underexploreand nowhere else.ExpiredRequestis deleted: it showed an 11-minute request, but the UI calls one expired after 10 minutes while the runtime cancels it after 5. The threshold mismatch is a real defect and is flagged on #1476 as its own follow-up.Three of four
capability-audit-stripstories rendered blank. The strip reports by exception and returnsnullwhen its four issue counts are zero, which is what the fixture factory defaults them to.SkillsFocusHealthy,AutomationsFocusHealthyandEmptywere empty panels under confident annotations describing a summary the component stopped writing. OnlyWithRiskssurvives, in the element the strip is actually a child of.The onboarding frame I "fixed" in round one was still wrong. It claimed to be the app's chain class for class, and it inverted
.mainColumnand.maka-panel-detailand dropped.maka-detail-with-artifacts, ChatView's 32px header and the scroll viewport — roughly 32px of offset, the same order as the 135px error that started #1433. Writing the chain out by hand was the original mistake one level down. It now renders the realChatViewwith the hero passed throughemptyOverride, exactly aschat-message-surface.tsxpasses it; only the three wrappersapp-shell.tsxowns are written out, because stories may not import it.The contract was fail-open on titles. Every assertion selects by meta title prefix, so a file whose title cannot be read fell into no bucket and was skipped by all of them — and
metaTitleonly reads a string literal, sotitle: `Product/${SECTION}`was enough to opt out. Stopping a new story from skipping the convention is this test's only job. Every file must now land in a known bucket.Also:
findRepoRootwas duplicated rather than shared, and the app-shell import guard matched any specifier containing the string — including leaves likeapp-shell-command-actions, importing which would makecommand-search.stories.tsxmore faithful. Both fixed.FIDELITY.mdgained three sections, each named after the mistake that produced it.Stacked on #1476.
Refs #1433
Verification
npm test -w @maka/desktop— 2812 pass, 0 fail.npm test -w @maka/ui— 243 pass.npm run typecheck -w @maka/desktop— clean (includestsconfig.storybook.json).npm run lint,npm run format:check— clean..maka-chatContentresolves todisplay: grid; align-content: start; padding-top: 25.2pxand.maka-onboarding-surfacetomin-height: 0; padding-top: 14.4px— the app's values, from the app's rules, none of which reached the old story.satisfies Storyexport with no annotation, a double-quotedtitle, and a template-literaltitle, and confirming each fails.preToolUseand the derived(category, reason, rememberForTurnAllowed)compared against the story name — that comparison is what produced the four corrections above, and it is now structurally impossible to skip.Not run: Playwright E2E. This PR changes comments, story frames and two test files; it touches no renderer, main, or preload source.