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:
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:
- Set
PLAYWRIGHT_HEADLESS=false in .env
- Run
python main.py --query "go to google.com"
- Expected: browser window appears
- 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
headless=bool(os.environ.get("PLAYWRIGHT_HEADLESS", False)),
After
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
Description of the bug:
Bug Description
Setting
PLAYWRIGHT_HEADLESS=falsein.envdoes not show the browser window. The browser always runs headless regardless of the env var valueRoot Cause
In
computers/playwright/playwright.pyline 114: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 headlessActual vs expected behavior:
PLAYWRIGHT_HEADLESS=falsein.envpython main.py --query "go to google.com"Counterintuitively, removing
PLAYWRIGHT_HEADLESSfrom.enventirely shows the browser, because the defaultFalse(boolean) is never passed throughbool()as a string.Any other information you'd like to share?
Proposed Fix
Before
After
This ensures only the string
"true"(case-insensitive) enables headless mode and treating all other values asfalse.I'd like to submit a PR for this fix if the approach looks good