Repository navigation
Description
Observed content loss
With a file attached, typing a short message and immediately clicking Send message can send the attachment with content: "", omit sourceMarkdown, and clear the visible editor. Reproduced for both an Inbox reply and a new email with the real Milkdown editor and actual send hooks in Chromium. All HTTP responses were mocked locally; no real email or production instance was used.
Source: 17c6e6ed16ee880eff4b9b18985f7af8e2e9295d. Installed @milkdown/plugin-listener is 7.20.0. Its markdownUpdated listener is debounced by 200ms.
Reproduction
- Open an Inbox reply or new-email composer with an empty body.
- Attach
invoice.pdffirst. Send becomes enabled because a file is present. - Type
Urgentand immediately click Send message, within the 200ms Markdown publication window. - Observe the outgoing body and the cleared composer.
The local regression captured the visible editor text and persisted draft immediately before clicking Send, then captured the real adapter's outgoing JSON:
| Surface | Visible text before Send | Persisted draft before Send | Send click completed after typing began | Outgoing body | After successful mocked send |
|---|---|---|---|---|---|
| Reply | Urgent |
null |
110.2ms | empty string | editor empty; persisted draft null |
| New email | Urgent |
null |
104.7ms | empty string | editor empty; persisted draft null |
A preceding run reproduced both at 111.5ms and 104.3ms. A control waiting for the persisted draft passed for both surfaces: the outgoing HTML contained Urgent.
Actual reply payload to /conversations/reply1/reply:
{"content":"","attachments":[{"storageId":"s3:org1/invoice","fileName":"invoice.pdf","contentType":"application/pdf","size":8}]}Actual compose payload to /conversations/compose:
{"contactId":"contact1","connectorName":"imap-smtp","credentialId":"mailbox1","subject":"Quote 7","content":"","from":"[email protected]","assigneeUserId":"upload-test-user","attachments":[{"storageId":"s3:org1/invoice","fileName":"invoice.pdf","contentType":"application/pdf","size":8}]}All identifiers and addresses above are synthetic fixtures.
Root cause
message-editor.tsx:127 updates message and hasContent only when Milkdown publishes markdownUpdated.
handleSendMessage:242 checks message.trim() before reading live HTML. While message is still empty, it skips getHTML() entirely. The attached file still permits sending. The same stale state also supplies sourceMarkdown, and success clears/remounts the editor. EditorActionBar:124 intentionally allows attachment-only sends.
HTML, emptiness and undo/source Markdown should come from one current editor snapshot at send time. Increasing or waiting out the debounce would leave a timing-dependent send path.
Regression evidence and acceptance
A scratch real-Chromium regression based on #3558's real-editor fixture produced 2 failing immediate-send cases / 2 passing wait-for-draft controls. The failing assertion required outgoing content to contain text already visible in the editor. The fixture uses actual ConversationPanel, ComposeEmailPane, MessageEditor and mutation adapters with only transport and surrounding unrelated data mocked.
Core reproduction sequence:
await user.upload(fileInput, invoice);
await waitFor(() => expect(send).toBeEnabled());
await user.click(editor);
await user.keyboard('Urgent');
expect(editor).toHaveTextContent('Urgent');
await user.click(send); // intentionally no wait for persisted Markdown
await waitFor(() => expect(sent).toHaveBeenCalledTimes(1));
expect(sent.mock.calls[0][0].content).toContain('Urgent');- Cover rapid initial input with a pre-attached file for reply and compose.
- Cover editing an existing draft immediately before Send; current HTML and source Markdown must agree.
- Preserve truly empty and attachment-only behavior, rich formatting and undo content.
- Make the race test deterministic under load without a debounce-duration workaround.
Local evidence is retained under /Users/yannick/.codex/notes/tale-immediate-send-20260928/: browser-fast-send.log, browser-control.log, regression-with-control.tsx, and an isolated checkout. The mixed run also recorded delayed Milkdown editorView context errors after remount; the captured payload and cleared DOM establish the data-loss finding independently of those errors.
Deduplication: searched open/closed issues for Milkdown, immediate send, debounce, Inbox lost text, and attachment/text/send; reviewed the related open editor/undo work. No matching issue found. Related: #3558.
Activity