extension: show the bridge footer only for grants given this session A standing PI_CHROME_AUTHORIZE is not session state worth a line at the bottom of every session that has it; announce only access the user granted through /chrome authorize.
Igor Soarez igor@soarez.org
Mon, 26 Oct 2026 15:42:32 +0200
1 files changed,
7 insertions(+),
1 deletions(-)
M
extensions/chrome-profile-bridge/index.ts
→
extensions/chrome-profile-bridge/index.ts
@@ -918,6 +918,9 @@
const bridge = new ChromeProfileBridge(DEFAULT_HOST, DEFAULT_PORT); let backgroundEnabled = true; let chromeAuthorizedUntil: number | "indefinite" | undefined; + // Whether the current grant stood in from PI_CHROME_AUTHORIZE rather than being given by + // the user this session. The footer announces only the latter. + let envGranted = false; // Restore an authorization that survived a /reload. Drop it if it already expired. const persistedAuth = globalState[PI_CHROME_AUTH_KEY]; if (persistedAuth) {@@ -1017,6 +1020,7 @@ deactivateChromeTools();
chromeToolsUsable = false; if (logAction && wasUsable) logChromeToolChange(logAction, { authorizedUntil: undefined }); chromeAuthorizedUntil = undefined; + envGranted = false; persistAuth(); // Revoking control ends pi-chrome's automation for this session; tidy up the target we own. void cleanupAutomationTargetBestEffort();@@ -1074,7 +1078,7 @@ return typeof id === "string" && id ? `session:${id}` : undefined;
}; const updateChromeStatus = (ctx: ExtensionContext): void => { - if (chromeControlAuthorized()) { + if (chromeControlAuthorized() && !envGranted) { ctx.ui.setStatus("chrome", ctx.ui.theme.fg("success", "●") + " Chrome Bridge" + authCountdownLabel()); } else { ctx.ui.setStatus("chrome", undefined);@@ -1168,6 +1172,7 @@ if (autoGrant && chromeAuthorizedUntil === undefined) {
const grant = parseAuthorizeArg(autoGrant); if (grant) { chromeAuthorizedUntil = grant.until; + envGranted = true; persistAuth(); } else { ctx.ui.notify(`Ignoring PI_CHROME_AUTHORIZE="${autoGrant}": use minutes (15m, 30, 45) or indefinite.`, "warning");@@ -1394,6 +1399,7 @@ return;
} const wasUsable = chromeToolsUsable; chromeAuthorizedUntil = until; + envGranted = false; persistAuth(); activateChromeTools(); chromeToolsUsable = true;