Skip to content

fix: save running timer segment when quitting the app - #28

Merged
wiseelf merged 1 commit into
mainfrom
fix/save-timer-on-quit
Jul 13, 2026
Merged

fix: save running timer segment when quitting the app#28
wiseelf merged 1 commit into
mainfrom
fix/save-timer-on-quit

Conversation

@wiseelf

@wiseelf wiseelf commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Quitting (menu item or in-app "Quit TimeTracker" button) called NSApplication.terminate directly, bypassing TimerManager.stop() — the only code path that persists the in-progress segment to SessionStore.
  • AppDelegate had no applicationWillTerminate hook, so any time tracked since the last save point was silently discarded on quit.
  • Adds applicationWillTerminate(_:) calling TimerManager.shared.stop(reason: "App quit"), mirroring the existing systemWillSleep handler that already does this for sleep/screensaver.

Test plan

  • swift build — clean
  • swift test — 40/40 passing
  • Manual: start the timer, quit via the menu bar "Quit TimeTracker" item, reopen the app — confirm the running segment shows up in today's total / Stats
  • Manual: same, but quit via the in-app "Quit TimeTracker" button in Settings

Quit (menu item and in-app button) called NSApplication.terminate
directly, bypassing TimerManager.stop() — the only path that persists
the in-progress segment to SessionStore. AppDelegate had no
applicationWillTerminate hook, so any time tracked since the last save
point was silently lost on quit. Mirrors the existing systemWillSleep
handler, which already flushes the timer on sleep/screensaver for the
same reason.
@wiseelf
wiseelf merged commit 6978fed into main Jul 13, 2026
@wiseelf
wiseelf deleted the fix/save-timer-on-quit branch July 13, 2026 00:44
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.

1 participant