feat(workspace): spawn per-project workspace host processes#4647
Merged
gregpriday merged 5 commits intodevelopfrom Mar 30, 2026
Merged
feat(workspace): spawn per-project workspace host processes#4647gregpriday merged 5 commits intodevelopfrom
gregpriday merged 5 commits intodevelopfrom
Conversation
- Extract WorkspaceHostProcess class for per-host lifecycle management - Rewrite WorkspaceClient as multi-process manager with Map<path, ProcessEntry> - Add refcounting with 5s grace period cleanup on zero-refcount - Route getAllStatesAsync by windowId to correct per-project host - Remove scope guards from WorkspaceService (now per-process isolated) - Update IPC handlers to pass windowId for per-project routing - Rewrite resilience tests for new multi-process architecture
- Fix poisoned entry on init failure: clean up failed entries and retry - Replace blind first-available fallback with worktree path reverse map - Only fall back to single-host case to avoid cross-project routing - Propagate real errors from deleteWorktree instead of swallowing - Skip WORKTREE_ACTIVATED emission when all hosts reject setActive - Add tests for worktree path routing and setActive rejection
- Remove unused worktree-removed no-op loop (TS6133) - Change let to const for workspaceReady (prefer-const)
- Fix useless assignment warning by renaming entry variables - Suppress no-explicit-any in test file and pendingRequests type - All checks pass: typecheck, lint ratchet (402, -1 from baseline), format
- CI test failure: worktree.rateLimit.test.ts missing BrowserWindow in electron mock - Handlers now use BrowserWindow.fromWebContents for windowId routing
64fa271 to
949918a
Compare
Collaborator
Author
|
The old workspace host's events leaked into the new project during the 5-second grace period. Scope filtering was needed on the transition boundary. Fixed in #4670. Regression audit for training data. |
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
WorkspaceServiceutility process with one process per active project, eliminating cross-project state contamination at the OS levelWorkspaceHostProcessto manage the lifecycle of per-project workspace hosts (spawn, health-check, restart on crash, teardown)WorkspaceClientfrom a message router with 16 guard mechanisms into a clean process lifecycle manager — the renderer IPC contract is unchangedResolves #4642
Changes
electron/services/WorkspaceHostProcess.ts— new class managing a single workspace utility process with MessagePort-based IPC, heartbeat monitoring, and restart backoffelectron/services/WorkspaceClient.ts— rewritten to maintain aMap<projectPath, WorkspaceHostProcess>with ref-counting for windows sharing a project; all thewindowScopes/generation-counter guard layers removedelectron/workspace-host/WorkspaceService.ts— removed per-scope filtering code; service now owns exactly one projectelectron/window/windowServices.ts— updated to callWorkspaceClient.attachWindow/detachWindowon project open/closeelectron/ipc/handlers/worktree.ts,copyTree.ts,artifacts.ts— minor updates to route through the new per-project client APIelectron/__tests__/WorkspaceClient.resilience.test.ts— test suite updated to cover per-project process lifecycle, crash recovery, and ref-countingTesting
npm run check)