Skip to content

Port upstream 0.69.0: Grok local session scan covers exact local calendar days - #687

Open
Finesssee wants to merge 2 commits into
port/upstream-0.69.0from
port/micro-0.69.0-grok-local-calendar-window
Open

Finesssee wants to merge 2 commits into
port/upstream-0.69.0from
port/micro-0.69.0-grok-local-calendar-window

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

The Grok local-session scan (rust/src/providers/grok/local_sessions.rs) now covers exactly days local calendar days: start = local midnight of today minus (max(1, days) - 1) days, end = local midnight of tomorrow (half-open [start, end)). Previously it used a rolling now - days cutoff and dropped files modified after now, so daily buckets and aggregate totals could disagree with the advertised 7/30-day window.

Upstream reference

Ported / Deferred

Ported:

  • Local-calendar-day scan window (start of day N-1 days ago through the next local midnight), with the new window test using upstream's four-file fixture layout (outside / first day / today / tomorrow, 100 tokens each, expecting 2 sessions and 200 tokens for 1, 7 and 30 days).
  • docs/PROVIDERS.md note.

Already satisfied locally, no code change needed:

  • "Wider history views keep the scan's actual coverage; narrower views project down": Win-CodexBar has no published-snapshot projection layer; commands/usage_spend.rs calls summarize(7) and summarize(30) directly, so no projection beyond the scan exists.
  • "Local token totals remain published when billing fails": Usage & Spend reads the local scan independently of the billing fetch (spend.seven_day_tokens / thirty_day_tokens come from local_sessions::summarize), so a billing outage does not hide them.

Deferred: none. The Swift-only UsageSnapshot.replacing(costUsage:) and UsageStore refresh publication changes have no Windows counterpart.

Validation

  • cargo +1.98.0 fmt --all: clean
  • cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: pass
  • cargo +1.98.0 test -p codexbar grok -- --test-threads=4: 48 passed, 0 failed (includes scan_totals_cover_only_the_advertised_local_calendar_days, calendar_window_starts_at_local_midnight, and the existing local-day test)

Affected areas

  • Rust backend (rust/src/providers/grok)
  • Docs (docs/PROVIDERS.md)
  • Tauri shell / frontend / tray / settings / float bar

UI proof

Not applicable.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: af5f9df9-ee23-472d-aece-66e13afa18c6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Reviewed by Codex gpt-6-luna (xhigh); verified and validated by Claude

Thermo-nuclear review of PR #687 (Grok local calendar-day window): 1 finding.

  • Medium rust/src/providers/grok/local_sessions.rs: converting local midnight to a timestamp fell back to now when midnight was ambiguous or nonexistent (DST gaps), shifting the advertised calendar-day window. The scan now compares local dates directly, which removes the conversion and the fallback helper.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Follow-up: the finding is fixed at the new head. Nothing left open.

Commands run: cargo +1.98.0 fmt --all --check, cargo +1.98.0 clippy --all-targets -- -D warnings on rust/ and apps/desktop-tauri/src-tauri, cargo +1.98.0 test --lib grok (48 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.

1 participant