Skip to content

Reset app usage at local day change#2

Merged
ancieraav merged 1 commit into
masterfrom
fix/daily-app-usage-reset
May 17, 2026
Merged

Reset app usage at local day change#2
ancieraav merged 1 commit into
masterfrom
fix/daily-app-usage-reset

Conversation

@ancieraav

Copy link
Copy Markdown
Owner

Summary

  • stores app usage with a trackedDate so stale stats reset at local day boundaries
  • clears in-memory usage when the app stays open across a local date change
  • migrates legacy raw usage_stats.json maps into the new dated shape
  • renames the reminder toggle copy to Reminder active

Verification

  • npm run typecheck
  • npm run test:run
  • npm run check
  • cargo fmt --check
  • cargo test
  • cargo clippy --all-targets -- -D warnings

Closes #1

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>
Copilot AI review requested due to automatic review settings May 17, 2026 02:27
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
focturn 86a3b29 May 17 2026, 02:27 AM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
@ancieraav ancieraav merged commit a35031c into master May 17, 2026
6 of 7 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.

Reset app usage stats automatically at local day change

2 participants