CRITICAL: Fix runaway CPU usage and React render loop on project workspace pages#100
Open
SmallSpider0 wants to merge 1 commit into
Open
CRITICAL: Fix runaway CPU usage and React render loop on project workspace pages#100SmallSpider0 wants to merge 1 commit into
SmallSpider0 wants to merge 1 commit into
Conversation
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
This PR fixes a severe production-impacting performance bug where opening an idle project workspace page, such as
/projects/004, could continuously consume more than one full CPU core.The issue was severe because a normal idle web page could keep browser CPU usage around 120%+ on user hardware and over 200% in automated profiling, causing laptop overheating and making the workspace unsafe to leave open.
Severity
Critical / High severity
Before this fix, simply opening an idle project page could cause sustained high CPU usage:
This is not expected behavior for an idle research workspace page.
Root Cause
The CPU issue had multiple contributing causes:
Runaway React render/update loop in the Copilot dock
CopilotDockCallbacksContext.Providerrecreated a new context value object on every render.QuestCopilotDockPanelhad effects depending on that context object.onHeaderExtraChange,onMetaChange, and related setters repeatedly.Maximum update depth exceededwarnings.Idle copilot workspaces were incorrectly treated as live/running
004hadactive_run_id: nulland was inwait_for_user_or_resume.bash_running_count.Bash operation cards performed unstable state propagation
QuestBashExecOperationparsed structured args/output on every render, creating fresh objects.McpBashExecViewalso reported unchanged live state back to the parent.Bash session stream updates were not sufficiently deduplicated
Idle decorative workspace animations added avoidable GPU/renderer work
Fix
This PR:
workspace_mode === "copilot"continuation_policy === "wait_for_user_or_resume"active_run_idis absentQuestBashExecOperationby:McpBashExecViewby:onLiveStateChangeemissionsCPU Usage Report
Before Fix
Initial production/dev reproduction showed sustained runaway CPU:
Additional root-cause probe:
Maximum update depth exceeded168warnings in a 10s sampling windowAfter Fix
Final deployed live measurement:
Final verification:
[]0/ui/assets/index-qDSXrMaL.jsTesting
Passed: