openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Renderer enters a sustained update loop (React #185) while a tool call's arguments stream: mascot and composer are bystanders

Open M3gA-Mind opened this issue 2 months ago • 11 comments

Summary

Driving the chat composer with synthetic input events crashes the renderer.

Problem

Programmatic typing into the composer (the technique used for automated UI testing and for agent-driven interaction with the app) takes down the renderer. This blocks automated end-to-end testing of the chat surface entirely — the composer is the entry point to almost every user flow, so nothing downstream of it can be exercised.

Solution (optional)

Likely related to the contenteditable/Lexical input path. Note app/patches/@[email protected] — the package is locally patched, so behaviour diverges from stock.

Acceptance criteria

  • [ ] Repro gone — synthetic input into the composer does not crash the renderer.
  • [ ] Regression safety — an automated test drives the composer programmatically.

Discovered 2026-09-22 during a fleet bug hunt against upstream/main @ 7b8f25096. Not re-verified against current main — if a later commit already fixed this, close it with the SHA.

M3gA-Mind avatar Sep 22 '26 21:09 M3gA-Mind

Programmatic input into the composer crashes the renderer, blocking automated end-to-end testing.

Labelled priority: p1.

tinysweeper avatar Sep 22 '26 21:09 tinysweeper

Reproduced live in a browser, 2026-09-23. This is not just a testing-infrastructure concern — it took the app down on the first attempt at driving the composer.

Environment: Playwright web lane (app/dist-web served at 127.0.0.1:4273, core on 17888), bundle built from upstream/main 0f1ecc9d2 plus PRs #6466/#6467/#6468, Chrome, /#/chat on an empty thread.

Actions: clicked the composer, then typed a fenced code block using shift+Return for newlines:

```ts            <- typed
shift+Return
const x = 1;     <- typed
shift+Return
```              <- typed
shift+Return
$$\frac{a}{b}$$ and $10 vs $20   <- typed

Result: the renderer crashed to the error boundary — "Something went wrong / An unexpected error occurred". Error ID 11d9bca978b742c1b2edb8f66a04e131.

Console:

Error: Minified React error #185; visit https://react.dev/errors/185 ...
    at $r (index-Bil1lnOS.js:8:27492)
    at Xr (index-Bil1lnOS.js:8:27017)
    at ns (index-Bil1lnOS.js:8:58756)
    at ts (index-Bil1lnOS.js:8:58377)
    at    (index-Bil1lnOS.js:961:23655)
    at qs (index-Bil1lnOS.js:8:92123)

React #185 is "Maximum update depth exceeded" — a setState loop, consistent with the composer re-entering its own sync on each input event.

What is NOT established — stated plainly so nobody over-reads this. I did not narrow which action triggers it. Two follow-up attempts were void and I am discarding both rather than reporting them:

  1. Navigating to http://127.0.0.1:4273/#/chat while already on that hash route is a no-op in a SPA — React never remounted, the error boundary persisted, and the identical error ID gave it away. Anything typed after that went nowhere.
  2. After a genuine location.reload(), my click missed the composer (the layout shifts once a thread has content), so the text was never entered.

So the open question is whether plain typed text is sufficient, or whether the backticks, the shift+Return, or the length are required. A one-line minimal repro would make this immediately actionable.

Unrelated console noise in the same session, recorded so it is not mistaken for a cause: [useDaemonHealth] Failed to probe agent status: Error: Not running in Tauri ×3, ~90 seconds before the crash. That is expected in web mode (isTauri() is false there) and is not connected.

Impact confirmed: this blocked the first attempt at browser-driven verification of three unrelated UI PRs. Any automated or agent-driven flow that reaches the app through the composer — which is the entry point to nearly every user flow — hits this first.

M3gA-Mind avatar Sep 22 '26 22:09 M3gA-Mind

Narrowing update, from a second operator on the same running app.

Plain single-line typing does NOT trigger it. Clicking the composer, typing please render the sample as ordinary single-line text, and pressing Return sends and renders normally — no React #185, no error boundary.

So the trigger is not typing per se. It is one of the things my earlier repro added:

  • shift+Return (soft newline in the composer), and/or
  • the backtick fence characters, and/or
  • multi-line content length

My sequence used all three, which is why it crashed and why I could not attribute it. This narrows the search to the soft-newline / multi-line path rather than input handling generally.

Practical consequence for anyone automating the app: a single-line prompt typed into [data-testid=chat-message-input] is safe today. Driving multi-line or fenced content through the composer is what breaks.

Worth noting for whoever picks this up — a workaround exists for producing rich assistant markdown without touching the crash: configure the mock to emit the markup (an llmKeywordRules behaviour) so the typed input stays trivial while the rendered assistant content is genuine. That is how the markdown/LaTeX verification was completed despite this bug.

M3gA-Mind avatar Sep 22 '26 22:09 M3gA-Mind

Second independent occurrence, and it casts doubt on this issue's framing — including its title. Whoever picks this up should not assume the composer.

Occurrence 2, different operator, different bundle: React error #185, error ID 21c190bb442d49cfab80ca50489dac48, fired during a turn (not on load, not on input). The input was plain single-line text — no shift+Return, no backticks, no multi-line content.

That does not match the behaviour this issue describes.

Isolation attempts, all negative. After the crash, the same operator ran: text only → no crash; reasoning only → no crash; one tool call → no crash; three consecutive tool calls → no crash; reasoning + three tool calls (the exact crashing shape) → no crash; and finally a reload → new thread → immediate send, reproducing the original conditions exactly → no crash. One occurrence in roughly ten turns, not reproduced.

Both occurrences are React #185 — "Maximum update depth exceeded" — which is a RENDER LOOP, not an input-handling fault. Taken together with the fact that plain typing sent cleanly in every one of ~10 turns across two different bundles, the "crashes when text is typed programmatically" description may simply be wrong. Occurrence 1 (this issue's original report) involved a fenced block and shift+Return, but that may have been coincidental to what was actually rendering at the time rather than causal.

A more likely hypothesis, offered as a hypothesis: the trigger is in turn RENDERING — something about the sequence or timing of parts arriving during a turn — and the composer is a bystander. That would explain why it is intermittent, why it fires mid-turn, and why deliberate attempts to reproduce by typing fail.

Practical consequence: anyone starting from the title will go looking at the composer / Lexical input path, which on this evidence is probably the wrong place. The title likely needs revising once someone reproduces it reliably — I am not renaming it on two unreproduced observations, since that would replace one unproven framing with another.

What would actually settle it: catching #185 with a non-minified build so the component stack is readable. Both occurrences give only the minified frame (at $r / at Xr / at ns). A dev-mode reproduction naming the looping component would turn this from speculation into a fix.

Recorded because both sightings are real and the intermittency means the next person may otherwise spend the time re-deriving what is already known.

M3gA-Mind avatar Sep 22 '26 23:09 M3gA-Mind

Consolidated repro and current evidence

Retitled. The original title — "crashes when text is typed programmatically" — is contradicted by the evidence below and was sending readers to the composer / Lexical input path, which is probably the wrong place. Both sightings are React #185, "Maximum update depth exceeded", which is a render loop, not an input-handling fault.

Sighting 1 — fenced block, shift+Return

Playwright web lane, bundle from upstream/main 0f1ecc9d2 + PRs #6466/#6467/#6468, Chrome, /#/chat, empty thread.

  1. Click the composer ([data-testid=chat-message-input])
  2. Type ```ts, shift+Return, const x = 1;, shift+Return, ```, shift+Return
  3. Type $$\frac{a}{b}$$ and $10 vs $20

Crash to the error boundary. Error ID 11d9bca978b742c1b2edb8f66a04e131.

Error: Minified React error #185
    at $r (index-Bil1lnOS.js:8:27492)
    at Xr (index-Bil1lnOS.js:8:27017)
    at ns (index-Bil1lnOS.js:8:58756)
    at ts (index-Bil1lnOS.js:8:58377)
    at    (index-Bil1lnOS.js:961:23655)

Sighting 2 — plain single-line text, mid-turn

Different operator, different bundle (rebuilt with #6473). Error ID 21c190bb442d49cfab80ca50489dac48, fired during a turn, not on input. Input was plain single-line text — no shift+Return, no backticks.

What is ruled OUT

  • Typing is not the trigger. Plain single-line text typed into the composer sent and rendered cleanly in ~10 turns across two different bundles.
  • Not caused by #6473. Sighting 1 predates that PR being merged into the test bundle.
  • Not reproducible on demand. After sighting 2, the same operator ran: text only; reasoning only; one tool call; three consecutive tool calls; reasoning + three tool calls (the exact crashing shape); then a reload → new thread → immediate send reproducing the original conditions. No crash in eight subsequent turns.

Current hypothesis, offered as a hypothesis

The trigger is in turn rendering — something about the sequence or timing of message parts arriving during a turn — and the composer is a bystander. That fits an intermittent #185 firing mid-turn, and explains why deliberate attempts to reproduce by typing fail.

A weaker pattern, from two data points only and not to be acted on as fact: both sightings were early in a session, possibly the first turn after a fresh load.

What would actually settle it

A reproduction against a non-minified build. Both sightings yield only minified frames (at $r / at Xr / at ns). React #185 in dev mode names the component whose state update loops — that single line turns this from speculation into a fix. Everything else here is elimination.

Unrelated console noise, recorded so it is not mistaken for a cause

[useDaemonHealth] Failed to probe agent status: Error: Not running in Tauri ×3, ~90s before sighting 1. Expected in web mode (isTauri() is false there).

Impact

This blocked the first attempt at browser-driven verification of three unrelated UI PRs. Any automated or agent-driven flow reaching the app through the composer hits it, and the composer is the entry point to nearly every user flow.

M3gA-Mind avatar Sep 23 '26 00:09 M3gA-Mind

An unminified reproduction needs no special build — just the dev server

The acceptance criterion here asks for a non-minified build so React #185 names the looping component. That is free today.

app/package.json:

"dev": "vite",
"dev:web": "vite",
"dev:app:web": "bash ../scripts/run-dev-web.sh",

The Vite dev server serves React's development build, which prints the full "Maximum update depth exceeded" message plus a component stack instead of the minified #185 code. Both sightings so far were against a built bundle (index-Bil1lnOS.js), which is why only at $r / at Xr / at ns survived.

So whoever next tries to reproduce should drive dev:app:web / the dev server rather than a production build. Same effort, component names for free.

The component names may already exist in Sentry

app/vite.config.ts:233-236:

// Emit source maps so @sentry/vite-plugin can upload them; the plugin
// deletes the on-disk .map files after upload so users don't receive
// them in the shipped bundle.
sourcemap: true,

Sourcemaps for every production bundle are uploaded to Sentry before the local .map files are deleted. Both sightings carry Sentry error IDs (11d9bca978b742c1b2edb8f66a04e131, 21c190bb442d49cfab80ca50489dac48).

If the maps for those bundles uploaded, Sentry has already symbolicated those frames, and this issue may be answerable from evidence captured days ago with no reproduction at all. Worth opening those two events before anyone spends a night chasing an intermittent crash.

Static sweep of the mid-turn text-render path — what is ruled OUT

eslint --format json across features/conversations, components/assistant-ui, providers, store, components/chat, filtered to react-hooks/set-state-in-effect: 9 findings. None survives as a candidate for sighting 2 (plain single-line text, mid-turn, text surface). Detail, so nobody re-derives it:

  • Slash-command registry — the most promising-looking candidate, and it is safe by construction. useSlashCommands is live on /chat (via AssistantUiChat.tsx:140) and uses useSyncExternalStore, which is the classic #185 shape: an unstable getSnapshot loops. But registry.getActiveActions is memoised behind snapshotCache (lib/commands/registry.ts:29,92,115), and useRegisterAction's effect deps are all primitives with handler/enabled routed through refs (lib/commands/useRegisterAction.ts:49-56). So nothing re-registers per render and nothing busts the cache per render — the register → bust cache → new snapshot → re-render → re-register loop is closed deliberately.

  • settledRevision does NOT churn per token. Worth stating explicitly because it is the first thing anyone hunting a per-token cascade will suspect. settledRevision (providers/useOpenHumanExternalStore.ts:210) is built from the last settled message, and streaming tokens land in chatRuntime.streamingAssistantByThread — a different slice from thread.messagesByThreadId. The settled list does not grow mid-turn, so the derived-transcript projection does not refetch per token. That separation is deliberate.

  • Core transcript projection. useCoreTranscriptProjection deps are primitives (liveRequestId, revision, threadId), state is written only inside the effect, and identity is stable between fetches.

  • Live useAuiState selectors. components/assistant-ui/attachment.tsx:126-153 all return primitives (strings / booleans / undefined) — no fresh object identity to defeat the store's equality check. reasoning.tsx:313 is moot: no reasoning part is ever emitted on the main surface, so it is unreachable.

  • Both set-state-in-effect findings in Conversations.tsx (:923, :1613). Both converge rather than loop, and both are voice-path (replyMode / TTS) — not the text surface where sighting 2 fired.

The remaining lint findings are in attachment.tsx, image.tsx, ModelQualityPill.tsx, SubagentDrawer.tsx and UserTurnBody.tsx — none on the mid-turn text path without attachments, images or a drawer open, and UserTurnBody is the voice surface.

What I did NOT rule out

assistant-ui's own useSmooth. It animates streamed text over requestAnimationFrame, updating state per frame, and it is the one per-token state writer that cannot be cleared by reading our code. If the Sentry stack (or a dev-server reproduction) names a library component rather than one of ours, that is where I would look first.


No fix attempted and nothing changed — a plausible fix for a loop nobody has observed would close this issue while leaving the crash in place.

M3gA-Mind avatar Sep 23 '26 01:09 M3gA-Mind

Addendum — the Sentry route is blocked on credentials, so nobody repeats these calls.

Two independent tokens (mine and the fleet's shared ~/tinyhuman/.sentry.env) fail identically:

GET /api/0/organizations/tinyhumans/projects/                              -> 403 "You do not have permission to perform this action."
GET /api/0/projects/tinyhumans/{tauri-react,tauri-rust,internal}/events/<id>/  -> 500

Both event IDs, all three candidate projects. Two different tokens failing the same way points at an expired or rotated credential, not a mis-scoped one — and the 500 on the event endpoint is the same permission failure wearing a different status code, not a broken Sentry instance. Worth stating because checking only one of the two endpoints would send you to the wrong diagnosis in either direction.

Regenerating the token is a user action at the Sentry UI. Until then the symbolicated stacks above are unreachable, and the dev:web route is the token-free alternative — no credentials needed, component names come free from React's development build.

M3gA-Mind avatar Sep 23 '26 01:09 M3gA-Mind

Triage: needs opinion — “Renderer crashes mid-turn with React #185 (maximum update depth) — intermittent, not caused by typing” needs a maintainer decision on product scope/priority or fresh reproduction evidence before its status can be settled. Please advise whether to pursue, narrow, or close it.

senamakel avatar Oct 09 '26 17:10 senamakel

Still valid: new unminified sighting on the dev build (bf3cf35245, 2026-10-12 20:32), during a normal chat turn with no typing. The model streamed text, then a todo tool call whose arguments were streaming (tool_args_delta).

  • 20:32:00: Maximum update depth exceeded, thrown from loop in features/human/useHumanMascot.ts:774 (the mascot's per-frame re-render while it "speaks" streamed text).
  • 20:32:07: the same error, thrown from forceStoreRerender ← react-redux notify ← onToolArgsDelta (ChatRuntimeProvider.tsx:1334) ← socket tool_args_delta.

React throws this when more than 50 consecutive commits leave sync work pending. Two unrelated throwers 7 s apart mean a continuous sync loop for ≥7 s (main thread pegged). The throwing frames are bystanders, not the cause; the mascot just trips the counter first because it re-renders ~60×/s while text streams. The composer isn't involved, hence the retitle.

Ruled out (file:line in our notes): the 2026-09-24 selector fixes; every useAuiState/useSelector selector across 94 files (all return primitives or use useShallow); all direct useSyncExternalStore snapshots (cached); the task-card dock ref; TurnTaskProvider render-time setState (would be a different error); the imperative mascot overlay.

Lead (not proven): assistant-ui's useExternalStoreRuntime calls runtime.setAdapter in a dependency-less effect, and __internal_setAdapter notifies all subscribers whenever the adapter object identity changes, even with unchanged messages. Our provider re-renders on every streaming dispatch, so any subscriber that responds by dispatching or re-rendering the provider closes the loop.

Not yet reproduced on demand (2 natural hits in ~2 days, both in this turn). Next steps:

  1. Dev-only createRoot(…, { onUncaughtError: (e, info) => console.error(e, info.componentStack) }) in main.tsx, plus forwarding renderer errors to the core log, so the next occurrence names the looping component.
  2. Then a Vitest that streams tool_args_delta for a todo call through the external-store runtime and asserts no #185.

M3gA-Mind avatar Oct 13 '26 16:10 M3gA-Mind

Sentry triage for tinyhumansai/team#46: these unresolved tauri-rust / tauri-react issues share this root cause.

22 Sentry issue(s), 143 events in total, up to 8 users on a single issue. Releases seen: 0.64.10, 0.64.15.

Sentry Project Events Users Releases Last seen
TAURI-REACT-B8 tauri-react 38 8 0.64.15 2026-11-08
TAURI-REACT-BM tauri-react 17 7 0.64.15 2026-11-08
TAURI-REACT-BQ tauri-react 14 5 0.64.15 2026-11-09
TAURI-REACT-BF tauri-react 14 6 0.64.15 2026-11-08
TAURI-REACT-BN tauri-react 12 6 0.64.15 2026-11-08
TAURI-REACT-BA tauri-react 8 2 0.64.15 2026-11-01
TAURI-REACT-BJ tauri-react 7 4 0.64.15 2026-11-08
TAURI-REACT-BK tauri-react 7 2 0.64.15 2026-11-06
TAURI-REACT-BC tauri-react 5 2 0.64.15 2026-11-01
TAURI-REACT-BG tauri-react 4 2 0.64.15 2026-11-03
TAURI-REACT-CK tauri-react 3 3 0.64.15 2026-11-06
TAURI-REACT-CJ tauri-react 2 1 0.64.15 2026-11-01
TAURI-REACT-CH tauri-react 2 1 0.64.15 2026-11-01
TAURI-REACT-CB tauri-react 2 2 0.64.15 2026-11-01
TAURI-REACT-CW tauri-react 1 1 0.64.15 2026-11-08
7 more Sentry issues in this group

TAURI-REACT-CV, TAURI-REACT-CS, TAURI-REACT-CT, TAURI-REACT-CM, TAURI-REACT-CG, TAURI-REACT-CE, TAURI-REACT-CC

Comment on #6455 with this breakdown and the fact that it is the top React issue group on 0.64.15 (22 Sentry issues, ~165 events, ~60 users). Sentry frames are NOT symbolicated (sourcemaps did not resolve for bundles index-CcRJbsCZ / index-CHFbMPD4), so the #6455 next step (onUncaughtError with componentStack, forwarded to logs) is still the way to name the looping component. PR #7241 also listed 'Maximum update depth exceeded' as an unaddressed follow-up. No split needed.

senamakel avatar Nov 09 '26 13:11 senamakel