perf(flow-chat): render recent session history first#958
Merged
limityan merged 1 commit intoMay 30, 2026
Conversation
Load the latest restored turns first, hydrate older history in the background, and keep large completed model rounds anchored on their newest groups. Also adds a static preload hint for debug WebView cold start and fixes duplicate todo keys in restored plan displays.
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
restore_session_viewso the first historical session open does not read and convert every older turn before showing the latest content.Related issue: #949
Performance Test Scope
This PR is evaluated from user-facing business scenarios, not only isolated helper speedups. The main target is first open of historical sessions, especially sessions with enough history that reading every turn delays the latest visible conversation. Startup is included because the PR adds a preload hint, but this PR does not claim startup latency improvement.
Test environment and method:
main.d3eec23d.tailTurnCount=3, followed by the existing full restore as delayed background hydration.Scenario Results
showat 944 ms after main-window create startfirst_script_evalat 9799.4 msinteractive_shell_readyat 10557 msget_opened_workspaces15.1 ms,get_recent_workspaces13.9 ms, 7list_persisted_sessions_pagecalls max 14.6 msHistorical Session Restore Measurements
The table below shows the tradeoff explicitly: the PR improves the first visible restore by loading tail turns, while the delayed full hydrate still pays the old full restore cost in the background.
tail=3)Summary across these 5 samples:
Risks And Mitigations
isPartial=falseand skipping background hydration when all turns are already loaded.isPartial,loadedTurnCount, andtotalTurnCount; existing UI callers use those fields for hydration and do not rely on the responsesession.turnCountfor metadata. Future callers should usetotalTurnCountwhen requesting a partial view.interactive_shell_readytime.Validation
pnpm run fmt:rspnpm --dir src/web-ui run test:run -- TodoWriteDisplay.test.tsx FlowChatStore.test.ts modelRoundProgressiveRender.test.tspnpm --dir src/web-ui run test:run -- FlowChatStore.test.ts modelRoundProgressiveRender.test.tspnpm run type-check:webcargo test -p bitfun-core agentic::persistence::manager::tests::load_session_tail_turns_returns_latest_turns_in_chronological_order -- --nocapturecargo check -p bitfun-corecargo check -p bitfun-desktop(passes with the existingparse_clipboard_path_segmentsdead_code warning)git diff --checktailTurnCount: 3.26673380390: Frontend Build and Rust Build Check on macOS, Ubuntu, and Windows all passed.