🤖 feat: VS Code secondary sidebar mux chat view #1305
Draft
+1,044
−11
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
muxSecondary) with amux.chatViewwebview.mux: Open Workspaceopens a new window, auto-reveal the chat view and auto-select the matching workspace.Testing
make static-checkcd vscode && bun run compile📋 Implementation Plan
Plan: VS Code Secondary Sidebar – mux Workspace Selector + Chat
Goal
Add a Secondary Side Bar view for the existing
vscode/extension so you can:Key UX requirement: after you run the existing "mux: Open Workspace" command and VS Code opens that workspace, the mux chat view should automatically show the matching chat session (no switching back to the mux desktop app, and ideally no extra clicks).
This leverages VS Code 1.106’s new
viewsContainers.secondarySidebarcontribution point (release notes: https://code.visualstudio.com/updates/v1_106#_extension-authoring).Non-goals (initially)
Recommended approach (A): Single webview view with selector + chat
Net new product LoC: ~500–700
One view container in the Secondary Side Bar, containing one webview view:
Why this is the best “simple” path:
vscode/src/.Implementation steps
1) Manifest: contribute a container + webview view in the Secondary Side Bar
Update
vscode/package.json:engines.vscodeto^1.106.0(or the minimum version you confirm supportssecondarySidebar).contributes.viewsContainers.secondarySidebar: new container, e.g.muxSecondarycontributes.views["muxSecondary"]: onetype: "webview"view, e.g.mux.chatViewactivationEvents: includeonStartupFinished(to auto-reveal) andonView:mux.chatViewas a safe fallback2) Extension activation: register a
WebviewViewProviderIn
vscode/src/extension.ts:vscode.window.registerWebviewViewProvider("mux.chatView", provider, { webviewOptions: { retainContextWhenHidden: true } }).mux.openWorkspace,mux.configureConnection) unchanged.revealChatView()helper that runsworkbench.view.extension.<containerId>so the extension can programmatically show the secondary-sidebar view when appropriate.mux.focusChatView) for Command Palette use.3) Create a small “mux service” layer for the view (reuse existing code)
Add a small module (or refactor existing helpers) so both commands and the sidebar can share logic:
getWorkspacesForUi(context)discoverServerConfig+checkServerReachable+checkAuthmux.connectionMode(auto/server-only/file-only)WorkspaceWithContext[]getApiClientForUi(context)ApiClient(per extension host) so the sidebar doesn’t reconnect on every UI event.assertthat required config fields exist.4) Webview UI: minimal HTML/CSS/JS (no framework)
Implement a simple DOM-based UI (inline script is fine to avoid changing build pipeline):
<select>populated with workspaces (label includes project + branch + runtime icon)openWorkspace(workspaceId)textarea) + “Send” button--vscode-*) andvar(--vscode-font-family)for native feel.5) Webview ↔ extension message protocol
Define explicit message types (keep them JSON-serializable):
Webview → extension
readyrefreshWorkspacesselectWorkspace{ workspaceId }openWorkspace{ workspaceId }sendMessage{ workspaceId, text }Extension → webview
setSelectedWorkspace{ workspaceId: string | null }workspaces{ workspaces: UiWorkspace[] }connectionStatus{ mode: "api"|"file", baseUrl?: string, error?: string }chatEvent{ workspaceId, event: UiChatEvent }chatReset{ workspaceId }(when switching workspaces)Where
UiWorkspaceis a UI-friendly subset:id,label,description,runtimeType,streaming, plus anopenUristring if helpful.6) Workspace selection: “current VS Code folder” auto-detection
To support the workflow “open workspace in VS Code → chat immediately”:
mux.openWorkspaceopens a new window, persist a short-lived "pending auto-select" record incontext.globalState(e.g.{ workspaceId, expectedWorkspaceUri, createdAt }).expectedWorkspaceUriusing the same logic asopenWorkspace()(local/worktree file URI vs SSHvscode-remote://...).onStartupFinished):vscode.workspace.workspaceFolders?.[0]?.uriexpectedWorkspaceUri, callrevealChatView()and immediatelysetSelectedWorkspaceto the pendingworkspaceId, then clear the pending record.vscode.workspace.workspaceFolders?.[0]?.uri.openWorkspace) and auto-select the match.vscode.Uri.file(getWorkspacePath(workspace))vscode.Uri.parse("vscode-remote://ssh-remote+${host}${remotePath}")7) Chat wiring via mux oRPC
Chat requires API mode.
Subscribe (history replay + live events)
eventIteratorstreams from a VS Code extension host (Node fetch streaming). If not, switch the extension client to@orpc/client/websocketagainst${baseUrl}/orpc/wsand add a Node WebSocket implementation dependency.client.workspace.onChat({ workspaceId }, { signal }).AbortControllerper selected workspace; abort on:Send messages
client.workspace.sendMessage({ workspaceId, message: text })ResultSchemaerrors and surface them in the webview.Keep chat “simple”
messagestream-start,stream-delta,stream-end,stream-error8) Failure modes + UX
mux.configureConnectioncommandfile-only:Validation checklist
Alternative approach (B): Two views (tree for workspaces + webview for chat)
Net new product LoC: ~700–1000
Use a
TreeDataProviderfor workspaces (native list + context menu), and a separate webview view for chat.Why I’m not recommending it first
Future enhancements (after MVP)
workspace.onChat).workspace.resumeStream/workspace.interruptStream.sendMessageoptions (imageParts).Generated with
mux• Model:openai:gpt-5.2• Thinking:xhigh