-
Notifications
You must be signed in to change notification settings - Fork 69
feat: add support for multiple chat instances in editor panels #48
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: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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: