Skip to content

Fix cache loading#171

Merged
rajbos merged 3 commits intomainfrom
cache-fix
Feb 3, 2026
Merged

Fix cache loading#171
rajbos merged 3 commits intomainfrom
cache-fix

Conversation

@rajbos
Copy link
Owner

@rajbos rajbos commented Feb 2, 2026

This pull request updates the session file caching logic to improve cache validation and performance by including file size as part of the cache key and data. This ensures that cached session data is correctly invalidated when the file size changes, preventing stale or incorrect cache usage. The changes are backward compatible and update the cache version to reflect the new format.

Session File Caching Improvements

  • The session file cache now stores and validates against both modification time (mtime) and file size, instead of just mtime, for more accurate cache invalidation. (src/extension.ts, SessionFileCache, isCacheValid, setCachedSessionData, getSessionFileDataCached, and all cached read methods) [1] [2] [3] [4]
  • All cached session file read methods (estimateTokensFromSessionCached, countInteractionsInSessionCached, getModelUsageFromSessionCached, getUsageAnalysisFromSessionCached) now require and use file size as an argument for cache lookup and storage. This change is propagated throughout the codebase wherever these methods are called. [1] [2] [3] [4] [5]

Interface and Dependency Updates

  • The getSessionFileDataCached method signature in BackendFacadeDeps and SyncServiceDeps interfaces is updated to require the fileSize parameter, ensuring all consumers provide file size for cache operations. (src/backend/facade.ts, src/backend/services/syncService.ts) [1] [2]
  • The activation logic and backend service integration are updated to use the new getSessionFileDataCached signature with the file size parameter. (src/extension.ts, activate)

Sync Service Integration

  • The SyncService class and its methods are updated to retrieve and pass file size when performing cache operations, ensuring consistency across backend and extension layers. (src/backend/services/syncService.ts) [1] [2] [3]

Cache Versioning and Maintenance

  • The cache version is incremented to 9 to reflect the new format and force invalidation of old cache entries that do not include file size. (src/extension.ts, CopilotTokenTracker.CACHE_VERSION)
  • Cache saving logic is improved: the cache is now saved automatically after each update, and error handling is added to avoid blocking the UI if cache persistence fails. (src/extension.ts) [1] [2]

@rajbos rajbos enabled auto-merge February 2, 2026 19:50
@rajbos rajbos merged commit 7735255 into main Feb 3, 2026
12 checks passed
@rajbos rajbos deleted the cache-fix branch February 3, 2026 09:04
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

Comments