inbox streamlining

This commit is contained in:
debu-2 2026-10-05 22:22:18 +05:30
parent c26a8a2094
commit f969cfed44
4 changed files with 382 additions and 104 deletions

View file

@ -76,9 +76,26 @@ function metricTotal(stats) {
return cards.reduce((sum, card) => sum + (stats[card.key] || 0), 0);
}
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;
}
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("repl")) actions.push("Review replies");
if (text.includes("attach")) actions.push("Review attachments");
if (!actions.length) actions.push("Review message", "Draft a reply");
return actions.slice(0, 3);
}
export default function AgAgentPanel({
account,
emails,
contextEmail,
focus,
insight,
loading = false,
@ -95,9 +112,10 @@ export default function AgAgentPanel({
const firstName = account?.first_name || "there";
const allMetricsZero = metricTotal(stats) === 0;
const hasQuery = agentQuery.trim().length > 0;
const emailContextMode = Boolean(contextEmail) && !insight;
const showOnboarding = !insight && !loading && mailboxEmpty && isBrandNewMailbox;
const showQuietEmpty = !insight && !loading && mailboxEmpty && !isBrandNewMailbox;
const showFullPanel = !insight && !loading && !mailboxEmpty;
const showFullPanel = !insight && !loading && !mailboxEmpty && !emailContextMode;
function submitAgentQuery(event) {
event.preventDefault();
@ -108,7 +126,7 @@ export default function AgAgentPanel({
}
return (
<section className="agent-panel" aria-label="AG Agent">
<section className={`agent-panel${emailContextMode ? " email-context" : ""}`} aria-label="AG Agent">
<header className="agent-panel-head">
<span className="agent-panel-mark" aria-hidden="true">
<Sparkles {...ICON} />
@ -136,15 +154,33 @@ export default function AgAgentPanel({
<div className="agent-panel-hello">
<strong>{greeting(firstName)}</strong>
<span>
{showOnboarding
? "Your new inbox is ready."
: showQuietEmpty
? "Nothing needs your attention right now."
: "Here's what needs your attention today."}
{emailContextMode
? "About this email"
: showOnboarding
? "Your new inbox is ready."
: showQuietEmpty
? "Nothing needs your attention right now."
: "Here's what needs your attention today."}
</span>
</div>
)}
{emailContextMode && (
<section className="agent-email-context">
<h3>Summary</h3>
<p>{emailContextSummary(contextEmail)}</p>
<h3>Action items</h3>
<ul>
{emailContextActions(contextEmail).map((item) => (
<li key={item}>{item}</li>
))}
</ul>
<button type="button" className="agent-email-context-reply" onClick={() => onCompose?.()}>
<PenLine {...ICON_SM} /> Draft reply
</button>
</section>
)}
{!insight && loading && (
<div className="agent-loading-block" aria-hidden="true">
<span className="agent-loading-pulse" />