Skip to content

perf(workspace): stop booting and keeping alive inactive project locations - #2281

Merged
Hona merged 1 commit into
devfrom
fix/inactive-location-boots
Dec 3, 2026
Merged

Hona merged 1 commit into
devfrom
fix/inactive-location-boots

Conversation

@Hona

@Hona Hona commented Dec 3, 2026

Copy link
Copy Markdown
Member

Summary

Stops opencode-rune from booting inactive project locations or immediately re-booting them after server idle eviction (Part of #2267).

Each booted project location on the opencode server starts its own file watchers and configured stdio MCP servers. Auditing all location-scoped HTTP/WS paths against the #2267 server-1/opencode.log trace identified five client-side paths that woke or pinned inactive project directories:

  • Automations /automation capability probe (apps/desktop/src/surfaces/automations/source.rs, crates/opencode-kit/src/client/automations.rs): Opening Automations previously spawned parallel GET /api/command?location[directory]=<dir> requests for every used_projects() folder, every open tab, and every automation row (matching the 9–11 simultaneous location-boot burst in server-1/opencode.log). Now probes at most one already-warm location per server (the return tab or the server default "" with no location[directory] parameter) plus the single currently selected automation's directory.
  • Idle background tabs in rune client MCP (features/workspace-tools/src/rune_mcp/mod.rs, apps/desktop/src/workspace/lifecycle/rune_mcp.rs): Even after perf(rune-mcp): attach client MCP only to active/open folders, not all sidebar projects #2025 removed used_projects(), sync_window still held a persistent ClientMcp WebSocket for every open tab. Now attaches only to the active routed session/draft and actively busy background tabs (family_busy), detaching idle background tabs so they do not boot at launch or re-boot via WebSocket reconnect after eviction.
  • Browser RPC capability probe (apps/desktop/src/surfaces/browser/rpc/suppression.rs): maybe_start_capability_probe previously picked app.projects.first(), booting an unrelated unopened project for a server-wide capability check. Now probes the server's already-booted default directory (or active draft directory).
  • Browser RPC location.shutdown handling (apps/desktop/src/surfaces/browser/rpc/comes_back.rs, apps/desktop/src/surfaces/browser/rpc/mod.rs, apps/desktop/src/session/events/mod.rs): Disposes idle, off-screen attachments with no active commands when location.shutdown arrives so AttachMachine backoff retries do not immediately re-boot evicted locations (returning to the tab or waking it in the background re-attaches via reconcile_sessions).
  • File watches on connect/reconnect (features/files/src/watch.rs): watch::connected previously re-armed POST /api/experimental/fs/watch?location[directory]=... for every restored session's open file tabs. Now re-arms only the active session on connect/reconnect and re-arms off-screen sessions lazily in watch::shown.

Scope note

This addresses all client-side inactive-directory boots and keep-alives in opencode-rune, leaving #2267 open for macOS verification and the upstream anomalyco/opencode server behavior (spawning separate copies of global stdio MCP servers per booted location and reaping child processes on location eviction).

Verification

  • cargo check -j 1 -p opencode-desktop — passed
  • cargo clippy -j 1 -p opencode-kit -p opencode-feature-workspace-tools -p opencode-feature-files -p opencode-desktop --no-deps — passed (0 warnings in touched files)
  • pwsh scripts/guardrails.ps1 — passed (11/11)
  • Not tested interactively on macOS/Linux hardware (cross-platform builds verified via GitHub CI).

…tions

Audit and fix client-side code paths that booted cold project locations or
prevented/undid server idle location eviction (Refs #2267):

- Automations (`surfaces/automations/source.rs`, `opencode-kit/client/automations.rs`):
  stop firing parallel `GET /api/command?location[directory]=...` requests for
  every `used_projects()`, open tab, and automation row when Automations opens;
  probe at most one already-warm location (return tab or server default `""`)
  plus the single selected automation entry's directory.
- `rune` client MCP (`features/workspace-tools/src/rune_mcp/mod.rs`,
  `workspace/lifecycle/rune_mcp.rs`): attach `ClientMcp` WebSockets only to the
  active routed session/draft and actively busy open tabs (`family_busy`), not
  idle background tabs whose WebSockets boot locations at launch and re-boot
  evicted locations on reconnect.
- Browser RPC (`surfaces/browser/rpc/{suppression,comes_back,mod}.rs`,
  `session/events/mod.rs`): probe server-wide capability against the already-
  booted server default/draft directory instead of `app.projects.first()`, and
  dispose idle off-screen attachments on `location.shutdown` so backoff retries
  do not re-boot evicted locations.
- File watches (`features/files/src/watch.rs`): on connect/reconnect, re-arm
  `POST /api/experimental/fs/watch` only for the active session's open file
  tabs and defer off-screen sessions to `watch::shown`.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 10:29

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 fba4e73 into dev Dec 3, 2026
8 checks passed
@Hona
Hona deleted the fix/inactive-location-boots branch December 3, 2026 10:30
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