Skip to content

Fix review state render loop#2189

Open
fredluz wants to merge 1 commit into
PostHog:mainfrom
fredluz:fix/react-185-chat-crash
Open

Fix review state render loop#2189
fredluz wants to merge 1 commit into
PostHog:mainfrom
fredluz:fix/react-185-chat-crash

Conversation

@fredluz
Copy link
Copy Markdown

@fredluz fredluz commented May 18, 2026

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 when deferredPaths changed by object identity.

Closes #2165

Changes

  • Replace render-phase deferred-path state synchronization in ReviewShell.useCollapseState() with an effect guarded by a semantic deferred-path key.
  • Preserve reveal state when equivalent deferred paths are recreated with new object identity.
  • Add a focused regression test that recreates changedFiles across 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 lint
  • pnpm --filter code typecheck
  • pnpm --filter code exec vitest run src/renderer/features/code-review
  • pnpm --filter code exec vitest run src/main/services/archive/service.integration.test.ts --testTimeout=30000 --reporter=verbose

I also ran pnpm test; the full local suite hit unrelated 5s timeout failures in src/main/services/archive/service.integration.test.ts under 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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 18, 2026

Reviews (1): Last reviewed commit: "Fix review state render loop" | Re-trigger Greptile

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.

Chat crashes with React error 185 (max update depth)

1 participant