Repository navigation
Open
3 / 33 of 3 issues completedOpen
3 / 33 of 3 issues completed
Copy link
Labels
area:desktopTauri desktop appTauri desktop apparea:perfPerformancePerformancedifficulty:2Half a day - 1 dayHalf a day - 1 dayenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Summary
During a streaming reply, most of the desktop UI re-renders on every store update. The cause is coarse state updates combined with wide subscriptions:
updateSessionIn(desktop/src/stores/chatStore.ts:612-620) creates a new session object on every change.- Many components subscribe to that whole object, or to the whole store.
So a single text flush, a thinking delta, or the per-second timer re-renders the sidebar, the composer, the message list and the page itself.
Where it happens
- Whole session object:
pages/ActiveSession.tsx:240components/chat/MessageList.tsx:1222components/chat/StreamingIndicator.tsx:39components/chat/ChatInput.tsx:129
- No selector at all, so they re-render on any change to any session:
components/chat/ChatInput.tsx:127PermissionDialog.tsx:128AskUserQuestion.tsx:64
- Sidebar: subscribes to every session (
components/layout/Sidebar.tsx:69) and rebuilds the running-session set each time (:188-197). So the 1,900-line sidebar re-renders on every delta of every session. - Thinking deltas are not batched: text and tool-input deltas go through a 50ms buffer, but thinking deltas update the store on each event (
chatStore.ts:1309-1328). Each one rebuilds the whole render model inMessageListand re-renders every tool group through a newtoolResultMap. - Elapsed timer: increments
elapsedSecondsin the session state every second (chatStore.ts:850), which re-renders all of the above for the whole turn.
Tasks
Open to contributors, as sub-issues (comment on one to claim it):
- Batch thinking deltas like text deltas while streaming #155 Batch thinking deltas like text deltas.
- Compute the turn's elapsed time in its own component instead of the store #156 Compute the turn's elapsed time in its own component instead of the store. Done in perf(desktop): compute the turn's elapsed time in its own component #165.
- Re-render the sidebar only when the set of running sessions changes #157 Re-render the sidebar only when the set of running sessions changes. Done in fix(sidebar): avoid re-renders on streaming updates #158.
Maintainer:
- Add fine-grained selectors for common fields, such as "is this session running" and "this session's messages", and move the composer, message list, page, permission dialog and question card onto them. Done in perf(desktop): subscribe components to the session fields they use #169.
- Pass each tool group its own result instead of the whole
toolResultMap. Done in perf(desktop): subscribe components to the session fields they use #169.
Done when
- Each PR shows a before/after measurement: render counts from React Profiler, or a Safari Web Inspector timeline of a streaming reply.
- No component stops updating when it should. Tests cover the fields each changed component relies on.
- Desktop tests and typecheck pass.
Metadata
Metadata
Assignees
Labels
area:desktopTauri desktop appTauri desktop apparea:perfPerformancePerformancedifficulty:2Half a day - 1 dayHalf a day - 1 dayenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Activity
perf(desktop): subscribe components to the session fields they use
perf(desktop): subscribe components to the session fields they use
perf(desktop): subscribe components to the session fields they use (#169