Skip to content

[Bug]: React #185 infinite loop in ExpandedWorkGroupEntries (deterministic repro at 90%/110% zoom or constrained height) #47121

Done

Description

@CallMeFabioo

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

Related to #45997 (closed as could not reproduce) and #47106 (closed as duplicate of #45997). The bug is still present on main in apps/web/src/components/chat/TimelineWorkGroupRows.tsx (lines 263–274 and 327–331).

Root cause

In ExpandedWorkGroupEntries:

  • maxHeight changes by exactly workGroupOverflowAllowance (48px):
    calc(min(18rem, 50dvh) + ${expandedContentHeight + (fitsWithAllowance ? 48 : 0)}px)
  • The useLayoutEffect (lines 263–274) depends on [fitsWithAllowance, updateScrollFades] and synchronously runs:
    setFitsWithAllowance(overflow <= (fitsWithAllowance ? 0 : 48))

Because the hysteresis threshold delta (48 - 0 = 48) equals the exact maxHeight delta (48px), there is 0px tolerance. Whenever clientHeight(fitsWithAllowance=true) - clientHeight(fitsWithAllowance=false) <= 47, both conditions evaluate to flip state simultaneously inside the same commit chain (true -> false -> true -> ... > 50 times), throwing React error #185.

Why #45997 did not reproduce at 100% zoom (DPR=1)

In Chromium at DPR=1 with an unconstrained parent, clientHeight(true) - clientHeight(false) stays 48. However, it reproduces 100% deterministically in either of these conditions:

  1. Non-100% browser/Electron zoom (90% or 110%, i.e. Ctrl - / Ctrl +) + fractional expandedContentHeight:
    • Every expandedContentHeight ending in 4.5, 9.5, 14.5, 19.5... (which occurs naturally because SimpleWorkEntryRow uses text-sm leading-relaxed -> fractional row heights) snaps physical pixels in Chromium such that:
      • fitsWithAllowance = true (maxHeight = 18rem + 52.5px = 340.5px) -> clientHeight = 340
      • fitsWithAllowance = false (maxHeight = 18rem + 4.5px = 292.5px) -> clientHeight = 293
      • Difference is 47px instead of 48px.
    • With content height 340.6px (scrollHeight = 341):
  2. At 100% zoom (DPR=1) if an ancestor caps height slightly below min(18rem, 50dvh) + 48px (e.g. 330px), giving clientHeight(true) = 330 vs clientHeight(false) = 288 (delta = 42) and scrollHeight = 331 (overflow = 1 vs 43).

Minimal deterministic repro (HTML + React 19 in Chromium at --force-device-scale-factor=1.1 or 0.9)

function Repro() {
  const ref = useRef(null);
  const [fitsWithAllowance, setFitsWithAllowance] = useState(true);
  const expandedContentHeight = 4.5; // fractional height from expanded entries
  const workGroupOverflowAllowance = 48;

  useLayoutEffect(() => {
    const el = ref.current;
    if (!el) return;
    const overflow = el.scrollHeight - el.clientHeight;
    setFitsWithAllowance(overflow <= (fitsWithAllowance ? 0 : workGroupOverflowAllowance));
  }, [fitsWithAllowance]);

  return (
    <div
      ref={ref}
      style={{
        overflowX: "hidden",
        overflowY: "auto",
        scrollbarGutter: "stable",
        width: 500,
        maxHeight: `calc(min(18rem, 50dvh) + ${
          expandedContentHeight + (fitsWithAllowance ? workGroupOverflowAllowance : 0)
        }px)`,
      }}
    >
      <div style={{ height: "340.6px" }} />
    </div>
  );
}

Running the above in Chrome with --force-device-scale-factor=1.1 (or 0.9) against the bundled React 19.3.0 immediately throws Minified React error #185 with the exact same stack frames (Hi -> zi -> _c -> gc -> updateLayout -> useLayoutEffect -> Dl -> yu -> Ru -> yu).

Suggested fix

Add a hysteresis margin (e.g. overflow <= (fitsWithAllowance ? 2 : workGroupOverflowAllowance - 2)), and/or guard against oscillating back to the previous state within the same layout pass (or Math.round(expandedContentHeight) + tolerance). Verified that adding a 1–2px margin (<= (fitsWithAllowance ? 1 : 47)) completely eliminates the crash in the repro above.

Expected behavior

The tool-call list inside ExpandedWorkGroupEntries should settle stably without entering a synchronous useLayoutEffect state loop or crashing the thread timeline.

Actual behavior

The renderer crashes with Minified React error #185 (Maximum update depth exceeded) while viewing an active thread timeline (ReadOnlyThreadTimeline / ExpandedWorkGroupEntries).

Impact

Major degradation or frequent failure

Version or commit

0.1.14-nightly.20261130.5479 (commit 9c5dea3; still present on main)

Environment

Windows (1920x1080, 96 DPI), T3 Code (Nightly) Desktop App 0.1.14-nightly.20261130.5479, Codex (gpt-6.2-sol) on a linked remote environment

Logs or stack traces

T3 Code (Nightly) 0.1.14-nightly.20261130.5479
Path: /<environmentId>/<threadId>
Time: 2026-12-01T23:11:14.125Z

Error: Minified React error #185; visit https://react.dev/errors/185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Hi (t3code://app/assets/client-D7xJT1KA.js:8:28288)
    at zi (t3code://app/assets/client-D7xJT1KA.js:8:27813)
    at _c (t3code://app/assets/client-D7xJT1KA.js:8:60299)
    at gc (t3code://app/assets/client-D7xJT1KA.js:8:59921)
    at t (t3code://app/assets/ReadOnlyThreadTimeline-CPZSJFx6.js:17:28376)
    at F (t3code://app/assets/ReadOnlyThreadTimeline-CPZSJFx6.js:17:28396)
    at Dl (t3code://app/assets/client-D7xJT1KA.js:8:94923)
    at yu (t3code://app/assets/client-D7xJT1KA.js:8:104381)
    at Ru (t3code://app/assets/client-D7xJT1KA.js:8:115603)
    at yu (t3code://app/assets/client-D7xJT1KA.js:8:104368)

Workaround

Reloading the T3 Code window / reopening the thread clears the crash (the background agent run is unaffected). Resetting zoom to 100% (Ctrl + 0) or slightly resizing the window avoids hitting the exact 1px rounding boundary.


Note: This bug report, root-cause investigation, and reproduction code were written by Antigravity (Gemini 4 Neon, High) running inside T3 Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions