Fix browser detection and fullscreen launch for macOS #13

Merged
Copilot merged 3 commits from copilot/fix-icon-webpages-opening into main 2025-11-16 14:41:47 -06:00
Copilot commented 2025-11-16 13:07:47 -06:00 (Migrated from github.com)

After restructuring, webpages weren't opening in fullscreen/kiosk mode due to broken browser detection on macOS.

Root Cause

macOS browser detection used shutil.which('Google Chrome') which fails because:

  • shutil.which() searches PATH for executables
  • macOS app bundles have spaces in names and live at full paths like /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

Changes

Browser Detection (services.py)

  • Added _is_browser_available() method with platform-specific logic:
    • macOS: Extract executable path from command template, use os.path.exists() for full paths, shlex.split() for proper parsing of escaped spaces
    • Linux/Windows: Continue using shutil.which() for PATH-based detection
def _is_browser_available(self, browser_name: str, browser_cmd: str, system: str) -> bool:
    if system == "Darwin":
        parts = shlex.split(browser_cmd.replace('{url}', 'placeholder'))
        if parts and parts[0].startswith('/'):
            return os.path.exists(parts[0])
        return shutil.which(parts[0]) is not None
    return shutil.which(browser_name) is not None

Fallback Handling

  • Check webbrowser.open() return value and raise RuntimeError on failure instead of silent failure

Testing

  • Added test_browser_availability_detection covering all platform detection paths
Original prompt

From the restructuring changes, it seems like the wepages for the icons are not utomatically opening or opening in full screen mode.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

After restructuring, webpages weren't opening in fullscreen/kiosk mode due to broken browser detection on macOS. ## Root Cause macOS browser detection used `shutil.which('Google Chrome')` which fails because: - `shutil.which()` searches PATH for executables - macOS app bundles have spaces in names and live at full paths like `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` ## Changes ### Browser Detection (`services.py`) - Added `_is_browser_available()` method with platform-specific logic: - **macOS**: Extract executable path from command template, use `os.path.exists()` for full paths, `shlex.split()` for proper parsing of escaped spaces - **Linux/Windows**: Continue using `shutil.which()` for PATH-based detection ```python def _is_browser_available(self, browser_name: str, browser_cmd: str, system: str) -> bool: if system == "Darwin": parts = shlex.split(browser_cmd.replace('{url}', 'placeholder')) if parts and parts[0].startswith('/'): return os.path.exists(parts[0]) return shutil.which(parts[0]) is not None return shutil.which(browser_name) is not None ``` ### Fallback Handling - Check `webbrowser.open()` return value and raise `RuntimeError` on failure instead of silent failure ### Testing - Added `test_browser_availability_detection` covering all platform detection paths <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > From the restructuring changes, it seems like the wepages for the icons are not utomatically opening or opening in full screen mode. </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
SluberskiHomeLab (Migrated from github.com) approved these changes 2025-11-16 14:41:36 -06:00
Sign in to join this conversation.
No description provided.