app
Pup - the AI's own browser
Public Made by Adomby adom
pup gives your AI a real browser on your desktop that it drives completely, in the background, signed in as you: windows that never jump in front of your work, one shared profile that learns your logins, and every window labeled on the taskbar with its AI thread's name.
← Commit history
Fix inflated tab counts + vanished overlay icons (John caught count:4 on 1-tab windows). Root cause: rescanProfile keyed its already-attached map on the puppeteer Page OBJECT, which is recreated on every reconnect, so each rapid bridge restart re-attached the same Chrome tab as a duplicate — a 1-tab window grew 4 identical entries, the count badge read 4, and the favicon read hit a detached phantom so the overlay fell back to that wrong count. Now: rescan dedupes by CDP TARGET ID (stable across reconnects); new reconcileSessionTabs prunes dead/detached + duplicate tab entries (probe timeout = busy, kept — never drops a merely-slow tab) and re-stamps the overlay; runs at boot, every 45s, and at the end of every rescan.
4 files changed
+69−11
adom-bridge-puppeteer-manifest.json+4−4@@ -1,10 +1,10 @@ { "manifest_version": 1, "name": "puppeteer",- "version": "1.9.178",- "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.178/adom-bridge-puppeteer-v1.9.178.zip",- "sha256": "377038bfe79d5e95b0ffbecd07a6274c20fc0d10895d2c7cd7579d6d4eee2f7b",- "size": 413808,+ "version": "1.9.179",+ "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.179/adom-bridge-puppeteer-v1.9.179.zip",+ "sha256": "5e1a1c12ad4c9606546013942e15721ac0e63039135196dd76bdf1f5027f9dac",+ "size": 415077, "verbPrefixes": [ "browser_", "desktop_recorder_",
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-1.9.178+1.9.179
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "puppeteer", "displayName": "Puppeteer (Chrome for Testing + Native)",- "version": "1.9.178",+ "version": "1.9.179", "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+63−5@@ -857,6 +857,47 @@ function _isCrashedFrameError(e) { return /detached Frame|Target crashed|Session closed|Execution context was destroyed|no live page/i.test(m); } +// The CDP target id behind a page — the stable identity of a Chrome tab across bridge reconnects+// (the puppeteer Page OBJECT is recreated on every reconnect; the target id is not).+function _pageTargetId(page) {+ try { const t = page.target(); return (t && (t._targetId || (t._targetInfo && t._targetInfo.targetId))) || null; } catch (e) { return null; }+}++// v1.9.179: prune DEAD (closed / detached-frame) and DUPLICATE tab entries from a session. Rapid+// bridge restarts + crash reconnects bound the same Chrome tab multiple times (rescan keyed on the+// page OBJECT, which changes on reconnect), so a single-page window accumulated 4 identical entries —+// inflating the taskbar count badge to "4" and, because the active entry was a detached phantom, the+// favicon read (page.evaluate) threw and the overlay fell back to that wrong count. This makes the tab+// list reflect the REAL live tabs again. A probe TIMEOUT means "busy", not dead — those are kept, so a+// merely-slow tab is never wrongly dropped.+async function reconcileSessionTabs(session, sessionId) {+ if (!session || !Array.isArray(session.tabs) || session.tabs.length === 0) return 0;+ const kept = []; const seenTargets = new Set(); let dropped = 0;+ for (const t of session.tabs) {+ let dead = false;+ try {+ if (!t.page || t.page.isClosed()) dead = true;+ else {+ try { await withTimeout(t.page.evaluate('1'), 1500, 'tab-reconcile'); }+ catch (e) { if (_isCrashedFrameError(e)) dead = true; /* timeout = busy → keep */ }+ }+ } catch (e) { dead = true; }+ const tid = dead ? null : _pageTargetId(t.page);+ if (dead || (tid && seenTargets.has(tid))) { dropped++; continue; }+ if (tid) seenTargets.add(tid);+ kept.push(t);+ }+ if (dropped > 0) {+ session.tabs = kept;+ if (session.activeTabId && !kept.find(t => t.tabId === session.activeTabId)) {+ session.activeTabId = kept.length ? kept[kept.length - 1].tabId : null;+ }+ console.log(`[tabs] session "${sessionId}" reconciled: dropped ${dropped} dead/duplicate tab(s) → ${kept.length} live`);+ try { refreshWindowChrome(session, sessionId).catch(() => {}); } catch (e) {} // re-stamp count/favicon overlay+ }+ return dropped;+}+ function _throwIfCrashed(t, sessionId) { if (!t || !t._crashed) return; const secs = Math.round((Date.now() - (t._crashedAt || Date.now())) / 1000);@@ -1250,25 +1291,31 @@ async function attemptReconnectProfile(profileName) { // in place. async function rescanProfile(browser, profileName, { adoptOrphans = false } = {}) { const pages = await browser.pages();- // Build the "page → existing tab" map so we know what's already attached.+ // v1.9.179: key the "already attached" map on the CDP TARGET ID, not the page OBJECT. On a+ // reconnect (bridge restart / crash recovery) puppeteer hands back a BRAND-NEW Page object for the+ // SAME Chrome tab, so an object-keyed map never matched and re-attached the tab as a duplicate —+ // which is how a 1-tab window grew to 4 identical entries. Target ids survive reconnects, so this+ // matches the existing tab and skips it instead of duplicating. (Falls back to the object when a+ // target id can't be read, preserving the old behaviour for that edge.) const existingPageTab = new Map();+ const keyFor = (pg) => _pageTargetId(pg) || pg; for (const s of sessions.values()) { if (s.profileName !== profileName) continue;- for (const t of s.tabs) existingPageTab.set(t.page, { sid: null, t });+ for (const t of s.tabs) existingPageTab.set(keyFor(t.page), { sid: null, t }); } for (const [sid, s] of sessions.entries()) { if (s.profileName !== profileName) continue; for (const t of s.tabs) {- const cur = existingPageTab.get(t.page);+ const cur = existingPageTab.get(keyFor(t.page)); if (cur) cur.sid = sid; } } let reattached = 0, adopted = 0, alreadyLive = 0; const seenSessions = new Set(); for (const page of pages) {- if (existingPageTab.has(page)) {+ if (existingPageTab.has(keyFor(page))) { alreadyLive++;- const cur = existingPageTab.get(page);+ const cur = existingPageTab.get(keyFor(page)); if (cur && cur.sid) seenSessions.add(cur.sid); continue; }@@ -1322,6 +1369,11 @@ async function rescanProfile(browser, profileName, { adoptOrphans = false } = {} `[rescan] profile "${profileName}": ${reattached} reattached, ${adopted} orphans adopted, ` + `${alreadyLive} pages already live` );+ // v1.9.179: after re-binding, prune any dead/duplicate tab entries this or a prior reconnect left+ // behind, so the tab count + overlay are correct immediately (browser_rescan triggers this).+ for (const [sid, s] of sessions.entries()) {+ if (s.profileName === profileName) { try { await reconcileSessionTabs(s, sid); } catch (e) {} }+ } // 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) {@@ -10180,6 +10232,12 @@ server.listen(PORT, BIND_HOST, async () => { // net, so an unbranded window can never persist even if its window-opened event was missed. setTimeout(() => { reclaimUnmanagedWindows().catch(() => {}); }, 12000); setInterval(() => { reclaimUnmanagedWindows().catch(() => {}); }, 90000);+ // v1.9.179 — TAB RECONCILER. Prune dead/detached and duplicate tab entries so the taskbar count+ // badge reflects the REAL live tabs (rapid reconnects had inflated 1-tab windows to "4") and the+ // favicon overlay reads from a LIVE active tab instead of a detached phantom. Runs on a gentle+ // cadence; only sessions whose tab list actually changed re-stamp their overlay.+ setTimeout(() => { for (const [sid, s] of [...sessions]) reconcileSessionTabs(s, sid).catch(() => {}); }, 8000);+ setInterval(() => { for (const [sid, s] of [...sessions]) reconcileSessionTabs(s, sid).catch(() => {}); }, 45000); // v1.9.171 — CRASH SELF-HEAL. The shared Chrome dies two ways on heavy/hostile pages (measured // repeatedly on the Autodesk sign-in flow), and pup must recover from BOTH without a human: //