feat(cli): add browser launch options to preview and play
Summary
Adds explicit browser launch options to hyperframes preview and hyperframes play.
New options:
--browser-path <path>: open the preview/player URL with a specific browser executable--user-data-dir <dir>: pass a Chromium-compatible profile directory when launching via--browser-path
Default behavior is unchanged. Without these flags, both commands continue to use the existing default-browser behavior. --no-open still prevents any browser launch.
Why
This is useful for local QA and development workflows where users want to open HyperFrames in a dedicated browser instead of their main browser session.
For example:
hyperframes preview --browser-path /usr/bin/chromium
hyperframes preview --browser-path "C:\Program Files\Mozilla Firefox\firefox.exe"
hyperframes preview --browser-path "C:\Program Files\Google\Chrome\Application\chrome.exe" --user-data-dir .hyperframes/chrome-profile
Behavior
--user-data-dirrequires--browser-path--no-openstill takes priority and launches no browser- default behavior still uses the existing
openpackage path - browser spawn failures are ignored, matching the existing best-effort browser-open behavior
Non-goals
- Does not add browser automation
- Does not open a DevTools/CDP port
- Does not add a Playwright dependency
- Does not change the default browser behavior
Testing
Automated:
bunx oxlint packages/cli/src/commands/play.ts packages/cli/src/commands/preview.ts packages/cli/src/utils/openBrowser.ts packages/cli/src/utils/openBrowser.test.ts
bunx oxfmt --check packages/cli/src/commands/play.ts packages/cli/src/commands/preview.ts packages/cli/src/utils/openBrowser.ts packages/cli/src/utils/openBrowser.test.ts
bun test packages/cli/src/utils/openBrowser.test.ts
Manual smoke tests:
preview --user-data-dir /tmp/profileexits with validation errorpreview --no-openstarts the server without opening a browserpreview --no-open --browser-path ...Firefoxdoes not open a browserplay --user-data-dir /tmp/profileexits with validation errorpreview --browser-path ...Firefoxopens Firefoxpreview --browser-path ...Chrome --user-data-dir ...opens Chrome with an isolated profile
interesting, try to fix the failed ci checks, I'll consider this, seems very useful
Thanks! I fixed the CI issue, and the checks are green now.
I had tested locally with bun test, but the repo’s CI runs Vitest, so I adjusted the fix against Vitest. I also added a spawn error listener so invalid browser paths keep the existing best-effort behavior instead of crashing with ENOENT.
Appreciate you taking a look!