Skip to content

perf(rune-mcp): attach client MCP only to active/open folders, not all sidebar projects - #2025

Merged
Hona merged 1 commit into
devfrom
fix/rune-mcp-active-folders-only
Dec 1, 2026
Merged

Hona merged 1 commit into
devfrom
fix/rune-mcp-active-folders-only

Conversation

@Hona

@Hona Hona commented Dec 1, 2026

Copy link
Copy Markdown
Member

Summary

Stops rune_mcp::sync_window from eagerly attaching a rune client MCP WebSocket (GET /api/experimental/client-mcp?location[directory]=…&name=rune) to every sidebar project in used_projects() on launch, and fixes Windows case-only duplicate folder attaches and cross-server tab folder leaks.

Refs #1649

Root cause

  • Every GET /api/experimental/client-mcp?location[directory]=<dir>&name=rune WebSocket forces the local OpenCode server to boot a full project location instance (loading plugins, starting file watchers, and spawning every configured stdio MCP server for that folder).
  • Previously, sync_window added every folder in host.used_projects() to folders, even when no tab, active session, or active draft was open in that folder. With a ~200 MB Node.js stdio MCP server configured and 6 sidebar projects, this booted 7 server locations at launch and spawned 7 separate Node.js MCP processes (~1.38 GB) plus ~423 MB in the Bun server sidecar while OpenCode (Rune) itself used ~58 MB.
  • rune_mcp's call router (match_window) only ever routes calls to open tabs (open_roots) or the active session route (routed_exact / routed_root) and rejects all other sessions with SESSION_NOT_OPEN_ERROR, so attaching to unopened sidebar projects served no routing purpose.
  • In addition, folders and RuneMcpHub::connections keyed directories case-sensitively, so two paths on Windows differing only in letter casing or separator booted duplicate server locations, and tab iteration did not filter tabs to the active server.

Changes

  • features/workspace-tools/src/rune_mcp/mod.rs:
    • Attach rune client MCP only to folders with an active session/draft route or an open tab on the active server (removing for p in host.used_projects()).
    • Deduplicate folders and key RuneMcpHub::connections with Windows case- and separator-insensitive normalization (folder_key) while preserving the raw cleaned directory path on the wire.
    • Scope tab folder collection and open_roots to tabs belonging to active server, and drop unused used_project_ids / projects / used_projects methods from RuneMcpHost and sync_stamp.
  • apps/desktop/src/workspace/lifecycle/rune_mcp.rs:
    • Remove now-unused RuneMcpHost trait method implementations and Project import.

Verification

  • Verified locally on Windows:
    • pwsh scripts/guardrails.ps1 (11/11 passed)
    • cargo check -p opencode-feature-workspace-tools -p opencode-desktop (pass)
    • cargo clippy --no-deps -p opencode-feature-workspace-tools -- -D warnings (pass, 0 warnings)
    • cargo clippy --no-deps -p opencode-desktop (0 warnings in touched files)
  • Not run locally: live desktop GUI window verification or macOS/Linux builds (covered by CI).

Copilot AI balanced review requested due to automatic review settings December 1, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Hona
Hona merged commit c59f2b3 into dev Dec 1, 2026
8 checks passed
@Hona
Hona deleted the fix/rune-mcp-active-folders-only branch December 1, 2026 14:29
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.

2 participants