mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:18:55 +00:00
Switching between chat sessions in the desktop app froze for up to ~1–2s on large transcripts. Profiling the switch path surfaced three main-thread blockers, fixed here minimally and without changing behavior. 1. JSON.stringify deep-compare (worst case). chatMessagesEquivalent compared message parts with JSON.stringify(a) === JSON.stringify(b) on every switch. On image-/large-blob-bearing transcripts this serialized every part twice and cost well over a second. Replaced with a structural compare that never stringifies: array-level identity fast-path, per-part reference fast-path, then type-aware field comparison. The compare's only consumer asks "did the transcript change, should I setMessages?", so it is deliberately conservative — a false-negative just causes one extra idempotent setMessages, while a false-positive (the unsafe direction) is avoided. 2. Scroll-settle loop. thread-list ran a requestAnimationFrame settle loop up to 90 frames (or 5 stable frames) on every sessionKey change, each frame forcing a synchronous layout read + write — racing the markdown paint for up to ~1.5s. A normal synchronous switch stabilizes within a couple frames, so the ceiling is now 2 stable frames / 15 max. 3. Synchronous first paint of up to 300 parts. On switch, thread-list reset the render budget to the full RENDER_BUDGET=300, so up to 300 parts went through markdown + shiki syntax-highlighting synchronously on the switch commit. It now paints a small FIRST_PAINT_BUDGET=60 first, then bumps to the full 300 in a requestAnimationFrame after the first commit. Salvaged from PR #49807 by professorpalmer — re-applied to the restructured file layout (use-session-actions/utils.ts, thread/list.tsx) and tests merged into the existing utils.test.ts. Co-authored-by: Cary Palmer <professorpalmer@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| app | ||
| components | ||
| contrib | ||
| fonts | ||
| hooks | ||
| i18n | ||
| lib | ||
| plugins | ||
| sdk | ||
| store | ||
| themes | ||
| types | ||
| global.d.ts | ||
| hermes-parity.test.ts | ||
| hermes-profile-scope.test.ts | ||
| hermes.test.ts | ||
| hermes.ts | ||
| main.tsx | ||
| styles.css | ||
| vite-env.d.ts | ||