perf(flowchat): reduce embedded subagent memory and render churn - #3236
Merged
Merged
Conversation
Keep thinking, file-operation, and process cards compact while embedded subagent output is streaming. This avoids mounting their full previews by default and preserves explicit expansion for readers who need the details.
Return the latest target directly while immediate reveal mode is active instead of committing every streamed chunk to React state. Seed the state once when animated visibility resumes so hidden content does not build update work or stale playback state.
Keep the shared flow-root boundary on embedded virtual rows so trailing child margins remain part of the measured row height. Add layout and virtualizer regression coverage for the feedback loop that could remount rows while tail-following.
Reuse bounded date and number formatters across repeated transcript renders, while clearing them when the locale changes and bypassing unsupported option objects. This reduces repeated ICU construction during streaming updates without changing formatted values.
Avoid translating the full processing-hint catalog on every RuntimeStatusSlot render. Cache translated hints by i18n instance and language, and only resolve them when an unlabeled runtime status needs a generated hint.
Track only the session fields rendered by the navigation and return a primitive revision from a memoized selector. Streaming updates that do not affect navigation no longer rebuild the full joined signature string.
Reuse the latest content-end geometry during streaming RAFs and refresh it from explicit follow scheduling or viewport changes. This avoids forcing a scrollHeight read on every frame while preserving opening, navigation, rollback, and settling behavior.
Prevent primary-session expansion state from forcing thinking cards open inside embedded subagent panels. The panel can still expand a card explicitly through its own control.
RuntimeStatusSlot only needs translated hint metadata when an unlabeled status is visible. Use a stable fallback cache owner and default language when lightweight test translation mocks omit the i18n object, preventing renderer crashes from cascading across FlowChat suites.\n\nUpdate the visibility contract test to expect projected subagent thinking cards to remain collapsed by default.\n\nVerified with the complete Web UI test suite: 900 files and 9965 tests passed.
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.
Summary
Reduce renderer memory and layout churn while streaming embedded subagent sessions.
Type and Areas
Type: Performance improvement, regression fix, test
Areas: Web UI / FlowChat / embedded subagent panels / i18n
Motivation / Impact
Embedded subagent panels could retain large Markdown, tool-card, and typewriter render trees while streaming. Repeated viewport geometry reads, selector recalculation, locale formatting, and runtime-hint translation also added unnecessary renderer work.
This PR includes:
The changes are presentation and renderer optimizations. They do not change the agent protocol or persisted session format.
Verification
git diff --checkpnpm exec vitest run src/flow_chat/components/modern/RuntimeStatusSlot.test.tsx src/flow_chat/tool-cards/ModelThinkingDisplay.test.tsx src/flow_chat/tool-cards/ExecProcessToolCardView.test.tsx src/flow_chat/components/modern/useFlowChatFollowOutput.test.tsx src/flow_chat/components/btw/BtwSessionPanelLayout.test.ts src/flow_chat/components/btw/BtwVirtualSessionList.test.tsx src/app/components/NavPanel/sections/sessions/sessionsNavSelector.test.ts src/infrastructure/i18n/core/I18nService.test.ts@openbitfun/flow-chat-presentationpackage link.pnpm run type-check:weblucide-reactpackage does not exportBookSearch.Reviewer Notes
upstream/mainafter the FlowChat presentation refactor.Checklist