authorgravatar for 67309069+a20hek@users.noreply.github.comabhwshek <67309069+a20hek@users.noreply.github.com> 2026-08-15 17:32:21+05:30
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-15 12:02:21+00:00
logc7b14a8666dc44ee426f8d139e0493af9fe4b6db
tree8781a23a6f0d0bca0f621f915096e001c81598c5
parent9e61d0f127cad164702ca37aad6f5f38babc1ac7
signature Signed by PGP key B5690EEEBB952194

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


1 files changed, 22 insertions(+), 19 deletions(-)

  • packages
packages/client-runtime/src/state/vcs.ts+22-19
......@@ -236,29 +236,32 @@ export function cachedVcsRefsChanges(
236236export function createVcsEnvironmentAtoms<R, E>(
237237 runtime: Atom.AtomRuntime<EnvironmentRegistry | EnvironmentCacheStore | R, E>,
238238) {
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,
255254 );
256 }),
257 );
255 })
256 .pipe(
257 Atom.setIdleTTL(VCS_REFS_IDLE_TTL_MS),
258 Atom.withLabel(`environment-data:vcs:list-refs:${key}`),
259 );
260 });
258261 const listRefs = (target: {
259262 readonly environmentId: EnvironmentId;
260263 readonly input: VcsListRefsInput;
261 }) => listRefsByEnvironment(target.environmentId)(JSON.stringify(target.input));
264 }) => listRefsFamily(JSON.stringify([target.environmentId, target.input]));
262265 const invalidateRefs = (
263266 target: { readonly environmentId: EnvironmentId; readonly input: { readonly cwd: string } },
264267 registry: AtomRegistry.AtomRegistry,