From 745e43d88fe13831a8c5e46c8e4e0a7b6262e855 Mon Sep 17 00:00:00 2001 From: 1bobby-git <66291955+1bobby-git@users.noreply.github.com> Date: Thu, 19 Nov 2026 12:49:25 +0900 Subject: [PATCH] fix(bridge): the native login guard scan uses the per-step budget The read-only guard that scans the whole document before any change had a fixed 1.5 s bound while every later probe already used the per-step budget (3 s default, 5 s max). A scan of a 20,000-element page takes about 1.3 s at normal speed and about 3 s with 2x CPU throttling, so on slow hosts or runners the guard alone could end a run with ui_timeout (main's Validate failed three times this way on 2026-11-19 before #120 gave the scenario the 5 s budget, which the guard did not use). The guard now uses the same budget. Ships with the next version (no version change here). Co-Authored-By: Claude Opus 5.5 --- bridge/src/browser/native-login-policy.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bridge/src/browser/native-login-policy.ts b/bridge/src/browser/native-login-policy.ts index d1679627..e54455bc 100644 --- a/bridge/src/browser/native-login-policy.ts +++ b/bridge/src/browser/native-login-policy.ts @@ -81,9 +81,12 @@ export async function ensureNativeKeepSignedIn( if (!options.enabled) return report("disabled", "automation_disabled"); if (!nativeLoginTarget(target) || page.url() !== target || page.isClosed()) return report("attention", "invalid_target", false); if (!supportsNativeLoginPolicy(page)) return report("attention", "browser_unsupported"); + // One per-step budget for every DOM probe of this run. The guard scans the whole document; a fixed 1.5 s + // bound timed out on large dashboards on slow hosts while every later probe already allowed `timeout`. + const timeout = Math.max(100, Math.min(5_000, options.timeoutMs ?? 3_000)); let settingsOpen = false; try { - const guard = await bounded(page.evaluate!(inspectLoginSettingsDom, { action: "guard", marker: "", target }), 1_500); + const guard = await bounded(page.evaluate!(inspectLoginSettingsDom, { action: "guard", marker: "", target }), timeout); settingsOpen = guard.settingsOpen === true; if (guard.result === "blocked" || guard.result === "ambiguous") return report("attention", guard.reason ?? (guard.result === "ambiguous" ? "ambiguous" : "blocked"), false); } catch { return report("attention", "ui_timeout", false); } @@ -96,7 +99,6 @@ export async function ensureNativeKeepSignedIn( if (existingPreference?.state === "enabled") return { report: existingPreference, clean: !settingsOpen }; const marker = randomUUID(); const selector = `[${MARKER}="${marker}"]`; - const timeout = Math.max(100, Math.min(5_000, options.timeoutMs ?? 3_000)); const valid = () => !page.isClosed() && page.url() === target && (options.canContinue?.() ?? true); const focusOwnedPage = async () => { if (!valid()) throw new Error("page_changed");