From 0475a2cea709b23b135872227e3799f7646c99d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Fri, 20 Nov 2026 10:55:28 +0100 Subject: [PATCH] desktop: Refresh the repo list when seeded repos arrive A seeded repo appears as soon as the node has fetched it, instead of on the next five-second poll. --- desktop/src/components/SidebarRepoList.svelte | 11 +++++++++-- desktop/src/lib/startup.svelte.ts | 8 +++++++- shared/core/src/keys.ts | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/desktop/src/components/SidebarRepoList.svelte b/desktop/src/components/SidebarRepoList.svelte index a173a005c..fe75a61a9 100644 --- a/desktop/src/components/SidebarRepoList.svelte +++ b/desktop/src/components/SidebarRepoList.svelte @@ -57,14 +57,16 @@ import type { RepoInfo } from "@bindings/repo/RepoInfo"; import type { CrossfadeParams } from "svelte/transition"; + import { keys } from "@radicle-gui/core/keys"; import RepoAvatar from "@radicle-gui/ui/components/RepoAvatar.svelte"; + import { onInvalidate } from "@radicle-gui/ui/lib/query.svelte"; import { onMount, untrack } from "svelte"; import { flip } from "svelte/animate"; import { backOut, cubicOut } from "svelte/easing"; import { get } from "svelte/store"; import { crossfade, fade, scale, slide } from "svelte/transition"; - import { nodeRunning } from "@app/lib/events"; + import { nodeEvents, nodeRunning } from "@app/lib/events"; import type { FlipSnapshot } from "@app/lib/flip"; import { captureFlip, playFlip } from "@app/lib/flip"; import { dynamicInterval, resetDynamicInterval } from "@app/lib/interval"; @@ -78,6 +80,7 @@ import { entityUrl } from "@app/lib/mentions"; import { show } from "@app/lib/modal"; import { motion } from "@app/lib/motion"; + import { queryClient } from "@app/lib/query"; import { repoListScope } from "@app/lib/repoListScope"; import * as router from "@app/lib/router"; import { seededRepos, seedRepo, setFetchingRepos } from "@app/lib/seedRepo"; @@ -185,8 +188,9 @@ } }); + // Without the node's events, poll while a seeded repo hasn't arrived yet. $effect(() => { - if (seededNotReplicated.length > 0) { + if (seededNotReplicated.length > 0 && !$nodeEvents) { dynamicInterval("seededNotReplicated", reloadRepos, 5_000); } else { resetDynamicInterval("seededNotReplicated"); @@ -388,6 +392,9 @@ untrack(() => void reloadRepos()); }); + // Reloads when a seeded repo arrives, or an identity update renames one. + onInvalidate(queryClient, () => keys.repos(), reloadRepos); + async function reloadRepos() { invalidateReposSummary(); const [reloaded, fetching] = await Promise.all([ diff --git a/desktop/src/lib/startup.svelte.ts b/desktop/src/lib/startup.svelte.ts index db7e0f80a..f152e4f7d 100644 --- a/desktop/src/lib/startup.svelte.ts +++ b/desktop/src/lib/startup.svelte.ts @@ -10,6 +10,7 @@ import { get } from "svelte/store"; import { invoke } from "@app/lib/invoke"; import { queryClient } from "@app/lib/query"; +import { fetchingRepos } from "@app/lib/seedRepo"; import { artifactNodeRunning, nodeEvents, nodeRunning } from "./events"; @@ -19,7 +20,6 @@ function batch(delay: number): (affected: Key[]) => void { const pending = new Map(); let flush: ReturnType | undefined; return affected => { - if (affected.length === 0) return; for (const key of affected) pending.set(key.join("\0"), key); flush ??= setTimeout(() => { flush = undefined; @@ -40,6 +40,12 @@ function onRefUpdate(update: RefUpdate) { ...affectedKeys(update), // The node writes notifications as it fetches. keys.notificationCount(), + // The repository list changes when a seeded repository arrives, or when an + // identity update renames one. + ...(get(fetchingRepos).includes(update.rid) || + update.refs?.some(ref => ref.endsWith("refs/rad/id")) + ? [keys.repos()] + : []), ]); } diff --git a/shared/core/src/keys.ts b/shared/core/src/keys.ts index 158386c8d..608c6b5a0 100644 --- a/shared/core/src/keys.ts +++ b/shared/core/src/keys.ts @@ -16,6 +16,7 @@ export const keys = { patchList: (rid: string, status: string) => ["repo", rid, "patches", status] as const, patch: (rid: string, id: string) => ["repo", rid, "patch", id] as const, + repos: () => ["repos"] as const, notificationCount: () => ["notifications", "count"] as const, };