hermes-agent/apps/desktop/scripts
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
..
assert-root-install.cjs Improve desktop runtime UX by surfacing inference readiness in gateway status and hardening WSL link opening. 2026-05-15 16:33:04 -05:00
before-build.cjs feat(desktop): thin installer + first-launch install.ps1 bootstrap 2026-05-18 02:26:46 -04:00
click-session.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
dev-no-hmr.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
diag-submit.mjs perf(desktop): cut FadeText forced layouts during streaming 2026-05-21 16:09:44 -05:00
dump-state.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
latency-under-stream.mjs perf(desktop): cut FadeText forced layouts during streaming 2026-05-21 16:09:44 -05:00
leak-typing.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
measure-latency.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
measure-submit.mjs perf(desktop): cut FadeText forced layouts during streaming 2026-05-21 16:09:44 -05:00
notarize-artifact.cjs fix(desktop): address CodeQL alerts on PR #20059 2026-05-11 16:52:32 -04:00
notarize.cjs ci(desktop): automate desktop releases 2026-05-05 13:04:33 -05:00
probe-renderer.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
profile-typing-lag.md perf(desktop): cut FadeText forced layouts during streaming 2026-05-21 16:09:44 -05:00
profile-typing.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
profile-under-stream.mjs perf(desktop): cut FadeText forced layouts during streaming 2026-05-21 16:09:44 -05:00
reload-renderer.mjs perf(desktop): cut per-keystroke layout + listener churn in chat composer 2026-05-21 15:45:01 -05:00
stage-native-deps.cjs desktop: swap node-pty fork for upstream microsoft/node-pty 1.1.0 2026-05-18 21:50:53 -07:00
test-desktop.mjs desktop: swap node-pty fork for upstream microsoft/node-pty 1.1.0 2026-05-18 21:50:53 -07:00
write-build-stamp.cjs feat(desktop): thin installer + first-launch install.ps1 bootstrap 2026-05-18 02:26:46 -04:00