thread fix

This commit is contained in:
debu-2 2026-10-06 04:42:47 +05:30
parent d58fb8841b
commit a58ba11566
11 changed files with 177 additions and 30 deletions

View file

@ -39,7 +39,13 @@ function joinAddresses(value) {
.join(", ");
}
function messagePreview(message) {
return (message?.new_reply_content || message?.snippet || "").trim();
}
function messageBody(email) {
const preview = messagePreview(email);
if (preview) return { mode: "text", value: preview };
const text = (email?.body_text || email?.text_body || email?.plain_text || "").trim();
if (text) return { mode: "text", value: text };
const html = (email?.body_html || "").trim();
@ -49,6 +55,39 @@ function messageBody(email) {
return { mode: "text", value: "This message has no readable content." };
}
function MessageBodyContent({ message }) {
const [showQuoted, setShowQuoted] = useState(false);
const body = messageBody(message);
const quoted = (message?.quoted_content || "").trim();
const hasQuoted = Boolean(message?.has_quoted_text && quoted);
return (
<>
<div className={`mail-detail-body${body.mode === "html" ? " is-html" : ""}`}>
{body.mode === "html" ? (
<div className="mail-detail-body-html" dangerouslySetInnerHTML={{ __html: body.value }} />
) : (
<div className="mail-detail-body-text">{body.value}</div>
)}
</div>
{hasQuoted ? (
<button
type="button"
className="mail-quoted-toggle"
onClick={() => setShowQuoted((open) => !open)}
aria-expanded={showQuoted}
aria-label={showQuoted ? "Hide quoted text" : "Show quoted text"}
>
<span aria-hidden="true">···</span>
</button>
) : null}
{showQuoted && quoted ? (
<pre className="mail-quoted-body">{quoted}</pre>
) : null}
</>
);
}
function detailTime(email) {
const value = email?.received_at || email?.sent_at || email?.created_at || email?.updated_at;
if (!value) return { absolute: "", relative: "" };
@ -149,7 +188,6 @@ function MessageBlock({
onMove,
}) {
const [headersOpen, setHeadersOpen] = useState(false);
const body = messageBody(message);
const time = detailTime(message);
const sender = senderIdentity(message);
const attachments = message?.attachments || [];
@ -160,7 +198,7 @@ function MessageBlock({
<SenderAvatar email={message} />
<span className="mail-thread-message-collapsed-main">
<strong>{sender?.name}</strong>
<span>{message.snippet || message.body_text || ""}</span>
<span>{messagePreview(message) || message.body_text || ""}</span>
</span>
<time>{time.absolute}</time>
</button>
@ -218,14 +256,8 @@ function MessageBlock({
</MessageAction>
</div>
</div>
<div className={`mail-detail-message-content${body?.mode === "html" ? " is-html" : ""}`}>
<div className={`mail-detail-body${body?.mode === "html" ? " is-html" : " is-text"}`}>
{body?.mode === "html" ? (
<div className="mail-detail-body-html" dangerouslySetInnerHTML={{ __html: body.value }} />
) : (
<div className="mail-detail-body-text">{body?.value}</div>
)}
</div>
<div className="mail-detail-message-content">
<MessageBodyContent message={message} />
{attachments.length > 0 && (
<div className="mail-detail-attachments" aria-label="Attachments">
{attachments.map((file) => (

View file

@ -86,7 +86,7 @@ function buildReplyContext(message, replyAll = false) {
const sender = message?.sender || { name: "", address: "" };
const subject = (message?.subject || "").trim();
const replySubject = /^re:/i.test(subject) ? subject : `Re: ${subject || "(No subject)"}`;
const quote = (message?.body_text || message?.snippet || "").trim();
const quote = (message?.new_reply_content || message?.body_text || message?.snippet || "").trim();
return {
replyToMessageId: message.id,
replyAll,
@ -781,7 +781,7 @@ export default function MailboxView({
const target = threadDetail?.messages?.[threadDetail.messages.length - 1] || detail;
onCompose?.({
subject: `Fwd: ${target?.subject || ""}`,
bodyHtml: `<p><br></p><blockquote>${(target?.body_text || target?.snippet || "").replace(/\n/g, "<br>")}</blockquote>`,
bodyHtml: `<p><br></p><blockquote>${(target?.new_reply_content || target?.body_text || target?.snippet || "").replace(/\n/g, "<br>")}</blockquote>`,
});
}}
onExtractActions={() => detail && extractActions(detail)}

View file

@ -855,6 +855,9 @@ h1 em { color:var(--coral); font-style:normal; font-weight:500; }
.mail-thread-message-collapsed-main strong { font:600 12px/1.3 "DM Sans"; color:#171424; }
.mail-thread-message-collapsed-main span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#77758a; font-size:11px; }
.mail-thread-message-collapsed time { color:#77758a; font-size:11px; white-space:nowrap; }
.mail-quoted-toggle { margin:10px 0 0; padding:2px 10px; border:1px solid #e8e5ee; border-radius:999px; background:#f7f6f9; color:#77758a; font-size:16px; line-height:1; letter-spacing:1px; cursor:pointer; }
.mail-quoted-toggle:hover { background:#f1eff3; color:#4a4652; }
.mail-quoted-body { margin:10px 0 0; padding:12px 14px; border-left:2px solid #e8e5ee; border-radius:0 8px 8px 0; background:#faf9fc; color:#77758a; font-size:12px; line-height:1.5; white-space:pre-wrap; overflow:auto; }
.mailbox-thread-count { min-width:18px; height:18px; padding:0 6px; display:inline-grid; place-items:center; border-radius:999px; background:#f1eff3; color:#716d7a; font-size:10px; font-weight:600; }
.agent-panel.email-context .agent-stat-grid,
.agent-panel.email-context .agent-context-block,