📧✨ Beautiful email. For everyone.
feat: show and manage reply drafts in conversations (#24)
Paul Koeck50f49e892730
diff --git a/apps/desktop/src/renderer/src/App.tsx b/apps/desktop/src/renderer/src/App.tsxindex c638a30..758e9e6 100644--- a/apps/desktop/src/renderer/src/App.tsx+++ b/apps/desktop/src/renderer/src/App.tsx@@ -51,6 +51,7 @@ import {identitySignature,mailtoDraft,replyRecipients,+ replyTarget,type Address,type Bootstrap,type Conversation,@@ -702,9 +703,21 @@ export function App() {'error',)}+ /** A draft filed in the open conversation, preferring the local copy the composer edits. */+ const threadDraft = (message: Message): DraftItem => {+ const local = drafts.data?.find(+ (d) => d.accountId === message.accountId && d.serverId === message.id,+ )+ return local+ ? { kind: 'local', key: 'local:' + local.id, draft: local }+ : { kind: 'server', key: 'server:' + scopeKey(message.accountId, message.id), message }+ }const discardDrafts = (keys: Iterable<string>) => {const chosen = new Set(keys)- const items = draftItems.filter((item) => chosen.has(item.key) && deletable(item))+ discardDraftItems(draftItems.filter((item) => chosen.has(item.key)))+ }+ const discardDraftItems = (candidates: DraftItem[]) => {+ const items = candidates.filter(deletable)if (!items.length) return// Only one deletion waits for undo at a time; an earlier one is committed right away.if (pendingDiscard.current) void commitDiscard(pendingDiscard.current.items)@@ -871,7 +884,7 @@ export function App() {setSearchOpen(true)requestAnimationFrame(() => searchInput.current?.select())}- const latest = thread.data?.at(-1)+ const latest = thread.data && replyTarget(thread.data)// The newest mailing-list message carries the sender's current unsubscribe address.const listMessage = thread.data && [...thread.data].reverse().find((m) => m.unsubscribe)const listKey = listMessage && scopeKey(listMessage.accountId, listMessage.id)@@ -1492,7 +1505,9 @@ export function App() {thread.data ? (<Readerkey={scopeKey(readerAccount.id, route.thread!)}- messages={thread.data}+ messages={thread.data.filter(+ (m) => !discarding.has('server:' + scopeKey(m.accountId, m.id)),+ )}view={route.q ? 'all' : view}backLabel={title}busy={busy}@@ -1512,6 +1527,12 @@ export function App() {onAction={(action) => void act(action)}onMove={() => openMove(targets())}onReply={(message, kind) => void compose(message, kind)}+ onEditDraft={(message) => void openDraft(threadDraft(message))}+ onDiscardDraft={(message) => {+ const item = threadDraft(message)+ if (deletable(item)) discardDraftItems([item])+ else notify('Check this message’s delivery status before deleting the draft.')+ }}notify={notify}onMailto={onMailto}unsubscribe={unsubscribeState}diff --git a/apps/desktop/src/renderer/src/ConversationRow.tsx b/apps/desktop/src/renderer/src/ConversationRow.tsxindex 20ce929..d577b5f 100644--- a/apps/desktop/src/renderer/src/ConversationRow.tsx+++ b/apps/desktop/src/renderer/src/ConversationRow.tsx@@ -1,6 +1,6 @@import { Archive, Mail, MailOpen, Paperclip, Star, Trash2 } from '@inlark/ui/icons'import { Checkbox, IconButton } from '@inlark/ui'-import type { Account, Conversation } from '@inlark/core'+import { isDraft, type Account, type Conversation } from '@inlark/core'import { shortDate } from './mail-date'import { SenderAvatar } from './SenderAvatar'import { AccountMark } from './AccountMark'@@ -44,6 +44,9 @@ export function ConversationRow({const keys = useShortcutText()const moveLimit = actionLimit(a, 'move')const subject = c.subject || '(No subject)'+ // An unsent reply is flagged rather than counted, so it never reads as sent.+ const drafts = c.messages.filter(isDraft).length+ const count = c.count - draftsreturn (<divclassName={@@ -76,7 +79,8 @@ export function ConversationRow({remoteImages={remoteImages}/><span title={c.from.map((sender) => sender.email).join(', ')}>{senderLabel(c)}</span>- {c.count > 1 && <small>{c.count}</small>}+ {count > 1 && <small>{count}</small>}+ {drafts > 0 && <span className="row-draft">Draft</span>}</div><div className="row-content" role="gridcell"><span className="row-subject">{subject}</span>diff --git a/apps/desktop/src/renderer/src/Reader.tsx b/apps/desktop/src/renderer/src/Reader.tsxindex 6bfe5e8..a4045aa 100644--- a/apps/desktop/src/renderer/src/Reader.tsx+++ b/apps/desktop/src/renderer/src/Reader.tsx@@ -27,11 +27,13 @@ import {ShieldCheck,Check,MailMinus,+ PencilEdit,} from '@inlark/ui/icons'import { Tooltip } from '@base-ui/react/tooltip'import { Button, IconButton, Dropdown, MenuItem, Spinner } from '@inlark/ui'import {friendlyError,+ isDraft,type Account,type Message,type Settings,@@ -495,6 +497,8 @@ interface ReaderProps {onAction: (action: MailAction) => voidonMove: () => voidonReply: (message: Message, kind: 'reply' | 'replyAll' | 'forward') => void+ onEditDraft: (message: Message) => void+ onDiscardDraft: (message: Message) => voidnotify: (message: string, tone?: 'error' | 'info') => voidonMailto: (url: string) => void/** Set when the conversation comes from a mailing list that can be left. */@@ -576,6 +580,8 @@ export function Reader({onAction,onMove,onReply,+ onEditDraft,+ onDiscardDraft,notify,onMailto,unsubscribe,@@ -583,11 +589,14 @@ export function Reader({loading = false,}: ReaderProps) {const keys = useShortcutText()- const last = messages[messages.length - 1]+ // Unsent drafts sit below the conversation they would continue, never among what was said.+ const history = messages.filter((m) => !isDraft(m))+ const drafts = messages.filter(isDraft)+ const last = history.at(-1)const initiallyExpanded = () =>new Set(messages- .filter((m) => !m.keywords.$seen)+ .filter((m) => !m.keywords.$seen || isDraft(m)).map((m) => m.id).concat(last?.id || ''),)@@ -621,15 +630,16 @@ export function Reader({return next})const [showAll, setShowAll] = useState(false)- if (!last) return null+ const newest = last || drafts.at(-1)+ if (!newest) return null// Long threads show their first message and the latest few; the middle folds into one row.const folded =- !showAll && messages.length > 4- ? messages.slice(1, -2).filter((m) => !expanded.has(m.id) || m.id === last.id)+ !showAll && history.length > 4+ ? history.slice(1, -2).filter((m) => !expanded.has(m.id) || m.id === last?.id): []const foldedIds = new Set(folded.length > 1 ? folded.map((m) => m.id) : [])const participants = [- ...new Set(messages.flatMap((m) => m.from.map((a) => a.name || a.email.split('@')[0]))),+ ...new Set(history.flatMap((m) => m.from.map((a) => a.name || a.email.split('@')[0]))),]return (<div className="reader-page">@@ -769,17 +779,17 @@ export function Reader({<span title={account.email}>{account.name}</span><ChevronRight size={11} /><span>- {messages.length > 1- ? messages.length ++ {history.length > 1+ ? history.length +' messages · ' +participants.slice(0, 3).join(', ') +(participants.length > 3 ? ' +' + (participants.length - 3) : ''): 'Conversation'}</span></div>- <h1>{last.subject || '(No subject)'}</h1>+ <h1>{newest.subject || '(No subject)'}</h1><div className="conversation-messages">- {messages.map((message) => {+ {[...history, ...drafts].map((message) => {if (foldedIds.has(message.id))return message.id === folded[0].id ? (<button key="folded" className="folded-messages" onClick={() => setShowAll(true)}>@@ -787,59 +797,83 @@ export function Reader({</button>) : nullconst open = expanded.has(message.id) || messages.length === 1+ const draft = isDraft(message)const sender = message.from[0]const when = messageDate(message.receivedAt)+ const recipients = [...message.to, ...message.cc].map((a) => a.name || a.email)const attachments =message.attachments?.filter((a) => !a.cid || a.disposition === 'attachment') || []return (<article- className={'message-card ' + (!open ? 'collapsed-message' : '')}+ className={+ 'message-card' ++ (draft ? ' draft-message' : '') ++ (!open ? ' collapsed-message' : '')+ }+ aria-label={draft ? 'Draft, not sent' : undefined}key={message.id}><div className="message-heading">- <SenderAvatar- name={sender?.name || sender?.email || '?'}- email={sender?.email}- color={account.color}- size={35}- remoteImages={settings.remoteImages}- />+ {draft ? (+ <span className="draft-mark" aria-hidden="true">+ <PencilEdit size={16} />+ </span>+ ) : (+ <SenderAvatar+ name={sender?.name || sender?.email || '?'}+ email={sender?.email}+ color={account.color}+ size={35}+ remoteImages={settings.remoteImages}+ />+ )}<buttonclassName="message-person"onClick={() => toggle(message.id, setExpanded)}aria-expanded={open}disabled={messages.length === 1}>- <span className="sender-name">- {sender?.name || sender?.email}- <span className="sender-address">{sender?.name ? sender.email : ''}</span>- </span>+ {draft ? (+ <span className="sender-name">+ <span className="draft-badge">Draft</span>+ Not sent yet+ </span>+ ) : (+ <span className="sender-name">+ {sender?.name || sender?.email}+ <span className="sender-address">{sender?.name ? sender.email : ''}</span>+ </span>+ )}<span className="message-to">- {open- ? 'to ' +- ([...message.to, ...message.cc]- .map((a) => a.name || a.email)- .join(', ') || 'undisclosed recipients')- : message.preview}+ {!open+ ? message.preview+ : recipients.length+ ? 'to ' + recipients.join(', ')+ : draft+ ? 'No recipients yet'+ : 'to undisclosed recipients'}</span></button>{!!message.attachments?.length && !open && (<Paperclip size={13} className="message-attachment-hint" />)}<time dateTime={message.receivedAt} title={longDate(message.receivedAt)}>+ {draft && 'Saved '}{when.date}<span> · {when.time}</span></time>- <IconButton- label="Message details"- aria-expanded={details.has(message.id)}- onClick={() => toggle(message.id, setDetails)}- >- <ChevronDown- size={13}- className={'details-chevron' + (details.has(message.id) ? ' open' : '')}- />- </IconButton>+ {!draft && (+ <IconButton+ label="Message details"+ aria-expanded={details.has(message.id)}+ onClick={() => toggle(message.id, setDetails)}+ >+ <ChevronDown+ size={13}+ className={'details-chevron' + (details.has(message.id) ? ' open' : '')}+ />+ </IconButton>+ )}</div>{details.has(message.id) && (<dl className="message-details">@@ -918,33 +952,47 @@ export function Reader({})}</div>)}+ {draft && (+ <div className="draft-message-actions">+ <Button onClick={() => onEditDraft(message)}>+ <PencilEdit size={14} />+ Continue editing+ </Button>+ <Button variant="ghost" onClick={() => onDiscardDraft(message)}>+ <Trash2 size={14} />+ Discard draft+ </Button>+ </div>+ )}</div>)}</article>)})}</div>- <div className="reply-panel">- <button className="reply-prompt" onClick={() => onReply(last, 'reply')}>- <Reply size={17} />- <span>- <strong>Reply to {last.from[0]?.name || last.from[0]?.email || 'sender'}</strong>- </span>- <ShortcutHint id="reply" />- </button>- <div className="reply-bar">- <Button variant="ghost" onClick={() => onReply(last, 'replyAll')}>- <ReplyAll size={14} />- Reply all- <ShortcutHint id="replyAll" />- </Button>- <Button variant="ghost" onClick={() => onReply(last, 'forward')}>- <Forward size={14} />- Forward- <ShortcutHint id="forward" />- </Button>+ {last && (+ <div className="reply-panel">+ <button className="reply-prompt" onClick={() => onReply(last, 'reply')}>+ <Reply size={17} />+ <span>+ <strong>Reply to {last.from[0]?.name || last.from[0]?.email || 'sender'}</strong>+ </span>+ <ShortcutHint id="reply" />+ </button>+ <div className="reply-bar">+ <Button variant="ghost" onClick={() => onReply(last, 'replyAll')}>+ <ReplyAll size={14} />+ Reply all+ <ShortcutHint id="replyAll" />+ </Button>+ <Button variant="ghost" onClick={() => onReply(last, 'forward')}>+ <Forward size={14} />+ Forward+ <ShortcutHint id="forward" />+ </Button>+ </div></div>- </div>+ )}</div></div>{link && (diff --git a/apps/desktop/src/renderer/src/demo.ts b/apps/desktop/src/renderer/src/demo.tsindex 356ac86..810029f 100644--- a/apps/desktop/src/renderer/src/demo.ts+++ b/apps/desktop/src/renderer/src/demo.ts@@ -21,6 +21,7 @@ import {type MutationInput,type SubmissionSummary,} from '@inlark/core'+import { longDate } from './mail-date'const names = ['Personal', 'Studio', 'Projects', 'Community', 'Archive']const emails = [@@ -498,6 +499,91 @@ const submissionFor = (draftId: string) => {if (!found) throw new Error('This send is no longer tracked.')return found}++/* ——— Server drafts: a synced reply is filed in its conversation, as a real server does ——— */+const serverDrafts = new Map<string, Message>()+const threadDrafts = (accountId: string, threadId: string) =>+ [...serverDrafts.values()]+ .filter((m) => m.accountId === accountId && m.threadId === threadId)+ .sort((a, b) => a.receivedAt.localeCompare(b.receivedAt))+/** A list entry for a sample message, with any drafts filed in its conversation. */+function listed(accountId: string, m: Message) {+ const messages = [m, ...threadDrafts(accountId, m.threadId)]+ // Display the matching message, as the providers do, even when a draft is newer.+ return {+ ...conversationFromMessages(accountId, m.threadId, messages),+ subject: m.subject,+ preview: m.preview,+ receivedAt: m.receivedAt,+ count: messages.length,+ }+}+function fileDraft(draft: Draft): Draft {+ if (!draft.replyThreadId) return draft+ const id = draft.serverId || 'draft-' + draft.id+ const account = demoAccounts.find((a) => a.id === draft.accountId)!+ serverDrafts.set(id, {+ id,+ accountId: account.id,+ threadId: draft.replyThreadId,+ subject: draft.subject,+ from: [{ name: account.senderName || 'Paul', email: account.email }],+ to: draft.to,+ cc: draft.cc,+ bcc: draft.bcc,+ replyTo: [],+ receivedAt: draft.updatedAt,+ preview: draft.text.replace(/\s+/g, ' ').trim().slice(0, 140),+ size: draft.text.length,+ hasAttachment: draft.attachments.length > 0,+ keywords: { $draft: true, $seen: true },+ mailboxIds: { drafts: true },+ html: draft.html,+ text: draft.text,+ messageId: [id + '@demo.example'],+ inReplyTo: draft.inReplyTo,+ references: draft.references,+ })+ return { ...draft, serverId: id }+}+const unfileDraft = (draft: Draft | undefined) => {+ if (draft) serverDrafts.delete(draft.serverId || 'draft-' + draft.id)+}+// One reply waits unsent in Maya's conversation, to show how a draft reads in a thread.+{+ const original = message(0, 2)+ const sender = original.from[0]+ const reply =+ 'Agreed, the quieter direction is the one. I’ll tidy up the explorations and send them over on Thursday.'+ const attribution =+ 'On ' + longDate(original.receivedAt) + ', ' + sender.name + ' <' + sender.email + '> wrote:'+ const draft = fileDraft({+ // Stable, so the cached draft list restored on reload still matches the thread.+ id: 'b6f1d2a4-7c3e-4f8a-9d2b-5e6c7a8b9c0d',+ accountId: original.accountId,+ identityId: 'identity',+ to: original.from,+ cc: [],+ bcc: [],+ subject: 'Re: ' + original.subject,+ html:+ '<p>Hi Maya,</p><p>' ++ reply ++ '</p><p>Paul</p><p>' ++ attribution.replace('<', '<').replace('>', '>') ++ '</p><blockquote>' ++ original.html ++ '</blockquote>',+ text: 'Hi Maya,\n\n' + reply + '\n\nPaul\n\n' + attribution + '\n> ' + original.preview,+ attachments: [],+ updatedAt: new Date(referenceTime.getTime() - 20 * 60_000).toISOString(),+ status: 'synced',+ inReplyTo: original.messageId,+ references: original.messageId,+ replyThreadId: original.threadId,+ })+ drafts.set(draft.id, draft)+}const copyOf = (source: Draft, patch: Partial<Draft>): Draft => ({...source,id: crypto.randomUUID(),@@ -716,10 +802,7 @@ export const demoAPI: DesktopMailAPI = {accountId: account.id,position,page: {- items: selected.map((m) => ({- ...conversationFromMessages(account.id, m.threadId, [m]),- count: 1,- })),+ items: selected.map((m) => listed(account.id, m)),total,next: position + 50 < total ? position + 50 : undefined,incomplete: indexing(account),@@ -733,7 +816,7 @@ export const demoAPI: DesktopMailAPI = {const accountIndex = demoAccounts.findIndex((a) => a.id === accountId)const m = get(accountIndex, Number(threadId.replace('thread-', '')))if (!m) throw new Error('Conversation not found.')- return [m]+ return [m, ...threadDrafts(accountId, threadId)]},mutate: async (input) => {const saved: [string, Message | null | undefined][] = []@@ -813,8 +896,12 @@ export const demoAPI: DesktopMailAPI = {)changed()},- resumeDraft: async () => {- throw new Error('No server draft is available.')+ resumeDraft: async (accountId, messageId) => {+ const linked = [...drafts.values()].find(+ (d) => d.accountId === accountId && d.serverId === messageId,+ )+ if (!linked) throw new Error('No server draft is available.')+ return linked},stageRemoteAttachments: async () => [],drafts: async () => [...drafts.values()],@@ -823,15 +910,22 @@ export const demoAPI: DesktopMailAPI = {return draft},syncDraft: async (draft) => {- const result = { ...draft, status: 'synced' as const }+ const result = fileDraft({ ...draft, status: 'synced' as const })drafts.set(draft.id, result)+ if (result.serverId) changed()return result},deleteDraft: async (id) => {+ unfileDraft(drafts.get(id))drafts.delete(id)changed()},deleteServerDraft: async (accountId, messageId) => {+ if (serverDrafts.delete(messageId)) {+ for (const draft of drafts.values())+ if (draft.accountId === accountId && draft.serverId === messageId) drafts.delete(draft.id)+ return changed()+ }const accountIndex = demoAccounts.findIndex((a) => a.id === accountId)changes.set(accountIndex + ':' + messageId.replace('message-', ''), null)changed()@@ -869,6 +963,7 @@ export const demoAPI: DesktopMailAPI = {message: 'Delivery is not confirmed. Your draft is safe. Check status before trying again.',}}+ unfileDraft(drafts.get(draft.id) || draft)drafts.delete(draft.id)// Record the outcome before announcing the change, as the desktop app does.queueMicrotask(changed)diff --git a/apps/desktop/src/renderer/src/styles.css b/apps/desktop/src/renderer/src/styles.cssindex c9bb476..834c0bf 100644--- a/apps/desktop/src/renderer/src/styles.css+++ b/apps/desktop/src/renderer/src/styles.css@@ -3068,6 +3068,65 @@ fieldset.compose-format:disabled {.details-chevron.open {transform: rotate(180deg);}+/* An unsent draft must never pass for sent mail. A dashed outline marks it as unfinished, and+ the small amber label is its only colour. The card bleeds past the column so its mark still+ lines up with the senders above. */+.draft-message {+ margin: 6px -20px 0;+ padding: 18px 20px 20px;+ border: 1px dashed color-mix(in srgb, var(--text) 22%, transparent);+ border-radius: 10px;+}+.draft-message + .draft-message {+ margin-top: 10px;+}+.draft-message.collapsed-message {+ padding-top: 14px;+ padding-bottom: 14px;+}+.draft-message.collapsed-message .message-heading {+ opacity: 1;+}+.draft-mark {+ display: grid;+ place-items: center;+ width: 35px;+ height: 35px;+ flex-shrink: 0;+ border: 1px dashed color-mix(in srgb, var(--text) 28%, transparent);+ border-radius: 50%;+ color: var(--muted);+}+.draft-message .sender-name {+ display: flex;+ align-items: center;+ gap: 8px;+ color: var(--secondary);+ font-weight: 500;+}+.draft-badge {+ padding: 0 6px;+ border-radius: 4px;+ background: color-mix(in srgb, var(--draft) 14%, transparent);+ color: var(--draft);+ font-size: 11px;+ font-weight: 550;+ line-height: 18px;+}+.draft-message .message-content {+ padding-top: 18px;+}+.draft-message-actions {+ display: flex;+ gap: 6px;+ margin-top: 16px;+}+.row-draft {+ flex-shrink: 0;+ color: var(--draft);+ font-size: 11px;+ font-weight: 600;+}.attachment-card {padding: 6px 6px 6px 8px;gap: 4px;diff --git a/packages/core/src/mail.ts b/packages/core/src/mail.tsindex 6268aff..943a614 100644--- a/packages/core/src/mail.ts+++ b/packages/core/src/mail.ts@@ -29,6 +29,10 @@ export function identitySignature(if (identity.htmlSignature?.trim()) return { format: 'html', value: identity.htmlSignature }return { format: 'text', value: identity.textSignature ?? '' }}+/** A saved but unsent message. Servers file reply drafts in the conversation they answer. */+export const isDraft = (message: Pick<Message, 'keywords'>) => !!message.keywords.$draft+/** The newest message of a conversation that was actually sent or received, oldest-first input. */+export const replyTarget = (messages: Message[]) => messages.filter((m) => !isDraft(m)).at(-1)export function conversationFromMessages(accountId: string,threadId: string,@@ -36,13 +40,17 @@ export function conversationFromMessages(): Conversation {const sorted = [...messages].sort((a, b) => b.receivedAt.localeCompare(a.receivedAt))const latest = sorted[0]+ // The author of an unsent draft has not taken part yet.+ const said = sorted.filter((m) => !isDraft(m))return {id: threadId,accountId,key: scopeKey(accountId, threadId),subject: latest?.subject || '(No subject)',from: [- ...new Map(sorted.flatMap((m) => m.from).map((a) => [a.email.toLowerCase(), a])).values(),+ ...new Map(+ (said.length ? said : sorted).flatMap((m) => m.from).map((a) => [a.email.toLowerCase(), a]),+ ).values(),],preview: latest?.preview || '',receivedAt: latest?.receivedAt || '',@@ -96,7 +104,7 @@ export function unlinkedServerDrafts(conversations: Conversation[], local: Draft...new Map(conversations.flatMap((c) => c.messages)- .filter((m) => m.keywords.$draft && !linked.has(scopeKey(m.accountId, m.id)))+ .filter((m) => isDraft(m) && !linked.has(scopeKey(m.accountId, m.id))).map((m) => [scopeKey(m.accountId, m.id), m]),).values(),].sort((a, b) => b.receivedAt.localeCompare(a.receivedAt))diff --git a/packages/ui/src/icons.tsx b/packages/ui/src/icons.tsxindex 30f42fa..5363429 100644--- a/packages/ui/src/icons.tsx+++ b/packages/ui/src/icons.tsx@@ -53,6 +53,7 @@ import {ParagraphBulletsPoint02Icon as BulletListGlyph,Paperclip as PaperclipGlyph,PenLine as PenLineGlyph,+ PencilEdit02Icon as PencilEditGlyph,Plus as PlusGlyph,RefreshCw as RefreshCwGlyph,Reply as ReplyGlyph,@@ -137,6 +138,7 @@ export const PanelLeftOpen = icon(PanelLeftOpenGlyph)export const BulletList = icon(BulletListGlyph)export const Paperclip = icon(PaperclipGlyph)export const PenLine = icon(PenLineGlyph)+export const PencilEdit = icon(PencilEditGlyph)export const Plus = icon(PlusGlyph)export const RefreshCw = icon(RefreshCwGlyph)export const Reply = icon(ReplyGlyph)diff --git a/packages/ui/src/styles.css b/packages/ui/src/styles.cssindex 368a84b..4ae62af 100644--- a/packages/ui/src/styles.css+++ b/packages/ui/src/styles.css@@ -42,6 +42,8 @@--green: #76bc9a;--red: #ea9198;--star: #d4b36e;+ /* The label on unsent drafts, so they never pass for sent mail. */+ --draft: #d4b36e;--skeleton: #ffffff0d;--shadow: 0 24px 80px #0005, 0 4px 16px #0003;font-family:@@ -80,6 +82,7 @@--green: #3d9066;--red: #b94d55;--star: #b8892c;+ --draft: #8f661a;--skeleton: #17191f0e;--shadow: 0 18px 70px #10121a1a;}diff --git a/tests/core.test.ts b/tests/core.test.tsindex 6939247..bfe1abf 100644--- a/tests/core.test.ts+++ b/tests/core.test.ts@@ -6,6 +6,7 @@ import {conversationFromMessages,mergePages,replyRecipients,+ replyTarget,parseAddresses,mailtoDraft,draftSchema,@@ -75,6 +76,32 @@ describe('mail domain', () => {),).toEqual([scopeKey('account', 'conflict'), scopeKey('other', 'local')])})+ it('replies to the newest sent or received message, never to an unsent draft', () => {+ const first = message({ id: 'first' })+ const answer = message({ id: 'answer', receivedAt: '2026-09-23T11:00:00Z' })+ const reply = message({+ id: 'reply',+ receivedAt: '2026-09-23T12:00:00Z',+ keywords: { $draft: true, $seen: true },+ })+ expect(replyTarget([first, answer, reply])?.id).toBe('answer')+ expect(replyTarget([reply])).toBeUndefined()+ })+ it('lists only the people who wrote, not the author of an unsent draft', () => {+ const received = message({ id: 'received' })+ const reply = message({+ id: 'reply',+ from: [{ name: 'Me', email: '[email protected]' }],+ receivedAt: '2026-09-23T12:00:00Z',+ keywords: { $draft: true, $seen: true },+ })+ expect(+ conversationFromMessages('account', 'thread', [received, reply]).from.map((a) => a.email),+ ).toEqual(['[email protected]'])+ expect(conversationFromMessages('account', 'thread', [reply]).from.map((a) => a.email)).toEqual(+ ['[email protected]'],+ )+ })it('merges pages without skipping unconsumed messages from another account', () => {const conv = (a: string, id: string, time: string) =>conversationFromMessages(a, id, [message({ accountId: a, threadId: id, receivedAt: time })])