-
Notifications
You must be signed in to change notification settings - Fork 60
Fix for multiple workspaces not working #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes migrate Changes
Sequence DiagramsequenceDiagram
actor User
participant IDE as IDE Instance
participant Project1 as Project 1
participant Project2 as Project 2
participant SOP as SystemObjectProvider
rect rgb(200, 220, 240)
note over User,SOP: Old Behavior (Global)
User->>IDE: Open Project 1
IDE->>SOP: register("pluginService", obj1)
SOP->>SOP: Store in global map
User->>IDE: Open Project 2
IDE->>SOP: register("pluginService", obj2)
SOP->>SOP: Overwrite global map (conflict)
end
rect rgb(220, 240, 200)
note over User,SOP: New Behavior (Per-Project)
User->>IDE: Open Project 1
IDE->>Project1: initialize()
Project1->>SOP: register(project1, "pluginService", obj1)
SOP->>SOP: Store in project1 map
User->>IDE: Open Project 2
IDE->>Project2: initialize()
Project2->>SOP: register(project2, "pluginService", obj2)
SOP->>SOP: Store in project2 map (isolated)
User->>IDE: Close Project 1
IDE->>SOP: dispose(project1)
SOP->>SOP: Clean up project1 map only
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes The changes follow a consistent, straightforward pattern: import removals are trivial, the Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/plugin/SystemObjectProvider.kt (1)
69-69
: Minor optimization: redundant clear() after remove().The
clear()
call afterremove()
is technically redundant since the removed map will be garbage collected. However, this is harmless and may serve as defensive programming.If you prefer a minor optimization, you can simplify to:
- projectObjects.remove(project)?.clear() + projectObjects.remove(project)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/actors/MainThreadLanguageModelToolsShape.kt
(0 hunks)jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/actors/MainThreadTaskShape.kt
(0 hunks)jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/actors/MainThreadWindowShape.kt
(0 hunks)jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/plugin/SystemObjectProvider.kt
(1 hunks)jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/plugin/WecoderPlugin.kt
(2 hunks)jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/ui/RunVSAgentToolWindowFactory.kt
(1 hunks)
💤 Files with no reviewable changes (3)
- jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/actors/MainThreadLanguageModelToolsShape.kt
- jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/actors/MainThreadTaskShape.kt
- jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/actors/MainThreadWindowShape.kt
🔇 Additional comments (6)
jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/ui/RunVSAgentToolWindowFactory.kt (1)
1274-1274
: Correct per-project disposal pattern.The change correctly updates the disposal call to pass the project parameter, aligning with the new per-project lifecycle management approach in
SystemObjectProvider
.jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/plugin/WecoderPlugin.kt (2)
144-144
: Correct per-project disposal pattern.The disposal call correctly passes the project parameter, ensuring project-specific resources are cleaned up when the project is disposed.
362-362
: Correct per-project registration pattern.The registration call correctly passes the project as the first parameter, storing the plugin service instance in project-scoped storage rather than global storage.
jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/plugin/SystemObjectProvider.kt (3)
19-20
: Sound architecture change for per-project lifecycle.The introduction of per-project storage using
ConcurrentHashMap<Project, ConcurrentHashMap<String, Any>>
correctly implements the per-project lifecycle pattern needed to support multiple workspaces simultaneously.
34-78
: All SystemObjectProvider callsites updated to use per-project API
All initialize, register, get, and dispose calls now include the requiredproject
parameter; no legacy usages remain.
75-78
: disposeAll() is defined but never invoked
SystemObjectProvider.disposeAll()
clears all project entries but isn’t called anywhere. Remove it or invoke it during plugin/application shutdown (e.g., in yourWecoderPlugin.dispose()
or a similar lifecycle hook).
Fixes #98
This PR possibly fixes multiple workspaces problem.
Instance state is tied to a single Project. Services like WebViewManager and WecoderPluginService are marked with @service(Service.Level.PROJECT) and store the active WebViewInstance and RPC connection in project-scoped fields (WebViewManager.getLatestWebView(), PluginContext.getRPCProtocol()), but they also relied on static/singleton access (WecoderPlugin.getInstance(project), PluginContext.getInstance(project)). When a second IDE window opens, the new project gets fresh service instances while the extension process was still running for the first project. The new window never registered a WebView because the extension host remained bound to the earlier ExtensionHostManager, so the RunVSAgentToolWindowContent placeholder kept showing, producing e.g. the blank web view.
Summary by CodeRabbit