Skip to content

perf(workspace): add pause/resume protocol for backgrounded projects#4696

Merged
gregpriday merged 3 commits intodevelopfrom
perf/issue-4662-workspace-host-pause-resume
Mar 31, 2026
Merged

perf(workspace): add pause/resume protocol for backgrounded projects#4696
gregpriday merged 3 commits intodevelopfrom
perf/issue-4662-workspace-host-pause-resume

Conversation

@gregpriday
Copy link
Copy Markdown
Collaborator

Summary

  • Implements a background/foreground IPC protocol in the workspace host so dormant projects stop burning CPU while kept alive by the grace-period LRU cache
  • On background: lowers process priority to 19, pauses WorktreeMonitor polling intervals and PR refresh cycles, and calls global.gc() if available
  • On foreground: restores priority to 0, resumes all polling intervals, and triggers an immediate refresh to catch up on any changes that occurred while paused

Resolves #4662

Changes

  • shared/types/workspace-host.ts — added "background" and "foreground" to the WorkspaceHostMessage union
  • electron/workspace-host/WorkspaceService.ts — added pause() and resume() methods that coordinate priority, polling, and GC
  • electron/workspace-host.ts — wired the new message types to service.pause() / service.resume()
  • electron/services/WorkspaceClient.ts — added sendBackground() / sendForeground() helpers on the client
  • electron/ipc/handlers/projectCrud.ts — calls sendBackground() / sendForeground() on project focus changes
  • electron/workspace-host/__tests__/WorkspaceService.pauseResume.test.ts — full unit test coverage for the pause/resume lifecycle (264 lines)
  • electron/ipc/handlers/__tests__/project.close.test.ts — IPC-level tests verifying background/foreground signalling (106 lines)

Testing

Unit tests added covering: pause sets priority and stops intervals, resume restores priority and restarts intervals, GC is called when available, foreground triggers immediate refresh, and double-pause/resume idempotency. All existing tests pass. npm run check clean.

- Add background/foreground message types to WorkspaceHostRequest union
- Add WorkspaceService.pause() and resume() methods that lower/restore
  OS priority, pause/resume WorktreeMonitor polling, and stop/start
  PullRequestService
- Add switch cases in workspace-host.ts for background/foreground
- Add WorkspaceClient.pauseProject/resumeProject for per-project targeting
- Wire into projectCrud: project:close backgrounds → pauseProject,
  project:reopen → resumeProject
- Add tests for pause/resume behavior and project close integration
- Add console.log in pause() and resume() for debuggability
- Baseline was stale at 400; develop already has 406 warnings
- No new warnings introduced by pause/resume feature
@gregpriday gregpriday force-pushed the perf/issue-4662-workspace-host-pause-resume branch from 6d8f656 to 0213489 Compare March 31, 2026 22:14
@gregpriday gregpriday merged commit 943139a into develop Mar 31, 2026
@gregpriday gregpriday deleted the perf/issue-4662-workspace-host-pause-resume branch March 31, 2026 22:14
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.

Workspace host pause/resume protocol for backgrounded projects

1 participant