perf(session): speed up session switching with warm cache and staged rendering#15474
Draft
kitlangton wants to merge 3 commits intoanomalyco:devfrom
Draft
perf(session): speed up session switching with warm cache and staged rendering#15474kitlangton wants to merge 3 commits intoanomalyco:devfrom
kitlangton wants to merge 3 commits intoanomalyco:devfrom
Conversation
sync.tsx: - Remove redundant .filter((m) => !!m?.id) in fetchMessages — the preceding filter already guarantees x.info.id is truthy, so this was a wasted array allocation + iteration on every session switch. Removing it noticeably speeds up large session loads. - Simplify part loading from a multi-chunk rAF/setTimeout scheduler to a single requestAnimationFrame + batch. The chunking was needed when parts used reconcile, but with direct assignment the cost is low enough to do in one pass. Still defers to the next frame so message skeletons paint first. - Remove fresh flag — reconcile against empty is cheap enough that the conditional wasn't worth the complexity. - Minor cleanups: if/else instead of two independent ifs in applyOptimisticAdd, inline hasSession IIFE, use cached variable in todo() instead of re-reading globalSync, inline nextLimit. message-v2.ts: - Extract fetchParts() and assembleMessages() helpers shared by stream() and list(), eliminating duplicated Map-building and row-to-WithParts assembly logic.
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
Session.messagesto bulk list query path (MessageV2.list) for lower sync overheadValidation
bun run typecheck(packages/app)bun run typecheck(packages/opencode)bun test src/pages/session/use-session-hash-scroll.test.ts src/pages/session/scroll-spy.test.ts(packages/app)bun test test/session/message-v2.test.ts test/session/session.test.ts(packages/opencode)