hermes-agent/apps/desktop/src
Brooklyn Nicholson 88e7d7537c perf(desktop): cut FadeText forced layouts during streaming
The slowest user-felt path is typing into the composer while the
assistant is streaming. Profile (scripts/profile-under-stream.mjs):

  FadeText measureOverflow self time:  35.8 ms → 18.1 ms  (-50%)
  total active CPU during 7s window:   ~150 ms → ~50 ms

Two changes in src/components/ui/fade-text.tsx:

1. Drop the `useEffect([children])` that re-ran `measureOverflow`
   (reads scrollWidth + clientWidth — forced layout) on every parent
   re-render. `useResizeObserver` already fires the same callback on
   mount and whenever the host span's box size changes; that covers
   the only case where overflow state can legitimately change. The
   previous explicit useEffect was a forced-layout flush on every
   parent render, which during streaming meant every token tick.

2. Wrap the component in `memo` with a custom comparator that
   short-circuits the entire render when scalar string `children` and
   the className/fadeWidth/style props are unchanged. The hot path
   was tool-fallback's title chips being re-rendered by parent
   streaming updates even though their text was stable; memo+
   comparator skips that.

Also adds two harness scripts under apps/desktop/scripts/:
  - latency-under-stream.mjs (key→paint latency while a turn streams)
  - profile-under-stream.mjs (CPU profile while a turn streams)

Updates profile-typing-lag.md with the streaming numbers and confirms
the Enter→paint submit path is already fast (≤320ms on the populated
session; the 2s "stall after Enter" the user noticed once was a
one-time cold-start, not reproducible at the UI layer).

I'd guess the felt jank in real use is fast-burst typing during a
long-form streaming reply (code blocks + markdown lists multiply the
per-token render cost). The CPU savings here scale linearly with
token volume.
2026-05-21 16:09:44 -05:00
..
app perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
components perf(desktop): cut FadeText forced layouts during streaming 2026-05-21 16:09:44 -05:00
hooks feat: glass ui pass 2026-05-16 19:21:33 -05:00
lib feat: more ui qa 2026-05-16 21:26:50 -05:00
store feat: more ui qa 2026-05-16 21:26:50 -05:00
themes feat: more ui qa 2026-05-16 21:26:50 -05:00
types feat: glass ui pass 2026-05-16 19:21:33 -05:00
global.d.ts feat(desktop): thin installer + first-launch install.ps1 bootstrap 2026-05-18 02:26:46 -04:00
hermes.ts feat: more ui qa 2026-05-16 21:26:50 -05:00
main.tsx feat: better composer etc 2026-05-04 22:19:16 -05:00
styles.css feat: more ui qa 2026-05-16 21:26:50 -05:00
vite-env.d.ts feat(desktop): add structured desktop chat app 2026-05-01 12:49:12 -05:00