← Commit history

v2.0.253: Visibility invariant, third cut: assert it over the POPULATION by owning process instead of per session. Verified live that the per-session versions repaired nothing, because they had to find a session's handle first and a window in trouble is exactly the window that lacks one: the enumerating resolver only sees VISIBLE windows (circular), a park-failed window never persisted a handle, and a pup restart clears the birth capture. The property that matters needs no session mapping: no titled top-level window of a pup-owned Chrome process may be hidden. One enumeration now repairs every stranded window including ones pup has lost track of, for one PowerShell per sweep instead of one per session.

John Lauer ·73bc8023af ·2mo ago ·parent f8cbf58
4 files changed +62−21
adom-bridge-puppeteer-manifest.json+5−5
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "2.0.252",-  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.252/adom-bridge-puppeteer-v2.0.252.zip",-  "sha256": "b3d3b7d42d56a9ccdd4b95e9250d4f341d702e111e0821ca2443a65a12e57951",-  "size": 950597,+  "version": "2.0.253",+  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.253/adom-bridge-puppeteer-v2.0.253.zip",+  "sha256": "caa0eee49279d29b20d114f024e7137292e974a3166f3d5bb0f4a4f64bc73df4",+  "size": 951552,   "verbPrefixes": [     "browser_",     "desktop_recorder_",@@ -12,5 +12,5 @@   ],   "healthEndpoint": "/status",   "statusVerb": "browser_readiness",-  "released_at": "2026-08-20T10:23:22.624076Z"+  "released_at": "2026-08-20T10:26:50.108980Z" }
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-2.0.252\ No newline at end of file+2.0.253\ No newline at end of file
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "2.0.252",+  "version": "2.0.253",   "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. pup_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. pup_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. macOS (v1.9.74+): full parity with mac-native mechanics \u2014 background-by-default is the app-level hide (windows stay drivable/screenshottable while hidden), raise/lower map to unhide+activate/hide, pup_alert_window posts a native toast whose click focuses the window, pup_use {browser:'chrome',install:true} installs Chrome from the official dmg, and taskbar identity/badging remains Windows-only.",   "homepage": "https://wiki.adom.inc/adom/adom-bridge",   "author": "Adom Inc.",
src/server.js+55−14
@@ -18527,21 +18527,62 @@ setInterval(async () => {     // rebuild. _nudgeUntil covers the in-flight window; a nudge that STRANDED a window has long since     // passed it, so the repair still lands (at worst one sweep later).     if (Date.now() < _nudgeUntil) return;-    for (const [sid, sess] of [...sessions]) {+    // Assert the invariant over the POPULATION, by owning process — deliberately NOT per session.+    // Two earlier cuts of this sweep repaired nothing because they went looking for a session's+    // handle first: windowHwnd -> bestSessionHwnd falls back to enumerate-and-wiggle, which only ever+    // sees VISIBLE windows (circular — 28 straight "NOT resolved" misses on a hidden window sitting+    // right there), and the cached/birth handles are exactly what a window in trouble tends to lack+    // (a park-failed window never persisted one, and a pup restart clears the birth capture).+    // The property that actually matters needs no session mapping at all: NO titled top-level window+    // of a pup-owned Chrome process may be hidden. One enumeration repairs every stranded window,+    // including ones pup has lost track of, and costs one PowerShell per sweep instead of one per+    // session. Titled + WS_CAPTION only, so Chrome's own untitled helper windows are never touched.+    const pids = [...pupBrowserPidSet()].filter(Boolean);+    if (!pids.length) return;+    const ps = `$s=@'+using System; using System.Text; using System.Collections.Generic; using System.Runtime.InteropServices;+public static class VS {+  public delegate bool EnumProc(IntPtr h, IntPtr l);+  [DllImport("user32.dll")] public static extern bool EnumWindows(EnumProc cb, IntPtr l);+  [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr h);+  [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr h, int cmd);+  [DllImport("user32.dll")] public static extern int GetWindowText(IntPtr h, StringBuilder s, int n);+  [DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr h, int i);+  [DllImport("user32.dll")] public static extern int GetWindowThreadProcessId(IntPtr h, out int pid);+  public static List<string> Fix(int[] pids) {+    var outp = new List<string>();+    EnumWindows((h, l) => {+      if (IsWindowVisible(h)) return true;+      int pid; GetWindowThreadProcessId(h, out pid);+      if (Array.IndexOf(pids, pid) < 0) return true;+      if ((GetWindowLong(h, -16) & 0x00C00000) == 0) return true;   // WS_CAPTION — real windows only+      var sb = new StringBuilder(300); GetWindowText(h, sb, 300);+      if (sb.Length == 0) return true;+      ShowWindow(h, 4);                                              // SW_SHOWNOACTIVATE+      outp.Add((IsWindowVisible(h) ? "RESHOWN|" : "RESHOW-FAILED|") + h + "|" + sb.ToString());+      return true;+    }, IntPtr.Zero);+    return outp;+  }+}+'@; Add-Type -TypeDefinition $s; [VS]::Fix(@(${pids.join(',')})) | ForEach-Object { $_ }`;+    await new Promise((resolve) => {       try {-        if (!sess || !(sess.tabs || []).length) continue;-        // Resolve the handle WITHOUT the enumerating resolver. windowHwnd -> bestSessionHwnd falls-        // back to enumerate-and-wiggle, which only ever sees VISIBLE windows — so asking it to find a-        // HIDDEN window is circular, and the first cut of this sweep silently repaired nothing-        // (verified live: 28 straight "NOT resolved" misses on a window sitting right there, hidden).-        // The cached and birth-captured handles need no enumeration, and ownership is then proven by-        // PID (GetWindowThreadProcessId answers for hidden windows too).-        const hw = Number(sess._hwnd) || birthHwnd(sess);-        if (!hw) continue;-        if (!(await hwndBelongsToPup(hw, sess))) continue;-        await ensureWindowShown(hw, sid, `the ${cause} visibility sweep`);-      } catch (e) {}-    }+        execFile('powershell', ['-NoProfile', '-Command', ps], { windowsHide: true, timeout: 25000 }, (err, stdout) => {+          for (const line of String(stdout || '').trim().split(/\r?\n/)) {+            const m = /^(RESHOWN|RESHOW-FAILED)\|(\d+)\|(.*)$/.exec(line.trim());+            if (!m) continue;+            if (m[1] === 'RESHOWN') {+              console.log(`[visibility] re-showed a HIDDEN pup window (hwnd ${m[2]}, "${m[3].slice(0, 60)}") during the ${cause} visibility sweep — a hidden window's taskbar button reveals nothing to a human click`);+              try { recordCleanup(`re-showed a pup window that had been left HIDDEN ("${m[3].slice(0, 60)}") — its taskbar button would have revealed nothing when clicked`); } catch (e) {}+            } else {+              console.log(`[visibility] hwnd ${m[2]} ("${m[3].slice(0, 60)}") is hidden and would NOT re-show — reporting rather than pretending it is fine`);+            }+          }+          resolve();+        });+      } catch (e) { resolve(); }+    });   };   setTimeout(() => { sweepVisibility('startup').catch(() => {}); }, 20000);   setInterval(() => { sweepVisibility('periodic').catch(() => {}); }, 120000);