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