CLI: Respect BROWSER and BROWSER_ARGS#34513
Conversation
pass correct option to open()
There was a problem hiding this comment.
Pull request overview
Fixes Storybook’s browser-opening behavior so BROWSER/BROWSER_ARGS are passed through to the open() library correctly (closing #30553).
Changes:
- Updates
open()invocation to pass browser arguments viaapp: { name, arguments }instead of the legacy “array form”.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (1)
📝 WalkthroughWalkthroughReplaced string+args coercion for browser launching: when ChangesBrowser Argument Handling
Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code/core/src/core-server/utils/open-browser/opener.ts`:
- Line 192: The options object currently always sets app: { name: browser,
arguments: args } which produces an invalid shape when browser is undefined and
causes open() to reject silently; change the logic around the options
construction in opener.ts so that you only include the app property when browser
is a defined string (use browser and args to build app only when browser !=
null/undefined), otherwise create options without app (e.g., { wait:false,
url:true }); also ensure the open(url, options) rejection is not swallowed—catch
errors from open() and return false or propagate the error instead of always
returning true.
🪄 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: 7a4b2d6d-bfb5-4e4c-bca3-4549504073df
📒 Files selected for processing (1)
code/core/src/core-server/utils/open-browser/opener.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code/core/src/core-server/utils/open-browser/opener.ts`:
- Around line 192-196: Add a regression test in
code/core/src/core-server/utils/open-browser/opener.test.ts that exercises the
new BROWSER_ARGS path: set up the environment (or pass values) so the code path
that constructs the options object in opener.ts runs with a non-empty args
value, call the function that builds the options (the same entry used by
existing tests around lines 97-109), and assert that the returned options.app is
an object with name equal to the provided browser and arguments equal to the
expected args array/string; also include a test case for when browser is truthy
but no args are provided to ensure arguments is undefined or handled as before.
Ensure the test cleans up environment changes so it won’t affect other tests.
🪄 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: 9036eee4-c550-4123-8fd6-7771db87d349
📒 Files selected for processing (1)
code/core/src/core-server/utils/open-browser/opener.ts
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sidnioulz
left a comment
There was a problem hiding this comment.
Tested locally, the fix works well! Thanks @ianzone!
Could you please include a new paragraph in https://storybook.js.org/docs/configure/environment-variables#using-environment-variables-to-choose-the-browser to explain that BROWSER_ARGS can be used to adjust params (but requires BROWSER to be set to)? I'll see if Copilot is in the mood to do it for you but no promises.
Also, FYI: the "manual testing" section should explain how I, as a reviewer, can test your PR. It shouldn't explain how you tested as a PR author. The goal is to help reviewers save time by jumping into review faster :)
Sidnioulz
left a comment
There was a problem hiding this comment.
I've added the docs. Let's wait for CI and I'll merge if it's green. Thanks again!
pass correct options to open()
Closes #30553
What I did
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
tested on my local machine.
Documentation
MIGRATION.MD
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.tsMake 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/coreteam 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
Bug Fixes
Tests