fix: derive session/week reset times from actual account behavior - #20
Merged
Merged
Conversation
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.
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
--week-resetit now reports as unknown (trailing 7-day usage shown as an upper bound) instead of a fabricated reset timestamp.IsAnchorEstimatedbool with a three-stateWindowConfidence(Confirmed/Estimated/Unknown).--session-anchor/--week-anchorto--session-reset/--week-reset, now taking the reset time itself rather than a window start time.watch'srhotkey 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 warningsdotnet test AIUsageMonitor.slnx— 53/53 passingWindowConfidencecombinations (Confirmed/Estimated/Unknown for both windows) via a scratch harness to verify table/notes outputrhotkey flow in a real terminal (not verifiable from this environment — Spectre'sLivedisplay requires a real console)