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

CLI: Reuse existing chromium tab if possible #10329

Merged
merged 2 commits into from
Apr 14, 2020

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Apr 6, 2020

Issue: #10328

What I did

This PR moves from the library open to better-opn. What it does is basically tries to use the well known solution started at CRA, with an applescript to check if there is an existing tab on chrome and if so, reuses it. As a fallback, it uses the open lib.

This feature is unfortunately available on OSX Chrome only. better-opn is entirely based in the solution from facebook, and actually they recently added support for chromium based browsers here. I might add a PR on better-opn to update that as well.

The alternatives to support reusing tabs are:

instead of using:
import open from 'better-opn'
use:
import open from 'react-dev-utils/openBrowser'
However they do not recommend to use their internal tools directly because they can always change it without notice. In this particular case, I guess the chances are small though.

How to test

On OSX, checkout the branch and run yarn start, then kill the process and run it again.
You should see the tab being reused.
I couldn't test on windows, but as the lib falls back to open, it should behave the same as before, but of course if someone could test it out would be great.

closes #10328

- Move from open to better-opn
- Feature available on chrome only unfortunately
@yannbf
Copy link
Member Author

yannbf commented Apr 6, 2020

update: PR is open to update better-opn at michaellzc/better-opn#5, so if that is also merged then and storybook does use the lib, it will reuse the existing tab for most if not all chromium based browsers 😄

@shilman shilman changed the title feat: reuse existing chrome tab if possible CLI: Reuse existing chrome tab if possible Apr 7, 2020
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Awesome!! Should we wait until the better-opn PR is merged?

@yannbf
Copy link
Member Author

yannbf commented Apr 7, 2020

Awesome!! Should we wait until the better-opn PR is merged?

It's been merged and I have updated it! It would be great however if someone with windows could run it. It should be fine as it uses open as a fallback, but as I could not test I'd prefer if we could make sure it works fine.

@yannbf yannbf changed the title CLI: Reuse existing chrome tab if possible CLI: Reuse existing chromium tab if possible Apr 7, 2020
@yannbf
Copy link
Member Author

yannbf commented Apr 14, 2020

Did anyone by any chance manage to test on windows?

@shilman
Copy link
Member

shilman commented Apr 14, 2020

Yes, I think @tooppaaa tested on windows 👍

@shilman shilman added this to the 6.0 milestone Apr 14, 2020
@shilman shilman merged commit 40ca654 into storybookjs:next Apr 14, 2020
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.

Reuse existing tab if possible
2 participants