feat(activity): use process CPU metrics to prevent premature idle transitions#4560
Merged
gregpriday merged 2 commits intodevelopfrom Mar 29, 2026
Merged
Conversation
added 2 commits
March 29, 2026 14:18
…nsitions - Extend ProcessStateValidator interface with getDescendantsCpuUsage() - Add CPU hysteresis tracking (10% enter, 3% exit) to ActivityMonitor - Guard isWorkingSilenceTimeout, prompt fast-path, lexeme fallback, isQuietForIdle, and debounce idle paths - Implement getDescendantsCpuUsage in createProcessStateValidator - Add 10 new tests covering CPU idle prevention, hysteresis, completion passthrough, and error handling
- Add verbose logging to getCpuUsageSafe() for consistency with hasActiveChildrenSafe() - Fix vacuous assertion in cpu-10 dispose test
58487a7 to
0920623
Compare
gregpriday
added a commit
that referenced
this pull request
Apr 8, 2026
…s-cpu-metrics feat(activity): use process CPU metrics to prevent premature idle transitions
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
ProcessStateValidatorinterface withisCpuBusy()to expose process-level CPU activity alongside the existinghasActiveChildren()checkActivityMonitornow uses CPU busyness to prevent theCompletionTimerfrom firing idle transitions when the process tree is still consuming CPU, reducing false "idle" calls during silent processing phasesHIGH_CPU_THRESHOLD_PERCENTconstant (10%) and aCpuBusyTrackerhelper that integrates with the existingWorkingSignalDebouncerpatternResolves #4151
Changes
electron/services/ActivityMonitor.ts— addedisCpuBusy()toProcessStateValidator,CpuBusyTrackerclass, CPU-aware guard inCompletionTimer, and wired CPU signal into confidence scoringelectron/services/pty/terminalActivityPatterns.ts— exportedHIGH_CPU_THRESHOLD_PERCENTconstantelectron/services/__tests__/ActivityMonitor.test.ts— comprehensive test coverage for CPU signal integration: silent high-CPU suppression, near-zero CPU acceleration, graceful degradation when data is unavailableTesting
Full unit test suite passes. CPU signal tests cover all four quadrants (high/low CPU × with/without output), threshold boundary cases, and graceful degradation when
isCpuBusyis not provided by the validator.