Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-5391: unify upload placeholder UI (#6025)

Naiyuan Qing18adb20c149f
diff --git a/packages/core/drafts/draft-upload.test.ts b/packages/core/drafts/draft-upload.test.ts
index ffcca38a3e..b25c1b8abf 100644
--- a/packages/core/drafts/draft-upload.test.ts
+++ b/packages/core/drafts/draft-upload.test.ts
@@ -64,12 +64,13 @@ describe("draft-upload helpers", () => {
expect(uploadedAttachments(normalized).map((a) => a.id)).toEqual(["att-1"]);
});
- it("coerces an `uploading` placeholder to `interrupted` on load", () => {
- const normalized = normalizeStoredUploads([pending("a")]);
- expect(normalized).toHaveLength(1);
- expect(normalized[0]?.status).toBe("interrupted");
- // The bytes are gone, so it is NOT a bindable attachment.
- expect(uploadedAttachments(normalized)).toEqual([]);
+ it("drops an `uploading` placeholder on load", () => {
+ // The bytes were never persisted, so this upload can neither resume nor
+ // be retried, and no surface can act on it: a placeholder is never
+ // serialised, so the document has no node for it either. Keeping the
+ // record only held an otherwise-empty draft alive for the full TTL. The
+ // attachment's absence from the body is what tells the user to re-attach.
+ expect(normalizeStoredUploads([pending("a")])).toEqual([]);
});
it("keeps failed/interrupted/uploaded placeholders across load", () => {
diff --git a/packages/core/drafts/draft-upload.ts b/packages/core/drafts/draft-upload.ts
index 2c83eacbd8..8951219327 100644
--- a/packages/core/drafts/draft-upload.ts
+++ b/packages/core/drafts/draft-upload.ts
@@ -120,8 +120,13 @@ export function normalizeStoredUploads(raw: unknown): DraftUpload[] {
for (const item of raw) {
if (isDraftUploadShape(item)) {
if (item.status === "uploading") {
- const { clientUploadId, filename, size, contentType } = item;
- out.push({ clientUploadId, status: "interrupted", filename, size, contentType });
+ // Dropped, not coerced to `interrupted`. The bytes were never
+ // persisted, so this upload can neither resume nor be retried — and
+ // the document has no node for it either, because a placeholder is
+ // never serialised. Keeping a record no surface can act on only kept
+ // an otherwise-empty draft alive for the full TTL. The absence of the
+ // attachment in the body is what tells the user to attach it again.
+ continue;
} else if (item.status === "uploaded") {
// Trust the persisted attachment only if it still looks like one.
if (looksLikeAttachment((item as UploadedDraftUpload).attachment)) {
diff --git a/packages/core/issues/stores/comment-draft-store.test.ts b/packages/core/issues/stores/comment-draft-store.test.ts
index 341dc8ca2e..c2a9d7b36f 100644
--- a/packages/core/issues/stores/comment-draft-store.test.ts
+++ b/packages/core/issues/stores/comment-draft-store.test.ts
@@ -202,7 +202,7 @@ describe("comment draft store — prune on rehydrate", () => {
expect(state.getAttachments("new:issue-1")).toEqual([]);
});
- it("coerces an upload that was in flight at reload into an interrupted placeholder", async () => {
+ it("drops an upload that was in flight at reload", async () => {
seed({
"new:issue-1": {
content: "",
@@ -218,11 +218,12 @@ describe("comment draft store — prune on rehydrate", () => {
await flush();
const state = useCommentDraftStore.getState();
- // The placeholder survives (so the UI can show "interrupted"), but its
- // bytes are gone — it is NOT a bindable attachment.
- const uploads = state.getUploads("new:issue-1");
- expect(uploads.map((u) => u.status)).toEqual(["interrupted"]);
+ // The bytes are gone and nothing can act on the record: no surface renders
+ // it and the document has no node for it (placeholders are never
+ // serialised). Keeping it only held this empty draft alive for the TTL.
+ expect(state.getUploads("new:issue-1")).toEqual([]);
expect(state.getAttachments("new:issue-1")).toEqual([]);
+ expect(state.getDraft("new:issue-1")).toBeFalsy();
});
});
diff --git a/packages/core/issues/stores/draft-store.test.ts b/packages/core/issues/stores/draft-store.test.ts
index cb011f8bc8..ed7be67c8e 100644
--- a/packages/core/issues/stores/draft-store.test.ts
+++ b/packages/core/issues/stores/draft-store.test.ts
@@ -272,7 +272,7 @@ describe("issue draft store — legacy rehydrate", () => {
expect(draft.activeMode).toBe("agent");
});
- it("normalizes pre-L2 shared attachments and coerces stale uploading placeholders", async () => {
+ it("normalizes pre-L2 shared attachments and drops stale uploading placeholders", async () => {
localStorage.setItem(
"multica_issue_draft:gamma",
JSON.stringify({
@@ -311,9 +311,10 @@ describe("issue draft store — legacy rehydrate", () => {
await flush();
const { attachments } = useIssueDraftStore.getState().draft.shared;
- expect(attachments.map((u) => u.status)).toEqual(["uploaded", "interrupted"]);
+ // The legacy row is adopted; the in-flight one is dropped — it can neither
+ // resume nor be shown, so keeping it would only bloat the draft.
+ expect(attachments.map((u) => u.status)).toEqual(["uploaded"]);
expect(attachments[0]?.filename).toBe("old.png");
- expect(attachments[1]?.filename).toBe("mid.png");
});
});
diff --git a/packages/ui/components/common/submit-button.tsx b/packages/ui/components/common/submit-button.tsx
index 2212a87de1..08fde2faba 100644
--- a/packages/ui/components/common/submit-button.tsx
+++ b/packages/ui/components/common/submit-button.tsx
@@ -81,7 +81,12 @@ function SubmitButton({
onClick={onClick}
aria-label={ariaLabel}
>
- {loading ? (
+ {loading || busy ? (
+ // `busy` spins too, not just greys out: an upload can be running with
+ // nothing else on screen to explain the disabled control (a reopened
+ // composer is still rebuilding its placeholder, or the user deleted
+ // it). A spinner says "waiting on something" without a hover; the
+ // tooltip says what.
<Loader2 className="animate-spin" aria-hidden="true" />
) : (
<ArrowUp aria-hidden="true" />
diff --git a/packages/views/chat/components/chat-input.test.tsx b/packages/views/chat/components/chat-input.test.tsx
index aeb2a3520d..788de9d838 100644
--- a/packages/views/chat/components/chat-input.test.tsx
+++ b/packages/views/chat/components/chat-input.test.tsx
@@ -17,6 +17,11 @@ const mockApiUploadFile = vi.hoisted(() => vi.fn());
// delivers into the live editor through this method.
const insertMarkdownSpy = vi.hoisted(() => vi.fn());
+// The real handle mints an id when it inserts the placeholder and hands it to
+// the uploader, which adopts it as the draft `clientUploadId`. Mocks must do
+// the same or the two records drift apart only in tests.
+let mockUploadIdSeq = 0;
+
vi.mock("@multica/core/api", () => ({
api: { uploadFile: mockApiUploadFile },
}));
@@ -80,7 +85,7 @@ vi.mock("../../editor", async () => ({
value?: string;
onUpdate?: (md: string) => void;
placeholder?: string;
- onUploadFile?: (file: File) => Promise<UploadResult | null>;
+ onUploadFile?: (file: File, uploadId: string) => Promise<UploadResult | null>;
onUploadingChange?: (uploading: boolean) => void;
mentionMode?: string;
mentionContextItems?: unknown[];
@@ -119,7 +124,7 @@ vi.mock("../../editor", async () => ({
// the host learns about it through onUploadingChange, not by polling.
if (uploadingRef.current === 1) onUploadingChange?.(true);
try {
- const result = await onUploadFile?.(file);
+ const result = await onUploadFile?.(file, `mock-upload-${++mockUploadIdSeq}`);
if (result) {
// Mirror the real editor (uploadAndInsertFile in
// packages/views/editor/extensions/file-upload.ts): the
@@ -139,6 +144,11 @@ vi.mock("../../editor", async () => ({
}
},
hasActiveUploads: () => uploadingRef.current > 0,
+ // Placeholder rebuild contract: the real handle draws a card for an
+ // upload the document is not showing and reports whether it landed.
+ // Mocks track ids only — no document to draw into.
+ insertUploadPlaceholder: () => true,
+ settleUploadPlaceholder: () => false,
insertMarkdownAtEnd: (md: string) => {
insertMarkdownSpy(md);
valueRef.current = `${valueRef.current}\n\n${md}`.trim();
diff --git a/packages/views/chat/components/chat-input.tsx b/packages/views/chat/components/chat-input.tsx
index 1265a9d58b..fca86d38a9 100644
--- a/packages/views/chat/components/chat-input.tsx
+++ b/packages/views/chat/components/chat-input.tsx
@@ -17,7 +17,6 @@ import {
useCoordinatedUploads,
type UploadDraftBinding,
} from "../../editor/use-coordinated-uploads";
-import { ComposerUploadChips } from "../../issues/components/composer-upload-chips";
import { SubmitButton } from "@multica/ui/components/common/submit-button";
import { ChatAddMenu } from "./chat-add-menu";
import { useChatStore, DRAFT_NEW_SESSION } from "@multica/core/chat";
@@ -285,7 +284,6 @@ export function ChatInput({
uploads: draftUploads,
attachments: draftAttachments,
handleUpload,
- removeUpload,
gate,
} = useCoordinatedUploads(uploadBinding, storeUploads, {}, uploadGate, editorRef, {
resolveUploadTarget: () => makeUploadBinding(editorDraftKeyRef.current),
@@ -648,13 +646,6 @@ export function ChatInput({
showBubbleMenu
/>
</div>
- {draftUploads.some((u) => u.status !== "uploaded") && (
- <ComposerUploadChips
- uploads={draftUploads}
- onRemove={removeUpload}
- className="px-3 pb-1"
- />
- )}
{(uploadEnabled || projectSelectionEnabled || leftAdornment) && (
<div className="absolute bottom-1.5 left-1.5 flex items-center gap-1">
{(uploadEnabled || projectSelectionEnabled) && (
diff --git a/packages/views/editor/content-editor.test.tsx b/packages/views/editor/content-editor.test.tsx
index fd9ceb3c00..98b2028b42 100644
--- a/packages/views/editor/content-editor.test.tsx
+++ b/packages/views/editor/content-editor.test.tsx
@@ -460,8 +460,9 @@ describe("ContentEditor", () => {
// `normalizeMarkdown` (which would `trimEnd()`). This pins down that the
// F2a/F3 dedupe refactor preserved the method's exact return value —
// trailing blank lines included — instead of folding it into the trimming
- // helper. `stripBlobUrls` (unmocked here) only strips blob image markdown,
- // so the trailing newlines survive untouched.
+ // helper. It used to also pass through `stripBlobUrls`; that wrapper is
+ // gone (an in-flight placeholder no longer serialises at all), and the
+ // trailing newlines still survive untouched.
editorState.markdown = "kept body\n\n";
const ref = createRef<ContentEditorRef>();
diff --git a/packages/views/editor/content-editor.tsx b/packages/views/editor/content-editor.tsx
index be13c70333..04b39919b5 100644
--- a/packages/views/editor/content-editor.tsx
+++ b/packages/views/editor/content-editor.tsx
@@ -57,7 +57,11 @@ import {
import type { MentionItem } from "./extensions/mention-suggestion";
import type { IssueIdentifierResolver } from "./extensions/issue-identifier-autolink";
import { createEditorExtensions } from "./extensions";
-import { uploadAndInsertFile } from "./extensions/file-upload";
+import {
+ uploadAndInsertFile,
+ insertUploadPlaceholder,
+ settleUploadNode,
+} from "./extensions/file-upload";
import { configStore } from "@multica/core/config";
import { preprocessMarkdown } from "./utils/preprocess";
import { repairEmptyListItems } from "./utils/repair-list-items";
@@ -74,21 +78,22 @@ import "./styles/index.css";
// Helpers
// ---------------------------------------------------------------------------
-/** Blob URLs (blob:http://…) are process-local and expire on reload. Strip them
- * from serialised markdown so they never reach the database. */
-const BLOB_IMAGE_RE = /!\[[^\]]*\]\(blob:[^)]*\)\n?/g;
-
-function stripBlobUrls(md: string): string {
- return md.replace(BLOB_IMAGE_RE, "");
-}
-
-/** Canonical comparison form for a markdown string: drop process-local blob
- * URLs and trailing blank lines so both sides of a dirty check compare
- * like-for-like. One definition for the normalization rule — a future tweak
- * (e.g. stripping another ephemeral token) lands here instead of in the
- * several call sites it used to be copy-pasted across. */
+/** Canonical comparison form for a markdown string: drop the blank lines a
+ * block leaves behind at either end, so both sides of a dirty check compare
+ * like-for-like.
+ *
+ * This used to also strip `blob:` image lines with a regex, because an
+ * in-flight image serialised its process-local blob URL into the body. That
+ * is now impossible at the source: the image and fileCard `renderMarkdown`
+ * implementations emit nothing while `attrs.uploading` is set, so a
+ * placeholder never becomes text that has to be scrubbed back out.
+ *
+ * Leading blank lines are trimmed too, not just trailing: a placeholder in
+ * the FIRST block leaves its blank line at the head of the document, and a
+ * draft that opens with an empty line is the same content as one that does
+ * not. (The old regex left one such newline behind for the same reason.) */
function normalizeMarkdown(md: string): string {
- return stripBlobUrls(md).trimEnd();
+ return md.trim();
}
/** `normalizeMarkdown` applied to the live editor's serialized content. */
@@ -120,7 +125,14 @@ interface ContentEditorBaseProps {
debounceMs?: number;
onSubmit?: () => void;
onBlur?: () => void;
- onUploadFile?: (file: File) => Promise<UploadResult | null>;
+ /**
+ * Upload transport. `uploadId` is minted by the editor when it inserts the
+ * placeholder node; a host backed by a draft store MUST adopt it as the
+ * upload's `clientUploadId` so both records share one identity — that is
+ * what lets a settle find its placeholder in a document a later mount
+ * rebuilt. Hosts with no persistence may ignore it.
+ */
+ onUploadFile?: (file: File, uploadId: string) => Promise<UploadResult | null>;
/**
* Character count above which a plain-text paste is uploaded as a
* `pasted-text.txt` attachment instead of being inserted as body text.
@@ -266,6 +278,29 @@ interface ContentEditorRef {
* losing the fragment.
*/
insertMarkdownAtEnd: (markdown: string) => boolean;
+ /**
+ * Draw a placeholder for an upload this document is not showing yet, and
+ * report whether it landed.
+ *
+ * A composer that reopens over an upload a previous mount started has the
+ * draft's record of it but no node — placeholders are never serialised, so
+ * they die with the document that drew them. Without this the user faces a
+ * composer that looks idle while a send gate quietly blocks on the upload.
+ * Returns false when the Tiptap instance is not up yet (the handle exists
+ * from first commit, the instance arrives a passive effect later), so the
+ * caller can retry rather than assume.
+ */
+ insertUploadPlaceholder: (upload: {
+ uploadId: string;
+ filename: string;
+ size?: number;
+ }) => boolean;
+ /**
+ * Turn a placeholder into the finished attachment, in place. False when this
+ * document holds no node for the id — the caller then falls back to
+ * appending the link.
+ */
+ settleUploadPlaceholder: (uploadId: string, result: UploadResult) => boolean;
/**
* Cancel the pending debounced `onUpdate` and hand its markdown back to the
* caller instead of firing it. Returns null when nothing is pending.
@@ -343,7 +378,7 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
const onReadyRef = useRef(onReady);
const onUploadingChangeRef = useRef(onUploadingChange);
const onUploadFileRef = useRef<
- ((file: File) => Promise<UploadResult | null>) | undefined
+ ((file: File, uploadId: string) => Promise<UploadResult | null>) | undefined
>(undefined);
// Same reasoning as placeholderRef below: the extension array is built once
// at mount, so the paste-as-file threshold is read through a ref to stay
@@ -377,8 +412,8 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
// stable across renders the way the original passthrough did.
const wrappedOnUploadFile = useMemo(() => {
if (!onUploadFile) return undefined;
- return async (file: File): Promise<UploadResult | null> => {
- const result = await onUploadFile(file);
+ return async (file: File, uploadId: string): Promise<UploadResult | null> => {
+ const result = await onUploadFile(file, uploadId);
// Only track attachments that carry a persisted id — the no-workspace
// avatar branch returns an id-less record that the resolver can't key
// off of, and tracking it would just bloat memory without helping
@@ -796,9 +831,12 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
}, [editor, placeholderText]);
useImperativeHandle(ref, () => ({
- // Intentionally NOT routed through `normalizeMarkdown` — this refactor
- // must preserve the exact current return value (no `trimEnd`).
- getMarkdown: () => stripBlobUrls(editor?.getMarkdown() ?? ""),
+ // Intentionally NOT routed through `normalizeMarkdown` — see the "stays
+ // untrimmed" safety net in content-editor.test.tsx. It used to also pass
+ // through `stripBlobUrls`; that wrapper is gone because an in-flight
+ // placeholder no longer serialises at all, which is strictly stronger
+ // than scrubbing it back out afterwards.
+ getMarkdown: () => editor?.getMarkdown() ?? "",
clearContent: () => {
editor?.commands.clearContent();
},
@@ -834,6 +872,14 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
uploadAndInsertFile(editor, file, onUploadFileRef.current, endPos);
},
hasActiveUploads: () => (editor ? hasUploadingNode(editor) : false),
+ insertUploadPlaceholder: (upload) => {
+ if (!editor || editor.isDestroyed) return false;
+ return insertUploadPlaceholder(editor, upload);
+ },
+ settleUploadPlaceholder: (uploadId, result) => {
+ if (!editor || editor.isDestroyed) return false;
+ return settleUploadNode(editor, uploadId, result);
+ },
insertMarkdownAtEnd: (markdown: string) => {
if (!editor || editor.isDestroyed) return false;
editor.commands.insertContentAt(editor.state.doc.content.size, markdown, {
diff --git a/packages/views/editor/extensions/file-card-markdown.test.ts b/packages/views/editor/extensions/file-card-markdown.test.ts
index 17a20c9331..d27e85f525 100644
--- a/packages/views/editor/extensions/file-card-markdown.test.ts
+++ b/packages/views/editor/extensions/file-card-markdown.test.ts
@@ -41,6 +41,54 @@ describe("ImageExtension.renderMarkdown", () => {
// ---------------------------------------------------------------------------
// file-card tokenizer round-trip
// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// A placeholder is not content
+// ---------------------------------------------------------------------------
+// The document IS the persisted draft body, so anything renderMarkdown emits
+// for an in-flight upload becomes text that outlives the upload. Both node
+// types must stay silent until they hold a real URL.
+describe("in-flight placeholders never serialise", () => {
+ it("emits nothing for an uploading fileCard", () => {
+ // Serialising this used to write `!file[x.pdf]()` into the draft — a line
+ // the tokenizer below cannot parse back, so it survived as dead literal
+ // text and shipped with the comment.
+ expect(
+ fileCardRenderMarkdown({
+ attrs: { filename: "x.pdf", href: "", uploading: true } as never,
+ }),
+ ).toBe("");
+ });
+
+ it("emits nothing for a fileCard with no href, even when not marked uploading", () => {
+ expect(
+ fileCardRenderMarkdown({ attrs: { filename: "x.pdf", href: "" } as never }),
+ ).toBe("");
+ });
+
+ it("emits nothing for an uploading image", () => {
+ // Its src is a process-local blob: URL that dies on reload. This replaces
+ // the BLOB_IMAGE_RE scrub ContentEditor used to run after the fact.
+ expect(
+ imageRenderMarkdown({
+ attrs: { src: "blob:http://localhost/abc", alt: "x.png", uploading: true } as never,
+ }),
+ ).toBe("");
+ });
+
+ it("emits normally once the upload settled into a real URL", () => {
+ expect(
+ fileCardRenderMarkdown({
+ attrs: { filename: "x.pdf", href: "/api/attachments/a1/download", uploading: false } as never,
+ }),
+ ).toBe("!file[x.pdf](/api/attachments/a1/download)");
+ expect(
+ imageRenderMarkdown({
+ attrs: { src: "/api/attachments/a2/download", alt: "x.png", uploading: false } as never,
+ }),
+ ).toBe("![x.png](/api/attachments/a2/download)");
+ });
+});
+
describe("file-card tokenizer", () => {
it("round-trips a filename with all special chars", () => {
const filename = "report[final](v2)\\draft.pdf";
diff --git a/packages/views/editor/extensions/file-card.tsx b/packages/views/editor/extensions/file-card.tsx
index 9e554f81b7..292f2d11df 100644
--- a/packages/views/editor/extensions/file-card.tsx
+++ b/packages/views/editor/extensions/file-card.tsx
@@ -133,7 +133,14 @@ export const FileCardExtension = Node.create({
return helpers.createNode("fileCard", token.attributes);
},
renderMarkdown: (node: any) => {
- const { href, filename } = node.attrs || {};
+ const { href, filename, uploading } = node.attrs || {};
+ // An in-flight placeholder is not content. The document IS the draft body
+ // (getMarkdown → setDraft), so serialising it would persist `!file[x](
+ // )` — a line the tokenizer above cannot parse back, leaving dead literal
+ // text in the draft that outlives the upload and ships with the comment.
+ // Emitting nothing is the whole guarantee: the card becomes content the
+ // moment it has a real href, and never before.
+ if (uploading === true || !href) return "";
return `!file[${escapeMarkdownLabel(filename || "file")}](${href})`;
},
diff --git a/packages/views/editor/extensions/file-upload.test.ts b/packages/views/editor/extensions/file-upload.test.ts
index 93f32d9900..c7cf8dbade 100644
--- a/packages/views/editor/extensions/file-upload.test.ts
+++ b/packages/views/editor/extensions/file-upload.test.ts
@@ -9,6 +9,8 @@ import { FileCardExtension } from "./file-card";
import {
createFileUploadExtension,
uploadAndInsertFile,
+ insertUploadPlaceholder,
+ settleUploadNode,
pastedTextSource,
PASTED_TEXT_FILENAME,
} from "./file-upload";
@@ -28,6 +30,7 @@ function makeEditor() {
extensions: [
StarterKit,
ImageExtension,
+ FileCardExtension,
Markdown.configure({ indentation: { style: "space", size: 3 } }),
],
});
@@ -159,13 +162,16 @@ describe("uploadAndInsertFile", () => {
const uploadTask = uploadAndInsertFile(editor, file, handler);
- expect(handler).toHaveBeenCalledWith(file);
+ expect(handler).toHaveBeenCalledWith(file, expect.any(String));
expect(editor.state.selection.$from.parent.type.name).toBe("paragraph");
editor.commands.insertContent("after");
- expect(editor.getMarkdown().trimEnd()).toBe(
- [`![photo.png](${BLOB_URL})`, "", "after"].join("\n"),
- );
+ // The blob preview is visible in the document but is NOT content: the
+ // document is the persisted draft body, and a process-local blob: URL
+ // would outlive the upload as a dead link. It becomes markdown only once
+ // the swap below gives it a real URL.
+ expect(editor.getMarkdown()).not.toContain(BLOB_URL);
+ expect(editor.getMarkdown().trim()).toBe("after");
upload.resolve(
makeUpload({ id: "attachment-1", link: FINAL_URL, filename: "photo.png" }),
@@ -257,6 +263,82 @@ describe("uploadAndInsertFile", () => {
});
});
+describe("one identity from node to draft", () => {
+ it("hands the node's uploadId to the uploader, so both records name the same upload", async () => {
+ const editor = makeEditor();
+ const handler = vi.fn(async (_file: File, _uploadId: string) => null);
+ await uploadAndInsertFile(editor, new File(["x"], "photo.png", { type: "image/png" }), handler);
+ const [, uploadId] = handler.mock.calls[0]!;
+ expect(typeof uploadId).toBe("string");
+ expect(uploadId).toBeTruthy();
+ });
+
+ it("settles a placeholder a DIFFERENT document drew, by id alone", async () => {
+ // The reopen case: this editor never ran the upload, it only rebuilt the
+ // card from the draft record. Only a shared id can connect the two.
+ const editor = makeEditor();
+ expect(
+ insertUploadPlaceholder(editor, { uploadId: "u-1", filename: "report.pdf", size: 12 }),
+ ).toBe(true);
+ expect(editor.getMarkdown()).not.toContain("report.pdf");
+
+ expect(
+ settleUploadNode(
+ editor,
+ "u-1",
+ makeUpload({
+ id: "att-1",
+ link: "/api/attachments/att-1/download",
+ filename: "report.pdf",
+ content_type: "application/pdf",
+ }),
+ ),
+ ).toBe(true);
+ expect(editor.getMarkdown()).toContain("!file[report.pdf](/api/attachments/att-1/download)");
+ });
+
+ it("promotes a rebuilt card to an image when that is what arrived", async () => {
+ // The rebuild path has only a filename, never bytes, so it always draws a
+ // card; the settle is where the document learns it was an image.
+ const editor = makeEditor();
+ insertUploadPlaceholder(editor, { uploadId: "u-2", filename: "shot.png" });
+ settleUploadNode(
+ editor,
+ "u-2",
+ makeUpload({
+ id: "att-2",
+ link: "/api/attachments/att-2/download",
+ filename: "shot.png",
+ content_type: "image/png",
+ }),
+ );
+ expect(editor.getMarkdown()).toContain("![shot.png](/api/attachments/att-2/download)");
+ });
+
+ it("reports false when this document holds no node for the id", () => {
+ const editor = makeEditor();
+ expect(
+ settleUploadNode(
+ editor,
+ "nope",
+ makeUpload({ id: "a", link: "/l", filename: "f", content_type: "application/pdf" }),
+ ),
+ ).toBe(false);
+ });
+
+ it("is idempotent, so a retrying caller cannot draw two cards", () => {
+ const editor = makeEditor();
+ expect(insertUploadPlaceholder(editor, { uploadId: "u-3", filename: "a.pdf" })).toBe(true);
+ expect(insertUploadPlaceholder(editor, { uploadId: "u-3", filename: "a.pdf" })).toBe(true);
+ let cards = 0;
+ editor.state.doc.descendants((n) => {
+ if (n.type.name === "fileCard") cards++;
+ return undefined;
+ });
+ expect(cards).toBe(1);
+ });
+});
+
describe("paste-as-file", () => {
const THRESHOLD = 20;
diff --git a/packages/views/editor/extensions/file-upload.ts b/packages/views/editor/extensions/file-upload.ts
index f911532496..27d2148022 100644
--- a/packages/views/editor/extensions/file-upload.ts
+++ b/packages/views/editor/extensions/file-upload.ts
@@ -3,42 +3,118 @@ import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
import type { UploadResult } from "@multica/core/hooks/use-file-upload";
import { createSafeId } from "@multica/core/utils";
-/** Find and remove a fileCard node by uploadId. */
-
-function removeUploadingFileCard(editor: any, uploadId: string) {
- const { tr } = editor.state;
- let deleted = false;
+/**
+ * Locate this upload's placeholder node, whichever shape it took.
+ *
+ * `uploadId` is the SAME value the draft store knows as `clientUploadId` —
+ * minted once in {@link uploadAndInsertFile} (or by the rebuild path) and
+ * carried by both records. One identity is what lets a settle find its own
+ * node in a document that a different mount rebuilt.
+ */
+
+function findUploadNode(editor: any, uploadId: string): { pos: number; node: any } | null {
+ let found: { pos: number; node: any } | null = null;
editor.state.doc.descendants((node: any, pos: number) => {
- if (deleted) return false;
- if (node.type.name === "fileCard" && node.attrs.uploadId === uploadId) {
- tr.delete(pos, pos + node.nodeSize);
- deleted = true;
+ if (found) return false;
+ if (
+ (node.type.name === "fileCard" || node.type.name === "image") &&
+ node.attrs.uploadId === uploadId
+ ) {
+ found = { pos, node };
return false;
}
return undefined;
});
- if (deleted) editor.view.dispatch(tr);
+ return found;
}
-/** Update a fileCard node from uploading state to final state with real URL. */
-
-function finalizeFileCard(editor: any, uploadId: string, href: string) {
- const { tr } = editor.state;
- let updated = false;
- editor.state.doc.descendants((node: any, nodePos: number) => {
- if (updated) return false;
- if (node.type.name === "fileCard" && node.attrs.uploadId === uploadId) {
- tr.setNodeMarkup(nodePos, undefined, {
- ...node.attrs,
- href,
- uploading: false,
- });
- updated = true;
- return false;
- }
- return undefined;
- });
- if (updated) editor.view.dispatch(tr);
+/** Drop this upload's placeholder node, whichever shape it took. */
+
+export function removeUploadNode(editor: any, uploadId: string): boolean {
+ const hit = findUploadNode(editor, uploadId);
+ if (!hit) return false;
+ editor.view.dispatch(editor.state.tr.delete(hit.pos, hit.pos + hit.node.nodeSize));
+ return true;
+}
+
+/**
+ * Turn this upload's placeholder into the finished attachment, in place.
+ *
+ * Returns false when no node carries the id — the caller then knows the
+ * document is not showing this upload and can fall back to appending.
+ *
+ * A fileCard settling into an image swaps node TYPE, not just attrs: the
+ * rebuild path cannot know an upload will turn out to be an image (it has no
+ * bytes, only a filename), so it always writes a card and this is where the
+ * document catches up with what actually arrived.
+ */
+
+export function settleUploadNode(editor: any, uploadId: string, result: UploadResult): boolean {
+ const hit = findUploadNode(editor, uploadId);
+ if (!hit) return false;
+ // Persist the stable per-attachment URL, never the short-lived signed one
+ // (MUL-3130). `link` is the fallback for the no-workspace avatar branch.
+ const href = result.markdownLink || result.link;
+ const isImage = (result.content_type ?? "").startsWith("image/");
+ const tr = editor.state.tr;
+
+ if (hit.node.type.name === "image") {
+ tr.setNodeMarkup(hit.pos, undefined, {
+ ...hit.node.attrs,
+ src: href,
+ alt: result.filename,
+ uploading: false,
+ uploadId: null,
+ });
+ } else if (isImage) {
+ tr.replaceWith(
+ hit.pos,
+ hit.pos + hit.node.nodeSize,
+ editor.schema.nodes.image.create({ src: href, alt: result.filename, uploading: false }),
+ );
+ } else {
+ tr.setNodeMarkup(hit.pos, undefined, {
+ ...hit.node.attrs,
+ href,
+ uploading: false,
+ uploadId: null,
+ });
+ }
+ editor.view.dispatch(tr);
+ return true;
+}
+
+/**
+ * Write a placeholder for an upload this document is not showing yet.
+ *
+ * Used when a composer reopens over an upload a previous mount started: the
+ * bytes are gone with that mount, so there is no preview to render and the
+ * card is all we can honestly draw — {@link settleUploadNode} promotes it to
+ * an image if that is what arrives.
+ */
+
+export function insertUploadPlaceholder(
+ editor: any,
+ upload: { uploadId: string; filename: string; size?: number },
+): boolean {
+ // Idempotent: already drawn counts as success, so a caller retrying until
+ // it lands cannot be fooled into retrying forever by its own first insert.
+ if (findUploadNode(editor, upload.uploadId)) return true;
+ const endPos = editor.state.doc.content.size;
+ editor
+ .chain()
+ .insertContentAt(endPos, {
+ type: "fileCard",
+ attrs: {
+ filename: upload.filename,
+ href: "",
+ fileSize: upload.size ?? 0,
+ uploading: true,
+ uploadId: upload.uploadId,
+ },
+ })
+ .run();
+ return true;
}
export function findImagePosBySrc(editor: any, src: string): number | null {
@@ -55,17 +131,6 @@ export function findImagePosBySrc(editor: any, src: string): number | null {
return imagePos;
}
-function removeImageBySrc(editor: any, src: string) {
- const imagePos = findImagePosBySrc(editor, src);
- if (imagePos === null) return;
-
- const imageNode = editor.state.doc.nodeAt(imagePos);
- if (!imageNode) return;
-
- const tr = editor.state.tr.delete(imagePos, imagePos + imageNode.nodeSize);
- editor.view.dispatch(tr);
-}
-
/**
* Read an image's intrinsic pixel dimensions off-thread. Returns null when the
* decode fails or the API is unavailable (e.g. jsdom in tests, where
@@ -136,14 +201,18 @@ export async function uploadAndInsertFile(
editor: any,
file: File,
- handler: (file: File) => Promise<UploadResult | null>,
+ handler: (file: File, uploadId: string) => Promise<UploadResult | null>,
pos?: number,
) {
const isImage = file.type.startsWith("image/");
+ // One id for both records. The handler adopts it as the draft's
+ // `clientUploadId`, so a settle arriving at a different mount can still find
+ // the node this one drew — see findUploadNode.
+ const uploadId = createSafeId();
if (isImage) {
const blobUrl = URL.createObjectURL(file);
- const imgAttrs = { src: blobUrl, alt: file.name, uploading: true };
+ const imgAttrs = { src: blobUrl, alt: file.name, uploading: true, uploadId };
if (pos !== undefined) {
editor.chain().focus().insertContentAt(pos, { type: "image", attrs: imgAttrs }).run();
} else {
@@ -157,42 +226,21 @@ export async function uploadAndInsertFile(
void applyImageDimensions(editor, file, blobUrl);
try {
- const result = await handler(file);
+ const result = await handler(file, uploadId);
// The upload outlives the mount (coordinator-owned, MUL-5181): by the
// time it settles this editor may be destroyed. Dispatching against a
// destroyed EditorView throws, and the catch would dispatch again —
// the write-back path owns delivery for dead editors, not this swap.
if (editor.isDestroyed) return;
- if (result) {
- const imagePos = findImagePosBySrc(editor, blobUrl);
- const imageNode = imagePos === null ? null : editor.state.doc.nodeAt(imagePos);
- if (imagePos !== null && imageNode) {
- const tr = editor.state.tr.setNodeMarkup(imagePos, undefined, {
- ...imageNode.attrs,
- // Persist the stable per-attachment URL into markdown so
- // the comment doesn't capture a short-lived signed URL
- // (MUL-3130). Falls back to `link` for the no-workspace
- // avatar branch where there's no attachment-row id; that
- // path is unreachable from comment/issue editors but the
- // fallback keeps the contract consistent for any caller
- // that drops in without an issue context.
- src: result.markdownLink || result.link,
- alt: result.filename,
- uploading: false,
- });
- editor.view.dispatch(tr);
- }
- } else {
- removeImageBySrc(editor, blobUrl);
- }
+ if (result) settleUploadNode(editor, uploadId, result);
+ else removeUploadNode(editor, uploadId);
} catch {
- if (!editor.isDestroyed) removeImageBySrc(editor, blobUrl);
+ if (!editor.isDestroyed) removeUploadNode(editor, uploadId);
} finally {
URL.revokeObjectURL(blobUrl);
}
} else {
// Non-image: insert skeleton fileCard → upload → finalize with real URL
- const uploadId = createSafeId();
const cardAttrs = { filename: file.name, href: "", fileSize: file.size, uploading: true, uploadId };
const insertContent = { type: "fileCard", attrs: cardAttrs };
if (pos !== undefined) {
@@ -202,17 +250,14 @@ export async function uploadAndInsertFile(
}
try {
- const result = await handler(file);
+ const result = await handler(file, uploadId);
// See the image branch: a settle after this editor's destroy must not
// dispatch against the dead EditorView.
if (editor.isDestroyed) return;
- if (result) {
- finalizeFileCard(editor, uploadId, result.markdownLink || result.link);
- } else {
- removeUploadingFileCard(editor, uploadId);
- }
+ if (result) settleUploadNode(editor, uploadId, result);
+ else removeUploadNode(editor, uploadId);
} catch {
- if (!editor.isDestroyed) removeUploadingFileCard(editor, uploadId);
+ if (!editor.isDestroyed) removeUploadNode(editor, uploadId);
}
}
}
@@ -258,7 +303,9 @@ export function pastedTextSource(file: File): string | undefined {
}
export function createFileUploadExtension(
- onUploadFileRef: React.RefObject<((file: File) => Promise<UploadResult | null>) | undefined>,
+ onUploadFileRef: React.RefObject<
+ ((file: File, uploadId: string) => Promise<UploadResult | null>) | undefined
+ >,
/**
* Character count above which a plain-text paste is uploaded as a .txt
* attachment instead of being inserted into the document. A ref because the
diff --git a/packages/views/editor/extensions/index.ts b/packages/views/editor/extensions/index.ts
index 9cc4757a05..4f5adb4a72 100644
--- a/packages/views/editor/extensions/index.ts
+++ b/packages/views/editor/extensions/index.ts
@@ -76,6 +76,14 @@ export const ImageExtension = Image.extend({
attrs.uploading ? { "data-uploading": "" } : {},
parseHTML: (el: HTMLElement) => el.hasAttribute("data-uploading"),
},
+ // The upload this placeholder belongs to — the same value the draft
+ // store knows as `clientUploadId`. Lets a settle arriving at a mount
+ // that did not start the upload find the node to replace. Render-only,
+ // and cleared once the node holds a real URL.
+ uploadId: {
+ default: null,
+ rendered: false,
+ },
// Intrinsic pixel dimensions, captured on upload (file-upload.ts). The
// browser uses width/height on <img> to compute aspect-ratio and reserve
// the box before the image decodes, so inserting an image causes no
@@ -107,6 +115,11 @@ export const ImageExtension = Image.extend({
},
renderMarkdown: (node: any) => {
const src = node.attrs?.src || "";
+ // Same rule as fileCard: an in-flight placeholder is not content. Its src
+ // is a process-local `blob:` URL that expires on reload, so emitting it
+ // would put a dead link in the persisted draft. This replaces the
+ // after-the-fact regex scrub ContentEditor used to run on every serialise.
+ if (node.attrs?.uploading === true || !src) return "";
const alt = escapeMarkdownLabel(node.attrs?.alt || "");
const title = node.attrs?.title;
if (title) {
@@ -131,7 +144,7 @@ export interface EditorExtensionsOptions {
queryClient?: import("@tanstack/react-query").QueryClient;
onSubmitRef?: RefObject<(() => void) | undefined>;
onUploadFileRef?: RefObject<
- ((file: File) => Promise<UploadResult | null>) | undefined
+ ((file: File, uploadId: string) => Promise<UploadResult | null>) | undefined
>;
/**
* Character count above which a plain-text paste becomes a .txt attachment
diff --git a/packages/views/editor/use-coordinated-uploads.ts b/packages/views/editor/use-coordinated-uploads.ts
index 386be41bc4..9ab4130cc2 100644
--- a/packages/views/editor/use-coordinated-uploads.ts
+++ b/packages/views/editor/use-coordinated-uploads.ts
@@ -31,6 +31,7 @@
import {
useCallback,
+ useEffect,
useLayoutEffect,
useMemo,
useRef,
@@ -138,6 +139,13 @@ function deliverFinishedUpload(
const md = attachmentMarkdown(attachment);
const live = liveEditors.get(binding.registryKey);
+ // A composer showing this target rebuilt the placeholder on mount, so the
+ // finished attachment REPLACES it where the user last saw it instead of
+ // being appended a second time at the end.
+ if (live?.current?.settleUploadPlaceholder(clientUploadId, toUploadResult(attachment)) === true) {
+ binding.appendToBody(md);
+ return;
+ }
if (live?.current?.insertMarkdownAtEnd(md) === true) {
binding.appendToBody(md);
return;
@@ -192,7 +200,7 @@ function deliverPastedTextBack(
}
export interface CoordinatedUploads {
- /** Every upload for this composer (placeholders included) — for status chips. */
+ /** Every upload for this composer, placeholders included. */
uploads: DraftUpload[];
/** Completed attachment rows — the editor preview set; submit binds the
* subset whose link the body still references. */
@@ -289,13 +297,78 @@ export function useCoordinatedUploads(
return done.length === 0 ? EMPTY_ATTACHMENTS : done;
}, [uploads]);
+ // Rebuild placeholders for uploads this document is not showing.
+ //
+ // An upload outlives the mount that started it, but its placeholder node
+ // does not — placeholders are never serialised into the draft body, so a
+ // reopened composer starts with no trace of one that is still running. The
+ // draft still holds the record, which is enough to draw it again, and the
+ // settle then replaces it in place (see deliverFinishedUpload). Without this
+ // the composer looks idle while `gate` quietly blocks the send.
+ //
+ // ONCE per id per mount, tracked here rather than by scanning the document:
+ // a user who deletes the placeholder mid-upload means it, and MUL-5181's
+ // rule that a deleted placeholder stays deleted would be undone by the next
+ // store write re-drawing it.
+ //
+ // Retried while it cannot land, because the imperative handle exists from
+ // the first commit while the Tiptap instance arrives a passive effect later
+ // — the same window deliverFinishedUpload retries through.
+ const rebuiltUploadIdsRef = useRef<Set<string>>(new Set());
+ // Chat pins its document to the draft an in-flight upload started while the
+ // user browses another session, so `uploads` (the SELECTED draft) can name a
+ // different target than the document holds. Drawing then would put one
+ // draft's placeholder into another draft's document. The registry key is
+ // already the signal for exactly this divergence.
+ const editorHoldsThisTarget = !binding || registryKey === binding.registryKey;
+ useEffect(() => {
+ if (!editorHoldsThisTarget) return;
+ const pending = uploads.filter(
+ (u) => u.status === "uploading" && !rebuiltUploadIdsRef.current.has(u.clientUploadId),
+ );
+ if (pending.length === 0) return;
+ let cancelled = false;
+ let tries = 0;
+ const attempt = () => {
+ if (cancelled) return;
+ const missing = pending.filter((u) => {
+ const landed = editorRef.current?.insertUploadPlaceholder({
+ uploadId: u.clientUploadId,
+ filename: u.filename,
+ size: u.size,
+ });
+ if (landed === true) rebuiltUploadIdsRef.current.add(u.clientUploadId);
+ return landed !== true;
+ });
+ if (missing.length === 0) return;
+ if (++tries >= DELIVER_MAX_TRIES) return;
+ setTimeout(attempt, DELIVER_RETRY_MS);
+ };
+ attempt();
+ return () => {
+ cancelled = true;
+ };
+ }, [uploads, editorRef, editorHoldsThisTarget]);
+
const issueId = ctx.issueId;
const commentId = ctx.commentId;
const chatSessionId = ctx.chatSessionId;
const handleUpload = useCallback(
- (file: File): Promise<UploadResult | null> => {
- const clientUploadId = createSafeId();
+ (file: File, uploadId?: string): Promise<UploadResult | null> => {
+ // Adopt the editor's id rather than minting a second one: the document
+ // node and this draft record are the same upload, and a settle that
+ // reaches a mount which did not start it can only find the node by id.
+ // The fallback covers a caller with no editor placeholder to match.
+ const clientUploadId = uploadId ?? createSafeId();
+ // An id handed in by the editor means it ALREADY drew the node, so this
+ // upload counts as rebuilt from here on. Registering it now rather than
+ // letting the effect discover the node closes the gap between the two:
+ // in that window the effect would see no node (the user could have
+ // deleted it) and draw a second one, resurrecting a placeholder the
+ // user removed. The window is sub-frame, but the rule reads better as
+ // "whoever drew it registers it" than as a race nobody can hit.
+ if (uploadId) rebuiltUploadIdsRef.current.add(uploadId);
// Snapshot the target NOW: settle handlers must keep addressing the
// draft the file landed in, no matter what is selected when they fire.
const target = binding ? (resolveUploadTargetRef.current?.() ?? binding) : undefined;
@@ -310,21 +383,13 @@ export function useCoordinatedUploads(
const pastedText = pastedTextSource(file);
if (file.size > MAX_FILE_SIZE) {
- // Never enters the coordinator — surface it as a failed placeholder so
- // the composer shows the reason instead of silently dropping the file.
+ // Never enters the coordinator, and never enters the draft either —
+ // see the settle handler below for why a failure leaves no placeholder.
const reason = "File exceeds 100 MB limit";
if (pastedText !== undefined) {
- // A paste has no on-disk copy to retry from: give the text back
- // rather than leaving a failed chip standing in for lost content.
+ // A paste has no on-disk copy to re-attach from, so the text goes
+ // back into the composer instead of being lost with the upload.
deliverPastedTextBack(target, editorRef, pastedText);
- } else if (target) {
- target.addUpload(placeholder);
- target.failUpload(clientUploadId, reason);
- } else {
- setLocalUploads((prev) => [
- ...prev,
- { clientUploadId, status: "failed", filename: file.name, size: file.size, error: reason },
- ]);
}
toast.error(t(($) => $.upload.failed, { filename: file.name, reason }));
return Promise.resolve(null);
@@ -371,35 +436,33 @@ export function useCoordinatedUploads(
resolve(toUploadResult(outcome.attachment));
} else {
const reason = outcome.error.message;
- if (pastedText !== undefined) {
- // Paste-as-file: the text has no copy anywhere else, so it is
- // restored instead of being represented by a failed chip. Runs
- // whether or not this mount survived — deliverPastedTextBack
- // owns that choice, and it is the ONLY responder so the live
- // and dead cases can never both fire or both be skipped.
- if (target) {
- if (target.getUploads().some((u) => u.clientUploadId === clientUploadId)) {
- target.removeUpload(clientUploadId);
+ // A failure leaves NOTHING behind. The toast below has already
+ // said it, at the moment it happened, and the file is still on
+ // disk — a chip adds no information and cannot retry (the bytes
+ // were never persisted). Keeping one costs more than it gives:
+ // it survives reload and reopen until dismissed by hand, and
+ // `isMeaningful` counts it, so a single flaky request keeps an
+ // otherwise-empty draft alive for the full 30-day TTL.
+ //
+ // `interrupted` is the opposite case and still gets a chip: it
+ // is discovered a session later, when the user no longer
+ // remembers attaching anything.
+ if (target) {
+ if (target.getUploads().some((u) => u.clientUploadId === clientUploadId)) {
+ target.removeUpload(clientUploadId);
+ // Paste-as-file has no on-disk copy to re-attach from, so
+ // its text goes back into the composer.
+ if (pastedText !== undefined) {
deliverPastedTextBack(target, editorRef, pastedText);
}
- } else {
- setLocalUploads((prev) =>
- prev.filter((u) => u.clientUploadId !== clientUploadId),
- );
- deliverPastedTextBack(undefined, editorRef, pastedText);
- }
- } else if (target) {
- if (target.getUploads().some((u) => u.clientUploadId === clientUploadId)) {
- target.failUpload(clientUploadId, reason);
}
} else {
setLocalUploads((prev) =>
- prev.map((u) =>
- u.clientUploadId === clientUploadId
- ? { clientUploadId, status: "failed", filename: file.name, size: file.size, error: reason }
- : u,
- ),
+ prev.filter((u) => u.clientUploadId !== clientUploadId),
);
+ if (pastedText !== undefined) {
+ deliverPastedTextBack(undefined, editorRef, pastedText);
+ }
}
toast.error(t(($) => $.upload.failed, { filename: file.name, reason }));
resolve(null);
diff --git a/packages/views/editor/use-upload-gate.ts b/packages/views/editor/use-upload-gate.ts
index 07bbe20847..09cc33b5ce 100644
--- a/packages/views/editor/use-upload-gate.ts
+++ b/packages/views/editor/use-upload-gate.ts
@@ -4,9 +4,10 @@
* The submit gate for composers that accept attachments (MUL-4808).
*
* While a file is still uploading, the editor holds a `blob:` placeholder and
- * the attachment's id does not exist yet. Serializing at that moment strips
- * the blob (see ContentEditor's stripBlobUrls) and binds no id, so the send
- * succeeds while the file silently disappears from what the recipient gets.
+ * the attachment's id does not exist yet. Serializing at that moment emits
+ * nothing for the placeholder (see the image / fileCard `renderMarkdown`) and
+ * binds no id, so the send would succeed while the file silently disappears
+ * from what the recipient gets.
* Every action that FIXES a draft — send, create, save, and the mode switch
* that re-serializes a draft into another form — must therefore wait.
*
diff --git a/packages/views/issues/components/comment-card-edit-gate.test.tsx b/packages/views/issues/components/comment-card-edit-gate.test.tsx
index fd612f6b98..9fdf42c976 100644
--- a/packages/views/issues/components/comment-card-edit-gate.test.tsx
+++ b/packages/views/issues/components/comment-card-edit-gate.test.tsx
@@ -13,6 +13,11 @@ const editorDefaultValues = vi.hoisted(() => ({
values: [] as Array<string | undefined>,
}));
+// The real handle mints an id when it inserts the placeholder and hands it to
+// the uploader, which adopts it as the draft `clientUploadId`. Mocks must do
+// the same or the two records drift apart only in tests.
+let mockUploadIdSeq = 0;
+
vi.mock("@multica/core/api", () => ({
// Uploads flow through the coordinator, which calls api.uploadFile (MUL-5181).
api: { uploadFile: apiUploadFile },
@@ -72,7 +77,7 @@ vi.mock("../../editor", async () => ({
}: {
defaultValue?: string;
onUpdate?: (markdown: string) => void;
- onUploadFile?: (file: File) => Promise<UploadResult | null>;
+ onUploadFile?: (file: File, uploadId: string) => Promise<UploadResult | null>;
onUploadingChange?: (uploading: boolean) => void;
onSubmit?: () => void;
placeholder?: string;
@@ -99,7 +104,7 @@ vi.mock("../../editor", async () => ({
inFlightRef.current += 1;
if (inFlightRef.current === 1) onUploadingChange?.(true);
try {
- const result = await onUploadFile?.(file);
+ const result = await onUploadFile?.(file, `mock-upload-${++mockUploadIdSeq}`);
if (!result) return;
valueRef.current = `${valueRef.current}\n${result.url}`.trim();
onUpdate?.(valueRef.current);
@@ -109,6 +114,11 @@ vi.mock("../../editor", async () => ({
}
},
hasActiveUploads: () => inFlightRef.current > 0,
+ // Placeholder rebuild contract: the real handle draws a card for an
+ // upload the document is not showing and reports whether it landed.
+ // Mocks track ids only — no document to draw into.
+ insertUploadPlaceholder: () => true,
+ settleUploadPlaceholder: () => false,
}));
return (
<textarea
diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsx
index 7d58333efe..2c323cb4b8 100644
--- a/packages/views/issues/components/comment-card.tsx
+++ b/packages/views/issues/components/comment-card.tsx
@@ -32,7 +32,6 @@ import { useTimeAgo } from "../../i18n";
import { ContentEditor, type ContentEditorRef, ReadonlyContent, useFileDropZone, FileDropOverlay, Attachment as AttachmentRenderer, AttachmentDownloadProvider, useUploadGate, useComposerSubmit } from "../../editor";
import { PASTE_AS_FILE_THRESHOLD } from "../../editor/paste-as-file";
import { useCommentUploads } from "./use-comment-uploads";
-import { ComposerUploadChips } from "./composer-upload-chips";
import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { api, dispatchReasonCode } from "@multica/core/api";
import { ReplyInput } from "./reply-input";
@@ -694,9 +693,6 @@ function CommentRow({
}
/>
)}
- {edit.uploads.some((u) => u.status !== "uploaded") && (
- <ComposerUploadChips uploads={edit.uploads} onRemove={edit.removeUpload} className="mt-2 max-w-full" />
- )}
<div className="flex items-center justify-between gap-2 mt-2">
<div className="min-w-0 flex-1">
<CommentTriggerChips
@@ -1009,9 +1005,6 @@ function CommentCardImpl({
}
/>
)}
- {edit.uploads.some((u) => u.status !== "uploaded") && (
- <ComposerUploadChips uploads={edit.uploads} onRemove={edit.removeUpload} className="max-w-full" />
- )}
<CommentTriggerChips
agents={edit.triggerPreview.agents}
blocked={edit.triggerPreview.blocked}
diff --git a/packages/views/issues/components/comment-composers.test.tsx b/packages/views/issues/components/comment-composers.test.tsx
index 182b582dc4..e192dcd2ac 100644
--- a/packages/views/issues/components/comment-composers.test.tsx
+++ b/packages/views/issues/components/comment-composers.test.tsx
@@ -28,7 +28,18 @@ const editorDefaultValues = vi.hoisted(() => ({
// posted comment instead), a thread reply keeps the caret for the next reply.
const focusCalls = vi.hoisted(() => ({ focused: 0, blurred: 0 }));
const insertMarkdownSpy = vi.hoisted(() => vi.fn());
+const insertPlaceholderSpy = vi.hoisted(() => vi.fn());
const insertMarkdownBehavior = vi.hoisted(() => ({ succeed: true }));
+// Lets a test drop the editor's uploading placeholder out of the document
+// (Cmd+Z after a paste) without settling the upload behind it.
+const editorUploadSignal = vi.hoisted(
+ () => ({ notify: undefined as ((uploading: boolean) => void) | undefined }),
+);
+
+// The real handle mints an id when it inserts the placeholder and hands it to
+// the uploader, which adopts it as the draft `clientUploadId`. Mocks must do
+// the same or the two records drift apart only in tests.
+let mockUploadIdSeq = 0;
vi.mock("@multica/core/api", () => ({
api: { uploadFile: apiUploadFile },
@@ -84,7 +95,7 @@ vi.mock("../../editor", async () => ({
defaultValue?: string;
onUpdate?: (markdown: string) => void;
placeholder?: string;
- onUploadFile?: (file: File) => Promise<UploadResult | null>;
+ onUploadFile?: (file: File, uploadId: string) => Promise<UploadResult | null>;
onUploadingChange?: (uploading: boolean) => void;
onSubmit?: () => void;
onReady?: () => void;
@@ -92,6 +103,7 @@ vi.mock("../../editor", async () => ({
ref: Ref<unknown>,
) {
editorDefaultValues.values.push(defaultValue);
+ editorUploadSignal.notify = onUploadingChange;
const valueRef = useRef(defaultValue ?? "");
// Mirrors the real editor's `uploading` node attrs: the placeholder exists
// from before the await until the upload settles, `hasActiveUploads` reads
@@ -122,7 +134,7 @@ vi.mock("../../editor", async () => ({
inFlightRef.current += 1;
if (inFlightRef.current === 1) onUploadingChange?.(true);
try {
- const result = await onUploadFile?.(file);
+ const result = await onUploadFile?.(file, `mock-upload-${++mockUploadIdSeq}`);
if (!result || destroyedRef.current) return;
valueRef.current = `${valueRef.current}\n${result.url}`.trim();
onUpdate?.(valueRef.current);
@@ -132,6 +144,14 @@ vi.mock("../../editor", async () => ({
}
},
hasActiveUploads: () => inFlightRef.current > 0,
+ // Placeholder rebuild contract: the real handle draws a card for an
+ // upload the document is not showing and reports whether it landed.
+ // Mocks track ids only — no document to draw into.
+ insertUploadPlaceholder: (upload: unknown) => {
+ insertPlaceholderSpy(upload);
+ return true;
+ },
+ settleUploadPlaceholder: () => false,
insertMarkdownAtEnd: (md: string) => {
insertMarkdownSpy(md);
if (destroyedRef.current || !insertMarkdownBehavior.succeed) return false;
@@ -218,6 +238,7 @@ beforeEach(() => {
uploadWithToast.mockReset();
apiUploadFile.mockReset();
insertMarkdownSpy.mockReset();
+ insertPlaceholderSpy.mockReset();
insertMarkdownBehavior.succeed = true;
localStorage.clear();
useCommentComposerStore.setState({ sticky: true });
@@ -606,6 +627,106 @@ describe("comment composers — upload submit gate", () => {
expect(getSubmitButton(container)).not.toHaveAttribute("aria-busy");
});
+
+
+ it("never asks the rebuild to draw an upload this mount started", async () => {
+ // The editor drew that node itself, synchronously, before the draft record
+ // existed. Registering the id at handleUpload rather than waiting for the
+ // effect to discover the node closes the window in which a delete could be
+ // undone by a redraw.
+ const { container } = renderCommentInput();
+ activateComposer("comment-composer-shell");
+ const pending = startPendingUpload(container, "mine.png");
+
+ await waitFor(() => expect(getSubmitButton(container)).toBeDisabled());
+ expect(insertPlaceholderSpy).not.toHaveBeenCalled();
+
+ await act(async () => {
+ pending.resolve(uploadAttachment("att-mine", "https://cdn.example/att-mine.png"));
+ });
+ expect(insertPlaceholderSpy).not.toHaveBeenCalled();
+ });
+
+ it("does not redraw a placeholder the user deleted mid-upload", async () => {
+ // MUL-5181's rule: a placeholder the user removed stays removed. The
+ // rebuild runs once per id per mount, so the next store write cannot undo
+ // that decision — the send button is what still says the upload is live.
+ useCommentDraftStore.getState().addUpload("new:issue-1", {
+ clientUploadId: "u-deleted",
+ status: "uploading",
+ filename: "gone.png",
+ size: 1,
+ });
+ renderCommentInput();
+ await screen.findByTestId("editor");
+ await waitFor(() => expect(insertPlaceholderSpy).toHaveBeenCalledTimes(1));
+
+ // A second upload changes `uploads`, which re-runs the rebuild effect —
+ // the moment a naive implementation would redraw the first one.
+ act(() => {
+ useCommentDraftStore.getState().addUpload("new:issue-1", {
+ clientUploadId: "u-second",
+ status: "uploading",
+ filename: "other.png",
+ size: 1,
+ });
+ });
+
+ await waitFor(() =>
+ expect(
+ insertPlaceholderSpy.mock.calls.some(([u]) => u.uploadId === "u-second"),
+ ).toBe(true),
+ );
+ expect(
+ insertPlaceholderSpy.mock.calls.filter(([u]) => u.uploadId === "u-deleted"),
+ ).toHaveLength(1);
+ });
+
+ it("leaves nothing behind when an upload fails", async () => {
+ // The toast already said it, at the moment it happened, and the file is
+ // still on disk. A chip cannot retry (the bytes were never persisted) and
+ // `isMeaningful` counts it, so keeping one would hold an otherwise-empty
+ // draft alive across reloads until dismissed by hand.
+ const { container } = renderCommentInput();
+ activateComposer("comment-composer-shell");
+
+ const pending = startPendingUpload(container, "doomed.png");
+ await waitFor(() => expect(getSubmitButton(container)).toBeDisabled());
+
+ await act(async () => {
+ pending.fail();
+ });
+
+ await waitFor(() =>
+ expect(useCommentDraftStore.getState().getUploads("new:issue-1")).toHaveLength(0),
+ );
+ expect(screen.queryByText(/doomed\.png/)).toBeNull();
+ // The empty draft is gone with it, not kept alive by a dead placeholder.
+ expect(useCommentDraftStore.getState().getDraft("new:issue-1")).toBeFalsy();
+ });
+
+ it("rebuilds a placeholder for an upload inherited from the persisted draft", async () => {
+ // Started by a mount that is gone: its placeholder node died with that
+ // editor, and placeholders are never serialised, so the reopened composer
+ // has the record but no node. It draws one again — otherwise the composer
+ // looks idle while `gate` quietly blocks the send.
+ useCommentDraftStore.getState().addUpload("new:issue-1", {
+ clientUploadId: "from-a-previous-mount",
+ status: "uploading",
+ filename: "orphan.png",
+ size: 1,
+ });
+
+ renderCommentInput();
+ await screen.findByTestId("editor");
+
+ await waitFor(() =>
+ expect(insertPlaceholderSpy).toHaveBeenCalledWith(
+ expect.objectContaining({ uploadId: "from-a-previous-mount", filename: "orphan.png" }),
+ ),
+ );
+ });
+
it("blocks the Cmd+Enter path while an upload is in flight", async () => {
const { container, onSubmit } = renderCommentInput();
activateComposer("comment-composer-shell");
diff --git a/packages/views/issues/components/comment-input.tsx b/packages/views/issues/components/comment-input.tsx
index 1790782454..61b8687f2d 100644
--- a/packages/views/issues/components/comment-input.tsx
+++ b/packages/views/issues/components/comment-input.tsx
@@ -13,7 +13,6 @@ import { useT } from "../../i18n";
import { CommentTriggerChips } from "./comment-trigger-chips";
import { useCommentTriggerPreview } from "../hooks/use-comment-trigger-preview";
import { useCommentUploads } from "./use-comment-uploads";
-import { ComposerUploadChips } from "./composer-upload-chips";
interface CommentInputProps {
issueId: string;
@@ -51,7 +50,7 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {
// status chips (uploading / failed / interrupted).
// `gate` widens the editor gate with coordinator-owned placeholders, so a
// composer reopened over a still-in-flight upload cannot send past it.
- const { uploads, attachments: pendingAttachments, handleUpload, removeUpload, gate } =
+ const { attachments: pendingAttachments, handleUpload, gate } =
useCommentUploads(draftKey, { issueId }, uploadGate, editorRef);
// Readonly-first: the composer renders as a same-looking static shell until
@@ -231,9 +230,6 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {
/>
</div>
)}
- {uploads.some((u) => u.status !== "uploaded") && (
- <ComposerUploadChips uploads={uploads} onRemove={removeUpload} className="px-3 pb-1" />
- )}
{/* Static shell — visually clones the empty single-line composer.
Real editor mounts (hidden) on first intent; shell stays visible
until it's ready so the card never blanks or shifts. */}
diff --git a/packages/views/issues/components/composer-upload-chips.tsx b/packages/views/issues/components/composer-upload-chips.tsx
deleted file mode 100644
index 619d056b84..0000000000
--- a/packages/views/issues/components/composer-upload-chips.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-"use client";
-
-import { AlertCircle, Loader2, X } from "lucide-react";
-import { Button } from "@multica/ui/components/ui/button";
-import { cn } from "@multica/ui/lib/utils";
-import type { DraftUpload } from "@multica/core/drafts";
-import { useT } from "../../i18n";
-
-/**
- * Status chips for uploads that are NOT yet a completed attachment (MUL-5181).
- *
- * Completed uploads render through the editor's inline preview / the standalone
- * AttachmentList; this strip covers the states those cannot show:
- * - `uploading` — a spinner, so a reopened composer proves the upload is still
- * running (it is owned by the coordinator, not this component).
- * - `interrupted` — a reload/restart killed an in-flight upload; the bytes are
- * gone, so the user must re-attach.
- * - `failed` — the request errored.
- *
- * Interrupted/failed chips are dismissable; there is no retry because the file
- * bytes are not persisted.
- */
-export function ComposerUploadChips({
- uploads,
- onRemove,
- className,
-}: {
- uploads: DraftUpload[];
- onRemove: (clientUploadId: string) => void;
- className?: string;
-}) {
- const { t } = useT("editor");
- const pending = uploads.filter((u) => u.status !== "uploaded");
- if (pending.length === 0) return null;
-
- return (
- <div className={cn("flex flex-col gap-1", className)}>
- {pending.map((u) => {
- const isUploading = u.status === "uploading";
- const isFailed = u.status === "failed";
- return (
- <div
- key={u.clientUploadId}
- className={cn(
- "flex items-center gap-2 rounded-md border px-2 py-1 text-xs",
- isUploading
- ? "border-border bg-muted/50 text-muted-foreground"
- : "border-destructive/40 bg-destructive/5 text-destructive",
- )}
- >
- {isUploading ? (
- <Loader2 className="h-3.5 w-3.5 shrink-0 animate-spin" aria-hidden />
- ) : (
- <AlertCircle className="h-3.5 w-3.5 shrink-0" aria-hidden />
- )}
- <span className="min-w-0 flex-1 truncate">
- {isUploading
- ? t(($) => $.upload.uploading_label, { filename: u.filename })
- : isFailed
- ? t(($) => $.upload.failed, {
- filename: u.filename,
- reason: u.error ?? "",
- })
- : `${t(($) => $.upload.failed_label, { filename: u.filename })} — ${t(($) => $.upload.interrupted)}`}
- </span>
- {!isUploading && (
- <Button
- type="button"
- size="icon-sm"
- variant="ghost"
- className="h-5 w-5 shrink-0"
- aria-label={t(($) => $.upload.remove)}
- onClick={() => onRemove(u.clientUploadId)}
- >
- <X className="h-3 w-3" />
- </Button>
- )}
- </div>
- );
- })}
- </div>
- );
-}
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index 1eafd82462..97b297c313 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -194,6 +194,11 @@ vi.mock("../../editor", async () => ({
blur: () => {},
// Read by the submit-time upload gate; no uploads are exercised here.
hasActiveUploads: () => false,
+ // Placeholder rebuild contract: the real handle draws a card for an
+ // upload the document is not showing and reports whether it landed.
+ // Mocks track ids only — no document to draw into.
+ insertUploadPlaceholder: () => true,
+ settleUploadPlaceholder: () => false,
uploadFile: () => {},
}));
return (
diff --git a/packages/views/issues/components/reply-input.tsx b/packages/views/issues/components/reply-input.tsx
index fb2479a61d..9f7160c2a3 100644
--- a/packages/views/issues/components/reply-input.tsx
+++ b/packages/views/issues/components/reply-input.tsx
@@ -15,7 +15,6 @@ import { useT } from "../../i18n";
import { CommentTriggerChips } from "./comment-trigger-chips";
import { useCommentTriggerPreview } from "../hooks/use-comment-trigger-preview";
import { useCommentUploads } from "./use-comment-uploads";
-import { ComposerUploadChips } from "./composer-upload-chips";
// ---------------------------------------------------------------------------
// Types
@@ -252,9 +251,6 @@ function ReplyInput({
/>
</div>
)}
- {uploads.some((u) => u.status !== "uploaded") && (
- <ComposerUploadChips uploads={uploads} onRemove={removeUpload} className="mt-1" />
- )}
{/* Static shell — clones the empty single-line reply box (see
CommentInput for the pattern). */}
{!lazy.ready && (
diff --git a/packages/views/modals/create-issue.test.tsx b/packages/views/modals/create-issue.test.tsx
index a69a8ac890..3c3392cdbd 100644
--- a/packages/views/modals/create-issue.test.tsx
+++ b/packages/views/modals/create-issue.test.tsx
@@ -134,6 +134,11 @@ const mockCreateSettingsStore = {
manualCreateFields: DEFAULT_MANUAL_FIELDS as ManualCreateField[],
};
+// The real handle mints an id when it inserts the placeholder and hands it to
+// the uploader, which adopts it as the draft `clientUploadId`. Mocks must do
+// the same or the two records drift apart only in tests.
+let mockUploadIdSeq = 0;
+
vi.mock("../navigation", () => ({
useNavigation: () => ({ push: mockPush }),
}));
@@ -297,13 +302,18 @@ vi.mock("../editor", async () => {
inFlightRef.current += 1;
if (inFlightRef.current === 1) onUploadingChange?.(true);
try {
- return await onUploadFile?.(file);
+ return await onUploadFile?.(file, `mock-upload-${++mockUploadIdSeq}`);
} finally {
inFlightRef.current -= 1;
if (inFlightRef.current === 0) onUploadingChange?.(false);
}
},
hasActiveUploads: () => inFlightRef.current > 0,
+ // Placeholder rebuild contract: the real handle draws a card for an
+ // upload the document is not showing and reports whether it landed.
+ // Mocks track ids only — no document to draw into.
+ insertUploadPlaceholder: () => true,
+ settleUploadPlaceholder: () => false,
}));
return (
<>
diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsx
index fa0213dde6..1efd2d9df8 100644
--- a/packages/views/modals/create-issue.tsx
+++ b/packages/views/modals/create-issue.tsx
@@ -51,7 +51,6 @@ import { Button } from "@multica/ui/components/ui/button";
import { Switch } from "@multica/ui/components/ui/switch";
import { ContentEditor, type ContentEditorRef, TitleEditor, type TitleEditorRef, useFileDropZone, FileDropOverlay, useUploadGate, useComposerSubmit } from "../editor";
import { useIssueCreateUploads } from "./use-issue-create-uploads";
-import { ComposerUploadChips } from "../issues/components/composer-upload-chips";
import { useShortcut } from "@multica/core/shortcuts";
import { ShortcutKeycaps } from "../common/shortcut-keycaps";
import { StatusIcon, StatusPicker, PriorityIcon, PriorityPicker, StagePicker, AssigneePicker, StartDatePicker, DueDatePicker, LabelPicker } from "../issues/components";
@@ -344,10 +343,8 @@ export function ManualCreatePanel({
// here survives dialog close, aborts on logout, and reads `interrupted`
// after a reload. `gate` widens the editor gate with the pool's placeholders.
const {
- uploads: draftUploads,
attachments: draftAttachments,
handleUpload,
- removeUpload,
gate,
} = useIssueCreateUploads("manual", uploadGate, descEditorRef);
@@ -878,13 +875,6 @@ export function ManualCreatePanel({
{descDragOver && <FileDropOverlay />}
</div>
- {draftUploads.some((u) => u.status !== "uploaded") && (
- <ComposerUploadChips
- uploads={draftUploads}
- onRemove={removeUpload}
- className="px-5 pb-1"
- />
- )}
{/* Pre-trigger preview — a passive caption above the toolbar; reveals
when an agent assignee will pick the issue up. */}
diff --git a/packages/views/modals/feedback.test.tsx b/packages/views/modals/feedback.test.tsx
index 94cb436aa7..2debc6d1d8 100644
--- a/packages/views/modals/feedback.test.tsx
+++ b/packages/views/modals/feedback.test.tsx
@@ -77,6 +77,11 @@ vi.mock("../editor", async () => {
const inFlightRef = useRef(0);
useImperativeHandle(ref, () => ({
hasActiveUploads: () => inFlightRef.current > 0,
+ // Placeholder rebuild contract: the real handle draws a card for an
+ // upload the document is not showing and reports whether it landed.
+ // Mocks track ids only — no document to draw into.
+ insertUploadPlaceholder: () => true,
+ settleUploadPlaceholder: () => false,
getMarkdown: () => liveEditorMarkdown,
uploadFile: async () => {
inFlightRef.current += 1;
diff --git a/packages/views/modals/feedback.tsx b/packages/views/modals/feedback.tsx
index 264d9bf668..dc0985a465 100644
--- a/packages/views/modals/feedback.tsx
+++ b/packages/views/modals/feedback.tsx
@@ -153,7 +153,7 @@ export function FeedbackModal({
defaultValue={seededMessage}
placeholder={t(($) => $.feedback.placeholder)}
onUpdate={(md) => { setMessage(md); setDraft({ message: md }); }}
- onUploadFile={uploadWithToast}
+ onUploadFile={(file) => uploadWithToast(file)}
onUploadingChange={uploadGate.onUploadingChange}
onSubmit={handleSubmit}
debounceMs={150}
diff --git a/packages/views/modals/quick-create-issue.test.tsx b/packages/views/modals/quick-create-issue.test.tsx
index 671499739b..e8097b24e5 100644
--- a/packages/views/modals/quick-create-issue.test.tsx
+++ b/packages/views/modals/quick-create-issue.test.tsx
@@ -84,6 +84,11 @@ const mockSquadsData = vi.hoisted(
() => ({ list: [] as Array<{ id: string; name: string; leader_id: string; archived_at: string | null }> }),
);
+// The real handle mints an id when it inserts the placeholder and hands it to
+// the uploader, which adopts it as the draft `clientUploadId`. Mocks must do
+// the same or the two records drift apart only in tests.
+let mockUploadIdSeq = 0;
+
vi.mock("@tanstack/react-query", () => ({
useQuery: ({ queryKey }: { queryKey: string[] }) => {
// Workspace-scoped query keys carry the wsId as `queryKey[1]`; the
@@ -253,7 +258,7 @@ vi.mock("../editor", async () => {
inFlightRef.current += 1;
if (inFlightRef.current === 1) onUploadingChange?.(true);
try {
- return await onUploadFile?.(file);
+ return await onUploadFile?.(file, `mock-upload-${++mockUploadIdSeq}`);
} finally {
inFlightRef.current -= 1;
if (inFlightRef.current === 0) onUploadingChange?.(false);
@@ -269,6 +274,11 @@ vi.mock("../editor", async () => {
uploadFile: runUpload,
focus: vi.fn(),
hasActiveUploads: () => inFlightRef.current > 0,
+ // Placeholder rebuild contract: the real handle draws a card for an
+ // upload the document is not showing and reports whether it landed.
+ // Mocks track ids only — no document to draw into.
+ insertUploadPlaceholder: () => true,
+ settleUploadPlaceholder: () => false,
}));
return (
diff --git a/packages/views/modals/quick-create-issue.tsx b/packages/views/modals/quick-create-issue.tsx
index 9a9706256a..8b70966c65 100644
--- a/packages/views/modals/quick-create-issue.tsx
+++ b/packages/views/modals/quick-create-issue.tsx
@@ -77,7 +77,6 @@ import {
useComposerSubmit,
} from "../editor";
import { useIssueCreateUploads } from "./use-issue-create-uploads";
-import { ComposerUploadChips } from "../issues/components/composer-upload-chips";
import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { useT } from "../i18n";
import { matchesPinyin } from "../editor/extensions/pinyin-match";
@@ -351,10 +350,8 @@ export function AgentCreatePanel({
// logout, and reads `interrupted` after a reload. `gate` widens the editor
// gate with the pool's placeholders.
const {
- uploads: draftUploads,
attachments: pendingAttachments,
handleUpload: handleUploadFile,
- removeUpload,
gate,
} = useIssueCreateUploads("agent", uploadGate, editorRef);
const { isDragOver, dropZoneProps } = useFileDropZone({
@@ -636,13 +633,6 @@ export function AgentCreatePanel({
{isDragOver && <FileDropOverlay />}
</div>
- {draftUploads.some((u) => u.status !== "uploaded") && (
- <ComposerUploadChips
- uploads={draftUploads}
- onRemove={removeUpload}
- className="px-5 pb-1"
- />
- )}
{error && (
<div className="px-5 pb-2 text-xs text-destructive">{error}</div>