Skip to content

[FEATURE]:Add toggle to disable editor context auto-attachment for multi-window isolation #24270

@xiangkehan

Description

@xiangkehan

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem:
The Editor Context Protocol automatically attaches the current editor file/selection to every prompt via WebSocket. This works well for a single opencode window, but breaks se
ssion isolation when running multiple opencode windows in parallel
.

Concrete scenario:
I often run 2–3 opencode TUI windows side-by-side for different tasks:

  • Window A: working on backend/api.ts
  • Window B: working on frontend/page.tsx
  • Window C: working on docs/README.md

Since all windows connect to the same VS Code instance via WebSocket, every window receives the same editor context (the file currently focused in VS Code). This means:

  • Window A's prompts get polluted with frontend/page.tsx context when I'm actually asking about the backend
  • Window B's prompts get polluted with backend/api.ts context when I'm working on the frontend
  • The session context is no longer isolated per window

Root cause:
There is no way to disable editor context auto-attachment per window. The only workaround is uninstalling the VS Code extension entirely, which also breaks @mention file autoc
omplete.

Proposed solution:
Add a per-window toggle command in the TUI command palette (Ctrl+K) to enable/disable editor context auto-attachment. The state should be persisted in the local KV store (kv. json) per workspace/session.

Expected behavior:

  • When enabled (default): current behavior — blue file label shows, selection auto-attached
  • When disabled: no editor context injected, but WebSocket stays alive for @mention autocomplete
  • Each opencode window has its own toggle state

Benefits:

  1. Restores session isolation for multi-window workflows
  2. Prevents token waste from irrelevant file context
  3. Keeps editor integration alive for manual @mention when needed
  4. Small, focused change with minimal surface area

Scope:

  • packages/opencode/src/cli/cmd/tui/context/editor.ts
  • packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
  • Unit tests

I am willing to implement and submit a PR if the core team approves.

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions