feat(resource-profile): introduce adaptive resource profiles for system-wide scaling#4629
Merged
gregpriday merged 4 commits intodevelopfrom Mar 30, 2026
Merged
Conversation
added 4 commits
March 30, 2026 06:36
…em-wide scaling - Add ResourceProfileService with hysteresis-based profile transitions (Performance/Balanced/Efficiency) - Add shared ResourceProfile types and per-profile configuration constants - Add set-resource-profile PtyHostRequest type and pty-host handler for ProcessTreeCache adjustment - Add update-monitor-config WorkspaceHostRequest type and handler for live polling interval changes - Add setPollInterval method to ProcessTreeCache for runtime interval adjustment - Add setMemoryPressureThresholdMs setter to HibernationService for profile-based threshold injection - Add setResourceProfile method to PtyClient and updateMonitorConfig method to WorkspaceClient - Convert TerminalWebGLManager.MAX_CONTEXTS from static readonly to getter/setter pattern - Add RESOURCE_PROFILE_CHANGED IPC channel with preload bridge and ElectronAPI type - Add useResourceProfile hook wired into App component for renderer-side WebGL budget adjustment - Wire ResourceProfileService lifecycle into windowServices.ts with lazy dep injection - Add comprehensive test suite (11 tests) covering hysteresis, warmup, oscillation prevention, and null deps
- Fix worktree count signal to use actual worktree count via WorkspaceClient.getAllStatesAsync instead of project count - Move disposed check before state mutation in applyProfile to prevent stale state on post-disposal calls - Add lower-bound validation (Math.max(1, n)) to TerminalWebGLManager.setMaxContexts - Remove getWorktreeCount dep in favor of cached count with async refresh on each eval tick
- Add RESOURCE_PROFILE_CHANGED to inlined CHANNELS in preload.cts - Replace any types with ResourceProfilePayload in preload bridge - Remove unused logWarn import from ResourceProfileService - Fix powerMonitor.isOnBatteryPower to be called as function - Add ResourceProfile type assertion in pty-host message handler
…k types - Use typed Mock interfaces for mock deps instead of any casts - Use vi.Mock type for module-level mock references - Use as unknown as Type pattern for mock-to-interface casts
35233d6 to
31e35c1
Compare
gregpriday
added a commit
that referenced
this pull request
Apr 8, 2026
…adaptive-resource-2 feat(resource-profile): introduce adaptive resource profiles for system-wide scaling
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
ResourceProfileService— a central coordinator in the main process that monitors memory pressure, event loop lag, battery state, and worktree count, then selects one of three profiles: Performance, Balanced, or Efficiency.Resolves #4324
Changes
electron/services/ResourceProfileService.ts— new service: profile evaluation, transition logic, hysteresis timers, IPC broadcastshared/types/resourceProfile.ts—ResourceProfileenum,ResourceProfileConfigtype with all tunable parameterselectron/window/windowServices.ts— initializes and wiresResourceProfileServiceinto the main process lifecycleelectron/pty-host.ts/electron/workspace-host.ts— subscribe to profile updates and propagate config toResourceGovernorandWorkspaceServiceelectron/services/HibernationService.ts,ProcessTreeCache.ts— accept dynamic config overrides from the active profilesrc/hooks/useResourceProfile.ts— renderer hook for consuming the current profilesrc/services/terminal/TerminalWebGLManager.ts— respects WebGL context budget from active profileelectron/services/__tests__/ResourceProfileService.test.ts— 294-line unit test suite covering profile evaluation, hysteresis, and IPC dispatchTesting
npm run checkpasses clean with no errors.