Skip to content

fix: use content timestamps for lastInteraction, not max(timestamp, mtime)#655

Merged
rajbos merged 1 commit intomainfrom
rajbos/fix-30day-utc-cutoff
Apr 23, 2026
Merged

fix: use content timestamps for lastInteraction, not max(timestamp, mtime)#655
rajbos merged 1 commit intomainfrom
rajbos/fix-30day-utc-cutoff

Conversation

@rajbos
Copy link
Copy Markdown
Owner

@rajbos rajbos commented Apr 23, 2026

Fixes #649

Problem

The "Today" section was showing sessions from the previous day. VS Code writes session files slightly after midnight when finalizing a session, making the file's mtime fall on "today" even though the last actual chat interaction was "yesterday."

The old code used max(contentTimestamp, mtime) for lastInteraction, so any session touched by VS Code at 00:00:01 would be classified as "today."

Fix

lastInteraction must come exclusively from content timestamps. mtime is only used as a last-resort fallback when no content timestamp exists at all.

Changes

  • getSessionFileDetails — 3 branches (delta JSONL, non-delta JSONL, regular JSON): use content timestamp directly instead of max(contentTimestamp, mtime)
  • getSessionFileDetailsFromCache — removed the 8-line block that overrode cached lastInteraction with mtime when mtime was newer
  • calculateUsageAnalysisStats — switched month/today checks from raw mtime to lastActivity derived from sessionData.lastInteraction
  • CACHE_VERSION bumped 39 → 40 to invalidate stale caches on next startup

Testing

  • tsc --noEmit passes (no TypeScript errors)
  • node esbuild.js builds cleanly

…time)

Fixes #649: 'Today' section was showing previous day's sessions because
VS Code writes session files slightly after midnight, making mtime 'today'
even though the last interaction was 'yesterday'.

- getSessionFileDetails: use content timestamp directly (3 places)
- getSessionFileDetailsFromCache: don't override with mtime
- calculateUsageAnalysisStats: use lastActivity from lastInteraction
- Bump CACHE_VERSION to 40 to invalidate stale caches

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rajbos rajbos enabled auto-merge April 23, 2026 17:06
@rajbos rajbos merged commit f310c7a into main Apr 23, 2026
15 checks passed
@rajbos rajbos deleted the rajbos/fix-30day-utc-cutoff branch April 23, 2026 17:07
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.

[BUG][vscode] Token usage does not reset at midnight / incorrect time chunk overlap

1 participant