fix: prevent infinite re-render loop in InstallDialog#13
Merged
Conversation
…nt detected The useEffect that auto-selects the only detected agent depended on `detectedAgents`, a new array reference every render. This caused an infinite loop: effect → setState(new Set) → re-render → effect → ... Changing the dependency to `detectedAgents.length` (a stable number) breaks the cycle. Closes #2 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
InstallDialogthat caused the Marketplace page to freeze when exactly one agent is detecteduseEffectdependency from[detectedAgents](unstable array reference) to[detectedAgents.length](stable number)Root Cause
detectedAgentsis recomputed viafilter()+sortAgents()every render, producing a new array reference. Whenlength === 1, the effect callssetSelectedAgents(new Set([...])), creating a new Set reference, triggering a re-render, which creates a newdetectedAgentsreference, which re-triggers the effect — infinite loop.Test plan
=== 6), confirmed the fix prevents the freeze=== 1, verified normal Marketplace navigation still worksnpm test— 84 passed)Closes #2
🤖 Generated with Claude Code