Skip to content

perf(web-ui): speed up BTW switching, Settings startup, and Canvas tabs - #3910

Merged
wsp1911 merged 3 commits into
openBitFun:mainfrom
wsp1911:pr-3806
Nov 14, 2026
Merged

wsp1911 merged 3 commits into
openBitFun:mainfrom
wsp1911:pr-3806

Conversation

@wsp1911

@wsp1911 wsp1911 commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Reuse BTW transcript projections when reopening the same history snapshot. Keep streaming prefix caches scoped to the mounted panel and allow evicted snapshots to be collected.
  • Build the settings search index on the first nonblank search. Reuse it across searches and refresh it when the language or relevant translation resources change.
  • Preserve the layout size of cached Canvas code and diff editors while they are hidden. Keep inactive editors inert so they cannot take focus or intercept clicks.

Refs #3806

Type and Areas

Type: Performance, bug fix

Areas: Web UI, FlowChat / BTW, Settings, Canvas / Monaco

Motivation / Impact

These changes address three workflows identified in #3806: returning to a BTW transcript, opening Settings, and switching among cached Canvas tabs. Ordinary settings page changes already reuse the search index. Deferring the first build removes translation work from Settings startup and allows search to pick up terms from newly loaded resources.

Verification

  • 270 focused Vitest tests passed across 15 files. Run from src/web-ui:

    node scripts/run-vitest.mjs run --maxWorkers=6 \
      src/flow_chat/store/modernFlowChatStore.test.ts \
      src/flow_chat/components/btw/{btwTailFollow.test.ts,useBtwSessionState.test.tsx,useBtwPanelViewport.test.tsx,BtwVirtualSessionList.test.tsx,BtwSessionPanel.review-action.test.tsx,BtwSessionPanelLayout.test.ts} \
      src/app/scenes/settings/{SettingsNav.test.tsx,SettingsScene.test.tsx,settingsRegistry.test.ts} \
      src/app/components/panels/content-canvas/{editor-area/EditorArea.test.tsx,CanvasToolbar.test.tsx,tab-bar/TabBar.test.tsx} \
      src/tools/editor/{services/editorViewResidency.test.ts,components/CodeEditor.test.tsx}
  • pnpm --dir src/web-ui exec tsc --noEmit, pnpm run i18n:audit, and pnpm run theme:color-audit:all passed.

  • pnpm run check:web stopped at the existing typography audit violation in Dialog.module.css:77 (--openbitfun-line-height-snug), which is also present on the base branch.

  • BTW: in a synthetic 80-round hot-remount benchmark, projection P95 fell from 1.15 ms to 0.004 ms. A local garbage-collection probe also confirmed that releasing the source turn array allows the cached projection to be collected.

  • Settings: in a six-pair local WebView2 prototype, first-open median was 264.3 ms with eager indexing and 186.9 ms with deferred indexing. This measures the whole navigation path. A separate smoke test of the implemented build found the late-loaded editor search phrase in all three runs.

  • Canvas: in a local Windows WebView2 comparison against forcing cached editors to use display: none, each condition had 42 hot switches per tab count. P95 to the next RAF after the pane became visible fell from 128.9 to 66.5 ms with 3 tabs and from 166.0 to 83.0 ms with 20 tabs. An additional 15 switches per condition recorded 30 versus 0 Monaco layout callbacks. Verified that hidden editors cannot take focus or intercept hit tests and that switching back preserves scroll position.

Reviewer Notes

AI-assisted. Focused tests and local manual verification are complete. The timings are local diagnostics; RAF measures frame opportunities. Remote Workspace, Remote Control, Peer Device Mode, and Detached Dispatch were not exercised.

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.

Cache BTW projections by their source turn array so reopening a panel
reuses the rendered items while evicted snapshots can be collected.
Keep streaming prefix caches scoped to the mounted panel.
Defer indexing until the first nonblank search to remove translation work
from settings startup. Reuse the index across searches and refresh it
when the active language or relevant translation resources change.
Keep hidden Editor and Diff panels at their layout size to avoid Monaco
relayouts on tab switches. Make inactive panels inert and cover pane reuse
and activation in the canvas tests.
@wsp1911
wsp1911 merged commit 5909a00 into openBitFun:main Nov 14, 2026
8 of 9 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