Skip to content

Feat ContextProxy to improve state management#1235

Merged
mrubens merged 10 commits intoRooCodeInc:mainfrom
samhvw8:feat/context-proxy
Mar 5, 2025
Merged

Feat ContextProxy to improve state management#1235
mrubens merged 10 commits intoRooCodeInc:mainfrom
samhvw8:feat/context-proxy

Conversation

@samhvw8
Copy link
Contributor

@samhvw8 samhvw8 commented Feb 27, 2025

  • Add ContextProxy class as a wrapper around VSCode's ExtensionContext
  • Implement batched state updates for performance optimization
  • Update ClineProvider to use ContextProxy instead of direct context access
  • Add comprehensive test coverage for ContextProxy
  • Extract SECRET_KEYS and GLOBAL_STATE_KEYS constants for better maintainability

Description

This feature will we can open multiple window (which can have different config (mode / api config))

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Introduces ContextProxy for efficient state management in ClineProvider, with batched updates and comprehensive testing.

  • Behavior:
    • Introduces ContextProxy class in contextProxy.ts to buffer state changes and secrets, committing them on request or disposal.
    • Replaces direct context access in ClineProvider.ts with ContextProxy for efficient state management.
    • Extracts SECRET_KEYS and GLOBAL_STATE_KEYS constants in globalState.ts for maintainability.
  • Testing:
    • Adds comprehensive tests for ContextProxy in contextProxy.test.ts.
    • Updates ClineProvider.test.ts to mock and test ContextProxy integration.
  • Misc:
    • Updates ClineProvider to use ContextProxy for state and secret management, ensuring proper disposal and state handling.

This description was created by Ellipsis for dec624cb2f425f59f1d3cd2b07603fa0c7e7c3ab. It will automatically update as commits are pushed.

@samhvw8 samhvw8 requested review from cte and mrubens as code owners February 27, 2025 07:43
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2025

⚠️ No Changeset found

Latest commit: 86401fa

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

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Enhancement New feature or request labels Feb 27, 2025
@samhvw8 samhvw8 force-pushed the feat/context-proxy branch 2 times, most recently from c12aea5 to fc11d96 Compare February 28, 2025 11:55
@samhvw8 samhvw8 force-pushed the feat/context-proxy branch from fc11d96 to fbb5a19 Compare March 3, 2025 03:47
@mrubens
Copy link
Collaborator

mrubens commented Mar 3, 2025

I'm having trouble making this work - when I open two windows they still seem to be clobber each other's state when I use the mode selector in the chat textarea. Am I doing something wrong?

@mrubens
Copy link
Collaborator

mrubens commented Mar 3, 2025

I just pushed a PR to add per-window isolation - seems to work better now, I think?

@samhvw8 samhvw8 force-pushed the feat/context-proxy branch from cf48c83 to d68794c Compare March 4, 2025 09:39
@samhvw8
Copy link
Contributor Author

samhvw8 commented Mar 4, 2025

https://drive.google.com/file/d/1S3LANpNB2ve6srseGP9KIitD-10SmUkR/view?usp=sharing

my test with 2 instance vscode with 2 workspace at time :D

samhvw8 added 4 commits March 4, 2025 21:55
- Add ContextProxy class as a wrapper around VSCode's ExtensionContext
- Implement batched state updates for performance optimization
- Update ClineProvider to use ContextProxy instead of direct context access
- Add comprehensive test coverage for ContextProxy
- Extract SECRET_KEYS and GLOBAL_STATE_KEYS constants for better maintainability
@samhvw8 samhvw8 force-pushed the feat/context-proxy branch 3 times, most recently from ec1f1b7 to f9a65ce Compare March 4, 2025 16:23
@samhvw8 samhvw8 force-pushed the feat/context-proxy branch 2 times, most recently from 0407bd6 to 956e1b1 Compare March 4, 2025 17:05
@samhvw8 samhvw8 force-pushed the feat/context-proxy branch from 956e1b1 to 9bbd902 Compare March 4, 2025 17:07
@hannesrudolph
Copy link
Collaborator

hannesrudolph commented Mar 5, 2025

Resolves #1208
Closes #1208
Fixes #1208

@hannesrudolph hannesrudolph linked an issue Mar 5, 2025 that may be closed by this pull request
@mrubens
Copy link
Collaborator

mrubens commented Mar 5, 2025

@samhvw8 can you fix tests? Then I think we’re good 🚀

@mrubens mrubens force-pushed the feat/context-proxy branch from 7e550f0 to c3da5b0 Compare March 5, 2025 14:49
@RooCodeInc RooCodeInc deleted a comment from hannesrudolph Mar 5, 2025
@RooCodeInc RooCodeInc deleted a comment from hannesrudolph Mar 5, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 5, 2025
@mrubens mrubens merged commit fcf0926 into RooCodeInc:main Mar 5, 2025
9 checks passed
@github-project-automation github-project-automation bot moved this from PR to Done in Roo Code Roadmap Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State overlap between instances of Roo Code

4 participants