|
| 1 | +--- |
| 2 | +title: Remote Browser Connection |
| 3 | +description: Connect to an existing Chrome browser for containerized development, custom profiles, and remote workflows |
| 4 | +sidebar_position: 11 |
| 5 | +--- |
| 6 | + |
| 7 | +# Remote Browser Connection |
| 8 | + |
| 9 | +## What Is Remote Browser Connection? |
| 10 | + |
| 11 | +Connect Roo to an existing Chrome browser instead of launching a new one. This powerful feature bypasses Roo's default browser process creation, enabling you to use Roo in containerized environments, with custom browser profiles, and across remote development workflows. |
| 12 | + |
| 13 | +> **Key Benefit:** Remote browser connection solves common challenges with containerized development and remote workflows by separating the browser process from the VS Code environment. |
| 14 | +
|
| 15 | +### When To Use Remote Browser Connection |
| 16 | + |
| 17 | +- **DevContainers:** Connect from containerized VS Code to a Chrome browser running on your host system |
| 18 | +- **Remote Development:** Use Chrome on a local development machine while working on a remote server |
| 19 | +- **Custom Chrome Profiles:** Leverage specific profiles with your preferred extensions and settings |
| 20 | +- **Shared Browser Sessions:** Allow multiple Roo instances to connect to the same browser session |
| 21 | + |
| 22 | +## Setting Up Remote Browser Connection |
| 23 | + |
| 24 | +To use the remote browser connection feature, you'll need to complete three simple steps: launch Chrome with remote debugging enabled, configure Roo settings, and (if using containers) set up network access. |
| 25 | + |
| 26 | +### 1. Launch Chrome with Remote Debugging |
| 27 | + |
| 28 | +Launch Chrome with the remote debugging port enabled: |
| 29 | + |
| 30 | +**On macOS:** |
| 31 | +```bash |
| 32 | +/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug |
| 33 | +``` |
| 34 | + |
| 35 | +**On Windows:** |
| 36 | +```bash |
| 37 | +"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir=C:\chrome-debug |
| 38 | +``` |
| 39 | + |
| 40 | +**On Linux:** |
| 41 | +```bash |
| 42 | +google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug |
| 43 | +``` |
| 44 | + |
| 45 | +> **Note:** The `--user-data-dir` parameter creates a separate Chrome profile that won't interfere with your regular browsing. |
| 46 | +
|
| 47 | +### 2. Configuring Roo Settings |
| 48 | + |
| 49 | +Once Chrome is running with remote debugging, configure Roo: |
| 50 | + |
| 51 | +1. Open VS Code settings and search for "Roo browser" |
| 52 | +2. Enable "Use remote browser connection" |
| 53 | +3. Optionally enter a custom Chrome DevTools Protocol URL (for non-standard setups) |
| 54 | +4. Click "Test Connection" to verify connectivity |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +### 3. Setting Up DevContainer Integration |
| 60 | + |
| 61 | +If you're developing inside a container, you'll need to configure network access to reach the host machine: |
| 62 | + |
| 63 | +For VS Code devcontainers, add this network configuration to your `devcontainer.json`: |
| 64 | + |
| 65 | +```json |
| 66 | +"runArgs": [ |
| 67 | + "--network=host" // Enables access to host's Chrome instance |
| 68 | +] |
| 69 | +``` |
| 70 | + |
| 71 | +## Understanding How Connections Work |
| 72 | + |
| 73 | +After configuration, Roo establishes connections with Chrome using a sophisticated multi-step process to ensure reliability. |
| 74 | + |
| 75 | +When enabled, Roo connects to Chrome following this sequence: |
| 76 | + |
| 77 | +1. Attempts connection using your custom URL (if provided) |
| 78 | +2. If unsuccessful, runs auto-discovery on localhost, Docker containers, and local network |
| 79 | +3. Falls back to launching a local browser instance if all remote connection attempts fail |
| 80 | + |
| 81 | +## Troubleshooting Connection Problems |
| 82 | + |
| 83 | +If you encounter issues with the remote browser connection, here are solutions to the most common problems: |
| 84 | + |
| 85 | +- **Connection Failed:** Verify Chrome is running with the correct debugging flag and port |
| 86 | +- **Port Already in Use:** Change to an alternative port (e.g., `9333`) in both your Chrome launch command and Roo settings |
| 87 | +- **Network Issues:** Ensure your container/VM network settings allow access to the Chrome host machine |
| 88 | +- **Chrome Not Detected:** Check that firewall settings aren't blocking WebSocket connections |
| 89 | +- **Permission Errors:** Make sure you have the necessary permissions to access the specified `--user-data-dir` location |
| 90 | + |
| 91 | +## Exploring Advanced Capabilities |
| 92 | + |
| 93 | +For power users and advanced scenarios, Roo's remote browser connection includes several sophisticated features that enhance flexibility and reliability. |
| 94 | + |
| 95 | +### How Auto-Discovery Works |
| 96 | + |
| 97 | +When no specific URL is provided, Roo automatically locates Chrome instances by searching: |
| 98 | +- Standard debugging ports on localhost (9222, 9223) |
| 99 | +- Running containers with debugging-enabled Chrome |
| 100 | +- Network-accessible instances using discovery protocols |
| 101 | + |
| 102 | +### Understanding Automatic Fallback |
| 103 | + |
| 104 | +When remote connection attempts fail, Roo automatically launches a local browser instance, ensuring continuous workflow without manual intervention. |
| 105 | + |
| 106 | +### Alternative Setup: Using Chrome DevTools |
| 107 | + |
| 108 | +For situations where command-line configuration isn't ideal: |
| 109 | + |
| 110 | +1. Open `chrome://inspect` in Chrome |
| 111 | +2. Click "Configure" next to "Discover network targets" |
| 112 | +3. Add `localhost:9222` and click "Done" |
| 113 | + |
| 114 | +## Related Features |
| 115 | + |
| 116 | +Remote browser connection works seamlessly with other Roo features: |
| 117 | + |
| 118 | +- **[Custom Modes](custom-modes)**: Create specialized browser-based modes |
| 119 | +- **[Code Actions](code-actions)**: Execute browser-based actions against remote instances |
| 120 | +- **[Large Projects](large-projects)**: Improve performance by separating browser processes |
| 121 | + |
| 122 | +## Summary |
| 123 | + |
| 124 | +Remote browser connection provides flexibility for containerized development, custom browser profiles, and remote workflows. By following the setup instructions in this guide, you can leverage the power of an existing Chrome instance for your Roo sessions, making your development process more efficient and adaptable to various environments. |
0 commit comments