Link and mention releases

- Route release and release list links to their views
- Offer releases for a pasted ID or link
- List delegate releases in # search
- Show release references as chips
- Cache release lookups for mentions
- Record release mentions in ADR 0003
This commit is contained in:
Daniel Norman
2026-10-08 18:21:48 +02:00
committed by Rūdolfs Ošiņš
parent 595a81150b
commit e930bfd397
9 changed files with 240 additions and 33 deletions
+45
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import type { Issue } from "@bindings/cob/issue/Issue";
import type { Patch } from "@bindings/cob/patch/Patch";
import type { Release } from "@bindings/cob/release/Release";
import type { Config } from "@bindings/config/Config";
import type { ComponentProps } from "svelte";
@@ -8,6 +9,7 @@
cachedConfig,
cachedIssueById,
cachedPatchById,
cachedReleaseById,
cachedRepoById,
cachedRepoCommit,
} from "@app/lib/invoke";
@@ -49,6 +51,7 @@
let resolvedRepoName: string | undefined = $state(undefined);
let issue: Issue | undefined = $state(undefined);
let patch: Patch | undefined = $state(undefined);
let release = $state<Release | undefined>(undefined);
let commitSummary: string | undefined = $state(undefined);
let missing = $state(false);
let config: Config | undefined = $state(undefined);
@@ -136,6 +139,27 @@
};
});
$effect(() => {
if (target.type !== "cob" || target.kind !== "release") return;
let cancelled = false;
void cachedReleaseById(target.rid, target.oid)
.then(result => {
if (cancelled) return;
if (result) release = result;
else missing = true;
})
.catch(() => {
if (!cancelled) missing = true;
});
return () => {
cancelled = true;
};
});
const releaseTitle = $derived(
release ? release.title || release.tagName : undefined,
);
$effect(() => {
if (target.type !== "commit") return;
let cancelled = false;
@@ -365,6 +389,27 @@
<span class="mention-oid">{formatOid(target.oid)}</span>
{/if}
</a>
{:else if target.kind === "release"}
<a
class="mention"
class:unresolved={missing}
{href}
target={missing ? "_blank" : undefined}
rel={missing ? "noopener noreferrer" : undefined}
onclick={handleClick}
onmousedown={keepSelection}
oncontextmenu={openMenu}
title={missing
? `${fallback} · ${target.oid} — not replicated locally`
: `${releaseTitle ?? fallback} · ${target.oid}`}>
<span class="mention-status">
<Icon name="parcel" />
</span>
<span class="mention-label">{releaseTitle ?? fallback}</span>
{#if missing || (release && !releaseTitle)}
<span class="mention-oid">{formatOid(target.oid)}</span>
{/if}
</a>
{:else}
<a
class="mention"
+53 -2
View File
@@ -9,6 +9,7 @@
<script lang="ts">
import type { AliasSuggestion } from "@bindings/cob/AliasSuggestion";
import type { Author } from "@bindings/cob/Author";
import type { Release } from "@bindings/cob/release/Release";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
import type { ComponentProps } from "svelte";
@@ -29,8 +30,10 @@
cachedIssueById,
cachedListIssueCandidates,
cachedListPatchCandidates,
cachedListReleaseCandidates,
cachedListReposSummary,
cachedPatchById,
cachedReleaseById,
cachedRepoById,
cachedRepoCommit,
cachedRepoCommitsByPrefix,
@@ -321,6 +324,25 @@
};
}
if (target.kind === "release") {
const release = await cachedReleaseById(target.rid, target.oid).catch(
() => undefined,
);
const label = release
? releaseTitle(release)
: `release ${formatOid(target.oid)}`;
return {
key,
target,
label,
primary: label,
secondary: formatOid(target.oid),
icon: "parcel",
haystack: label,
};
}
const patch = await cachedPatchById(target.rid, target.oid).catch(
() => undefined,
);
@@ -431,9 +453,10 @@
}
async function resolveOid(oid: string): Promise<Suggestion[]> {
const [issue, patch, commit] = await Promise.all([
const [issue, patch, release, commit] = await Promise.all([
cachedIssueById(rid, oid).catch(() => undefined),
cachedPatchById(rid, oid).catch(() => undefined),
cachedReleaseById(rid, oid).catch(() => undefined),
cachedRepoCommit(rid, oid).catch(() => undefined),
]);
const rows: Suggestion[] = [];
@@ -460,6 +483,9 @@
haystack: patch.title,
});
}
if (release) {
rows.push(releaseRow(release));
}
if (commit && rows.length === 0) {
rows.push({
key: `commit:${oid}`,
@@ -564,9 +590,10 @@
}
async function collectCobs(): Promise<Suggestion[]> {
const [allIssues, allPatches] = await Promise.all([
const [allIssues, allPatches, allReleases] = await Promise.all([
cachedListIssueCandidates(rid).catch(() => []),
cachedListPatchCandidates(rid).catch(() => []),
cachedListReleaseCandidates(rid).catch(() => []),
]);
const rows = [
...allIssues.map(issue => ({
@@ -601,6 +628,10 @@
icon: patchIcon[patch.state.status],
haystack: `${patch.title} ${patch.id}`,
})),
...allReleases.map(release => ({
timestamp: release.createdAt,
...releaseRow(release),
})),
];
return rows
@@ -608,6 +639,26 @@
.map(({ timestamp: _timestamp, ...row }) => row);
}
function releaseTitle(release: Release): string {
return (
release.title || release.tagName || `release ${formatOid(release.id)}`
);
}
function releaseRow(release: Release): Suggestion {
const label = releaseTitle(release);
return {
key: `release:${release.id}`,
target: { type: "cob", kind: "release", rid, oid: release.id },
label,
primary: label,
secondary: formatOid(release.id),
icon: "parcel",
haystack: `${label} ${release.tagName ?? ""} ${release.id}`,
};
}
const patchIcon: Record<string, IconName> = {
draft: "patch-draft",
open: "patch",