inbox streamlining

This commit is contained in:
debu-2 2026-10-05 22:33:29 +05:30
parent f969cfed44
commit 220168abd0
4 changed files with 279 additions and 245 deletions

View file

@ -77,18 +77,37 @@ function metricTotal(stats) {
}
function emailContextSummary(email) {
const text = (email?.body_text || email?.snippet || "").trim();
if (!text) return "Open message loaded — summary will appear here.";
return text.length > 160 ? `${text.slice(0, 157)}…` : text;
const text = (email?.body_text || email?.snippet || "").trim().toLowerCase();
const sender = email?.sender?.name || email?.sender_display_name || "The sender";
if (!text) return "This message is open — a summary will appear here.";
if (text.includes("check") && text.includes("inbox") && text.includes("repl")) {
return `${sender} asks you to check the inbox and review messages and replies.`;
}
if (text.includes("check") && text.includes("inbox")) {
return `${sender} asks you to check the inbox.`;
}
if (text.includes("repl")) {
return `${sender} is following up about replies or responses.`;
}
if (text.includes("attach")) {
return `${sender} references an attachment that may need review.`;
}
const snippet = (email?.body_text || email?.snippet || "").trim();
const firstSentence = snippet.split(/[.!?\n]/).find((part) => part.trim().length > 8)?.trim();
if (firstSentence) {
return `${sender} wrote: “${firstSentence.length > 120 ? `${firstSentence.slice(0, 117)}…` : firstSentence}.”`;
}
return `${sender} sent a short message that may need a response.`;
}
function emailContextActions(email) {
const text = (email?.body_text || email?.snippet || "").toLowerCase();
const actions = [];
if (text.includes("check") && text.includes("inbox")) actions.push("Check inbox");
if (text.includes("message")) actions.push("Review messages");
if (text.includes("repl")) actions.push("Review replies");
if (text.includes("attach")) actions.push("Review attachments");
if (!actions.length) actions.push("Review message", "Draft a reply");
if (!actions.length) actions.push("Review message");
return actions.slice(0, 3);
}
@ -170,9 +189,12 @@ export default function AgAgentPanel({
<h3>Summary</h3>
<p>{emailContextSummary(contextEmail)}</p>
<h3>Action items</h3>
<ul>
<ul className="agent-email-action-list">
{emailContextActions(contextEmail).map((item) => (
<li key={item}>{item}</li>
<li key={item}>
<span className="agent-email-action-check" aria-hidden="true" />
{item}
</li>
))}
</ul>
<button type="button" className="agent-email-context-reply" onClick={() => onCompose?.()}>
@ -209,7 +231,7 @@ export default function AgAgentPanel({
</div>
)}
{showFullPanel && !allMetricsZero && (
{showFullPanel && !emailContextMode && !allMetricsZero && (
<div className="agent-stat-grid">
{cards.map((card) => {
const Icon = card.icon;