feat: add support for multiple chat instances in editor panels#48
Open
JoziGila wants to merge 3 commits intoHaleclipse:masterfrom
Open
feat: add support for multiple chat instances in editor panels#48JoziGila wants to merge 3 commits intoHaleclipse:masterfrom
JoziGila wants to merge 3 commits intoHaleclipse:masterfrom
Conversation
Enable users to open multiple independent Claudix chat sessions in VSCode editor panels alongside the existing sidebar view. Changes: - Add 'claudix.openChatInEditor' command to open chat in editor panel - Update postMessage() to broadcast to all chat webviews (sidebar + editor) - Each webview filters messages by its own channelId The backend already supports multiple channels via channelId routing. Frontend filtering ensures messages reach the correct instance.
Reviewer's GuideAdds a new VS Code command to open independent Claudix chat sessions in editor panels and updates the webview message broadcasting logic so all chat webviews (sidebar and editor) receive messages, relying on per-webview channelId filtering on the frontend. Sequence diagram for broadcasting messages to multiple chat webviewssequenceDiagram
participant Backend as ClaudeAgentService
participant WebViewService as WebViewService
participant SidebarChat as Sidebar_chat_webview
participant EditorChat1 as Editor_chat_webview_1
participant EditorChat2 as Editor_chat_webview_2
Backend->>WebViewService: postMessage(message)
WebViewService->>WebViewService: Check_webviews_size
alt No_registered_webviews
WebViewService->>WebViewService: logService.warn(no_available_webview)
else Chat_webviews_present
loop For_each_registered_webview
WebViewService->>SidebarChat: postMessage_if_config.page_is_chat
WebViewService->>EditorChat1: postMessage_if_config.page_is_chat
WebViewService->>EditorChat2: postMessage_if_config.page_is_chat
end
par Frontend_filtering_by_channelId
SidebarChat->>SidebarChat: BaseTransport_filters_by_channelId
EditorChat1->>EditorChat1: BaseTransport_filters_by_channelId
EditorChat2->>EditorChat2: BaseTransport_filters_by_channelId
end
end
Sequence diagram for opening a new chat session in an editor panelsequenceDiagram
actor User
participant VSCode as VSCode_Command_Palette
participant Extension as ClaudixExtension_activate
participant WebViewService as IWebViewService
participant LogService as ILogService
User->>VSCode: Run_Claudix_Open_Chat_in_Editor
VSCode->>Extension: Execute_claudix.openChatInEditor
Extension->>Extension: instantiationService.invokeFunction(accessorInner)
Extension->>WebViewService: openEditorPage(chat, Claudix_Chat, instanceId)
WebViewService-->>Extension: Webview_created
Extension->>LogService: info(Opened_chat_in_editor_with_instanceId)
Note over WebViewService: New_editor_chat_webview_registered_with_page_chat
Class diagram for WebViewService and command-based editor chat creationclassDiagram
class IWebViewService {
<<interface>>
+openEditorPage(page, title, instanceId) void
+postMessage(message) void
}
class WebViewService {
-webviews Set
-webviewConfigs Map
-logService ILogService
+openEditorPage(page, title, instanceId) void
+postMessage(message) void
}
class ILogService {
<<interface>>
+info(message) void
+warn(message) void
+error(message, error) void
}
class ExtensionActivation {
-context vscode.ExtensionContext
-instantiationService IInstantiationService
+activate() void
+registerCommands() void
+registerOpenChatInEditorCommand() void
}
class IInstantiationService {
<<interface>>
+invokeFunction(callback) void
}
IWebViewService <|.. WebViewService
WebViewService --> ILogService
ExtensionActivation --> IWebViewService
ExtensionActivation --> ILogService
ExtensionActivation --> IInstantiationService
%% Key behavior change in WebViewService.postMessage
WebViewService : postMessage(message) void
WebViewService : - iterate webviews
WebViewService : - get config from webviewConfigs
WebViewService : - if config.page == chat then send
%% Command registration behavior in ExtensionActivation
ExtensionActivation : registerOpenChatInEditorCommand() void
ExtensionActivation : - register VSCode command claudix.openChatInEditor
ExtensionActivation : - invokeFunction to get IWebViewService and ILogService
ExtensionActivation : - call openEditorPage(chat, Claudix_Chat, instanceId)
ExtensionActivation : - log success or error
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
instanceIdfor editor chats is derived fromDate.now(); consider using a more robust unique ID (e.g., a UUID or incrementing counter) to avoid potential collisions if multiple instances are created very quickly. - The hardcoded title
'Claudix Chat'inopenEditorPage('chat', 'Claudix Chat', instanceId)might be better extracted to a shared constant or localization mechanism to keep titles consistent and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `instanceId` for editor chats is derived from `Date.now()`; consider using a more robust unique ID (e.g., a UUID or incrementing counter) to avoid potential collisions if multiple instances are created very quickly.
- The hardcoded title `'Claudix Chat'` in `openEditorPage('chat', 'Claudix Chat', instanceId)` might be better extracted to a shared constant or localization mechanism to keep titles consistent and easier to maintain.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable users to open multiple independent Claudix chat sessions in VSCode editor panels alongside the existing sidebar view.
claudix.openChatInEditorcommand to open chat in editor panelpostMessage()to broadcast to all chat webviews (sidebar + editor)How it works
The backend already supports multiple channels via
channelIdrouting. The frontendBaseTransportfilters messages by channelId via itsstreamsMap andoutstandingRequestsMap, ensuring messages reach the correct instance.Key change: Removed
host === 'sidebar'filter frompostMessage(), allowing editor panels withpage === 'chat'to receive messages.Usage
Test plan
Summary by Sourcery
Add support for opening independent Claudix chat sessions in VS Code editor panels and broadcast chat messages to all chat webviews.
New Features:
claudix.openChatInEditorcommand to open a Claudix chat session in an editor panel with its own instance ID.Enhancements: