Skip to content

Refactor file stat handling to always check for modifications, improving accuracy and performance#299

Merged
rajbos merged 2 commits intomainfrom
prevent-number-drifts
Feb 25, 2026
Merged

Refactor file stat handling to always check for modifications, improving accuracy and performance#299
rajbos merged 2 commits intomainfrom
prevent-number-drifts

Conversation

@rajbos
Copy link
Owner

@rajbos rajbos commented Feb 25, 2026

This pull request updates the token tracking logic in the CopilotTokenTracker class to always perform a file stat operation when processing session files, instead of relying on cached metadata to skip the stat. This change ensures that file modifications are reliably detected, trading a minor performance cost for improved data accuracy. The cache is still used for reading session data efficiently, but not for skipping file stats.

Key changes:

File stat and cache logic updates:

  • Always calls statSessionFile to get up-to-date mtime and size for each session file, instead of using cached values to skip the stat. This improves reliability in detecting file changes. [1] [2] [3] [4]
  • Updates cache usage: the cache is now used to validate if session data can be reused based on the latest mtime and size, rather than to skip the stat entirely.
  • When retrieving the repository name, now uses the value from the session data (which is validated against the current file) instead of potentially stale cached metadata.

@rajbos rajbos enabled auto-merge February 25, 2026 09:27
@rajbos rajbos merged commit 1786583 into main Feb 25, 2026
14 checks passed
@rajbos rajbos deleted the prevent-number-drifts branch February 25, 2026 09:30
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