Skip to content

Build: Automatically recompile on branch switch#34930

Merged
Sidnioulz merged 4 commits into
nextfrom
sidnioulz/post-checkout-optional-hook
May 27, 2026
Merged

Build: Automatically recompile on branch switch#34930
Sidnioulz merged 4 commits into
nextfrom
sidnioulz/post-checkout-optional-hook

Conversation

@Sidnioulz
Copy link
Copy Markdown
Contributor

@Sidnioulz Sidnioulz commented May 27, 2026

What I did

Added an optional Git hook on checkout to reinstall deps and recompile the codebase. Ensures you're ready to use the branch without manual intervention.

Gated by STORYBOOK_COMPILE_ON_CHECKOUT env.

Checklist for Contributors

Testing

Manual testing

  • Checkout this branch
  • git checkout -b dummy-branch and notice no compilation
  • export STORYBOOK_COMPILE_ON_CHECKOUT=true
  • git checkout -b dummier-branch and notice that SB now reinstalls deps and recompiles

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 publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Chores
    • Added optional automatic Storybook compilation when switching branches, controllable via an environment setting to keep build artifacts synchronized.
    • Exposed an additional manager error to improve error reporting and surface clearer failure information in the UI.

Review Change Stack

Copilot AI review requested due to automatic review settings May 27, 2026 09:57
@Sidnioulz Sidnioulz added build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). labels May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional Husky post-checkout Git hook that can reinstall dependencies and recompile the repo when switching branches, gated by STORYBOOK_COMPILE_ON_CHECKOUT.

Changes:

  • Introduces .husky/post-checkout to run yarn and yarn task compile -s compile when STORYBOOK_COMPILE_ON_CHECKOUT is set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .husky/post-checkout Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ab134657-fce5-4c9c-acdc-944cbc0bf2a5

📥 Commits

Reviewing files that changed from the base of the PR and between 54f6b4d and ead5b73.

📒 Files selected for processing (1)
  • .husky/post-checkout
🚧 Files skipped from review as they are similar to previous changes (1)
  • .husky/post-checkout

📝 Walkthrough

Walkthrough

Adds a conditional Git post-checkout hook .husky/post-checkout that runs yarn and yarn task compile -s compile when STORYBOOK_COMPILE_ON_CHECKOUT is "true", and adds UniversalStoreFollowerTimeoutError to the manager global exports list.

Changes

Post-checkout hook

Layer / File(s) Summary
Post-checkout hook configuration
.husky/post-checkout
Adds a post-checkout Git hook that checks STORYBOOK_COMPILE_ON_CHECKOUT for the exact value "true", then runs yarn and yarn task compile -s compile.

Manager globals export

Layer / File(s) Summary
Add UniversalStoreFollowerTimeoutError export
code/core/src/manager/globals/exports.ts
Adds UniversalStoreFollowerTimeoutError to the storybook/internal/manager-errors entry in the globalized export list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.husky/post-checkout:
- Around line 1-2: The post-checkout hook currently uses a non-empty check for
STORYBOOK_COMPILE_ON_CHECKOUT which treats any non-empty value (including
"false") as true; change the if condition in .husky/post-checkout to an explicit
boolean comparison such as [ "$STORYBOOK_COMPILE_ON_CHECKOUT" = "true" ] (or
check for "1" as an alternative) so yarn && yarn task compile -s compile only
runs when the variable is intentionally enabled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f23ef26-d3be-427e-b306-cb88665d4112

📥 Commits

Reviewing files that changed from the base of the PR and between 73fa773 and 394ef59.

📒 Files selected for processing (1)
  • .husky/post-checkout

Comment thread .husky/post-checkout Outdated
Copilot AI and others added 2 commits May 27, 2026 10:14
Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
@Sidnioulz Sidnioulz merged commit 23aef53 into next May 27, 2026
140 checks passed
@Sidnioulz Sidnioulz deleted the sidnioulz/post-checkout-optional-hook branch May 27, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants