desktop: Disallow attachments when editing a draft comment

Drafts are kept in local storage and publish only their bodies, so a
file attached while editing one never reached the COB and peers saw a
broken link. The draft composer already disallowed attaching; editing
didn't.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-10 16:54:20 +01:00
parent 2ec2fecbdd
commit 0ef41cc23b
6 changed files with 48 additions and 1 deletions
@@ -5,6 +5,7 @@
import partial from "lodash/partial";
import { draftAttachmentsDisabled } from "@app/lib/codeComments";
import {
formatAnchor,
formatAnchorLines,
@@ -112,6 +113,9 @@
resolvedBy={comments.resolvedBy}
inline
draft={isDraftThread}
disableAttachments={isDraftThread
? draftAttachmentsDisabled
: undefined}
origin={comments.threadOrigins?.[thread.root.id]}
reactOnComment={isDraftThread ? undefined : comments.reactOnComment}
createReply={(comments.canReply ?? true)
+2 -1
View File
@@ -19,6 +19,7 @@
import type { CommentOwner } from "@app/lib/codeCommentActions";
import { commentActions } from "@app/lib/codeCommentActions";
import type { CodeComments } from "@app/lib/codeComments";
import { draftAttachmentsDisabled } from "@app/lib/codeComments";
import { resolutionsByComment } from "@app/lib/commentResolutions";
import { STANDALONE_COMMENTS } from "@app/lib/commentSources";
import { diffOptions } from "@app/lib/diffOptions.svelte";
@@ -525,7 +526,7 @@
// to it.)
canReply: !draftReview,
hideThreadFileHeader: true,
disableAttachments: "Publish your review to attach files",
disableAttachments: draftAttachmentsDisabled,
};
});
+5
View File
@@ -48,6 +48,8 @@
// activity timeline for the outer rail to connect to.
inline?: boolean;
draft?: boolean;
// See `ExtendedTextarea`.
disableAttachments?: boolean | string;
origin?: CommentOrigin;
// Rendered on the root comment's authorship line while it is hovered. The
// replies do not get it: it says something about the thread, not a comment.
@@ -73,6 +75,7 @@
canResolve = false,
inline = false,
draft = false,
disableAttachments,
origin,
hoverNote,
highlightedCommentId,
@@ -220,6 +223,7 @@
timestamp={reply.edits[0].timestamp}
body={reply.edits.slice(-1)[0].body}
embeds={embedMap(reply.embeds)}
{disableAttachments}
editComment={canModifyComment(reply.author.did) &&
editComment?.bind(null, reply.id)}
reactOnComment={reactOnComment?.bind(null, reply.id)}
@@ -274,6 +278,7 @@
timestamp={root.edits.slice(-1)[0].timestamp}
body={root.edits.slice(-1)[0].body}
embeds={embedMap(root.embeds)}
{disableAttachments}
editComment={canModifyComment(root.author.did) &&
editComment?.bind(null, root.id)}
reactOnComment={reactOnComment?.bind(null, root.id)}
+5
View File
@@ -77,3 +77,8 @@ export interface CodeComments {
rid: string;
threads: Thread<CodeLocation>[];
}
// Drafts are kept in local storage and publish only their bodies. An
// uploaded file stays unreferenced in the repo until a COB lists it, so
// the node's `git gc` can prune it, and peers never receive it.
export const draftAttachmentsDisabled = "Publish your review to attach files";
+1
View File
@@ -210,6 +210,7 @@ export const draftReviewStorage = {
});
},
// Draft comments have no embeds, see `draftAttachmentsDisabled`.
addComment(
id: string,
comment: {