Skip to content

Refactoring extension.ts#365

Merged
rajbos merged 1 commit intomainfrom
refactoring
Mar 8, 2026
Merged

Refactoring extension.ts#365
rajbos merged 1 commit intomainfrom
refactoring

Conversation

@rajbos
Copy link
Owner

@rajbos rajbos commented Mar 8, 2026

This pull request introduces a new CacheManager class to handle persistent caching of session file data and adds a comprehensive set of shared type definitions in a new types.ts file. The changes focus on improving cache reliability, performance, and maintainability, as well as making type definitions reusable across the extension.

Cache Management Improvements:

  • Introduced a CacheManager class (src/cacheManager.ts) that manages persistent caching of parsed session data to avoid redundant file reads, including:
    • Methods for validating, setting, and retrieving cache entries, with logic to upgrade old cache formats and limit cache size to prevent memory issues.
    • Mechanisms for cache versioning and migration, ensuring compatibility and cleaning up legacy cache keys from previous extension versions.
    • File-based locking to prevent concurrent cache writes across multiple VS Code windows, including detection and cleanup of stale locks.
    • Integration with VS Code's globalState for persistent storage, with separate cache identifiers for development and production modes.

Type Definitions Refactoring:

  • Added a new src/types.ts file containing shared type definitions for token usage, session statistics, cache entries, usage analysis, and related data structures, extracted from extension.ts for better organization and reusability.
  • Defined interfaces for cache entries (SessionFileCache), usage analysis, session logs, customization files, and various statistics, enabling consistent typing across the codebase.

These changes lay the groundwork for more robust session file caching and pave the way for easier maintenance and future extension features.

References:
[1] [2]

@rajbos rajbos merged commit a901966 into main Mar 8, 2026
14 checks passed
@rajbos rajbos deleted the refactoring branch March 8, 2026 21: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.

1 participant