← Commit history

Re-evaluate a window category when a tab finishes navigating, so a window whose tabs were still loading no longer freezes on the wrong taskbar icon

John Lauer ·da3a610799 · ·parent d788565
4 files changed +49−6
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.47",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.47/adom-bridge-puppeteer-v1.9.47.zip",-  "sha256": "9c05af6098f98ee92b24c3cfabac4c3c14441769ae2730b8fd69f058205d4c31",-  "size": 296576,+  "version": "1.9.48",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.48/adom-bridge-puppeteer-v1.9.48.zip",+  "sha256": "0dc133d3c6fab96a03fefd2543a37a0fd5d26fcb61ae86eefc05b15404ffb53a",+  "size": 297384,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.47+1.9.48
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.47",+  "version": "1.9.48",   "description": "Drives a browser ALREADY on the machine \u2014 installed Chrome, else Microsoft Edge (every Windows PC ships with Edge) \u2014 launched with a FRESH isolated profile, so the common case has NO ~150 MB Chrome-for-Testing download and it never touches the user's real tabs/logins. Binds its local server to LOOPBACK (127.0.0.1) only, so no Windows Firewall 'allow Node through the firewall' prompt ever pops. Chrome for Testing is fetched only as a LAST RESORT if the machine has no Chromium browser at all. SPAWN-VERIFIED fallback: pup tries each detected browser (Chrome \u2192 Edge \u2192 CfT) and actually launches it, falling through to the next if one won't start (and handling browsers like Edge that relaunch onto another PID), so a corrupt/partial install never hard-fails an open. The browser that launches is cached as the default (persisted across restarts) so it isn't re-probed each time. On spawn the bridge SELF-WARMS: detects browsers + disk, and only if the box has no Chrome/Edge and no cached CfT does it background-fetch CfT so the first open is instant. browser_use pins a specific browser (chrome | edge | cft | auto); {browser:'chrome',install:true} downloads & installs REAL Google Chrome (user-scoped, no admin) on an Edge-only box. browser_readiness (READ-ONLY) reports which browser will be used + the full candidate list + the default + free disk. Every failure returns a specific errorCode + _hint (chrome_install_no_disk, chrome_download_network, chrome_install_permission, chrome_stable_not_detected, \u2026). Launches with FULL browser permissions by default for full debug (strictPermissions:true opts out). Headful automation: open/close windows+tabs, navigate, screenshot, eval JS, record. pup is a GENERIC, non-profile browser only \u2014 every session is a fresh isolated Chrome/Edge process, never the user's real signed-in browser; profile defaults to sessionId. To drive the user's REAL Chrome/Edge (their profile, cookies, SSO), use the Adom browser EXTENSION's nbrowser_* verbs \u2014 a separate bridge, not pup's job.",   "homepage": "https://wiki.adom.inc/adom/adom-desktop",   "author": "Adom Inc.",
src/server.js+43
@@ -241,6 +241,34 @@ function getTabById(session, tabId) { //   - "popup":          Chrome opened it via window.open() / target=_blank — auto-tracked //                       by the targetcreated listener wired in wirePopupTracking(). //                       openerTabId names the tab that triggered the popup.+// v1.9.48: debounced category re-check, fired by a tab's framenavigated. Debounced because a single+// user navigation emits several frame events (redirects, client-side routes) and each one would+// otherwise cost an AUMID re-register + re-stamp. Re-stamping is only done when the category ACTUALLY+// changed, so a settled window costs one cheap comparison.+const _catRecheckTimers = new Map();+function scheduleCategoryRecheck(sessionId) {+  if (process.platform !== 'win32') return;+  clearTimeout(_catRecheckTimers.get(sessionId));+  _catRecheckTimers.set(sessionId, setTimeout(async () => {+    _catRecheckTimers.delete(sessionId);+    try {+      const s = sessions.get(sessionId);+      if (!s) return;+      const cat = pupCategory(sessionId);+      if (!cat || cat === s._lastCat) return;+      console.log(`[identity] "${sessionId}" category changed ${s._lastCat || 'none'} -> ${cat} (after navigation) — re-stamping`);+      s._lastCat = cat;+      for (let i = 0; i < 4; i++) {+        let ok = false;+        try { ok = await brandPupWindow(sessionId); } catch (e) {}+        if (ok) { s._badgedAt = Date.now(); return; }+        await new Promise(r => setTimeout(r, 900 * (i + 1)));+      }+      console.log(`[identity] "${sessionId}" post-navigation re-stamp exhausted retries (wanted ${cat})`);+    } catch (e) {}+  }, 1500));+}+ function attachTab(session, sessionId, page, { makeActive = true, opener = 'user', openerTabId = null } = {}) {   const tabId = nextTabId(session);   const errors = [];@@ -278,6 +306,21 @@ function attachTab(session, sessionId, page, { makeActive = true, opener = 'user   // v1.8.21: install the shadow-DOM + scroll helpers on every document so browser_eval   // can use $deep / $$deep / deepText without hand-rolling a shadow-root walk.   try { page.evaluateOnNewDocument(PUP_DEEP_HELPERS).catch(() => {}); } catch (e) {}+  // v1.9.48: re-evaluate the window CATEGORY when this tab finishes navigating.+  //+  // Category used to be recomputed ONLY inside updateTabCountBadge, i.e. only when a tab VERB ran.+  // A tab's URL is not known at that instant — the page is still about:blank while the navigation+  // is in flight — so the category was computed from the tabs that happened to have loaded, cached+  // in _lastCat, and then never revisited, because nothing re-checks after a page settles. Opening+  // two tabs back-to-back reliably froze a wiki+web+app window on the plain "wiki" icon instead of+  // "mixed" (caught by the taskbar audit as r1: 3 tabs, registered wiki).+  // The navigation event is the correct trigger: it is exactly when a tab's category becomes known.+  try {+    page.on('framenavigated', (frame) => {+      try { if (frame !== page.mainFrame()) return; } catch (e) { return; }+      scheduleCategoryRecheck(sessionId);+    });+  } catch (e) {}   // v1.8.45: track when the USER activates this window (e.g. clicks its taskbar button to   // watch it) so pup can report per-window flash state PROGRAMMATICALLY. The window 'focus'   // event fires when the OS window is activated; we stamp the time. A focus AFTER the last