Skip to content

Keep session alive during active typing/reading, warn before expiry - #395

Open
apodacaduron wants to merge 5 commits into
mainfrom
fix/session-lifecycle-active-typing-timeout
Open

Keep session alive during active typing/reading, warn before expiry#395
apodacaduron wants to merge 5 commits into
mainfrom
fix/session-lifecycle-active-typing-timeout

Conversation

@apodacaduron

@apodacaduron apodacaduron commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Description

Sessions were expiring mid-sentence. Idle timeout only slid forward on
HTTP requests, so typing or scrolling (no requests sent) looked idle and
users got logged out mid-form.

Adds a global session controller, mixed into all admin pages:

  • Tracks real interaction (keydown, input, pointerdown, wheel, touchmove)
    and pings /admin/api/session-check on a cadence based on the session
    lifetime. Programmatic scroll doesn't count, only wheel/touchmove.
  • Shows a 60s countdown with "Stay signed in" before actual expiry.
    Only clicking it extends the session.
  • Uses localStorage so multiple tabs share one keepalive and only the
    active tab shows the warning.
  • Also fixes: split-view tabs never fire visibilitychange on each other,
    so a stale "Session Expired" dialog in tab B wouldn't close after
    signing in on tab A. Sign-in now broadcasts to sibling tabs.

Frontend only, no API/DB changes. Exposes the existing
PERMANENT_SESSION_LIFETIME via one Jinja attribute. Notification poller
(#343) untouched.

Not included: request recovery after expiry, draft autosave.

How to Test

Set SESSION_LIFETIME=120 in .env, restart, revert before merge.

  • Type on and off for 3-4 min: no logout, one keepalive every ~40s
  • Scroll a long record with trackpad only, no keyboard: no logout
  • Type then stop: warning shows around 1 min left, expires if ignored
  • Click "Stay signed in": dialog closes, timer resets
  • 5 tabs, use one: only that tab warns and pings
  • Split view, both expired, sign in on one: other tab closes on its own
  • Sleep past expiry, wake: no stale countdown
  • window.scrollTo() from console with no real input: no keepalive

Jira ID (if applicable)

BYNT-1763

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 46d9100b-674c-41ca-bbe5-89378a6c8d66

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@apodacaduron apodacaduron changed the title Fix/session lifecycle active typing timeout Keep session alive during active typing/reading, warn before expiry Aug 10, 2026
@apodacaduron
apodacaduron marked this pull request as ready for review August 10, 2026 19:23
@apodacaduron
apodacaduron requested a review from level09 as a code owner August 10, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants