Repository navigation
perf(web-ui): improve scrolling during concurrent BTW streaming - #3914
Merged
Merged
Conversation
Replace root-level startup relational selectors with explicit startup state and share native focus-visible state across scrollbar consumers. This preserves startup handoff and keyboard accessibility while avoiding broad style recalculation as virtualized transcript content changes. Add a BTW scrolling E2E suite using the 200-turn, 100-tool-call template. Check concurrent streams, bidirectional scrolling, reading anchors, bounded DOM windows, return-to-latest, and completed responses. Across two repetitions per direction on local Windows Desktop, pooled RAF FPS improves from 39.9 to 55.3 in primary live content, 18.4 to 40.7 in history, and 41.6 to 55.0 in BTW content. Both versions use the same native binary and benchmark protocol without CDP instrumentation. Validation: 24 E2E measurement segments, 104 focused tests, 8 benchmark contract tests, 4 ScrollArea tests, native focus/geometry checks, TypeScript, production build, and color/motion audits pass. check:web remains blocked by the existing Dialog.module.css:77 typography violation. Remote scenarios were not exercised.
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
Improve scrolling when a long primary conversation and its
/btwside conversation stream simultaneously. Replace broad relational CSS selectors with explicit startup state and a shared document focus subscription, and add a reproducible concurrent-scrolling E2E suite.Type and Areas
Type: Performance improvement, regression coverage.
Areas: Web UI startup, shared design-system scrollbars, Desktop E2E, documentation.
Motivation / Impact
Streaming updates and virtualized row changes caused broad style recalculation through root-level startup
:has()selectors and scrollbar selectors applied to every theme descendant. This reduced responsiveness even when scrolling the other conversation.Optimization method
data-startup-stage, clearing it on completion and fallback paths. Avoid keeping the application root as a relational-selector subject.:has(:focus-visible)matching with one reference-counted focus subscription per document. Read native focus visibility after input/focus events and update the shared flag only when it changes; scroll events and streaming mutations do not update it.Measured benefit
The existing 200-turn, 100-tool-calls-per-turn template supplies 20,000 historical tool records. The test opens a real
/btwchild, drives two real Agent runtime sessions with a private loopback SSE model, seeds each response with 512 Markdown paragraphs, and releases 192 further paragraphs per pane at 90 ms intervals during each phase. The child is a new transient conversation, not a second persisted history fixture.Both directions are measured in primary live content, primary historical tool content, and BTW live content. Each direction runs twice: 12 segments per version, 24 total. All functional checks pass.
FPS is time-weighted across pooled frame intervals; P95 uses the pooled nearest-rank distribution. Runs use the same native binary, protocol, harness, focused viewport, and immutable production frontend snapshots, with no concurrent build/test workload or CDP profiler. Environment: Windows x64, Core i7-8700, 32 GiB RAM, WebView2/Edge 157, 1992×1152 CSS-pixel viewport at 1.25 DPR; debug native host with production frontend assets.
These are RAF presentation opportunities, not compositor FPS. Historical tool calls are fixture records, not 20,000 newly executed tools. The historical tool region improves substantially but does not consistently reach 60 FPS.
Verification
Reproduce after building Desktop and production frontend assets:
The E2E checks both streams advance during scrolling, all wheel inputs reach the selected pane, further output preserves the reading anchor, both virtualized DOM windows remain bounded, return-to-latest reaches the final paragraph, and both completed responses render their completion markers. Raw frame timestamps, counters, screenshots, and frontend/native hashes are retained by the runner.
Current-head verification:
pnpm run check:web— passed (including appearance checks, typography audit, and TypeScript).pnpm --dir src/web-ui exec vitest run src/app/styles/scrollbar.test.ts src/app/styles/scrollbarFocus.test.ts src/app/startup/startupOverlay.test.ts src/app/startup/startupPreload.test.ts src/app/startup/startupPerformanceContract.test.ts src/app/scenes/welcome/WelcomeScene.test.tsx src/infrastructure/design-system/OpenBitFunDesignSystemProvider.test.tsx— 104 tests passed.node --test tests/e2e/scripts/long-session-performance.test.mjs design-system/packages/ui/tests/scroll-area.test.mjs— 12 tests passed.git diff --check upstream/main...HEAD— passed.Also passed during optimization: production build, standalone TypeScript check,
pnpm run theme:color-audit:all(27 surfaces),pnpm run motion:audit, and a native-browser focus/scrollbar geometry diagnostic covering hover, mouse-focused buttons, keyboard focus, text inputs, and focused-node removal.Reviewer Notes
05f2b55bb). The optimization patch has an identical stable Git patch ID after the rebase. Current-head checks above were rerun; performance measurements were not repeated after that rebase. A subsequent report-caption correction does not change workload or metric calculations.check:webstopped at the existingDialog.module.css:77typography violation. The upstream cleanup resolves that original blocker; current verification is reported above.Checklist