Skip to content

Add an opt-in session keep-alive - #46

Merged
olddonkey merged 1 commit into
mainfrom
feat/session-keep-alive
Jul 14, 2026
Merged

olddonkey merged 1 commit into
mainfrom
feat/session-keep-alive

Conversation

@olddonkey

Copy link
Copy Markdown
Owner

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:

  • Swallowing the page's logout signals (visibilitychange / webkitvisibilitychange / blur / pagehide / freeze) in the capture phase on window, so the site keeps believing the tab is visible and focused. Fully reversible when toggled back off.
  • 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).

⚠️ Reviewer note — this needs the MAIN world in the extension

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, where window.timeout is 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:

EXT_WORLD=MAIN npm run build

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 lint clean, npm test 77 passing, npm run build → dist/amex-assistant-1.4.0.zip.
  • Behavior (event suppression + window.timeout nudge) only fully observable on global.americanexpress.com — worth a real-page check.

🤖 Generated with Claude Code

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>
@olddonkey
olddonkey merged commit fa2efa7 into main Jul 14, 2026
1 check passed
@olddonkey
olddonkey deleted the feat/session-keep-alive branch July 14, 2026 05:39
@olddonkey olddonkey mentioned this pull request Jul 14, 2026
olddonkey added a commit that referenced this pull request Jul 14, 2026
Ships the opt-in session keep-alive (#46). Bumps @Version and
package.json together to keep them in lockstep.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant