Skip to content

fix: derive session/week reset times from actual account behavior - #20

Merged
coldhighsun merged 1 commit into
mainfrom
fix/session-week-reset-logic
Sep 15, 2026
Merged

coldhighsun merged 1 commit into
mainfrom
fix/session-week-reset-logic

Conversation

@coldhighsun

Copy link
Copy Markdown
Owner

Summary

  • Session (5h) reset was rolled forward by fixed 5h multiples forever once an anchor was supplied, drifting from reality across idle resets; it's now a one-shot reset time trusted only while still in the future, with local activity used to estimate the window once it elapses.
  • Weekly reset was estimated as a message-triggered rolling 7-day window, but the real weekly cap resets at a fixed account time unrelated to activity; without --week-reset it now reports as unknown (trailing 7-day usage shown as an upper bound) instead of a fabricated reset timestamp.
  • Replaces the old IsAnchorEstimated bool with a three-state WindowConfidence (Confirmed/Estimated/Unknown).
  • Renames --session-anchor/--week-anchor to --session-reset/--week-reset, now taking the reset time itself rather than a window start time.
  • watch's r hotkey recalibrates both reset times in place (no exit needed), prefills the currently configured value as the default so Enter keeps it, and the screen is cleared on exit.

Test plan

  • dotnet build AIUsageMonitor.slnx — 0 warnings
  • dotnet test AIUsageMonitor.slnx — 53/53 passing
  • Manually rendered all WindowConfidence combinations (Confirmed/Estimated/Unknown for both windows) via a scratch harness to verify table/notes output
  • Manual interactive check of the r hotkey flow in a real terminal (not verifiable from this environment — Spectre's Live display requires a real console)

The 5h session window and weekly limit were both modeled incorrectly:

- Session: a supplied --session-anchor was rolled forward by fixed 5h
  multiples forever, drifting from reality whenever an idle reset
  happened in between. It's now treated as a one-shot reset time that
  only applies while still in the future; local activity is used to
  estimate the window once it elapses, and the window is reported as
  unknown (rather than guessed) when neither is available.
- Week: the weekly cap resets at a fixed account time, not on a
  message-triggered rolling 7-day cycle. Without --week-reset there is
  no way to derive that instant locally, so the window now reports as
  unknown with the trailing 7-day usage shown as an upper bound,
  instead of a fabricated reset timestamp.

Introduces a three-state WindowConfidence (Confirmed/Estimated/Unknown)
replacing the old IsAnchorEstimated bool, since "unknown" needed a
distinct representation from "estimated".

Other user-facing changes bundled with this:
- --session-anchor/--week-anchor renamed to --session-reset/--week-reset
  and now take the reset time itself (matching what the account's own
  usage screen shows), not a window start time.
- `watch`'s `r` hotkey recalibrates both reset times without exiting,
  showing the currently configured value as the default so Enter keeps
  it, and clears the screen on exit.
@coldhighsun
coldhighsun merged commit b1f9184 into main Sep 15, 2026
4 checks passed
@coldhighsun
coldhighsun deleted the fix/session-week-reset-logic branch September 15, 2026 05:01
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