Skip to content

Conversation

@JoziGila
Copy link

@JoziGila JoziGila commented Jan 8, 2026

Summary

Enable users to open multiple independent Claudix chat sessions in VSCode editor panels alongside the existing sidebar view.

  • 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

How it works

The backend already supports multiple channels via channelId routing. The frontend BaseTransport filters messages by channelId via its streams Map and outstandingRequests Map, ensuring messages reach the correct instance.

Key change: Removed host === 'sidebar' filter from postMessage(), allowing editor panels with page === 'chat' to receive messages.

Usage

  1. Open Command Palette (Cmd+Shift+P)
  2. Run "Claudix: Open Chat in Editor"
  3. New chat panel opens in editor area
  4. Each panel works independently with its own session

Test plan

  • Open chat in editor via command palette
  • Verify messages work in editor panel
  • Open multiple editor panels, verify independent sessions
  • Verify sidebar chat still works
  • Close panels, verify no errors

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:

  • Introduce a claudix.openChatInEditor command to open a Claudix chat session in an editor panel with its own instance ID.

Enhancements:

  • Update the WebView message broadcasting logic to send chat messages to all chat pages (sidebar and editor panels) while relying on per-webview channel filtering.
  • Expose the new editor chat command in the extension contributions with a command palette entry and icon.

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.
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 8, 2026

Reviewer's Guide

Adds 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 webviews

sequenceDiagram
  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
Loading

Sequence diagram for opening a new chat session in an editor panel

sequenceDiagram
  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
Loading

Class diagram for WebViewService and command-based editor chat creation

classDiagram
  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
Loading

File-Level Changes

Change Details Files
Add a VS Code command to open Claudix chat in an editor panel with a unique instance identifier and logging.
  • Register new command identifier for opening chat in the editor within the extension activation function.
  • Use the existing instantiation service to resolve IWebViewService and ILogService when the command is executed.
  • Generate a unique instanceId per invocation and call openEditorPage with page='chat', a title label, and the instanceId.
  • Log success and error paths for opening the editor chat page.
src/extension.ts
Broaden webview message broadcasting so all chat pages (sidebar and editor) receive messages, relying on page-based filtering only.
  • Update postMessage documentation comments to describe broadcasting to all chat webviews (sidebar + editor) and channel-based filtering on the client.
  • Relax the filtering condition in postMessage to drop the host === 'sidebar' requirement and keep only page === 'chat' as the gate.
  • Preserve existing guard for missing webview configs and non-chat pages.
src/services/webViewService.ts
Expose the new open-in-editor chat command in the extension manifest with a title and icon.
  • Declare the new claudix.openChatInEditor command in package.json contributes.commands.
  • Set a user-facing title 'Claudix: Open Chat in Editor' and an appropriate $(comment-discussion) icon.
package.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a 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 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant