Skip to content

feat: Implement Smart Session Guard for Lock and Sleep Awareness#38

Merged
0xarchit merged 1 commit into
mainfrom
feature/smart-session
May 3, 2026
Merged

feat: Implement Smart Session Guard for Lock and Sleep Awareness#38
0xarchit merged 1 commit into
mainfrom
feature/smart-session

Conversation

@0xarchit
Copy link
Copy Markdown
Owner

@0xarchit 0xarchit commented May 3, 2026

🐾 Pull Request Description

Summary
This PR introduces the "Smart Session Guard," making PauseCat aware of the Windows session state and system power events. It ensures the work timer only ticks when the user is
actually at their desk and prevents reminders from triggering on locked screens.

Related Issues
Fixes #37

🚀 Key Changes

  • Native Lock Detection: Integrated Win32 WTSRegisterSessionNotification to pause the timer automatically when the screen is locked (Win+L).
  • Power State Awareness: Implemented WM_POWERBROADCAST handling to detect system sleep/suspend and resume events.
  • Zero-Ghosting Guard: Added a strict verification layer that prevents overlay initialization if the user session is not active and unlocked.
  • Automatic Dismiss: Configured the app to automatically clear active break reminders if the session is locked during a break.
  • RAM-Only State: Maintained your preference for non-persistent timers; all session logic lives purely in RAM and resets cleanly upon application restart or system reboot.

🛠 Technical Details

  • Added Win32_System_RemoteDesktop to Cargo.toml for session change notifications.
  • Refactored the main event loop to route SessionLocked and SessionUnlocked events to the timer engine.
  • Bumped application version to v1.0.1.

✅ Verification

  • Verified on Windows 11 that locking the screen instantly freezes the work timer.
  • Confirmed that the timer resumes seamlessly upon unlocking without losing progress.
  • Verified that the break reminder does not trigger while the session is locked.
  • Successfully built with MSVC optimizations (cargo build --release).

By submitting this PR, I agree to follow the project's Code of Conduct.

@0xarchit 0xarchit self-assigned this May 3, 2026
@0xarchit 0xarchit merged commit 9e09bdb into main May 3, 2026
3 checks passed
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.

feat: Implement Smart Session Guard (Lock/Sleep Awareness)

1 participant