Skip to content

Browsers via playwright need to be manually installed. #333

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

Closed
bhouston opened this issue Mar 20, 2025 · 3 comments · Fixed by #336
Closed

Browsers via playwright need to be manually installed. #333

bhouston opened this issue Mar 20, 2025 · 3 comments · Fixed by #336
Labels

Comments

@bhouston
Copy link
Member

bhouston commented Mar 20, 2025

Problem Description

When mycoder is installed globally via npm install -g mycoder, users encounter issues with the browser automation functionality. This is because Playwright (the library used for browser automation) requires browsers to be installed separately, and these browsers are not automatically installed with the global npm installation.

Current Implementation

Currently, mycoder uses Playwright's built-in browser management, which expects browsers to be installed via Playwright's own installation mechanism. The SessionManager in the agent package launches Chrome using:

const browser = await chromium.launch({
  headless: sessionConfig.headless,
});

This expects Playwright's Chrome browser to be installed, which doesn't happen automatically with a global npm installation.

Proposed Solution

We should modify the browser automation to detect and use system-installed browsers (Chrome, Edge, Firefox, or Safari) instead of relying on Playwright's own browser installations. The solution should:

  1. Look for existing installed browsers on the user's system in a cross-platform way (Windows, macOS, Linux)
  2. Use the detected browser for automation
  3. Maintain the ability to run browsers in headless mode
  4. Preserve the clean session behavior (equivalent to incognito/private browsing)

This would eliminate the need for users to manually install browsers after installing mycoder globally.

@bhouston
Copy link
Member Author

Research Findings and Implementation Proposal

I've researched the issue with Playwright browser detection when mycoder is installed globally. Here's what I found and my proposed solution:

Key Findings

  1. Playwright's executablePath Option:

    • Playwright allows specifying a custom browser executable path using the executablePath option
    • This can be used to point to system-installed browsers instead of Playwright's bundled ones
  2. Browser Detection Approaches:

    • We can implement cross-platform browser detection for Chrome, Edge, Firefox, and possibly Safari
    • Libraries like chrome-launcher already implement this for Chrome/Chromium, but we can create our own solution
  3. System Browser Compatibility:

    • Playwright warns that it works best with its bundled browsers, but many projects successfully use system browsers
    • Chrome/Chromium are the most compatible, followed by Firefox
    • All major browsers support headless mode and incognito/clean sessions

Proposed Implementation

  1. Create a BrowserDetector module that:

    • Detects installed browsers on Windows, macOS, and Linux
    • Returns information about each browser (name, type, path)
    • Prioritizes browsers by compatibility with Playwright
  2. Modify the SessionManager to:

    • Use the BrowserDetector to find system browsers
    • Launch browsers with the executablePath option pointing to system browsers
    • Fall back to Playwright's bundled browsers if no system browser is found
  3. Add configuration options to:

    • Specify a custom browser executable path
    • Choose preferred browser type
    • Toggle between system browsers and Playwright's bundled browsers

I've created a detailed implementation proposal with code examples. Let me know if you'd like to proceed with this approach!

bhouston added a commit that referenced this issue Mar 21, 2025
This change allows mycoder to detect and use system-installed browsers
instead of requiring Playwright's bundled browsers to be installed.
It improves the experience when mycoder is installed globally via npm.

- Add BrowserDetector module for cross-platform browser detection
- Update SessionManager to use detected system browsers
- Add configuration options for browser preferences
- Update documentation in README.md
- Maintain compatibility with headless mode and clean sessions

Fixes #333
github-actions bot pushed a commit that referenced this issue Mar 21, 2025
# [mycoder-agent-v1.6.0](mycoder-agent-v1.5.0...mycoder-agent-v1.6.0) (2025-03-21)

### Features

* **browser:** add system browser detection for Playwright ([00bd879](00bd879)), closes [#333](#333)
Copy link

🎉 This issue has been resolved in version mycoder-agent-v1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this issue Mar 21, 2025
# [mycoder-v1.6.0](mycoder-v1.5.0...mycoder-v1.6.0) (2025-03-21)

### Features

* **browser:** add system browser detection for Playwright ([00bd879](00bd879)), closes [#333](#333)
Copy link

🎉 This issue has been resolved in version mycoder-v1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

bhouston added a commit that referenced this issue Mar 21, 2025
This commit adds documentation for the system browser detection feature introduced in PR #336 and issue #333. It includes:\n\n- New browser-detection.md page with comprehensive information\n- Updates to configuration.md to document new options\n- Updates to getting started guides for all platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant