hyperframes icon indicating copy to clipboard operation
hyperframes copied to clipboard

feat(cli): add browser launch options to preview and play

Open na-navi opened this issue 6 months ago • 2 comments

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-dir requires --browser-path
  • --no-open still takes priority and launches no browser
  • default behavior still uses the existing open package 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/profile exits with validation error
  • preview --no-open starts the server without opening a browser
  • preview --no-open --browser-path ...Firefox does not open a browser
  • play --user-data-dir /tmp/profile exits with validation error
  • preview --browser-path ...Firefox opens Firefox
  • preview --browser-path ...Chrome --user-data-dir ... opens Chrome with an isolated profile

na-navi avatar May 16 '26 02:05 na-navi

interesting, try to fix the failed ci checks, I'll consider this, seems very useful

miguel-heygen avatar May 16 '26 02:05 miguel-heygen

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!

na-navi avatar May 16 '26 11:05 na-navi