Core: Restore the args a server-docgen preview cannot type - #35907
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (16)
Included review availability: 0 reviews are currently available. Based on recent review activity, included reviews refill at 3 per hour. WalkthroughChangesServer Docgen Argument Handling
Merge Risk: ⚪ Minimal · up to This PR restores untyped argument propagation for server-docgen previews and updates the affected Angular rendering and story expectations. The reported automated coverage passes, and no actionable merge-blocking risk remains beyond normal checks and review. Comment |
With experimentalDocgenServer enabled, prepareStory skips the inference pass so argTypes stays annotation-only for mergeServiceArgTypes. Both arg validation passes drop args they have no argType for, so a plain args entry set through the URL was silently discarded. Infer the missing types where the validation needs them, without putting them back on the story.
Under experimentalDocgenServer the inference passes move to the UI read, so the preview keeps only the annotated argTypes. The template story asserted the legacy shape and failed in every sandbox running the feature.
6cc94fe to
810863b
Compare
Package BenchmarksCommit: No significant changes detected, all good. 👏 |
…sibility rules The props table now hides class internals and keeps protected members, and the sandbox that records these baselines only runs in the daily set, so the change landed without them. The recording drops three internals from the doc-button entry and adds the three protected constructor dependencies to the DI component's.
810863b to
db8bea2
Compare
cleanArgsDecorator dropped any arg without a control or an action, which no other renderer does: React passes every arg straight to the component. The behaviour arrived in 2021 with no stated rationale, its only committed story change was a stray console.log decorator, and the guard it plausibly protected - invalid template bindings for non-inputs - lives in computesTemplateFromComponent, which starts from the component's real inputs/outputs. Under server docgen nothing carries a control at all, so a public property that is not an @input lost the value its story set. Scoped to angular-vite; @storybook/angular keeps its decorator. The suite asserting the strip was describe.skip'd as "infinitely running"; it runs in under half a second, so it is enabled here and the two stale template expectations that had drifted behind buildTemplate's line breaking are corrected.
db8bea2 to
a35203d
Compare
…ge drifted "Stop marking a defaulted input as required in the props table" flipped table.type.required from true to false on every input carrying a default value, but the angular-vite/docgen-server-ts sandbox only runs in the daily set, so its recorded baselines were never updated. 43 flips across 16 components. The verification step gates every later job in that sandbox.
Check the diff here: storybookjs/storybook@f96ed20...add38a0 List of included PRs since previous version: - storybookjs/storybook#35922 (valentin/sb-1766-angular-docgen-documentation-pass) - storybookjs/storybook#35844 (s-robertson/u/srobertson/fix-react-component-meta-union-props) - storybookjs/storybook#35931 (valentin/sb-1847-componentid-collision-warning) - storybookjs/storybook#35923 (valentin/sb-1789-server-side-code-snippets-resolve-spreads-and-identifier) - storybookjs/storybook#35940 (valentin/sb-1789-review-fixes) - storybookjs/storybook#35900 (julien/vue-api-description) - storybookjs/storybook#35938 (fix-publish-ansi-parsing) - storybookjs/storybook#35929 (valentin/sb-1821-pin-oxc-resolver) - storybookjs/storybook#35936 (chore/changelog-v10.5.9) - storybookjs/storybook#35930 (valentin/sb-1789-review-fixes) - storybookjs/storybook#35921 (valentin/sb-1809-bug-angular-constructor-and-generic-function-inputs-lose-the) - storybookjs/storybook#35917 (norbert/fix-publish-staged-retries) - storybookjs/storybook#35896 (valentin/sb-1776-angular-docs-end-to-end) - storybookjs/storybook#35920 (julien/vue_server_docgen_options) - storybookjs/storybook#35907 (valentin/docgen-server-arg-types) - storybookjs/storybook#35886 (valentin/sb-1799-default-docgen-server-angular-vite) - storybookjs/storybook#35902 (fix/vue-snippet-runtimeoverride) - storybookjs/storybook#35825 (norbert/module-graph-skip-noop-mirror) - storybookjs/storybook#35629 (reuben/fix-pseudo-states-cssom-rewrites) - storybookjs/storybook#35915 (next-merge-prerelease) - storybookjs/storybook#35906 (valentin/angular-docs-decorator-gate) - storybookjs/storybook#35830 (version-non-patch-from-10.6.0-alpha.5) - storybookjs/storybook#35899 (valentin/angular-required-input-with-default) - storybookjs/storybook#35831 (norbert/spike-module-graph-hot-cold-split)
Closes #
What I did
With
experimentalDocgenServerenabled, the preview no longer holds a complete set ofargTypes. Component metadata now lives on the server and is merged when the UI reads it, soprepareStorydeliberately skips the inference pass to keep the preview'sargTypesannotation-only. Consumers living in the preview still treatedargTypesas "the set of args that exist", and silently dropped everything else.The gate is in core and keyed only on the flag, so this is not Angular-specific. It applies to every renderer that enables the feature, React included:
1. URL args were discarded
mapArgsToTypesskips any key with noargType, andvalidateOptionsbuilds its result by iteratingargTypes, so a key absent from it can never come out. An arg set through the URL therefore never reached the story. The fix infers types where the validation needs them, without putting them back on the story where they would pollute the UI-read merge:Same function, same inputs it would have had in the first pass, just called locally. This lives in core, so it covers every renderer.
2. Angular stripped args the component did not declare
cleanArgsDecoratorkept an arg only when it was a component@Input/@Outputor carried acontrol/action. Server docgen leaves the preview with no control on anything, so a public property that is not an@Inputlost the value its story set.Rather than add a third escape hatch to that filter, this deletes it. No other renderer does this: React passes every arg straight through. The behaviour arrived in 2021 with no stated rationale, and the only story it touched in that commit was a stray debug decorator:
The failure it plausibly guarded against, an invalid binding for a non-input, is prevented elsewhere: template generation starts from the component's real metadata and intersects with the props it was given.
Scoped to
angular-vite.@storybook/angularkeeps its decorator, so the two frameworks now differ here. That is deliberate: the webpack package has no docgen-server path, so nothing in this PR forces the change there.The
decorateStorysuite wasdescribe.skip'd as "infinitely running". It completes in under half a second, so it is enabled here. Two template expectations had silently rotted behindbuildTemplate's 80-column line breaking while the suite was dark; those are corrected.3. Two baseline re-records this PR needs to run at all
angular-vite/docgen-server-tsonly runs in the daily set, so two merged changes never had their recorded baselines updated. The verification step gates every later job in that sandbox, so nothing above could be exercised until both were corrected.doc-button, added the three protected constructor dependencies to the DI componenttable.type.requiredon every input carrying a default valueThe second is the entire diff for 16 of the 17 files, 43 lines of exactly this:
"type": { - "required": true, + "required": false, "summary": "string" }Both are re-records, not behaviour changes.
Effect
Reproduced against a real
angular-vite/docgen-server-tsdev sandbox, before and after, same server:example-button--primary&args=label:Hello+world"Button""Hello world"WithComponentWrapperDecorator"Private text:""Private text: Child private text"The decorator deletion changes the legacy Compodoc path too, so both were verified against live sandboxes.
WithComponentWrapperDecoratorrenders identically on each:angular-vite/default-tssandbox e2e (Compodoc)angular-vite/docgen-server-tssandbox e2e@storybook/angular+@storybook/angular-viteunitcode/corepreview-api store unitbaselines:sandbox --template angular-vite/docgen-server-tsFollow-up, not fixed here
#35919 tracks removing
argTypesfrom user-facing story annotations entirely. Three internal consumers fell into this same trap, so users readingargTypesin aplayfunction will too.inferActionsFromArgTypesRegexis a fourth case, found by inspection with no failing test today, so it is left alone here and recorded in that issue.The
ArgTypeInferencetemplate story that first surfaced this was fixed separately onnextand is no longer part of this diff.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
ArgsStore.test.tsgainstypes args from their initial value when the story declares no argTypes, which fails onnextwith:Note
b: the initial value1is what identifies the arg as numeric, so the URL string'42'is coerced back to42.decorateStory.test.tscovers the pass-through, andaddon-controls.spec.ts › should apply controls automatically when passed via urlcovers the URL path in the sandbox.Manual testing
yarn task sandbox --template angular-vite/docgen-server-ts --start-from autocd ../storybook-sandboxes/angular-vite-docgen-server-ts && yarn storybookexample/button→primary, set the label control toHello world, then reload the page. The button must still readHello worldrather than reverting toButton.Private text: Child private text, not a barePrivate text:.angular-vite/default-tssandbox to confirm the Compodoc path is unchanged.Note
A linked
angular-vitesandbox currently cannot boot locally:yarn storybookdies withvalue `"builtin:vite-wasm-fallback"` does not match any variant of enum `BindingBuiltinPluginName`. Yarn's portal linking needs--preserve-symlinks, which makes the repo's nestedrolldown@1.0.3load the sandbox root's@rolldown/binding-darwin-arm64@1.2.0. Work around it by adding"resolutions": { "vite": "8.0.16", "rolldown": "1.0.3" }to the generated sandbox'spackage.jsonand re-runningyarn install. Unrelated to this PR, and worth its own issue.Documentation
MIGRATION.MD
No user-facing API changes. The behaviour restored here is what users already get from a non-docgen-server Storybook. The
angular-vitearg pass-through aligns it with every other renderer.Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsDeclare whether manual QA will be needed for this PR during the next release, through
qa:neededorqa:skipMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.bug. These are the failures that surface onceangular-vite/docgen-server-tsactually runs; they are present onnexttoday.