🤖 feat: VS Code extension prefers oRPC with fallback #1269
+631
−36
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.
This updates the VS Code extension to prefer a locally running mux server (localhost oRPC) for listing workspaces.
If it can't connect, it prompts the user to either fix connection config or fall back to direct local-file reads.
Adds:
mux: Configure Connectioncommandmux.connectionModeandmux.serverUrlValidation:
bun run --cwd vscode compilemake typecheckmake static-check📋 Implementation Plan
🤖 Plan: VS Code extension → oRPC-first with safe local-file fallback
Goal
Make the VS Code extension prefer talking to a locally running mux instance over localhost + oRPC instead of reading mux’s config/session files directly. If the extension cannot connect, it should:
Net new product code: ~+250 LoC (recommended approach).
What exists today (repo facts)
vscode/src/extension.tsregistersmux.openWorkspace.vscode/src/muxConfig.ts→new Config().getAllWorkspaceMetadata()(reads~/.mux/config.jsonetc)vscode/src/muxConfig.ts→readExtensionMetadata()(reads~/.mux/extensionMetadata.json)POST {baseUrl}/orpc{baseUrl}/orpc/wsGET {baseUrl}/healthMUX_SERVER_URL,MUX_SERVER_AUTH_TOKEN~/.mux/server.lockviasrc/node/services/serverLockfile.tsworkspace.list -> FrontendWorkspaceMetadata[]workspace.activity.list -> Record<workspaceId, WorkspaceActivitySnapshot>(recency/streaming/lastModel)Recommended approach (oRPC-first + guided fallback)
High-level behavior
mux.openWorkspace, try to create an oRPC client using server discovery (settings/env/lockfile/default).workspace.list()for metadataworkspace.activity.list()for recency/streamingConfiguration storage (per your answers)
mux.connectionMode:"auto" | "server-only" | "file-only"(default:"auto")mux.serverUrl: optional string (overrides discovery)mux.serverAuthTokenDiscovery precedence
Base URL:
mux.serverUrl(if set)process.env.MUX_SERVER_URL~/.mux/server.lock(ServerLockfile.read())http://localhost:3000Auth token:
mux.serverAuthTokenprocess.env.MUX_SERVER_AUTH_TOKENConnection test (fast + classified)
GET {baseUrl}/healthwith a short timeout (e.g. 750–1000ms)orpc.general.ping("vscode")(also timeout)Implementation steps (files + concrete changes)
1) Add connection + client utilities
New:
vscode/src/orpc/client.tscreateVscodeOrpcClient({ baseUrl, authToken }): ORPCClientRPCLinkfrom@orpc/client/fetchand injectAuthorization: Bearer <token>.baseUrlshape.New:
vscode/src/orpc/discovery.tsdiscoverServerConfig(): Promise<{ baseUrl: string; authToken?: string; source: ... }>New:
vscode/src/orpc/connectionCheck.tscheckServerReachable(baseUrl): Promise<"ok" | "unreachable">checkAuth(client): Promise<"ok" | "unauthorized" | "error">AbortController.2) Wire “oRPC workspace list” into the extension
Edit:
vscode/src/muxConfig.tsgetAllWorkspacesFromFiles()(keep current disk behavior)getAllWorkspacesFromOrpc():client.workspace.list()client.workspace.activity.list()ExtensionMetadatashapegetAllWorkspaces()becomes a mode switch:file-only→ alwaysgetAllWorkspacesFromFiles()server-only→ error if cannot connectauto→ prefer orpc; on failure show prompt; obey session choice3) Add UX for “fix config vs file access”
Edit:
vscode/src/extension.tslet sessionPreferredMode: "orpc" | "file" | null = null;let didShowFallbackPrompt = false;auto:showWarningMessagewith actions:4) Add a command to fix config
Edit:
vscode/src/extension.ts+vscode/package.jsonmux.configureConnection5) Add VS Code settings contributions
Edit:
vscode/package.jsoncontributes.configurationsection:mux.connectionMode(enum)mux.serverUrl(string)Validation plan
bun run -C vscode compilemake typecheckmux.connectionMode=file-only: never attempts network.mux.connectionMode=server-only: fails fast with actionable error.Alternatives considered
A) Server-side change: include activity in
workspace.listincludeActivityparam so VS Code makes a single RPC call.B) Don’t add VS Code settings
Generated with
mux• Model:openai:gpt-5.2• Thinking:xhigh