Reset app usage at local day change#2
Merged
Conversation
Store app usage with a tracked local date so stale usage does not carry into the next day, while preserving legacy usage files during migration. Constraint: Focturn uses local desktop storage for usage state Tested: npm run typecheck; npm run test:run; npm run check; cargo fmt --check; cargo test; cargo clippy Co-authored-by: OmX <omx@oh-my-codex.dev>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
focturn | 86a3b29 | May 17 2026, 02:27 AM |
There was a problem hiding this comment.
Pull request overview
This PR updates desktop app usage persistence so usage stats are associated with a tracked date and reset on day changes, while also updating reminder toggle copy.
Changes:
- Adds dated usage state persistence and legacy usage map migration.
- Resets in-memory usage when the tracked date differs from the current date.
- Renames reminder toggle copy in settings.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
apps/desktop/src/components/SettingsPanel.tsx |
Updates reminder toggle label and disabled-state helper text. |
apps/desktop/src-tauri/src/monitor.rs |
Loads/saves dated usage state and resets usage during monitor sampling when the date changes. |
apps/desktop/src-tauri/src/monitor_usage.rs |
Adds UsageState, current date helpers, reset/migration logic, and unit tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub(crate) fn current_local_date_key() -> String { | ||
| #[cfg(target_os = "windows")] | ||
| { | ||
| let local_time = unsafe { windows::Win32::System::SystemInformation::GetLocalTime() }; |
Comment on lines
+106
to
+110
| <strong>Reminder active</strong> | ||
| <small> | ||
| {settings.monitoringEnabled | ||
| ? 'Focturn can show reminders and notifications' | ||
| : 'Reminder popup and notifications are disabled'} | ||
| : 'Reminder popup and notifications are off'} |
Comment on lines
+59
to
+63
| let seconds = std::time::SystemTime::now() | ||
| .duration_since(std::time::UNIX_EPOCH) | ||
| .map(|duration| duration.as_secs()) | ||
| .unwrap_or(0); | ||
| date_key_from_unix_days((seconds / 86_400) as i64) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trackedDateso stale stats reset at local day boundariesusage_stats.jsonmaps into the new dated shapeReminder activeVerification
npm run typechecknpm run test:runnpm run checkcargo fmt --checkcargo testcargo clippy --all-targets -- -D warningsCloses #1