Repository navigation
perf(ui): keep chat, sidebar, and composer responsive while subagents run - #1853
Merged
Merged
Conversation
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.
Problem
When several subagents or background threads run at once, typing in the composer, moving the caret, and scrolling the conversation become sluggish—even inside an idle thread.
The window was receiving every background thread's and subagent's live message stream over Electron IPC only to discard it, re-rendering the open chat and sidebar on unrelated subagent churn, and re-rendering the composer and writing the full workspace to
localStorageon every keystroke and caret move.Change
src/main/ipc/registerGuiIpc.ts,src/main/mms/protocolEventBridge.ts,src/main/notifications/threadNotificationTarget.ts): Main now dropsthread.message,thread.message-updated, and non-replacethread.messagesevents for known non-side-chat threads that the window is not viewing. The selected thread, side chats, unlisted bot chats, and background undo replacements (replace: true) continue to forward as before.src/main/ipc/registerGuiIpc.ts,src/renderer/App.tsx):window-eventskips bridging events already broadcast byrouteWindowState, avoiding duplicateorchestrator:turn-stateandthreads:activityIPC messages. The renderer flushes its per-frame transcript batcher only when the selected thread's own turn state changes, not on background subagent turn updates.src/renderer/components/OrchestratorChat.tsx,src/renderer/hooks/useRunOnDevices.ts,src/renderer/components/SubagentParentBar.tsx,src/renderer/components/SubagentComposerBanner.tsx,src/renderer/components/ThreadRowStatus.tsx,src/renderer/components/ThreadsSidebar.tsx,src/renderer/stores/appStore.ts):threadsandsubagentsByParentsubscriptions inOrchestratorChat,useRunOnDevices,SubagentParentBar, andSubagentComposerBannerwith narrow selectors for the viewed thread.setSubagentsandsetBackgroundWorkwhen the payload matches held data.sameListedActivityto compare rolled-up visible-thread states (while still waking on anyawaiting_inputor pending-row change) so subagents flipping betweenprocessing,waiting,completed, andidleunder an already-working parent do not re-renderThreadsSidebar.src/renderer/components/ChatComposer.tsx,src/renderer/chat/components/MousseAgentChatShell.tsx,src/renderer/chat/components/agent-elements/agent-chat.tsx,src/renderer/stores/appStore.ts):@mentionquery, and memoized the Markdown backdrop.AgentChatand stabilized itsonSend/onStopcallbacks inMousseAgentChatShellso typing in the composer does not re-renderAgentChatorMessageList.composerDrafts-only workspace persistence, flushing immediately on draft clear, other workspace edits, profile switches,beforeunload,pagehide, andvisibilitychange.Verification
Tier 4 (cross-area: main IPC + renderer store and UI).
tests/backgroundSubagentIpcFilter.test.ts): verified through registeredregisterGuiIpchandlers that unselected subagent and background thread streaming updates emit 0 renderer IPC messages, while selected threads, side chats, unlisted bot threads, andreplace: trueundo snapshots still forward, andturn.stateemitsorchestrator:turn-stateonce.tests/renderer/subagentAndComposerPerformance.test.ts): mountedThreadsSidebarandOrchestratorChatwithcountRenderand verified 0 renders ofThreadsSidebar,OrchestratorChat,AgentChat, andMessageListduring background subagent activity churn, unrelated touches, and other parents' Nest updates; verified sidebar still updates onawaiting_inputand final completion; verified 0ChatComposerrenders when moving the caret across ordinary text while@mentionstill opens/closes; verified 0AgentChat/MessageListrenders during rapid typing with throttledlocalStoragewrites and immediate flush onbeforeunload/clear.tsc --noEmit -p tsconfig.node.json): fails on Linux with the same 2 pre-existingCannot find module 'koffi'errors insrc/mms/git/windowsGitProcess.tsandsrc/mms/harness/windowsJobProcess.tsasorigin/master; no errors in any changed file.Notes
No issue