Repository navigation
Description
Bug Description
The Hermes Desktop renderer crashes intermittently with tapClientLookup: Index N out of bounds (length: M) errors thrown from @assistant-ui/store. When this fires, the root error-boundary catches it and the UI shows the "Reload window" error screen, requiring the user to manually reload (or restart the app) to recover the chat.
The frequency has increased noticeably over the last few days of normal use (multiple hits per day).
Representative log excerpts from ~/.hermes/logs/desktop.log (renderer console relayed by Electron main):
[renderer console] Error: tapClientLookup: Index 0 out of bounds (length: 0) .../dist/assets/index-CDQNplt5.js:8
[renderer console] Error: tapClientLookup: Index 5 out of bounds (length: 5) .../dist/assets/index-DPLdCuM3.js:8
[renderer console] Error: tapClientLookup: Index 10 out of bounds (length: 8) .../dist/assets/index-DPLdCuM3.js:8
[renderer console] Error: tapClientLookup: Index 23 out of bounds (length: 18) .../dist/assets/index-DPLdCuM3.js:8
[renderer console] [error-boundary:root] Error: tapClientLookup: Index 0 out of bounds (length: 0)
[renderer console] [error-boundary:root] Error: tapClientLookup: Index 5 out of bounds (length: 5)
[renderer console] [error-boundary:root] Error: tapClientLookup: Index 10 out of bounds (length: 8)
[renderer console] [error-boundary:root] Error: tapClientLookup: Index 23 out of bounds (length: 18)
[renderer console] Uncaught Error: Minified React error #520; visit https://react.dev/errors/520
[renderer console] Error: Tried to unmount a fiber that is already unmounted
[renderer console] [error-boundary:root] Error: Tried to unmount a fiber that is already unmounted
Often co-occurring (probably a downstream symptom of the same race):
[renderer console] Uncaught (in promise) Error: Error invoking remote method 'hermes:api': Error: 404: {"detail":"Session not found"}
Steps to Reproduce
The error is timing-sensitive but the following sequences reproduce it most reliably for me on Hermes Desktop 0.16.0:
- Start a long chat with multiple tool calls / streaming responses (so
messages.lengthgrows past ~10–20). - Switch sessions in the sidebar (or open a session whose backend record has been pruned), or
- Cancel an in-flight streaming response and immediately switch / reload the thread, or
- Have an external process modify the active session while the UI is open.
- Within ~1 second of the message list shrinking (e.g. messages re-fetched, session swap), the renderer throws
tapClientLookup: Index N out of bounds (length: M)whereN >= M, the root error-boundary fires, and the chat is replaced by the "Reload window" screen.
The exact N/M pair varies (0/0, 5/5, 10/8, 23/18 observed), suggesting a stale index captured from a previous render is being used after the underlying array was shortened.
Expected Behavior
- A transient inconsistency between rendered indices and
keys.lengthshould not crash the entire app surface. - At minimum, an out-of-bounds lookup should resolve to a safe no-op (or
undefined) and let React reconcile on the next render, rather than throwing and tearing down the root. - The user should not have to "Reload window" to recover from what is logically a one-frame race.
Actual Behavior
@assistant-ui/store@0.2.9tapClientLookup({ index })throws synchronously whenlookup.index >= keys.length, which propagates out of the assistant-ui runtime client hooks (thread-runtime-client,composer-runtime-client,message-runtime-client,thread-list-runtime-client,suggestions,thread-message-client).- The root error-boundary in Hermes Desktop catches the throw and replaces the UI with the "Reload window" screen.
- A secondary
Tried to unmount a fiber that is already unmounted(React Feature: Tool Call Repair Middleware — Auto-Lowercase + Invalid Tool Handler (inspired by Kilocode) #520) sometimes follows, consistent with the renderer being torn down mid-commit. - Recovery requires Reload Window or full app restart.
Affected Component
Other (Hermes Desktop renderer / @assistant-ui integration)
Debug Report
Cannot share — the desktop / agent logs contain confidential conversation content from work usage. Happy to share sanitized excerpts privately on request. The renderer-console excerpts above are scrubbed and should be sufficient to localize the issue.
Operating System
macOS 26.5 (Apple Silicon, M4)
Python Version
n/a (renderer issue)
Hermes Version
Hermes Desktop 0.16.0 (release date 2026.6.5), built from main @ 2b119baac
Additional Logs / Traceback (optional)
The throwing function is @assistant-ui/store@0.2.9 tapClientLookup:
// node_modules/@assistant-ui/store/dist/tapClientLookup.js
export function tapClientLookup(getElements, getElementsDeps) {
const resources = tapResources(...);
const keys = tapMemo(() => Object.keys(resources), [resources]);
...
return {
state,
get: (lookup) => {
if ("index" in lookup) {
if (lookup.index < 0 || lookup.index >= keys.length) {
throw new Error(`tapClientLookup: Index ${lookup.index} out of bounds (length: ${keys.length})`);
}
return resources[lookup.index].methods;
}
...
},
};
}Callers in @assistant-ui/core@* that pass an index derived from a possibly-stale snapshot:
runtime-clients/thread-runtime-client.js—runtimeState.messages.map((m, idx) => ...)runtime-clients/composer-runtime-client.js—runtimeState.attachments.map((attachment, idx) => ...)runtime-clients/message-runtime-client.js—runtimeState.content.map((part, idx) => ...)andruntimeState.attachments.map(...)runtime-clients/thread-list-runtime-client.js—Object.keys(runtimeState.threadItems).map(...)clients/thread-message-client.js—message.content.map((part, idx) => ...)andmessage.attachmentsclients/suggestions.js—state.suggestions.map(...)
When the underlying array shrinks (session switch, message cancellation, external truncation, or thread-list refresh) and a child component re-renders with a captured index that no longer exists, the throw kills the whole tree.
Root Cause Analysis (optional)
Two-layer race:
- Hermes Desktop side: state updates that shrink the message / thread / attachment arrays (e.g. session swap,
Session not found404 fromhermes:api, externally truncated session) are not consistently sequenced with the children that consumetapClientLookup({ index }). A stale child momentarily holds an index from the previous render and queries the store with it. @assistant-ui/storeside:tapClientLookup's index path throws on every out-of-bound query instead of returningundefined(or another non-throwing sentinel). This makes the library brittle against any renderer race in any host app.
Repo grep confirms Hermes Desktop does not use tapClientLookup directly — all call sites are inside node_modules/@assistant-ui/{core,store} — so this is an interaction bug between Hermes' state lifecycle and the assistant-ui runtime.
Proposed Fix (optional)
Two complementary mitigations; either alone reduces the user-visible "Reload window" rate, both together should eliminate it:
A. Hermes Desktop — guard the root error-boundary against this throw class.
Treat tapClientLookup: Index ... out of bounds (and Tried to unmount a fiber that is already unmounted) as recoverable: log + reset the boundary and let React re-render with fresh state on the next tick, instead of replacing the entire UI with the "Reload window" screen. This preserves the chat across the inevitable one-frame races.
B. Hermes Desktop — sequence array-shrinking state transitions so children unmount before the store snapshot is committed.
Concretely, on session switch / Session not found recovery / external session truncation, clear the child runtime (messages: [] / detach thread runtime) before mutating the underlying session list, so no child renders against the new (shorter) array with an old index. The Session not found 404s in the same log block are a strong hint that the renderer is briefly pointing at a session whose state has been torn down.
C. Upstream @assistant-ui/store (out of scope for this repo but worth filing):
Switch tapClientLookup({ index }).get() from throw to undefined for the index path (the key path can keep its current behavior), so any host-app race becomes a missing-leaf-render instead of a tree-killing exception. Happy to file that upstream too if the maintainers here would like — flag in this issue.
I'd start with A since it's a one-file change in Hermes Desktop that immediately stops the "Reload window" UX regression for every user.
Are you willing to submit a PR for this?
Cannot push to external forks from my current environment (Amazon Code Defender). Happy to keep iterating in this issue if the maintainers want a verified diff for option A — just let me know which surface (error-boundary component path) you'd like the guard wired into.
Notes
- I run an unrelated set of local UI patches (preview width caps, file-tree, mermaid rendering, IME) on
local/patches. None of them touch@assistant-uiruntime clients, message state, or session lifecycle, and the throw originates entirely insidenode_modules/@assistant-ui/{core,store}— so the race is independent of the local patch set. - Verified locally on macOS 26.5 / Apple Silicon, Hermes Desktop 0.16.0,
@assistant-ui/store@0.2.9,@assistant-ui/react@^0.12.28.
Activity
JakubMerkandi commentedon Jun 11, 2026
Confirming this also affects our Hermes Desktop setup.
We are seeing the same renderer crash in
~/.hermes/logs/desktop.log, for example:and later:
In practice this does appear to kill the Desktop UI / leave it in the root error boundary state, while the backend process continues running.
One observation from local debugging: the failing path seems consistent with a stale
ThreadPrimitive.MessageByIndexrender after the assistant-ui runtime has already switched/reduced the message list. The virtualized thread can still have an old message index mounted for a render, and that stale index then reachestapClientLookup.So #41787 looks useful as a recovery mitigation, but there may also be a lower-level fix in the Desktop thread virtualizer to avoid rendering stale
MessageByIndexentries in the first place.whisky0809 commentedon Jun 12, 2026
Root cause (and a caveat for #41787)
The throw is the index path of
@assistant-ui/store'stapClientLookup, whichthrows whenever a consumer resolves{index}that is>= keys.length. The underlying race is in assistant-ui itself: aDerivedscope's lookup closure lagged one commit behind (tapEffectEvent), so a child mounted with a stale index could resolve it against an already-shortened message list. assistant-ui fixed that in@assistant-ui/store@0.2.11(commitdb721df, "keyDerivedscopes by{source, query}so a meta change produces a new client function in the same render pass").Bumping the dependency is not a clean fix here, though, for two reasons:
0.2.11 alone did not stop the crash in the packaged Desktop app. I bumped
@assistant-ui/storeto 0.2.11 (and verified the new fiber-keying was present in the built bundle) — the renderer still threwtapClientLookup: Index 14 out of bounds (length: 4)fromUserMessagewhen switching from a long chat to a short one, deterministically. A mountedMessageByIndexreads an unchanged-but-now-stale index during the session-shrink window, which 0.2.11's fix doesn't cover. The repro in fix(desktop): recover root boundary from transient render races #41787 stops throwing on 0.2.11, but the real packaged app still does — the surviving path only reproduces with the real virtualizer/scroll timing, not in jsdom.Can't simply track the latest store.
@assistant-ui/store@0.2.14renamestapClientLookup→useClientLookup, which is incompatible with the@assistant-ui/core@0.1.17pinned transitively via@assistant-ui/react@^0.12.28. A>=0.2.11range that floats into 0.2.14 breaks the build, so you'd need an exact0.2.11/<0.2.12pin — awkward against the repo's dependency-range policy.On the #41787 error-boundary approach (which does work as a user-visible mitigation): worth guarding against thrash. As written, a recoverable error that recurs every frame loops catch → reset → throw indefinitely. A bounded recovery budget (e.g. max N resets within a short window, then leave the fallback latched) stops a genuinely persistent error from spinning. I confirmed the unbounded-loop behavior with a test against that boundary.
Environment: Hermes Desktop on native Windows 11, built from local
main;@assistant-ui/store@0.2.9baseline,@assistant-ui/react@^0.12.28,@assistant-ui/core@0.1.17.supplefrog commentedon Jun 12, 2026
Additional repro evidence from Windows Desktop current local build/source:
NousResearch/hermes-agenta118b94a80.15.1Something broke in the interfacewithtapClientLookup: Index 14 out of bounds (length: 8)and buttonsRetry,Reload window,Open logs.The latest local
desktop.logshows the crash is still escaping to the root error boundary fromUserMessage, including during/around long-context compression and after app/backend restart:Earlier in the same log there are repeated variants:
Current source already has a local mitigation in
apps/desktop/src/components/assistant-ui/message-render-boundary.tsxthat is intended to swallow/tapClient(Lookup|Resource).*out of bounds/, andthread-virtualizer.tsxwraps each virtualized group inMessageRenderBoundary:So either the packaged Desktop build being run does not include the mitigation, or there is still an escaping path outside the per-message/group boundary. The log stack still reaches
[error-boundary:root], so the current user-visible failure mode remains full-interface loss rather than a single dropped/recovered message row.One extra observed recovery problem: closing and reopening the Desktop app did not reliably reload/recover the window state; the error screen persisted/reappeared until an explicit reload/recovery path was used. That makes the root-boundary escape worse because a normal app restart may not be perceived as a reset by users.
This seems correlated with very long chats / context compaction / session-state replacement, not a simple bad tool-result shape only.
zzj1965186613 commentedon Jun 13, 2026
Additional Reproduction Case
Trigger: Running
/team-pipeline(multi-agent orchestrator that spawns parallel subagents)Error:
Full stack trace from desktop.log:
Reproduction steps:
/team-pipeline) that spawns 2-3 subagents in paralleltapClientLookupwhen rendering aUserMessagecomponent where the part index (30) far exceeds the client array length (2)Key observation: The
N=30, M=2gap is much larger than the other reported cases (0/0,5/5,10/8,23/18). This suggests the issue is not just a one-frame race but a more fundamental state desync when the message structure changes dramatically (many subagent messages appended rapidly).Environment:
Workaround: Click "Reload window" to recover. No data loss — its purely a frontend rendering crash.
fix(desktop): recover the root error boundary from transient render r…
fix(desktop): recover the root error boundary from transient render r…
fix(desktop): recover the root error boundary from transient render r…
fix(desktop): recover the root error boundary from transient render r…
fix(desktop): recover the root error boundary from transient render r…
fix(desktop): recover the root error boundary from transient render r…
fix(desktop): recover the root error boundary from transient render r…
fix(desktop): recover the root error boundary from transient render r…
fzzkjd commentedon Aug 8, 2026
Thanks for the fix in #41787 — it covers the chat message render path. However, the same transient race still surfaces through contrib panel boundaries on Windows desktop v0.20.0 (latest, 2026-08-08):
User-visible result: the workspace (Projects) pane shows
"workspace" failed to renderwith a Retry button, instead of the auto-recovering behavior the message boundary now has. Retry recovers; chat/gateway are unaffected — it's a visible but non-blocking regression surface.Root cause:
message-render-boundary.tsxguards the assistant-ui message list withisTransientLookupError, but contrib panels use their own boundary (src/contrib/react/boundary.tsx→ genericErrorBoundary), which has no transient-error auto-retry. The sameuseClientLookupindex race (length 1, index 1) throws there and does not self-heal.Suggestion: extract/share
isTransientLookupError(or its regex) and apply the same recoverable-retry behavior incontrib/react/boundary.tsx, so transient store races in contrib panes recover on the next consistent snapshot instead of showing "failed to render".fix(desktop): recover the root error boundary from transient render r…
fix(desktop): auto-recover boundaries from React portal teardown races
fix(desktop): auto-recover boundaries from React portal teardown races
fix(desktop): auto-recover boundaries from React portal teardown races
fix(desktop): recover the root error boundary from transient render r…