Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Fix test provider event handling on startup #30083

Merged
merged 2 commits into from
Dec 17, 2024
Merged

UI: Fix test provider event handling on startup #30083

merged 2 commits into from
Dec 17, 2024

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Dec 17, 2024

What I did

Replaced useEffect with useLayoutEffect in order to have event listeners registered before rendering the test providers' UI. This is necessary because the VTA emits a progress report event when it has a warning (e.g. when not logged in to Chromatic), which happens on first render of its Description. The event is used to set runnable: false on the VTA, and if we miss this event, the VTA will have a Run button and respond to "Run all", which results in the addon getting stuck in "pending" state.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make 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.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 0 B 0.7 0%
initSize 136 MB 136 MB -203 B 0.5 0%
diffSize 58.4 MB 58.4 MB -203 B 0.5 0%
buildSize 7.24 MB 7.24 MB 1 B 0.33 0%
buildSbAddonsSize 1.88 MB 1.88 MB 0 B 0.33 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 1 B 0.36 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.93 MB 3.93 MB 1 B 0.33 0%
buildPreviewSize 3.3 MB 3.3 MB 0 B -0.07 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 6.7s 9s 2.3s -0.6 25.9%
generateTime 19.2s 20.5s 1.3s 0.26 6.4%
initTime 12.8s 14s 1.2s -0.1 8.9%
buildTime 12.8s 10s -2s -755ms 0.02 -27.4%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.5s 4.7s -803ms -0.5 -16.8%
devManagerResponsive 4s 3.5s -432ms -0.48 -12%
devManagerHeaderVisible 651ms 636ms -15ms 0.55 -2.4%
devManagerIndexVisible 723ms 664ms -59ms 0.42 -8.9%
devStoryVisibleUncached 1.7s 1.8s 132ms 0.36 7.2%
devStoryVisible 720ms 663ms -57ms 0.37 -8.6%
devAutodocsVisible 578ms 524ms -54ms -0.08 -10.3%
devMDXVisible 676ms 529ms -147ms -0.08 -27.8%
buildManagerHeaderVisible 694ms 567ms -127ms -0.56 -22.4%
buildManagerIndexVisible 780ms 648ms -132ms -0.65 -20.4%
buildStoryVisible 652ms 525ms -127ms -0.58 -24.2%
buildAutodocsVisible 551ms 413ms -138ms -0.79 -33.4%
buildMDXVisible 586ms 455ms -131ms -0.13 -28.8%

Greptile Summary

This PR changes the event listener registration timing in SidebarBottom from useEffect to useLayoutEffect to prevent the Visual Testing Addon (VTA) from missing critical initial render events.

  • Changed useEffect to useLayoutEffect in code/core/src/manager/components/sidebar/SidebarBottom.tsx to register event listeners before UI rendering
  • Updated @chromatic-com/storybook dependency from 3.2.0 to 3.2.2 in code/package.json
  • Fixes VTA getting stuck in 'pending' state when warnings occur during initial render (e.g., when not logged into Chromatic)

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

nx-cloud bot commented Dec 17, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit ceb8cc9. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@ghengeveld ghengeveld merged commit 9e9543b into next Dec 17, 2024
62 of 63 checks passed
@ghengeveld ghengeveld deleted the listen-early branch December 17, 2024 10:28
@github-actions github-actions bot mentioned this pull request Dec 17, 2024
7 tasks
@shilman shilman changed the title Core: Listen for test provider events before rendering test providers UI: Fix test provider event handling on startup Dec 18, 2024
@github-actions github-actions bot mentioned this pull request Dec 18, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants