fix(app): reduce reactive cascade overhead on session switch#36853
Open
BYK wants to merge 1 commit into
Open
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
BYK
force-pushed
the
byk/reactive-cascade
branch
from
July 17, 2026 11:57
3139eed to
9b669a5
Compare
- Replace messageById Map recreation in useSessionHashScroll with a lazy
findMessage() linear scan. The Map was rebuilt (O(n) insertions) on every
visibleUserMessages change including during streaming. Also removes the
wrapping memo that lacked an equality comparator.
- Add { equals: same } to the diffs memo so downstream components don't
re-render when diff content is unchanged.
- Replace object allocation in dir/id effect with a primitive string key.
SolidJS on() uses === comparison, so the old object always triggered the
effect body even when dir and id hadn't changed.
- Remove redundant historyLoader.userMessages memo that rewrapped
input.visibleUserMessages() with { equals: same } — the input already
uses the same comparator.
BYK
force-pushed
the
byk/reactive-cascade
branch
from
July 17, 2026 13:21
9b669a5 to
bb09a34
Compare
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.
Issue for this PR
Fixes #31548
Type of change
What does this PR do?
Reduces redundant reactive work that runs on every session switch (and during streaming):
findMessage()instead ofmessageByIdMap recreation (use-session-hash-scroll.ts): the Map was rebuilt (O(n) insertions) on everyvisibleUserMessageschange, including during streaming. Replaced with a lazy linear scan, and the wrapping memo that lacked an equality comparator was removed.{ equals: same }on thediffsmemo (session.tsx): downstream components no longer re-render when diff content is unchanged.on()effect (session.tsx): SolidJSon()uses===, so the previous object literal always re-ran the effect body even whendir/idwere unchanged. Now keyed on a primitive string.historyLoader.userMessagesmemo that rewrappedvisibleUserMessages()with{ equals: same }— the input already uses the same comparator.How did you verify your code works?
bun typecheckfrompackages/app— clean for all touched filesOPENCODE_CHANNEL=latest bun run script/build.ts --single— build + smoke test passed (v1.17.12)Checklist