Skip to content

fix(ui): Consider typing and scrolling as activity for auto logout - #65589

Open
DerDreschner wants to merge 1 commit into
masterfrom
fix/count-type-strokes-as-activity
Open

DerDreschner wants to merge 1 commit into
masterfrom
fix/count-type-strokes-as-activity

Conversation

@DerDreschner

Copy link
Copy Markdown
Contributor

Summary

When using auto_logout, only mouse movements and touch were considered an activity. In case the session_lifetime is set to something relatively short, users can be logged out if they only type for a pretty long time or only use the keyboard to navigate.

This is changed with this PR, which now considers the following events an activity:

  • mousemove
  • pointerdown
  • keydown
  • beforeinput
  • wheel

This cover almost every use-case. Known gaps and exceptions that Claude identified:

  • Safari Voice Control clicks: not covered until WebKit's 7 Oct 2026 change ships, because shipping Safari doesn't fire pointerdown for accessibility clicks yet.
  • Assistive tools that set a field's value directly: Android Voice Access dictation and Windows Voice Access or Dragon setting values through UI Automation. These only fire input, which isn't listened to on purpose because scripts fire it too, e.g. after setting a field's value. Rich editors like Text, Talk and the Mail composer get no event at all in this case.
  • Accessibility scroll commands: these only fire scroll, which isn't listened to on purpose because scripts fire it too, e.g. when a chat jumps to a new message.
  • Editors in iframes: not covered. Collabora is handled by richdocuments and uses a storage event in the same window, which is being documented and tested with this PR.

Additionally, the last activity is shared with other tabs at most once per logout check interval now, and a failing storage write no longer throws.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

With `auto_logout` enabled, only mouse movements and touch inputs were considered an activity. This means that people were logged out after `session_lifetime` if they only type or scroll without moving the mouse itself.

With this commit, key presses, text inputs (`beforeinput`, so dictation solutions do work as well) and mouse `wheel` inputs (instead of `scroll` to prevent scripts keeping the session active by e.g. simply scrolling to a new message) count as activity, too. Additionally, the last activity is shared with other tabs at most once per logout check interval now, and a failing storage write no longer throws. It also document and test that apps report activity through a storage event in the same window, which richdocuments relies on.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner DerDreschner self-assigned this Oct 16, 2026
@DerDreschner
DerDreschner requested a review from a team as a code owner October 16, 2026 18:08
@DerDreschner
DerDreschner requested review from kristian-zendato, pringelmann and skjnldsv and removed request for a team October 16, 2026 18:08
@DerDreschner

Copy link
Copy Markdown
Contributor Author

/backport to stable35

@DerDreschner

Copy link
Copy Markdown
Contributor Author

/backport to stable34

@DerDreschner

Copy link
Copy Markdown
Contributor Author

/backport to stable33

@DerDreschner
DerDreschner requested review from susnux and a balanced review from Copilot October 16, 2026 18:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues, and focused regression tests cover the changes, though they were not executed during review.

0 open findings

What changed in this PR

Improves auto-logout activity detection so keyboard input and wheel scrolling keep sessions active.

Changes:

  • Expands activity listeners and captures events stopped by editors.
  • Limits cross-tab storage writes and handles write failures.
  • Adds regression tests for activity detection, logout timing, and storage behavior.
File Description
core/​src/​tests/​OC/​session-heartbeat.spec.ts Adds auto-logout regression tests and listener cleanup.
core/​src/​session-heartbeat.ts Expands activity detection and throttles storage writes safely.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +142 to +150
// Capture phase, as editors may stop the propagation of input events
window.addEventListener('mousemove', markActive, { capture: true })
// Touch, pen and clicks, including clicks by assistive technology that do not move the mouse
window.addEventListener('pointerdown', markActive, { capture: true })
window.addEventListener('keydown', markActive, { capture: true })
// Text insertion without key events, e.g. dictation
window.addEventListener('beforeinput', markActive, { capture: true })
// Wheel instead of scroll events, as scripts fire scroll events too
window.addEventListener('wheel', markActive, { capture: true, passive: true })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure if this is not too much of events, did you do a performance analysis?

If there is a bad performance impact here, we might need to trim this down to

  • mousemove
  • touchstart (mobile)
  • keydown (typing or navigating with keyboard)
  • wheel (scrolling long documents)

This branch has not been deployed

No deployments
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.

3 participants