feat(linux): manage Chrome automatically like WebView2 on Windows (#11)
Joe Mild authored 3 weeks ago
* feat(browser): faster watchdog with login grace, no jitter, Teams-only login window
The app runs one Chrome per user (single instance), so the launch jitter only delayed every start by up to 2 s. The watchdog polls every 500 ms instead of 5 s, with a 4 s login_grace (matching WebView2's 4 s LOGIN_SHOW_DELAY_MS) so brief silent SSO redirects do not pop up a visible window.
login_window() and headless() acquire the operation lock before checking the current mode and return early when Chrome is already running in that mode. Before, every LoginRequired restarted the visible Chrome, which showed the login page again and looped once a second.
login_window() always opens only Teams instead of Teams + Outlook together: opening Outlook alongside Teams sends Outlook to login.microsoftonline.com?prompt=select_account before Teams has an SSO cookie, leaving that background tab stuck on login even after Teams finishes signing in.
Also exposes is_visible_managed(), is_busy(), and teams_has_msal_cache() so the Linux app host knows when a visible login Chrome has actually written MSAL tokens.
* feat(app): start and manage Chrome on Linux like WebView2 on Windows
Without --endpoint on Linux, the app now starts Chrome or Chromium itself through the browser crate (headless, own profile, port 9222) and runs its watchdog:
- first start without a profile opens the login window right away (Teams only)
- LoginRequired shows the Chrome window
- once Teams loaded and saved its MSAL cache (accesstoken + refreshtoken in localStorage) for 2 s, Chrome switches back to headless and wakes realtime/live retry immediately
- quitting the app stops Chrome with a 2 s timeout
LinuxTransport waits for the debug port and gates Session/Outlook behind the visible login window so Session neither opens Outlook Web in front of the user nor interrupts the login page with reload_all() or Trouter retries while the user is signing in.
--endpoint keeps the old behaviour (plain CdpTransport to an external Chrome).