← Commit history

Never-red overlays, clear-flashes that truly clears, fg/bg buttons, full-coverage ralph (four John asks in one build). (1) RED LEDS GALORE root cause: the overlay enforcer added in 1.9.236 sat inside the health interval whose FIRST LINE is 'if (minimalTouch()) return' - minimal-touch is the normal mode, so the enforcer never ran once; after every bridge restart all windows sat bare until some verb happened to repaint. Enforcement now has its OWN ungated 10s interval (overlays are explicitly allowed in minimal-touch, v1.9.191), and rescanProfile repaints every reattached session ~1.5s after a restart - so model==glass within seconds and a window is never knowingly bare longer than ~10s. (2) CLEAR-FLASHES: the 1.9.242 hwnd tracking was per-boot, so flashes started before a bridge restart (every ship) were invisible to the sweep - exactly what John hit twice. clear-all now ENUMERATES every visible top-level window of every pup-managed Chrome process (same PS enum as the badge resolver, filtered to pup's own PIDs so the user's personal Chrome is untouched) and stops each one - no bookkeeping to lose; response reports the swept count. (3) Every window row gets [bring to fg]/[send to bg] and every tab row gets [fg]/[bg] - implemented as loopback self-calls into the REAL raise/lower verbs so every safety behaviour applies unchanged (on-screen caption with the reason, standard reveal geometry, badge re-assert after reveal); a dashboard click is the user acting, which satisfies the foreground gate by definition. (4) The ralph suite now drives EVERY dashboard button and asserts EFFECTS: fg/bg assert the foreground flag + active tab actually changed; flash/clear assert ON GLASS via taskbar screenshots (attention-pixel count must rise on flash-all and fall back after clear) plus the enumerated sweep count; close-all asserts 0 windows remain; collapse/jump/filter widgets asserted in-DOM.

