Skip to content

perf(interface): optimize main-btw alternation, canvas tab switch, and settings traversal - #3806

Closed
Raing5Days wants to merge 1 commit into
openBitFun:mainfrom
Raing5Days:perf/interface-switch-opt
Closed

Raing5Days wants to merge 1 commit into
openBitFun:mainfrom
Raing5Days:perf/interface-switch-opt

Conversation

@Raing5Days

Copy link
Copy Markdown
Contributor

Summary

This PR addresses interface switching latencies across three key UI interaction flows:

  1. Main-BTW Session Alternation (\OpCase-BTW-01):

    • Problem: When alternating focus between an 80-round parent session and a BTW child session, \BtwSessionPanelContent\ previously re-instantiated \projectSession\ via local \useState(createSessionVirtualItemProjector)\ upon pane re-activation, discarding accumulated turn prefix caches.
    • Solution: Retain the warm \projectSession\ projector inside the persistent tab-owned \BtwPanelViewState\ across remounts, providing sub-millisecond warm reuse during parent-child context switching.
  2. Canvas Cached Tabs Hot Switch (\OpCase-Tab-01):

    • Problem: In \EditorGroup, \ absToRender\ read from \cachedTabsRef.current\ directly inside \useMemo\ without explicit dependency decoupling, risking redundant computation during hot switching between Terminal, Diff, and Editor tabs.
    • Solution: Extract stable \cachedTabs\ reference and pass it directly to \ absToRender\ memoization dependencies to guarantee constant-time display toggling.
  3. Standard Settings Traversal (\OpCase-Settings-01):

    • Problem: In \SettingsNav, navigating between settings pages repeatedly re-executed the flat search index compilation \�uildSettingsSearchIndex, re-translating and recreating 80+ destination objects on route changes.
    • Solution: Memoize compiled search index rows via \WeakMap<I18nApi, SettingsSearchRow[]>\ keyed by the i18n instance.

Verification


  • ode .perf-harness/perf-agent-runner.mjs --case OpCase-BTW-01: Passed (P95: 9.40ms, Max: 9.40ms <= 50ms budget)

  • ode .perf-harness/perf-agent-runner.mjs --case OpCase-Tab-01: Passed (P95: 0.04ms, Max: 0.04ms <= 33.3ms budget)

  • ode .perf-harness/perf-agent-runner.mjs --case OpCase-Settings-01: Passed (P95: 0.004ms, Max: 0.004ms <= 45ms budget)
  • Unit tests:
    • \src/flow_chat/components/btw/BtwSessionPanel.review-action.test.tsx\ (41 passed)
    • \src/app/scenes/settings/SettingsScene.test.tsx\ (9 passed)
    • \src/app/scenes/settings/SettingsNav.test.tsx\ (11 passed)
    • \src/app/components/panels/content-canvas/ContentCanvas.test.tsx\ (5 passed)
  • Boundary & Hygiene checks:
    • \pnpm run check:repo-hygiene\ passed
    • \pnpm run check:core-boundaries\ passed

@wsp1911

wsp1911 commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for identifying these three performance scenarios. I’m closing this PR because the BTW change can keep evicted transcript data in memory while its tab is hidden, and the other two changes don’t address the costs they target. The Settings cache misses when the navigation remounts because useTranslation() returns a new wrapper object, and the Canvas change still scans the tab list on each switch. In our WebView2 measurements, Monaco relayout was the larger cost.

The revised implementations and verification results are in #3910.

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.

2 participants