From c44a9ce6e073f445dd076fb497f0b9f464d33775 Mon Sep 17 00:00:00 2001 From: Chance Date: Sat, 9 May 2026 08:11:28 -0400 Subject: [PATCH] fix: fall back to primary identity signature on reply When auto-select picks an alias identity matching the original recipient, the alias often has no signature configured. The composer was using the alias's empty signature for both the visual preview and the appended signature on send, so neither showed up. New mail worked because no auto-select runs. Add a signatureIdentity that falls back to the primary when the current identity has no signature. From address, identity ID, S/MIME, and draft saves still use currentIdentity so mail goes out from the right address. --- components/email/email-composer.tsx | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/components/email/email-composer.tsx b/components/email/email-composer.tsx index 1bb8a74c..24fda38b 100644 --- a/components/email/email-composer.tsx +++ b/components/email/email-composer.tsx @@ -281,6 +281,12 @@ export function EmailComposer({ const currentIdentity = selectedIdentityId ? identities.find((identity) => identity.id === selectedIdentityId) || primaryIdentity : primaryIdentity; + // Alias identities often lack a configured signature — fall back to the primary + // identity's signature so replies (which auto-select a matching alias) still + // populate the user's signature. + const signatureIdentity = (currentIdentity?.htmlSignature || currentIdentity?.textSignature) + ? currentIdentity + : primaryIdentity; useEffect(() => { if (!autoSelectReplyIdentity) return; if (selectedIdentityId || initialData?.selectedIdentityId) return; @@ -322,10 +328,10 @@ export function EmailComposer({ selectedIdentityId, ]); - const composerSignatureHtml = currentIdentity?.htmlSignature - ? `
${sanitizeEmailHtml(currentIdentity.htmlSignature)}
` - : currentIdentity?.textSignature - ? `
${getPlainTextSignature(currentIdentity).replace(/&/g, '&').replace(//g, '>').replace(/\n/g, '
')}
` + const composerSignatureHtml = signatureIdentity?.htmlSignature + ? `
${sanitizeEmailHtml(signatureIdentity.htmlSignature)}
` + : signatureIdentity?.textSignature + ? `
${getPlainTextSignature(signatureIdentity).replace(/&/g, '&').replace(//g, '>').replace(/\n/g, '
')}
` : ''; const getAutocomplete = useContactStore((s) => s.getAutocomplete); const addToTrustedSendersBook = useContactStore((s) => s.addToTrustedSendersBook); @@ -954,11 +960,11 @@ export function EmailComposer({ // Body is already HTML from the rich text editor (or plain text in plain text mode). // Build HTML signature block (used only in rich text mode) const buildSignatureHtml = (): string => { - if (currentIdentity?.htmlSignature) { - return `

--
${sanitizeEmailHtml(currentIdentity.htmlSignature)}`; + if (signatureIdentity?.htmlSignature) { + return `

--
${sanitizeEmailHtml(signatureIdentity.htmlSignature)}`; } - if (currentIdentity?.textSignature) { - return `

--
${currentIdentity.textSignature.replace(/&/g, '&').replace(//g, '>').replace(/\n/g, '
')}`; + if (signatureIdentity?.textSignature) { + return `

--
${signatureIdentity.textSignature.replace(/&/g, '&').replace(//g, '>').replace(/\n/g, '
')}`; } return ''; }; @@ -970,8 +976,8 @@ export function EmailComposer({ // In plain text mode, send text/plain only (no HTML body) const finalBody = plainTextMode - ? appendPlainTextSignature(body, currentIdentity) - : appendPlainTextSignature(htmlToPlainText(body), currentIdentity); + ? appendPlainTextSignature(body, signatureIdentity) + : appendPlainTextSignature(htmlToPlainText(body), signatureIdentity); const rewritten = plainTextMode ? null : rewriteInlineImages(body); const finalHtmlBody = plainTextMode @@ -1500,9 +1506,9 @@ export function EmailComposer({ )} {plainTextMode ? ( - getPlainTextSignature(currentIdentity) ? ( + getPlainTextSignature(signatureIdentity) ? (
- {'-- \n'}{getPlainTextSignature(currentIdentity)} + {'-- \n'}{getPlainTextSignature(signatureIdentity)}
) : null ) : composerSignatureHtml ? (