aboutsummaryrefslogtreecommitdiff
path: root/extensions/chrome-profile-bridge/index.ts
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-10-26 15:42:32 +0200
committerIgor Soarez <igor@soarez.org>2026-10-26 15:42:32 +0200
commitee1ddab7f9f24adfc55a41e62efa3156a282c7a8 (patch)
treea2371dfd85c6eebb34478a374120ef2fce8fe07e /extensions/chrome-profile-bridge/index.ts
parent2a3854c2e246d38636779c2c8dea7cd368f0fe4b (diff)
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.
Diffstat (limited to 'extensions/chrome-profile-bridge/index.ts')
-rw-r--r--extensions/chrome-profile-bridge/index.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/extensions/chrome-profile-bridge/index.ts b/extensions/chrome-profile-bridge/index.ts
index e518833..342493b 100644
--- a/extensions/chrome-profile-bridge/index.ts
+++ b/extensions/chrome-profile-bridge/index.ts
@@ -918,6 +918,9 @@ export default function (pi: ExtensionAPI): void {
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 @@ export default function (pi: ExtensionAPI): void {
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 @@ export default function (pi: ExtensionAPI): void {
};
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 @@ export default function (pi: ExtensionAPI): void {
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 @@ Usage rules:
}
const wasUsable = chromeToolsUsable;
chromeAuthorizedUntil = until;
+ envGranted = false;
persistAuth();
activateChromeTools();
chromeToolsUsable = true;