@devries-cameron20 / t3code-1 / commits / c7b14a8666
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(client-runtime): branch list no longer resets while paging through refs (#5858)

abhwshek committed Aug 15, 2026 at 17:32 UTC c7b14a8666dc44ee426f8d139e0493af9fe4b6db
1 file changed +22 -19
packages/client-runtime/src/state/vcs.ts
+22 -19
@@ -236,29 +236,32 @@ export function cachedVcsRefsChanges(
236 export function createVcsEnvironmentAtoms<R, E>(
237 runtime: Atom.AtomRuntime<EnvironmentRegistry | EnvironmentCacheStore | R, E>,
238 ) {
239 - const listRefsByEnvironment = Atom.family((environmentId: EnvironmentId) =>
240 - Atom.family((inputKey: string) => {
241 - const input = JSON.parse(inputKey) as VcsListRefsInput;
242 - return runtime
243 - .atom((get) => {
244 - const state = get(vcsRefsCacheStateAtom({ environmentId }));
245 - return cachedVcsRefsChanges(
246 - environmentId,
247 - input,
248 - state.revision,
249 - state.persistedCacheReadable,
250 - );
251 - })
252 - .pipe(
253 - Atom.setIdleTTL(VCS_REFS_IDLE_TTL_MS),
254 - Atom.withLabel(`environment-data:vcs:list-refs:${environmentId}:${inputKey}`),
239 + /**
240 + * One flat family on purpose: families hold entries via WeakRef, so a nested
241 + * per-environment family can be collected between lookups, dropping every
242 + * cached page atom and collapsing paginated ref lists mid-scroll.
243 + */
244 + const listRefsFamily = Atom.family((key: string) => {
245 + const [environmentId, input] = JSON.parse(key) as [EnvironmentId, VcsListRefsInput];
246 + return runtime
247 + .atom((get) => {
248 + const state = get(vcsRefsCacheStateAtom({ environmentId }));
249 + return cachedVcsRefsChanges(
250 + environmentId,
251 + input,
252 + state.revision,
253 + state.persistedCacheReadable,
254 );
256 - }),
257 - );
255 + })
256 + .pipe(
257 + Atom.setIdleTTL(VCS_REFS_IDLE_TTL_MS),
258 + Atom.withLabel(`environment-data:vcs:list-refs:${key}`),
259 + );
260 + });
261 const listRefs = (target: {
262 readonly environmentId: EnvironmentId;
263 readonly input: VcsListRefsInput;
261 - }) => listRefsByEnvironment(target.environmentId)(JSON.stringify(target.input));
264 + }) => listRefsFamily(JSON.stringify([target.environmentId, target.input]));
265 const invalidateRefs = (
266 target: { readonly environmentId: EnvironmentId; readonly input: { readonly cwd: string } },
267 registry: AtomRegistry.AtomRegistry,