← Commit history

v1.9.7: wiki view-toggle callback does a real OS foreground raise (osRaiseSessionWindow) + taskbar flash so the clicked switch is visibly brought to front

John Lauer ·6bcec097ef · ·parent bc3f049
5 files changed +84−16
CHANGELOG.md+12
@@ -1,5 +1,17 @@ # Changelog β€” Adom Desktop Puppeteer Bridge +## 1.9.7 β€” 2026-07-19 β€” Wiki toggle now REALLY pops to the foreground when you click it++The taskbar wiki view-toggle worked functionally (verified: it relaunches the window under the+authed profile, /auth/me=200, tab title flips to "πŸ”“ Logged in") but the user couldn't SEE it: the+callback only did a CDP maximize, so the relaunched window came back behind whatever they were+looking at. Now browser_wiki_set_view does a real OS SetForegroundWindow raise (extracted into a+reusable osRaiseSessionWindow helper from the proven browser_raise_os_window path β€” CDP place ++clear WS_EX_NOACTIVATE + SetForegroundWindow, with a WMI child-PID fallback) plus a taskbar flash+in case Windows' foreground lock denies the raise. Clicking the jump-list task now unmistakably+brings the switched window to the front. (The ~50ms cmd flash on click is AD's console-subsystem+CLI launcher β€” tracked separately for an AD CREATE_NO_WINDOW fix.)+ ## 1.9.6 β€” 2026-07-19 β€” Kill the ~60s respawn loop (crash-poison recovery) + jump-list task icon  Two fixes. (1) THE BIG ONE: pup was respawning every ~60s for hours (AD's lifecycle log showed
adom-bridge-puppeteer-manifest.json+5−5
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.6",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.6/adom-bridge-puppeteer-v1.9.6.zip",-  "sha256": "da36501f788e968a7d4a617c6f871927cc8d3c4b5200b7b2f04f84f4b3016566",-  "size": 214354,+  "version": "1.9.7",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.7/adom-bridge-puppeteer-v1.9.7.zip",+  "sha256": "2d3b0d0fd1000e6a8f3edafa3828700671e1984ad974b071c324caf84fc5dbae",+  "size": 215239,   "verbPrefixes": [     "browser_",     "desktop_recorder_",@@ -12,5 +12,5 @@   ],   "healthEndpoint": "/status",   "statusVerb": "browser_readiness",-  "released_at": "2026-07-19T20:45:00Z"+  "released_at": "2026-07-19T21:10:00Z" }
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.6\ No newline at end of file+1.9.7\ 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": "1.9.6",+  "version": "1.9.7",   "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+65−9
@@ -2055,6 +2055,65 @@ function appIconReprimand(url, hadFavicon) {   return ' 🎨 APP ICON MISSING: this looks like an Adom app, but the page serves NO favicon, so its pup window cannot wear the app\'s icon (and its webview tab shows a blank icon too). The adom-ui-design standard requires every app to serve a favicon (<link rel="icon">, monochrome WHITE mark, clean 24x24 SVG β€” see the adom-ui-design + app-creator skills). Add one and reopen, or pass appIconB64/appIconUrl on browser_open_window meanwhile.'; } +// v1.9.7: reusable OS FOREGROUND raise, extracted verbatim from the proven browser_raise_os_window+// path, so the wiki view-toggle callback can actually POP the relaunched window to the user's+// screen. A jump-list click is a genuine USER action, so a real SetForegroundWindow raise is+// warranted β€” the earlier CDP-only maximize left the window BEHIND whatever the user was looking+// at, which is why John "never saw the switch work." CDP place+maximize β†’ blur β†’ bringToFront β†’+// clear WS_EX_NOACTIVATE + SetForegroundWindow (via the detached/browser PID, with a WMI child+// fallback for launcherβ†’browser PID relaunches). Best-effort throughout; never throws.+async function osRaiseSessionWindow(session, sessionId) {+  try {+    try {+      const cdp = await session.page.target().createCDPSession();+      const { windowId } = await cdp.send('Browser.getWindowForTarget');+      await cdp.send('Browser.setWindowBounds', { windowId, bounds: { left: 0, top: 0, width: 1280, height: 800, windowState: 'normal' } });+      await cdp.send('Browser.setWindowBounds', { windowId, bounds: { windowState: 'maximized' } });+    } catch (e) {}+    try { await session.page.evaluate(() => { const a = document.activeElement; if (a && a.blur) a.blur(); }); } catch (e) {}+    try { await session.page.bringToFront(); } catch (e) {}+    session._foreground = true;+    if (process.platform !== 'win32') return;+    const be = browsers.get(session.profileName);+    let pid = null;+    try { pid = (be && be.browser && (be.browser._detachedPid || (be.browser.process() && be.browser.process().pid))) || null; } catch (e) {}+    if (!pid) return;+    const psScript = path.join(require('os').tmpdir(), '_adom_focus.ps1');+    const psContent = [+      'Add-Type @"',+      'using System; using System.Runtime.InteropServices;',+      'public class WinFocus {',+      '  [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd);',+      '  [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);',+      '  [DllImport("user32.dll")] public static extern bool IsIconic(IntPtr hWnd);',+      '  [DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr h, int i);',+      '  [DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr h, int i, int v);',+      '  public static void Raise(IntPtr h){',+      '    int ex = GetWindowLong(h, -20); SetWindowLong(h, -20, ex & ~0x08000000);',+      '    if (IsIconic(h)) ShowWindow(h, 9); ShowWindow(h, 5); SetForegroundWindow(h);',+      '  }',+      '}',+      '"@',+      `$targetPid = ${pid}`,+      '$p = Get-Process -Id $targetPid -ErrorAction SilentlyContinue',+      'if ($p -and $p.MainWindowHandle -ne 0) {',+      '  [WinFocus]::Raise($p.MainWindowHandle)',+      "  Write-Output 'focused'",+      '} else {',+      '  Get-WmiObject Win32_Process | Where-Object { $_.ParentProcessId -eq $targetPid -and $_.Name -eq "chrome.exe" } | ForEach-Object {',+      '    $cp = Get-Process -Id $_.ProcessId -ErrorAction SilentlyContinue',+      '    if ($cp -and $cp.MainWindowHandle -ne 0) {',+      '      [WinFocus]::Raise($cp.MainWindowHandle)',+      "      Write-Output 'focused'",+      '      return',+      '    }',+      '  }',+      '}',+    ].join('\r\n');+    try { fs.writeFileSync(psScript, psContent); } catch (e) { return; }+    try { const r = runPsHidden(psScript, { timeout: 8000 }).toString().trim(); console.log(`[wiki] raised session "${sessionId}" to foreground: ${r}`); } catch (e) {}+  } catch (e) {}+} // Brand a pup window: full identity on capable AD, overlay badge fallback on older AD. async function brandPupWindow(sessionId) {   const stamped = await stampPupIdentity(sessionId);@@ -4705,15 +4764,12 @@ const server = http.createServer(async (req, res) => {           if (view === 'public') s2._publicProfile = newProfile;           s2._foreground = true;           s2._wikiJumplistView = undefined;-          // The user clicked a per-window taskbar task β†’ bring it on-screen (CDP place+maximize,-          // then bringToFront β€” same on-screen move as browser_raise_os_window, no PowerShell).-          try {-            const cdp = await s2.page.target().createCDPSession();-            const { windowId } = await cdp.send('Browser.getWindowForTarget');-            await cdp.send('Browser.setWindowBounds', { windowId, bounds: { left: 0, top: 0, width: 1280, height: 800, windowState: 'normal' } });-            await cdp.send('Browser.setWindowBounds', { windowId, bounds: { windowState: 'maximized' } });-          } catch (e) {}-          try { await s2.page.bringToFront(); } catch (e) {}+          // v1.9.7: the user clicked a per-window taskbar task β†’ REALLY pop it to the foreground+          // (full OS SetForegroundWindow raise, not the old CDP-only maximize that left it behind+          // the user's active window β€” the reason John "never saw the switch work"). Plus a taskbar+          // flash as a belt-and-suspenders notice in case Windows' foreground lock denies the raise.+          await osRaiseSessionWindow(s2, sessionId);+          try { flashViaAD(sessionId, {}); } catch (e) {}           s2._lastForeground = { ts: Date.now(), verb: 'browser_wiki_set_view', reason: `user clicked the taskbar "switch to ${view} view" task` };           try { recordAgentUpdate(s2, 'browser_wiki_set_view', { updateNote: `wiki view β†’ ${view} (user clicked taskbar task)` }, s2.activeTabId); } catch (e) {}           // Re-check auth (authed view only) + refresh the in-tab glyph, branding, and jump list.