John Lauer ·ed1f7c2f4c ·2mo ago ·parent b82d3bf
4 files changed +129−39
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.242",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.242/adom-bridge-puppeteer-v1.9.242.zip",-  "sha256": "9e721e55a955cdaf3a558725249c94ecae6cc5324ef8dfb9713dd4e068a0b718",-  "size": 464814,+  "version": "1.9.243",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.243/adom-bridge-puppeteer-v1.9.243.zip",+  "sha256": "86de3737b1e4cc64dad56ed3093fd44922a833b85f9398fea51cfabaab48cb86",+  "size": 466202,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.242+1.9.243
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.242",+  "version": "1.9.243",   "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. 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, browser_alert_window posts a native toast whose click focuses the window, browser_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-desktop",   "author": "Adom Inc.",
src/server.js+123−33
@@ -1455,6 +1455,15 @@ async function rescanProfile(browser, profileName, { adoptOrphans = false } = {}   for (const [sid, s] of sessions.entries()) {     if (s.profileName === profileName) { try { await reconcileSessionTabs(s, sid); } catch (e) {} }   }+  // v1.9.243: repaint overlays IMMEDIATELY on reattach. A bridge restart wipes in-memory painted+  // state while the REAL taskbar keeps whatever was on it — the dashboard and taskbar diverge until+  // something repaints (John: "the taskbar icon you show for icon 1 is not consistent with what you+  // show in the windows taskbar"). Converge at the source: every reattached session repaints now, so+  // model == glass within seconds of a restart, not minutes.+  for (const sid of seenSessions) {+    const s2 = sessions.get(sid);+    if (s2 && (s2.tabs || []).length) setTimeout(() => { applyAppOverlay(s2, sid).catch(() => {}); }, 1500);+  }   // v1.8.57: after a reattach, self-heal a window stranded off-screen by an older build's   // failed park (one heal per profile — all this profile's sessions share the window).   if (reattached > 0) {@@ -5957,6 +5966,55 @@ async function flashViaAD(sessionId, opts) {   catch (e) { return null; } } const _flashedHwnds = new Set(); // every hwnd pup ever flashed this boot — the clear-all sweep list+// v1.9.243 (John: "i just hit clear flashes again and it still didn't clear"). Per-boot bookkeeping+// was the hole: a bridge restart (every ship) empties the set while the taskbar keeps its orange, so+// clear-all had nothing to sweep. Bookkeeping across restarts is inherently fragile — so DON'T rely+// on it: enumerate every visible top-level window of every pup-managed Chrome process (same PS enum+// the badge resolver uses) and stop them ALL. Filtered to pup's own browser PIDs so the user's+// personal Chrome is never touched.+async function enumAllPupChromeHwnds() {+  if (process.platform !== 'win32') return [];+  const pupPids = new Set();+  for (const [, be] of browsers) {+    try { const pid = be && be.browser && (be.browser._detachedPid || (be.browser.process() && be.browser.process().pid)); if (pid) pupPids.add(Number(pid)); } catch (e) {}+  }+  if (!pupPids.size) return [];+  try {+    const scriptPath = path.join(require('os').tmpdir(), `_adom_allhwnd_${process.pid}.ps1`);+    const ps = [+      'Add-Type @"',+      'using System; using System.Runtime.InteropServices; using System.Text; using System.Collections.Generic;',+      'public class WEnumF {',+      '  public delegate bool Proc(IntPtr h, IntPtr l);',+      '  [DllImport("user32.dll")] public static extern bool EnumWindows(Proc p, IntPtr l);',+      '  [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr h);',+      '  [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid);',+      '  [DllImport("user32.dll")] public static extern int GetClassName(IntPtr h, StringBuilder s, int n);',+      '  public static List<string> Find() {',+      '    var outp = new List<string>();',+      '    EnumWindows((h, l) => {',+      '      if (!IsWindowVisible(h)) return true;',+      '      uint pid; GetWindowThreadProcessId(h, out pid);',+      '      var cn = new StringBuilder(128); GetClassName(h, cn, 128);',+      '      if (cn.ToString() != "Chrome_WidgetWin_1") return true;',+      '      outp.Add(((long)h).ToString() + "," + pid);',+      '      return true;',+      '    }, IntPtr.Zero);',+      '    return outp;',+      '  } }',+      '"@',+      '[WEnumF]::Find() | ForEach-Object { Write-Output $_ }',+    ].join(String.fromCharCode(13,10));+    fs.writeFileSync(scriptPath, ps);+    const out = (await runPsHiddenPromise(scriptPath, { timeout: 9000 }) || '').trim();+    const hwnds = [];+    for (const line of out.split(/\r?\n/)) {+      const [h, pid] = line.split(',').map(Number);+      if (h && pupPids.has(pid)) hwnds.push(h);+    }+    return hwnds;+  } catch (e) { return []; }+}  // v1.8.23: verbs that MUTATE a session's visible state → auto-flash the window so the // user knows the agent changed it. evaluate counts UNLESS {readOnly:true}.@@ -8213,7 +8271,9 @@ function render(){             +(crash?'<span class="tag warn">'+(w.lostBrowser?'browser lost':'crashed tab')+'</span>':'')             +(w.errorCount?'<span class="tag warn">'+w.errorCount+' err</span>':'')             +'<span class="meta">'+esc(w.profile)+' &middot; '+ago(w.uptimeMs)+'</span>'-            +'<span class="acts"><button class="btn sm" data-act="flash" data-sid="'+esc(w.sessionId)+'">flash</button>'+            +'<span class="acts">'+              +(w.foreground?'<button class="btn sm" data-act="bg" data-sid="'+esc(w.sessionId)+'">send to bg</button>':'<button class="btn sm" data-act="fg" data-sid="'+esc(w.sessionId)+'">bring to fg</button>')+              +'<button class="btn sm" data-act="flash" data-sid="'+esc(w.sessionId)+'">flash</button>'               +'<button class="btn sm" data-act="unflash" data-sid="'+esc(w.sessionId)+'">clear</button>'               +'<button class="btn sm danger" data-act="close-window" data-sid="'+esc(w.sessionId)+'" data-confirm="Close '+esc(w.sessionId)+'?">close</button></span></div>'           +'<div class="'+(wcoll?'hidden':'')+'">'@@ -8226,7 +8286,9 @@ function render(){             +(t.active?'<span class="tag fg">active</span>':'')             +(t.crashed?'<span class="tag warn">crashed</span>':'')             +favTags(t.fav)-            +'<span class="acts"><button class="btn xs danger" data-act="close-tab" data-sid="'+esc(w.sessionId)+'" data-tid="'+esc(t.tabId)+'">close</button></span></div>'+            +'<span class="acts"><button class="btn xs" data-act="fg" data-sid="'+esc(w.sessionId)+'" data-tid="'+esc(t.tabId)+'">fg</button>'+            +'<button class="btn xs" data-act="bg" data-sid="'+esc(w.sessionId)+'">bg</button>'+            +'<button class="btn xs danger" data-act="close-tab" data-sid="'+esc(w.sessionId)+'" data-tid="'+esc(t.tabId)+'">close</button></span></div>'           ).join('')+'</div></div></div>';       }).join('')+'</div></div>';   }).join(''):'<div class="empty">no pup windows open'+(th||q?' matching this filter':'')+'</div>';@@ -8340,19 +8402,47 @@ const server = http.createServer(async (req, res) => {           try { await tab.page.close(); } catch (e) {}           return done({ ok: true, closed: tid });         }+        if (act === 'fg' && sid) {+          // v1.9.243 (John: "add a 'bring to fg' and 'send to bg' button to each tab/window").+          // Self-call the REAL raise verb so every safety behaviour applies unchanged (caption with+          // the reason, standard reveal geometry, badge re-assert). A dashboard click IS the user+          // acting, so the foreground gate's reason is exactly that.+          try {+            if (body.tabId) { await fetch(`http://127.0.0.1:${PORT}/command`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ command: 'browser_switch_tab', args: { sessionId: sid, tabId: body.tabId } }) }); }+            const r = await fetch(`http://127.0.0.1:${PORT}/command`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ command: 'browser_raise_os_window', args: { sessionId: sid, foregroundReason: 'you clicked "bring to fg" on this window in the pup dashboard' } }) });+            const j = await r.json().catch(() => ({}));+            return done({ ok: !!j.success });+          } catch (e) { return done({ ok: false, error: e.message }); }+        }+        if (act === 'bg' && sid) {+          try {+            const r = await fetch(`http://127.0.0.1:${PORT}/command`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ command: 'browser_lower_os_window', args: { sessionId: sid } }) });+            const j = await r.json().catch(() => ({}));+            return done({ ok: !!j.success });+          } catch (e) { return done({ ok: false, error: e.message }); }+        }         if (act === 'flash' && sid)    { try { await flashViaAD(sid, { force: true }); } catch (e) {} return done({ ok: true }); }         if (act === 'unflash' && sid)  { try { await flashViaAD(sid, { stop: true, force: true }); } catch (e) {} return done({ ok: true }); }         if (act === 'flash-all' || act === 'unflash-all') {           const stop = act === 'unflash-all';           for (const id of [...sessions.keys()]) { try { await flashViaAD(id, stop ? { stop: true, force: true } : { force: true }); } catch (e) {} }           if (stop) {-            // v1.9.242: ALSO sweep every hwnd pup ever flashed this boot. A per-session stop misses-            // windows whose session closed/renamed since the flash, and FlashWindowEx keeps those-            // buttons highlighted forever without an explicit stop on that exact hwnd.+            // v1.9.243: sweep by ENUMERATION, not bookkeeping. The tracked set is per-boot, so any+            // flash started before the last bridge restart was invisible to it (exactly what John+            // hit). Enumerate every visible window of every pup-managed Chrome process and stop each+            // one — no memory required, covers retitled/closed-session/pre-restart flashes alike.+            const swept = new Set();+            try {+              for (const h of await enumAllPupChromeHwnds()) {+                try { await chrome.adCommand('desktop_flash_window', { hwnd: h, stop: true }, { timeoutMs: 6000 }); swept.add(h); } catch (e) {}+              }+            } catch (e) {}             for (const h of [..._flashedHwnds]) {-              try { await chrome.adCommand('desktop_flash_window', { hwnd: h, stop: true }, { timeoutMs: 6000 }); } catch (e) {}+              if (!swept.has(h)) { try { await chrome.adCommand('desktop_flash_window', { hwnd: h, stop: true }, { timeoutMs: 6000 }); } catch (e) {} }               _flashedHwnds.delete(h);             }+            console.log(`[flash] clear-all swept ${swept.size} enumerated pup Chrome windows + tracked set`);+            return done({ ok: true, n: sessions.size, swept: swept.size });           }           return done({ ok: true, n: sessions.size });         }@@ -12170,6 +12260,33 @@ server.listen(PORT, BIND_HOST, async () => {   const _healingIds = new Set();          // sessionIds with a relaunch in flight (guards the 15s re-tick)   const MAX_HEAL_ATTEMPTS = 2;   const HEAL_COOLDOWN_MS = 5 * 60 * 1000;+  // v1.9.243 (John: "you have red led's galore in your dashboard. why?"). The overlay ENFORCER was+  // dead on arrival: it sat inside the health interval ABOVE, whose first line is `if (minimalTouch())+  // return;` — and minimal-touch is the normal mode, so it never ran once. Overlays are explicitly+  // ALLOWED in minimal-touch (v1.9.191, gentle branding), so enforcement gets its OWN interval with no+  // minimal-touch gate. 10s cadence: a window is never knowingly bare for more than ~10s.+  setInterval(async () => {+    if (process.platform !== 'win32' || _identitySupported !== true) return;+    try {+      for (const [sid2, s2] of [...sessions]) {+        if (s2._lostBrowser || !(s2.tabs || []).length) continue;+        const bare = !s2._appOverlay;+        const stuckGeneric = s2._appOverlay && s2._overlayIsGeneric;+        if (!bare && !stuckGeneric) continue;+        const last = s2._overlayEnforceAt || 0;+        const cooldown = bare ? 20000 : 90000;+        if (Date.now() - last < cooldown) continue;+        s2._overlayEnforceAt = Date.now();+        const wasGeneric = stuckGeneric;+        applyAppOverlay(s2, sid2).then(okp => {+          if (!okp) return;+          if (wasGeneric && !s2._overlayIsGeneric) console.log(`[overlay] "${sid2}" UPGRADED generic → real favicon (enforcer re-fetched it)`);+          else if (bare) console.log(`[overlay] "${sid2}" ENFORCED (was bare) — every pup window must wear its overlay`);+        }).catch(() => {});+      }+    } catch (e) {}+  }, 10000);+   setInterval(async () => {     if (process.platform !== 'win32') return;     // v1.9.185 minimal-touch: NEVER kill or relaunch the user's Chrome behind their back. John:@@ -12232,33 +12349,6 @@ server.listen(PORT, BIND_HOST, async () => {         _healingIds.delete(sid);       }     }-    // (2b) OVERLAY ENFORCEMENT (v1.9.236, John: 'the whole point here is to get you to finally-    // create overlay icons correctly... you still seem to not ensure there are overlay icons').-    // An overlay is not fire-and-forget: paints fail transiently (window not yet resolvable, favicon-    // not loaded, AD busy) and were never retried, and a bridge restart wiped the painted state, so-    // real taskbar buttons sat BARE. Every sweep, any session without a painted overlay gets one-    // re-applied, with a 60s per-session cooldown so a genuinely unpaintable window is retried-    // gently instead of hammered.-    try {-      for (const [sid2, s2] of [...sessions]) {-        // Two things to heal: a BARE window (no overlay at all), and a window stuck on the GENERIC-        // fallback that should be wearing its real page favicon. The generic case is retried on a-        // slower cadence (favicon may legitimately never resolve) but still upgrades the moment it can.-        const bare = !s2._appOverlay;-        const stuckGeneric = s2._appOverlay && s2._overlayIsGeneric;-        if (!bare && !stuckGeneric) continue;-        const last = s2._overlayEnforceAt || 0;-        const cooldown = bare ? 60000 : 90000;-        if (Date.now() - last < cooldown) continue;-        s2._overlayEnforceAt = Date.now();-        const wasGeneric = stuckGeneric;-        applyAppOverlay(s2, sid2).then(okp => {-          if (!okp) return;-          if (wasGeneric && !s2._overlayIsGeneric) console.log(`[overlay] "${sid2}" UPGRADED generic → real favicon (health sweep re-fetched it)`);-          else if (bare) console.log(`[overlay] "${sid2}" ENFORCED (was bare) — every pup window must wear its overlay`);-        }).catch(() => {});-      }-    } catch (e) {}     // (3) USER-ACTIVITY WATCHER + STUCK-OCCLUSION check (v1.9.180/181). One OS foreground read per     // tick. When the foreground IS a pup window: (a) stamp it user-active + foreground (PERSISTED),     // so no park/recovery/adoption path ever demotes a window the user chose to bring up — the