diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte
index cc5270923..fc9e77c07 100644
--- a/src/components/Comment.svelte
+++ b/src/components/Comment.svelte
@@ -45,6 +45,14 @@
caption?: string;
// Marks a comment that is part of an unpublished draft review.
draft?: boolean;
+ // Marks a comment whose thread has been dealt with. The review sidebar says
+ // this with a checkmark against a dimmed row; everywhere else the comment is
+ // shown at full strength, so it needs to say so itself.
+ resolved?: boolean;
+ // Names who resolved it, for the badge's tooltip. The comment carries only
+ // the flag, so the caller has to look this up (see `resolutionsByComment`);
+ // where it cannot, the badge says what it always said.
+ resolvedCaption?: string;
origin?: CommentOrigin;
timestamp?: number;
lastEdit?: Edit;
@@ -72,6 +80,8 @@
embeds,
caption = "commented",
draft = false,
+ resolved = false,
+ resolvedCaption,
origin,
timestamp,
lastEdit,
@@ -232,6 +242,23 @@
font: var(--txt-body-m-regular);
color: var(--color-text-quaternary);
}
+ /* Shaped and coloured like the verdict badge a review is headed with (see
+ `ReviewItem`), so the two green "this went well" marks read as one thing said
+ in two places.
+
+ The font is declared rather than inherited: inside a diff this card is
+ slotted into Pierre's shadow tree, whose own font size is larger, and the
+ captions beside it each set their own — so an inheriting chip came out the
+ biggest thing on the line. */
+ .resolved-chip {
+ flex-shrink: 0;
+ white-space: nowrap;
+ padding: 0.125rem 0.375rem;
+ border-radius: var(--border-radius-sm);
+ background-color: var(--color-feedback-success-bg);
+ color: var(--color-feedback-success-text);
+ font: var(--txt-body-s-regular);
+ }
.menu {
border: 1px solid var(--color-border-subtle);
border-radius: var(--border-radius-md);
@@ -286,6 +313,13 @@
• edited
{/if}
+ {#if resolved}
+
+ Resolved
+
+ {/if}
{/if}
diff --git a/src/components/Thread.svelte b/src/components/Thread.svelte
index 027fd0528..ff390e80f 100644
--- a/src/components/Thread.svelte
+++ b/src/components/Thread.svelte
@@ -8,7 +8,8 @@
import { tick } from "svelte";
- import { scrollIntoView } from "@app/lib/utils";
+ import type { Resolution } from "@app/lib/commentResolutions";
+ import { formatResolvedCaption, scrollIntoView } from "@app/lib/utils";
import CommentComponent from "@app/components/Comment.svelte";
import ExtendedTextarea from "@app/components/ExtendedTextarea.svelte";
@@ -53,6 +54,9 @@
// A single comment to ring, so a jump from elsewhere can say where it
// landed. Marks that one comment, root or reply, not the thread around it.
highlightedCommentId?: string;
+ // Who resolved a comment, for its badge to name. Looked up rather than read
+ // off the comment, which carries only the flag (see `resolutionsByComment`).
+ resolvedBy?: (commentId: string) => Resolution | undefined;
}
const {
@@ -71,8 +75,17 @@
origin,
hoverNote,
highlightedCommentId,
+ resolvedBy,
}: Props = $props();
+ function resolvedCaption(commentId: string): string | undefined {
+ const resolution = resolvedBy?.(commentId);
+ return (
+ resolution &&
+ formatResolvedCaption(resolution.author, resolution.timestamp)
+ );
+ }
+
async function toggleReply() {
showReplyForm = !showReplyForm;
if (!showReplyForm) {
@@ -200,6 +213,8 @@
id={reply.id}
author={reply.author}
caption="replied"
+ resolved={reply.resolved}
+ resolvedCaption={resolvedCaption(reply.id)}
reactions={reply.reactions}
timestamp={reply.edits[0].timestamp}
body={reply.edits.slice(-1)[0].body}
@@ -248,6 +263,8 @@
{draft}
{origin}
{hoverNote}
+ resolved={root.resolved}
+ resolvedCaption={resolvedCaption(root.id)}
id={root.id}
lastEdit={root.edits.length > 1 ? root.edits.at(-1) : undefined}
author={root.author}
@@ -265,8 +282,11 @@
+
changeCommentStatus(root.id, !root.resolved)} />
{/if}
diff --git a/src/lib/codeComments.ts b/src/lib/codeComments.ts
index 3eeaed911..40d03364c 100644
--- a/src/lib/codeComments.ts
+++ b/src/lib/codeComments.ts
@@ -4,6 +4,8 @@ import type { Embed } from "@bindings/cob/thread/Embed";
import type { Thread } from "@bindings/cob/thread/Thread";
import type { Config } from "@bindings/config/Config";
+import type { Resolution } from "@app/lib/commentResolutions";
+
/// Says where a comment lives when a view mixes comments from several places —
/// a review's own comments and comments left directly on a revision look alike
/// otherwise, but they differ in what can be done to them.
@@ -23,6 +25,10 @@ export interface CodeComments {
// Decided by the host: the protocol allows the comment author, the review
// author or the revision author, and only the host knows all three.
canResolveComment?: (commentId: string) => boolean;
+ // Who resolved a comment, for the resolved badge to name. Only the host can
+ // say: it comes from the patch's operation log rather than from the comment
+ // (see `resolutionsByComment`).
+ resolvedBy?: (commentId: string) => Resolution | undefined;
config: Config;
createComment: (
body: string,
diff --git a/src/lib/commentResolutions.ts b/src/lib/commentResolutions.ts
new file mode 100644
index 000000000..db233b203
--- /dev/null
+++ b/src/lib/commentResolutions.ts
@@ -0,0 +1,37 @@
+import type { Author } from "@bindings/cob/Author";
+import type { Operation } from "@bindings/cob/Operation";
+import type { Action } from "@bindings/cob/patch/Action";
+
+export interface Resolution {
+ author: Author;
+ timestamp: number;
+}
+
+/// Who last resolved each comment, taken from the patch's own operation log.
+///
+/// A `Comment` records only *that* it is resolved: `radicle`'s thread applies the
+/// resolve op without keeping hold of its actor, so the comment itself cannot say
+/// who. The op that did it is authored, though, so the log still can.
+///
+/// Unresolving drops the entry again, which is what leaves a comment that was
+/// resolved and then reopened without one — matching `resolved: false` on the
+/// comment. A revision's `resolves` set is deliberately not read: it records what
+/// a revision claims to address and never marks a comment resolved.
+export function resolutionsByComment(
+ activity: Operation[],
+): Map {
+ const resolutions = new Map();
+ for (const op of [...activity].sort((a, b) => a.timestamp - b.timestamp)) {
+ for (const action of op.actions) {
+ if (action.type === "review.comment.resolve") {
+ resolutions.set(action.comment, {
+ author: op.author,
+ timestamp: op.timestamp,
+ });
+ } else if (action.type === "review.comment.unresolve") {
+ resolutions.delete(action.comment);
+ }
+ }
+ }
+ return resolutions;
+}
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index d6a3db860..22b5a9e16 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -204,6 +204,10 @@ export function formatEditedCaption(author: Author, timestamp: number) {
return `${author.alias ? author.alias : truncateDid(author.did)} edited ${absoluteTimestamp(timestamp)}`;
}
+export function formatResolvedCaption(author: Author, timestamp: number) {
+ return `${author.alias ? author.alias : truncateDid(author.did)} resolved this ${absoluteTimestamp(timestamp)}`;
+}
+
export function pluralize(singular: string, count: number): string {
if (count === 1) return singular;
if (/(?:ch|sh|s|x|z)$/i.test(singular)) {
diff --git a/src/views/repo/Patch.svelte b/src/views/repo/Patch.svelte
index b2c02decf..b86c243b1 100644
--- a/src/views/repo/Patch.svelte
+++ b/src/views/repo/Patch.svelte
@@ -1546,6 +1546,7 @@
repoDelegates={repo.delegates}
review={currentReview}
{revisions}
+ {activity}
rid={repo.rid}
{status}
fromView={patchView} />