Repository navigation
Conversation
This was referenced Oct 20, 2026
This was referenced Oct 20, 2026
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is an isolated mobile performance refactor that stabilizes paginated branch-query atoms and removes redundant rendering without changing branch data, pagination semantics, or product defaults. The limited runtime impact and contained scope make it low risk. You can add or adjust custom eligibility rules. Learn more. |
Contributor
flamboh
force-pushed
the
perf/mobile-branch-picker-memo
branch
from
October 20, 2026 05:32
e0f853c to
5fea58d
Compare
macroscopeapp
Bot
dismissed
their stale review
October 20, 2026 05:32
Dismissing prior approval to re-evaluate 5fea58d
This branch has not been deployed
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.
Note
Part of a series fixing values the React Compiler stopped caching after the mobile migrations. Each PR restructures the code so the compiler can cache it, without adding
useMemooruseCallback. Each is independent and can merge in any order:Note
🤖 Claude Opus 5.5 on behalf of Oliver
Problem
The mobile React Compiler migration #21137 left
usePaginatedBranches(apps/mobile/src/state/queries.ts) building its combinedpagesAtomwithAtom.make(...)during render. The compiler can't cache it: the value stays live across the lateruseAtomValuecall, and a cache block can't span a hook call, so the compiler drops that scope without a build error. Every render therefore creates a new atom,useAtomValueresubscribes, and the caller renders a second time. This affectsNewTaskFlowProviderand the scheduled-task branch picker.Fix
Move the atom out of render. A module-level
Atom.familykeyed by a JSON string of[environmentId, cwd, query, cursors]returns the same atom for equal inputs, so render no longer needs a cache. This follows the repo's string-key family pattern (vcsEnvironment.listRefsalready keys its family the same way):useMemo,useCallback, or ref/state memo stand-ins.nullinstead ofundefined, so it survives the JSON key unchanged.refreshlooks up the first-page atom through the samebranchPageAtomhelper, so it no longer depends on a per-render array.keepAlive, so the registry releases its node once no component subscribes.Atom.familyholds entries byWeakRef, so an unused key is garbage-collected like the existinglistRefsentries.Verification
Compiler output. Compiled
queries.tswithbabel-preset-expousing Metro's iOS release caller flags and a compiler logger. The atom passed touseAtomValuenow comes from the family, so it keeps the same identity across renders without a cache slot.refreshis now cached (depsquery,setPagination,target,targetKey). On main it changed identity on every render. The one pruned block inusePaginatedBranchesis unchanged from main: the stringquery/targetKeycomputation before the hooks, which doesn't need a cache. No newCompileErrorevents, and no file was added toKNOWN_BAILOUTS.Render counts. A jsdom harness compiled the real
usePaginatedBranchessource from each branch with the same compiler preset, then ran it under@effect/atom-reactwith a plainAtomRegistry.make()provided throughRegistryContext, the same setup asApp.tsx. OnlyvcsEnvironment.listRefswas stubbed. Results matched across 3 runs:refreshidentity changesChecks.
vp test run apps/mobile/src/reactCompilerCoverage.test.tspassed (887).queries.test.tsandqueries.filesystem.test.tspassed. Mobiletypecheckpassed.vp lintonqueries.tsis clean.Not checked. No simulator or device run.
Claude Opus 5.5 via Claude Code in T3 Code