← Commit history

Live pup management dashboard at /dashboard (John's ask), served by the bridge's own HTTP server with SSE. Shows every window pup is driving right now: its ACTUAL composed overlay badge served inline from the debug dump (not a re-render, so what you see is what Windows was handed), full tab list with the active tab and any crashed ones marked, the owning AI thread plus whether that ownership is declared or authenticated from caller identity, foreground vs background WITH the justification the caller had to give to foreground it, highFps lease and minutes remaining, uptime, resolved hwnd (or 'unresolved' in red, which is the signature of the title-vs-handle class of bug), pinned emulated viewport, page error counts and lost-browser state. Filter by AI thread or free-text across session/url. Updates every 2s over SSE. Built from the SAME in-memory registries the verbs use with NO CDP calls, so opening the dashboard can never wake a throttled page or add load to the shared socket — it reports what pup BELIEVES, which is exactly what you want when debugging pup, because a divergence between the dashboard and the screen IS the bug. Single self-contained document, no CDN or build step, so it works on a machine with no network.

John Lauer ·19d457e53d ·3mo ago ·parent 393200d
4 files changed +225−6
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.223",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.223/adom-bridge-puppeteer-v1.9.223.zip",-  "sha256": "ee178901449971d3bec5dfbc018413bbf0b87f3428baecf29cc57e5249f97419",-  "size": 446404,+  "version": "1.9.224",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.224/adom-bridge-puppeteer-v1.9.224.zip",+  "sha256": "5b97f807b0da8c28b261dff119957eff9c1d362496e81fa063c6e5b1e4e6f4bb",+  "size": 451265,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.223+1.9.224
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.223",+  "version": "1.9.224",   "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+219
@@ -7744,6 +7744,184 @@ function ownershipRefusal(session, sessionId, args, verb) {   }; } +// v1.9.224 — dashboard state. Deliberately built from the SAME in-memory registries the verbs use,+// with NO CDP calls, so opening the dashboard can never wake a throttled page, disturb a window, or+// add load to the shared socket. It reports what pup BELIEVES, which is exactly what you want when+// debugging pup: a divergence between this and the screen IS the bug.+async function dashboardSnapshot() {+  const now = Date.now();+  const wins = [];+  for (const [sid, sess] of sessions) {+    const tabs = (sess.tabs || []).map(t => {+      let u = null, ttl = null;+      try { u = t.page && t.page.url(); } catch (e) {}+      try { ttl = t._lastTitle || null; } catch (e) {}+      return {+        tabId: t.tabId, url: u, title: ttl,+        active: t.tabId === sess.activeTabId,+        crashed: !!t._crashed,+        crashReason: t._crashReason || null,+        opener: t.opener || null,+      };+    });+    const hf = sess._highFpsUntil && sess._highFpsUntil > now;+    wins.push({+      sessionId: sid,+      profile: sess.profileName,+      owner: sess.owner || null,+      ownerSource: sess.owner ? (sess._ownerFromCallerIdentity ? 'caller-identity' : 'declared') : null,+      ownerThread: sess._ownerThread || null,+      ownerContainer: sess._ownerContainer || null,+      lastThread: sess._lastThread || null,+      foreground: !!sess._foreground,+      foregroundReason: (sess._lastForeground && sess._lastForeground.reason) || null,+      foregroundAt: (sess._lastForeground && sess._lastForeground.ts) || null,+      foregroundVerb: (sess._lastForeground && sess._lastForeground.verb) || null,+      background: sess._bgResult || null,+      highFps: !!hf,+      highFpsMinutesLeft: hf ? Math.max(0, Math.round((sess._highFpsUntil - now) / 60000)) : null,+      openedAt: sess.createdAt || null,+      uptimeMs: sess.createdAt ? now - sess.createdAt : null,+      tabCount: tabs.length,+      tabs,+      overlay: sess._overlayDesc || null,+      hwnd: sess._hwnd || null,+      emulatedViewport: sess._emulatedViewport || null,+      lostBrowser: !!sess._lostBrowser,+      lastAgentUpdate: sess._lastAgentUpdate || null,+      errorCount: (sess.errors || []).length,+      flashCount: sess._flashCount || 0,+      url: (() => { try { return sess.page && sess.page.url(); } catch (e) { return sess._lastUrl || null; } })(),+    });+  }+  const threads = [...new Set(wins.map(w => w.owner || w.ownerThread).filter(Boolean))].sort();+  const profiles = {};+  for (const w of wins) profiles[w.profile] = (profiles[w.profile] || 0) + 1;+  let depsOk = false; try { require.resolve('puppeteer'); depsOk = true; } catch (e) {}+  return {+    ts: now,+    bridge: { version: BRIDGE_VERSION, platform: process.platform, uptimeMs: Math.round(process.uptime() * 1000), depsOk, minimalTouch: minimalTouch() },+    counts: { windows: wins.length, tabs: wins.reduce((a, w) => a + w.tabCount, 0), browsers: browsers.size, threads: threads.length },+    threads, profiles,+    windows: wins.sort((a, b) => (b.openedAt || 0) - (a.openedAt || 0)),+  };+}+++// v1.9.224 — the dashboard page. Single self-contained document (no CDN, no build step) because it+// is served by the bridge itself and must work on a machine with no network. Adom dark theme.+const DASHBOARD_HTML = `<!doctype html><html lang="en"><head>+<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">+<title>pup — live windows</title>+<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='7' fill='%2312e0c4'/><circle cx='12' cy='13' r='4' fill='%2306282a'/><circle cx='21' cy='20' r='4' fill='%2306282a'/></svg>">+<style>+*{box-sizing:border-box} html,body{margin:0;background:#0b1116;color:#e6edf3;font:14px/1.5 "Segoe UI",system-ui,sans-serif}+a{color:#12e0c4}+header{position:sticky;top:0;z-index:9;background:#0d141b;border-bottom:1px solid #1d2833;padding:12px 18px;display:flex;gap:16px;align-items:center;flex-wrap:wrap}+h1{font-size:15px;margin:0;font-weight:650;letter-spacing:.2px}+.dot{width:8px;height:8px;border-radius:50%;background:#3fb950;display:inline-block;margin-right:6px}+.dot.stale{background:#d29922}+.pill{background:#111b23;border:1px solid #1d2833;border-radius:999px;padding:3px 10px;font-size:12px;color:#9fb0c0}+.pill b{color:#e6edf3;font-weight:600}+select,input{background:#111b23;color:#e6edf3;border:1px solid #23303c;border-radius:6px;padding:5px 9px;font-size:13px}+main{padding:16px 18px;display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(430px,1fr))}+.card{background:#0f1720;border:1px solid #1d2833;border-radius:10px;overflow:hidden}+.card.fg{border-color:#12e0c4;box-shadow:0 0 0 1px rgba(18,224,196,.25)}+.card.crash{border-color:#f85149}+.chead{display:flex;gap:10px;align-items:center;padding:10px 12px;background:#0d141b;border-bottom:1px solid #1d2833}+.badge{width:26px;height:26px;border-radius:6px;background:#111b23;flex:0 0 26px;object-fit:contain}+.sid{font-weight:650}+.sub{color:#7d8f9f;font-size:12px;margin-left:auto;text-align:right}+.tags{display:flex;gap:5px;flex-wrap:wrap;padding:8px 12px 0}+.tag{font-size:11px;border-radius:5px;padding:2px 7px;border:1px solid #23303c;color:#9fb0c0}+.tag.fg{background:#12e0c41a;border-color:#12e0c4;color:#12e0c4}+.tag.bg{color:#7d8f9f}+.tag.hf{background:#d299221a;border-color:#d29922;color:#e3b341}+.tag.warn{background:#f851491a;border-color:#f85149;color:#ff7b72}+.tag.vp{background:#a371f71a;border-color:#a371f7;color:#c297ff}+.why{margin:8px 12px 0;padding:7px 10px;background:#12e0c40f;border-left:2px solid #12e0c4;border-radius:0 6px 6px 0;font-size:12px;color:#a9c4cd}+.why b{color:#12e0c4;font-weight:600}+table{width:100%;border-collapse:collapse;margin-top:8px;font-size:12px}+td{padding:5px 12px;border-top:1px solid #16202a;vertical-align:top}+td.k{color:#7d8f9f;width:96px;white-space:nowrap}+.url{color:#9fb0c0;word-break:break-all}+.tabs{padding:6px 12px 12px}+.tab{display:flex;gap:8px;padding:4px 0;border-top:1px solid #16202a;font-size:12px}+.tab:first-child{border-top:0}+.tab .id{color:#7d8f9f;flex:0 0 46px}+.tab.act .id{color:#12e0c4;font-weight:600}+.tab .u{color:#9fb0c0;word-break:break-all;flex:1}+.tab .x{color:#ff7b72;flex:0 0 auto}+.empty{color:#7d8f9f;padding:40px;text-align:center;grid-column:1/-1}+footer{color:#5c6c7a;font-size:11px;padding:6px 18px 22px}+</style></head><body>+<header>+  <h1><span class="dot" id="live"></span>pup — live windows</h1>+  <span class="pill">windows <b id="cW">0</b></span>+  <span class="pill">tabs <b id="cT">0</b></span>+  <span class="pill">chromes <b id="cB">0</b></span>+  <span class="pill">v<b id="cV">?</b></span>+  <span class="pill" id="cM" style="display:none">minimal-touch</span>+  <select id="f"><option value="">all AI threads</option></select>+  <input id="q" placeholder="filter url / session…" size="22">+  <span class="sub" id="age"></span>+</header>+<main id="m"><div class="empty">connecting…</div></main>+<footer id="ft"></footer>+<script>+const $=s=>document.querySelector(s); let SNAP=null;+const ago=ms=>{if(ms==null)return'—';const s=Math.round(ms/1000);if(s<60)return s+'s';const m=Math.round(s/60);if(m<60)return m+'m';const h=Math.floor(m/60);return h+'h '+(m%60)+'m';};+const esc=t=>String(t==null?'':t).replace(/[&<>"]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));+function render(){+  if(!SNAP)return; const d=SNAP;+  $('#cW').textContent=d.counts.windows; $('#cT').textContent=d.counts.tabs;+  $('#cB').textContent=d.counts.browsers; $('#cV').textContent=d.bridge.version;+  $('#cM').style.display=d.bridge.minimalTouch?'':'none';+  $('#age').textContent='updated '+new Date(d.ts).toLocaleTimeString();+  const sel=$('#f'), cur=sel.value;+  if(sel.options.length-1!==d.threads.length){+    sel.innerHTML='<option value="">all AI threads</option>'+d.threads.map(t=>'<option>'+esc(t)+'</option>').join('');+    sel.value=cur;+  }+  const q=$('#q').value.toLowerCase(), th=sel.value;+  const rows=d.windows.filter(w=>{+    if(th&&(w.owner||w.ownerThread)!==th)return false;+    if(q){const hay=(w.sessionId+' '+(w.url||'')+' '+(w.owner||'')+' '+w.tabs.map(t=>t.url||'').join(' ')).toLowerCase();if(!hay.includes(q))return false;}+    return true;});+  $('#m').innerHTML = rows.length? rows.map(w=>{+    const crashed=w.tabs.some(t=>t.crashed)||w.lostBrowser;+    return '<div class="card '+(w.foreground?'fg':'')+(crashed?' crash':'')+'">'+    +'<div class="chead">'+      +'<img class="badge" src="/dashboard/badge?session='+encodeURIComponent(w.sessionId)+'&t='+d.ts+'" onerror="this.style.visibility=\'hidden\'">'+      +'<span class="sid">'+esc(w.sessionId)+'</span>'+      +'<span class="sub">'+esc(w.profile)+' · '+ago(w.uptimeMs)+'</span>'+    +'</div>'+    +'<div class="tags">'+      +'<span class="tag '+(w.foreground?'fg':'bg')+'">'+(w.foreground?'FOREGROUND':'background')+'</span>'+      +(w.highFps?'<span class="tag hf">highFps '+w.highFpsMinutesLeft+'m left</span>':'')+      +(w.emulatedViewport?'<span class="tag vp">viewport pinned '+w.emulatedViewport.width+'×'+w.emulatedViewport.height+'</span>':'')+      +(w.lostBrowser?'<span class="tag warn">browser lost</span>':'')+      +(w.tabs.some(t=>t.crashed)?'<span class="tag warn">crashed tab</span>':'')+      +(w.errorCount?'<span class="tag warn">'+w.errorCount+' page errors</span>':'')+      +(w.owner?'<span class="tag">owner: '+esc(w.owner)+(w.ownerSource==='caller-identity'?' ✓':'')+'</span>':'<span class="tag warn">UNOWNED</span>')+    +'</div>'+    +(w.foreground&&w.foregroundReason?'<div class="why"><b>why foreground:</b> '+esc(w.foregroundReason)+'</div>':'')+    +'<table>'+      +'<tr><td class="k">url</td><td class="url">'+esc(w.url||'—')+'</td></tr>'+      +'<tr><td class="k">overlay</td><td>'+esc(w.overlay||'none')+'</td></tr>'+      +'<tr><td class="k">hwnd</td><td>'+(w.hwnd||'<span style="color:#ff7b72">unresolved</span>')+'</td></tr>'+      +(w.lastAgentUpdate?'<tr><td class="k">last action</td><td>'+esc(w.lastAgentUpdate.verb||'')+' '+esc(w.lastAgentUpdate.note||'')+'</td></tr>':'')+    +'</table>'+    +'<div class="tabs">'+w.tabs.map(t=>'<div class="tab '+(t.active?'act':'')+'"><span class="id">'+esc(t.tabId)+'</span><span class="u">'+esc(t.url||'—')+'</span>'+(t.crashed?'<span class="x">crashed</span>':'')+'</div>').join('')+'</div>'+    +'</div>';}).join('') : '<div class="empty">no pup windows open'+(th||q?' matching this filter':'')+'</div>';+  $('#ft').textContent='bridge up '+ago(d.bridge.uptimeMs)+' · '+d.bridge.platform+' · deps '+(d.bridge.depsOk?'ok':'MISSING')+' · profiles: '+Object.entries(d.profiles).map(([k,v])=>k+'('+v+')').join(', ');+}+$('#f').onchange=render; $('#q').oninput=render;+const es=new EventSource('/dashboard/events');+es.onmessage=e=>{SNAP=JSON.parse(e.data);$('#live').classList.remove('stale');render();};+es.onerror=()=>$('#live').classList.add('stale');+</script></body></html>`;+ const server = http.createServer(async (req, res) => {   const url = new URL(req.url, `http://localhost:${PORT}`);   const pathname = url.pathname;@@ -7761,6 +7939,47 @@ const server = http.createServer(async (req, res) => {    try {     // GET /health+    // ── v1.9.224 — LIVE MANAGEMENT DASHBOARD (John's ask) ─────────────────────────────────────+    // Point a browser at http://<pup-host>:<port>/dashboard to see every window pup is driving right+    // now: its overlay badge (the ACTUAL composed PNG, inline), tab list, owning AI thread, fg/bg with+    // the justification the caller had to give to foreground it, highFps lease, uptime — filterable by+    // thread. Updates live over SSE, so it reflects reality rather than a snapshot you have to reload.+    //+    // This is also a debugging instrument: most of the hardest pup bugs (a stale badge from a dead+    // session, duplicate sessions painting one window, a window pinned by an emulated viewport) are+    // obvious the moment you can SEE all the state at once, and were invisible while state could only+    // be read one verb at a time.+    if (pathname === '/dashboard/events') {+      res.writeHead(200, {+        'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache',+        'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*',+      });+      let alive = true;+      const push = async () => {+        if (!alive) return;+        try { res.write(`data: ${JSON.stringify(await dashboardSnapshot())}\n\n`); } catch (e) { alive = false; }+      };+      await push();+      const iv = setInterval(push, 2000);+      req.on('close', () => { alive = false; clearInterval(iv); });+      return;+    }+    if (pathname === '/dashboard/badge') {+      // Serve the exact overlay PNG pup last composed for a session, so the dashboard shows the REAL+      // badge rather than a re-render that might differ from what Windows was handed.+      const sid = url.searchParams.get('session') || '';+      try {+        const f = path.join(require('os').tmpdir(), 'pup-badge-debug', `${sid}.png`);+        const buf = fs.readFileSync(f);+        res.writeHead(200, { 'Content-Type': 'image/png', 'Cache-Control': 'no-store' });+        res.end(buf); return;+      } catch (e) { res.writeHead(404); res.end(); return; }+    }+    if (pathname === '/dashboard' || pathname === '/dashboard/') {+      res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });+      res.end(DASHBOARD_HTML);+      return;+    }     if (pathname === '/health') {       const sessionList = [];       for (const [id, s] of sessions) {