perf(desktop): stop re-rendering the app shell on every keystroke#1692
Open
noahjalex wants to merge 2 commits into
Open
perf(desktop): stop re-rendering the app shell on every keystroke#1692noahjalex wants to merge 2 commits into
noahjalex wants to merge 2 commits into
Conversation
usePresenceSession stored raw Date.now() activity timestamps in React state and bumped them from capture-phase keydown/pointerdown listeners, so every keystroke anywhere in the app re-rendered AppShell (the app root) and swept context changes through the whole tree. Track activity in a ref and keep only the derived automatic status in state, updated solely when it actually flips (online <-> away, on activity, interval tick, or visibility change). Probe: AppShell renders during a 74-keystroke burst drop 70 -> 1. Benchmark keystroke input-to-paint medians halve across every scenario (32 -> 16ms channel, 48 -> 24ms in a 68-reply thread at 4x throttle); thread keystrokes over the 50ms frame budget drop 76 -> 1-3. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Noah: Typing in a thread with lots of agents working was painfully slow and building. I basically couldn't send messages, this fixes it for me.
AI: Every keystroke, anywhere in the app, re-rendered the entire app shell.
usePresenceSession(mounted in AppShell) stored rawDate.now()activity timestamps in React state and updated them from capture-phasekeydown/pointerdownlisteners — new state at the app root per keystroke. This was the largest single contributor to typing feeling slow, on every surface.What
online/away) in state.Repro / Verify
React DevTools → Profiler → record → type a sentence in any composer → stop.
main: one AppShell-rooted commit per keystroke (the whole tree re-renders).Quantified (render-count probe + Event Timing benchmark, 4x CPU throttle):
Risk Assessment
Low — single hook, derived-state refactor with identical semantics. 2266 unit tests and messaging/thread/status e2e specs pass.
Related: #1652 (thread-panel render fixes; same investigation, independent change).
🤖 Generated with AI