Repository navigation
perf(navigation): skip the shell render when a visit opens - #2992
Draft
kalvinnchau wants to merge 2 commits into
Draft
kalvinnchau wants to merge 2 commits into
kalvinnchau wants to merge 2 commits into
Conversation
an attempt that opens only changes its status from opening to opened, and the shell reads only failed. useAppNavigation now keeps the opening snapshot for that transition, sparing a render of the whole app shell per channel switch. channelspage read the visit status during render and relied on that render, so it now subscribes to the one case it uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
server-rendered pages call useSyncExternalStore without a client store, so channelspage needs getServerSnapshot; pass the same getter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
kalvinnchau
force-pushed
the
peon/sw-opened-view
branch
from
November 7, 2026 21:33
e2ca4e9 to
42e0c3d
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.
Problem
A channel switch renders the whole app shell three times. The third render comes from
navigation.complete({ status: "opened" }). The controller then publishes a new snapshot that differs only instatus, and the shell re-renders about 470 components. The shell never reads"opened":App.tsxandnavigation.tsonly checkstatus === "failed".Change
shellSnapshot(navigation)insrc/app/navigation.tsis theuseSyncExternalStoregetter foruseAppNavigation. When a snapshot differs from the one last shown only by"opening"→"opened", it keeps showing the opening snapshot. Every other change is shown as before, including history updates that land on an opened visit.ChannelsPagereadnavigator.snapshot().statusduring render and relied on that shell render to notice a settled visit. This mattered only when the relay is in error and retrying ("Connecting…" vs "Can't connect. We'll keep trying."). It now subscribes, with a getter that is true only in that case, so ordinary switches don't re-render it.No behavior change
"failed".ChannelsPage.test.tsxno longer re-renders the page by hand after the visit completes. It now fails without the subscription.navigation.test.tsxcase checks that an opened visit keeps the shell's snapshot and that a later history change still reaches the shell. It fails if the getter swallows anything beyond the status change.Navigationtest mocks gainsubscribe.A plugin page that reads
navigation.snapshot().statusduring render without subscribing no longer gets a free re-render at"opened". No in-repo page does this.Evidence
The warm channel-switch probe:
Main
9a7c1d228was compared against this change. 2 Linux and 2 macOS boxes each ran 8 interleaved rounds, giving 24 samples per variant per box. Medians are below, with Mann–Whitney p ≤ 3e-5 for every cell.Local tests run:
vitestforsrc/bundled/channels/(1135 passed),src/app/navigation.test.tsxand the other navigation/App suites,src/features/navigation/controller.test.tsandattachment-panes.test.tsx.tsc --noEmitandbiome check.🤖 Generated with Claude Code