Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

ClosedCallMeFabioo(GitHub profile, opens in a new tab) opened this issue 1 comment

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):
      • true: overflow = 341 - 340 = 1 <= 0 (false) -> setFitsWithAllowance(false)
      • false: overflow = 341 - 293 = 48 <= 48 (true) -> setFitsWithAllowance(true)
      • Synchronous infinite loop -> React Error #185.
  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 9c5dea3b06f0; 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.

  1. tanstack-source added labelsbug

  2. juliusmarminge closed this

  3. New reproduction from a Linux desktop, same stack and same component. 2026-12-02.

    Environment

    • T3 Code (Beta) desktop app, version 0.1.13, launched as a systemd user service. Custom build based on upstream main at 53bc5b5d17 (between v0.1.13 and 0.1.14-nightly.20261130.5479), plus one local UI patch that auto-expands the latest reasoning and in-progress shell commands in the running turn, so expandedContentHeight is non-zero without the reader expanding anything by hand.
    • Fedora 44, KDE Plasma on Wayland, display scale 100% (KWin Scale=1).
    • The thread was shown in the read-only timeline (the linked/side-thread pane), local environment.

    What happened

    • At 2026-12-02T00:40:18.929Z the renderer crashed with Minified React error #185 while an agent run was actively streaming in that thread (run started 00:38:50Z, completed 00:41:07Z; the thread had 22 command executions and 64 reasoning items).
    • The stack matches the one in the report frame for frame; the two app frames in the ReadOnlyThreadTimeline chunk are the fitsWithAllowance layout effect in ExpandedWorkGroupEntries:
        at Hi (t3code://app/assets/client-Cz7HgKLm.js:8:28288)
        at zi (t3code://app/assets/client-Cz7HgKLm.js:8:27813)
        at _c (t3code://app/assets/client-Cz7HgKLm.js:8:60299)
        at gc (t3code://app/assets/client-Cz7HgKLm.js:8:59921)
        at t (t3code://app/assets/ReadOnlyThreadTimeline-CQNEbm9l.js:17:28968)
        at L (t3code://app/assets/ReadOnlyThreadTimeline-CQNEbm9l.js:17:28988)
        at Dl (t3code://app/assets/client-Cz7HgKLm.js:8:94923)
        at yu (t3code://app/assets/client-Cz7HgKLm.js:8:104381)
        at yu (t3code://app/assets/client-Cz7HgKLm.js:8:104368)
    • With display scale at 100% this is presumably the constrained-height variant (the read-only pane caps the container just under the min(18rem, 50dvh) + 48px band) rather than the fractional-zoom one.
    • "Retry" reloaded the renderer and it recovered; the background run was unaffected and completed normally.

    Happy to verify the suggested 1–2px hysteresis margin once it lands on main.

    This comment was drafted with Qwen 3.8 27B running in OpenCode (T3 triage session).

Sign in to join this conversation.