Skip to content

Conversation

philipvas
Copy link
Contributor

This pull request introduces a ContextProxy to centralize and improve state management within the extension. The primary motivation is to address memory fragmentation issues caused by frequent large writes to the global state, particularly the taskHistory.

Implementation

  • ContextProxy: A new class that acts as a singleton proxy for ExtensionContext.globalState and ExtensionContext.secrets. All state access is now routed through this proxy.
  • Disk-Backed Large State: Large state values, such as taskHistory, are now stored on disk instead of in the global state. This significantly reduces memory pressure.
  • Debounced Writes: Writes to large state values are debounced to minimize disk I/O.
  • Durable Instrumentation: A durable instrumentation log (frag-instrument.log) has been added to track state writes and help diagnose memory fragmentation issues.
  • Test Migration: Tests have been migrated to use a mocked ContextProxy for better isolation and testability.

Screenshots

before after

|
470948952-f25c3adb-5391-43dd-911d-53c77c4f0564
|
Screenshot 2025-08-25 at 17 31 53
|

How to Test

  • Run the extension and perform various tasks to generate history.
  • Verify that the taskHistory is stored in the global storage directory.
  • Verify that the frag-instrument.log is created and updated.
  • Run the unit tests to ensure that the ContextProxy is working as expected."

Get in Touch

discord handle: 40ftrobot

- Implement ContextProxy to manage globalState and secrets.
- Offload large state values to disk to reduce memory pressure.
- Add debounced writes for large state values.
- Introduce durable instrumentation log for state writes.
- Migrate tests to use a mocked ContextProxy.
Copy link

changeset-bot bot commented Aug 26, 2025

⚠️ No Changeset found

Latest commit: 1e1c303

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@mcowger mcowger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only concern I have is the write of both the history and fragmentation log as unbounded size. Could you address that?

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.

2 participants