Skip to content

fix: prevent infinite re-render loop in InstallDialog#13

Merged
RealZST merged 1 commit intomainfrom
fix/marketplace-infinite-loop
Apr 13, 2026
Merged

fix: prevent infinite re-render loop in InstallDialog#13
RealZST merged 1 commit intomainfrom
fix/marketplace-infinite-loop

Conversation

@RealZST
Copy link
Copy Markdown
Owner

@RealZST RealZST commented Apr 13, 2026

Summary

  • Fixed infinite re-render loop in InstallDialog that caused the Marketplace page to freeze when exactly one agent is detected
  • Changed useEffect dependency from [detectedAgents] (unstable array reference) to [detectedAgents.length] (stable number)

Root Cause

detectedAgents is recomputed via filter() + sortAgents() every render, producing a new array reference. When length === 1, the effect calls setSelectedAgents(new Set([...])), creating a new Set reference, triggering a re-render, which creates a new detectedAgents reference, which re-triggers the effect — infinite loop.

Test plan

  • Temporarily changed condition to match local agent count (=== 6), confirmed the fix prevents the freeze
  • Reverted condition to === 1, verified normal Marketplace navigation still works
  • Clicked "Install from Git" dialog, confirmed it opens and functions correctly
  • All existing tests pass (npm test — 84 passed)

Closes #2

🤖 Generated with Claude Code

…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>
@RealZST RealZST merged commit 2b20484 into main Apr 13, 2026
3 checks passed
@RealZST RealZST deleted the fix/marketplace-infinite-loop branch April 13, 2026 20:31
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.

Clicking other tabs becomes unresponsive after navigating to Marketplace tab

1 participant