Skip to content

PLAYWRIGHT_HEADLESS=false has no effect, browser always run headless #119

Description

@tsukayaa

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:

  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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions