Repository navigation
perf(workspace): stop booting and keeping alive inactive project locations - #2281
Merged
Merged
Conversation
…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`.
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Stops
opencode-runefrom booting inactive project locations or immediately re-booting them after server idle eviction (Part of #2267).Each booted project location on the
opencodeserver starts its own file watchers and configured stdio MCP servers. Auditing all location-scoped HTTP/WS paths against the #2267server-1/opencode.logtrace identified five client-side paths that woke or pinned inactive project directories:/automationcapability probe (apps/desktop/src/surfaces/automations/source.rs,crates/opencode-kit/src/client/automations.rs): Opening Automations previously spawned parallelGET /api/command?location[directory]=<dir>requests for everyused_projects()folder, every open tab, and every automation row (matching the 9–11 simultaneous location-boot burst inserver-1/opencode.log). Now probes at most one already-warm location per server (the return tab or the server default""with nolocation[directory]parameter) plus the single currently selected automation's directory.runeclient 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 removedused_projects(),sync_windowstill held a persistentClientMcpWebSocket 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.apps/desktop/src/surfaces/browser/rpc/suppression.rs):maybe_start_capability_probepreviously pickedapp.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).location.shutdownhandling (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 whenlocation.shutdownarrives soAttachMachinebackoff retries do not immediately re-boot evicted locations (returning to the tab or waking it in the background re-attaches viareconcile_sessions).features/files/src/watch.rs):watch::connectedpreviously re-armedPOST /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 inwatch::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 upstreamanomalyco/opencodeserver 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— passedcargo 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)