google-gemini / google-gemini/computer-use-preview
PLAYWRIGHT_HEADLESS=false has no effect, browser always run headless
- Dominant language
- Python
- Stars
- 3.2k
- Forks
- 405
- PR merge metrics
- No merged PRs in 30d
Description
### Description of the bug:
## Bug Description
Setting `PLAYWRIGHT_HEADLESS=false` in `.env` does not show the browser window. The browser always runs headless regardless of the env var value
## Root Cause
In `computers/playwright/playwright.py` line 114:
```python
headless=bool(os.environ.get("PLAYWRIGHT_HEADLESS", False)),
```
os.environ.get() always returns a string never a Python boolean
bool("false") evaluates to True in Python because any non-empty string is truthy
So ```PLAYWRIGHT_HEADLESS=false ```-> bool("false") -> True -> always headless
### Actual vs expected behavior:
1. Set `PLAYWRIGHT_HEADLESS=false` in `.env`
2. Run `python main.py --query "go to google.com"`
3. Expected: browser window appears
4. Actual: browser runs headless and no window shown
Counterintuitively, removing `PLAYWRIGHT_HEADLESS` from `.env` entirely shows the browser, because the default `False` (boolean) is never passed through `bool()` as a string.
### Any other information you'd like to share?
## Proposed Fix
**Before**
```python
headless=bool(os.environ.get("PLAYWRIGHT_HEADLESS", False)),
```
**After**
```python
headless=os.environ.get("PLAYWRIGHT_HEADLESS", "false").lower() == "true",
```
This ensures only the string `"true"` (case-insensitive) enables headless mode and treating all other values as `false`.
I'd like to submit a PR for this fix if the approach looks good
Contributor guide
Assessment
This issue has not been assessed yet.