Skip to content

perf(flowchat): reduce embedded subagent memory and render churn - #3236

Merged
wsp1911 merged 9 commits into
GCWing:mainfrom
wsp1911:dev-omen
Sep 27, 2026
Merged

wsp1911 merged 9 commits into
GCWing:mainfrom
wsp1911:dev-omen

Conversation

@wsp1911

@wsp1911 wsp1911 commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

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:

  • Keep embedded subagent thinking, file-operation, and process cards collapsed by default while streaming.
  • Preserve explicit card expansion while preventing hidden typewriter state updates.
  • Keep projected thinking cards independent from the primary session expansion state.
  • Preserve embedded row-height containment during card collapse and streaming updates.
  • Cache repeated locale formatter instances.
  • Defer and cache generated runtime-status hint translation.
  • Replace repeated session navigation derivation with a stable selector.
  • Cache FlowChat follow-output geometry and reduce redundant viewport calculations.
  • Add focused tests and update the FlowChat virtualization notes.

The changes are presentation and renderer optimizations. They do not change the agent protocol or persisted session format.

Verification

  • git diff --check
    • Passed.
  • pnpm 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
    • 4 suites passed, 16 tests passed.
    • 4 suites could not load because the local workspace installation is missing the @openbitfun/flow-chat-presentation package link.
  • pnpm run type-check:web
    • Blocked before Web UI type checking by the existing design-system dependency mismatch: the installed lucide-react package does not export BookSearch.
  • Manual UI validation was not run.

Reviewer Notes

  • The branch was rebased onto upstream/main after the FlowChat presentation refactor.
  • The shared presentation architecture is retained; embedded-collapse behavior is routed through its existing disclosure APIs.
  • Explicit expansion remains available for readers who need full tool or thinking content.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

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.
@wsp1911
wsp1911 merged commit 3764baa into GCWing:main Sep 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant