Skip to content

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

Merged
miguel-heygen merged 2 commits into
heygen-com:mainfrom
na-navi:feat-browser-launch-options-clean
May 16, 2026
Merged

feat(cli): add browser launch options to preview and play#884
miguel-heygen merged 2 commits into
heygen-com:mainfrom
na-navi:feat-browser-launch-options-clean

Conversation

@na-navi
Copy link
Copy Markdown
Contributor

@na-navi na-navi commented May 16, 2026

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

@miguel-heygen
Copy link
Copy Markdown
Collaborator

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

@na-navi na-navi force-pushed the feat-browser-launch-options-clean branch from a5dc854 to 5133613 Compare May 16, 2026 02:58
@na-navi
Copy link
Copy Markdown
Contributor Author

na-navi commented May 16, 2026

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!

@miguel-heygen miguel-heygen merged commit 64b3ae7 into heygen-com:main May 16, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants