Fix review state render loop#2189
Open
fredluz wants to merge 1 commit into
Open
Conversation
Contributor
|
Reviews (1): Last reviewed commit: "Fix review state render loop" | Re-trigger Greptile |
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.
Problem
The chat panel can hit React error #185 / maximum update depth. While investigating, I found a reproducible render loop in the code review/diff state path:
useCollapseState()was synchronizing derived deferred-path state by calling React state setters during render whendeferredPathschanged by object identity.Closes #2165
Changes
ReviewShell.useCollapseState()with an effect guarded by a semantic deferred-path key.changedFilesacross renders and verifies the hook no longer hits React's re-render limit.Follow-up note
While investigating this, I also noticed a similar render-phase prop/state synchronization smell in
InteractiveFileDiff.tsx. I’m not changing it in this PR because I don’t currently have a focused repro showing it triggers the reported crash, but it may be worth hardening separately.How did you test this?
I couldn’t manually test the exact scenario, but this PR includes a focused regression test that reproduces the React #185-shaped loop on main and verifies the fix.
pnpm lintpnpm --filter code typecheckpnpm --filter code exec vitest run src/renderer/features/code-reviewpnpm --filter code exec vitest run src/main/services/archive/service.integration.test.ts --testTimeout=30000 --reporter=verboseI also ran
pnpm test; the full local suite hit unrelated 5s timeout failures insrc/main/services/archive/service.integration.test.tsunder full-suite load. That same file passes when run directly with a larger timeout, as listed above.Publish to changelog?
do not publish to changelog