desktop: Name the refs behind local announcements

The node announces the user's own writes, and those of the `rad` CLI,
without saying which refs changed, so each one refetched the whole repo,
including a scan of every CI job. Comparing the announced signed refs
with the previous ones names them. Releases and boards get keys of their
own instead of falling back to the whole repo.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-20 19:32:17 +01:00
parent cbdd3d2d86
commit 94ac124c62
5 changed files with 338 additions and 42 deletions
+2
View File
@@ -35,6 +35,8 @@ 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,
releases: (rid: string) => ["repo", rid, "releases"] as const,
boards: (rid: string) => ["repo", rid, "boards"] as const,
jobs: (rid: string) => ["repo", rid, "jobs"] as const,
repos: () => ["repos"] as const,
notificationCount: () => ["notifications", "count"] as const,
+9 -2
View File
@@ -2,8 +2,8 @@ import type { Key } from "./keys";
import { keys } from "./keys";
// Refs that changed in a repository. Without `refs`, the backend doesn't know
// which refs changed, such as when the local user pushed.
// Refs that changed in a repository. Without `refs`, it isn't known which refs
// changed, such as on the first announcement after a restart.
export interface RefUpdate {
rid: string;
refs?: string[];
@@ -12,6 +12,9 @@ export interface RefUpdate {
const ISSUE = "xyz.radicle.issue";
const PATCH = "xyz.radicle.patch";
const JOB = "xyz.radworks.job";
// Releases are artifact COBs.
const RELEASE = "dev.radicle.artifact";
const BOARD = "works.monadic.board";
export function affectedKeys({ rid, refs }: RefUpdate): Key[] {
if (refs === undefined) {
@@ -37,6 +40,10 @@ export function affectedKeys({ rid, refs }: RefUpdate): Key[] {
// A job names its commit only in its contents, so every job list of
// the repository is affected.
add(keys.jobs(rid));
} else if (cob && cob[1] === RELEASE) {
add(keys.releases(rid));
} else if (cob && cob[1] === BOARD) {
add(keys.boards(rid));
} else if (/^refs\/(heads|tags)\//.test(name)) {
add(keys.code(rid));
add(keys.repoInfo(rid));