Skip to content

feat: Switch notification refresh from schedule to inactivity timer #2168

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 20, 2025

The notification refresh system previously used a fixed 60-second interval that could interrupt users while they were actively managing notifications (e.g., marking them as read). This PR changes the behavior to only refresh notifications after 60 seconds of user inactivity.

Changes Made

  • New useInactivityTimer hook: Tracks user activity across the app and triggers callbacks only after periods of inactivity
  • Replaced scheduled refresh: Changed from useInterval to useInactivityTimer for notification fetching in App.tsx
  • Comprehensive activity tracking: Monitors mouse movements, clicks, key presses, scrolling, and touch events
  • Smart timer reset: Any user interaction resets the 60-second countdown

Benefits

  • No more interruptions: Users can mark notifications as read without the list refreshing mid-action
  • Same responsiveness: Notifications still update every 60 seconds when the user is idle
  • Better UX: Maintains app responsiveness while respecting user workflow

Implementation Details

The new useInactivityTimer hook:

  • Listens for user activity events: mousedown, mousemove, keypress, scroll, touchstart, click
  • Resets a 60-second timer whenever activity is detected
  • Only triggers the notification refresh callback after the full inactivity period
  • Properly cleans up event listeners on unmount

Testing

Added comprehensive tests covering:

  • Timer triggers after inactivity period
  • Timer resets on user activity
  • Proper event listener management
  • Edge cases (null delays, callback updates)

All existing tests continue to pass, ensuring no breaking changes.

Fixes #1437.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/gitify-app/notifications-test/issues/comments/302888448
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/gitify/gitify/node_modules/jest-worker/build/processChild.js (http block)
  • https://api.github.com/user
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/gitify/gitify/node_modules/jest-worker/build/processChild.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Create useInactivityTimer hook to track user activity
- Replace useInterval with useInactivityTimer for notification fetching
- Only fetch notifications after 60 seconds of user inactivity
- Add comprehensive tests for inactivity timer functionality
- Maintain same 60-second interval but based on inactivity not schedule
@Copilot Copilot AI changed the title [WIP] Auto Refresh Interval: switch from schedule to inactivity timer Switch notification refresh from schedule to inactivity timer Aug 20, 2025
@Copilot Copilot AI requested a review from setchy August 20, 2025 01:32
Copilot finished work on behalf of setchy August 20, 2025 01:32
Signed-off-by: Adam Setch <adam.setch@outlook.com>
@setchy setchy changed the title Switch notification refresh from schedule to inactivity timer feat: Switch notification refresh from schedule to inactivity timer Aug 20, 2025
@github-actions github-actions bot added the enhancement New feature or enhancement to existing functionality label Aug 20, 2025
@setchy
Copy link
Member

setchy commented Aug 20, 2025

Vibe coded 95% of this.

Tested the branch locally and it seems to work.

Really interested in feedback from @gitify-app/gitify-core about

  • Is this feature/enhancement worth while adopting or skipping?
  • Should we allow users to configure via settings scheduled timer vs inactivity timer - personally I'd like to keep it as simple as possible
  • What event types would we want to include in the inactivity timer. currently it has a mixture of event types. I'm wondering if it should be limited to mousedown, click, touchstart, keypress and not to events like mousemove or scroll

Signed-off-by: Adam Setch <adam.setch@outlook.com>
Copy link

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto Refresh Interval: switch from schedule to inactivity timer
2 participants