Repository navigation
Add an opt-in session keep-alive - #46
Merged
Merged
Conversation
Amex signs an idle tab out after a few minutes, which can cut a long multi-card run short. This adds an opt-in keep-alive, toggled from a header button and off by default (persisted in localStorage). While on it keeps the session warm entirely on the client — it makes no network request of its own — by: - swallowing the page's logout signals (visibilitychange / blur / pagehide / freeze) in the capture phase so the site keeps believing the tab is active, fully reversible when toggled back off; and - nudging the page's inactivity manager (window.timeout) once a minute, falling back to synthetic focus/mousemove activity when no manager is present. eslint.config.mjs: allow the globals the feature uses (setInterval, clearInterval, Event, MouseEvent). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Amex signs an idle tab out after a few minutes, which can cut a long multi-card run short. This adds an opt-in keep-alive, toggled from a header button and off by default (persisted in
localStorage).What it does
While on, it keeps the session warm entirely on the client — it makes no network request of its own — by:
visibilitychange/webkitvisibilitychange/blur/pagehide/freeze) in the capture phase onwindow, so the site keeps believing the tab is visible and focused. Fully reversible when toggled back off.window.timeout) once a minute, falling back to syntheticfocus/mousemoveactivity when no manager is present.eslint.config.mjs: allow the globals the feature uses (setInterval,clearInterval,Event,MouseEvent).The nudge reads
window.timeout, a page main-world global. That works in the Tampermonkey userscript (@grant none→ main world), but the Chrome extension ships as an isolated-world content script by default, wherewindow.timeoutis unreachable — so the nudge half degrades to synthetic events there.If keep-alive should work fully in the extension, build it with the existing escape hatch:
The event-suppression half works in either world (shared DOM dispatch). Decide whether to ship the extension as MAIN-world for this feature, or accept the degraded nudge — no manifest change is made here.
Verification
npm run lintclean,npm test77 passing,npm run build→dist/amex-assistant-1.4.0.zip.window.timeoutnudge) only fully observable onglobal.americanexpress.com— worth a real-page check.🤖 Generated with Claude Code