`2px solid ${c}`),
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.05)",
}}
>
{/* Email header */}
{derive(analysis, (a) => a.email.subject)}
{derive(analysis, (a) => a.email.from)} •{" "}
{derive(analysis, (a) => formatDate(a.email.date))}
{derive(
analysis,
(a) => truncateText(a.email.snippet, 150),
)}
{/* Confidence badge */}
{ifElse(
derive(
{
pending: analysis.pending,
result: analysis.result,
},
({ pending, result }) => !pending && result,
),
{
if (!result) return "#f3f4f6";
if (result.confidence >= 0.8) {
return "#d1fae5";
}
if (result.confidence >= 0.5) {
return "#fef3c7";
}
return "#f3f4f6";
},
),
color: derive(
analysis.result,
(result) => {
if (!result) return "#6b7280";
if (result.confidence >= 0.8) {
return "#059669";
}
if (result.confidence >= 0.5) {
return "#b45309";
}
return "#6b7280";
},
),
}}
>
{derive(
analysis.result,
(result) =>
result
? `${Math.round(result.confidence * 100)}%`
: "",
)}
,
null,
)}
{/* Suggestion section */}
{ifElse(
analysis.pending,
Analyzing...
,
// Show suggestion when analysis is complete
ifElse(
derive(
analysis.result,
(result) => result?.actionType === "edit-note",
),
// Edit note suggestion
Suggest: Edit note "
{derive(analysis.result, (result) =>
result?.actionType === "edit-note"
? result.noteTitle || ""
: "")}
"
{derive(
analysis.result,
(result) => result?.reasoning || "",
)}
{derive(
analysis.result,
(result) =>
result?.actionType === "edit-note"
? truncateText(result.addition || "", 200)
: "",
)}
,
ifElse(
derive(
analysis.result,
(result) =>
result?.actionType === "create-note",
),
// Create note suggestion
Suggest: Create note "
{derive(
analysis.result,
(result) =>
result?.actionType === "create-note"
? result.title || ""
: "",
)}
"
{derive(
analysis.result,
(result) => result?.reasoning || "",
)}
{derive(
analysis.result,
(result) =>
result?.actionType === "create-note"
? truncateText(result.content || "", 200)
: "",
)}
,
// No action or low confidence
{derive(
analysis.result,
(result) =>
result?.actionType === "no-action"
? `No auto-suggestion: ${
result.reason || ""
}`
: "No auto-suggestion available",
)}
,
),
),
)}
{/* Action buttons */}
{ifElse(
derive(analysis.pending, (pending) => !pending),
{/* Execute button - only show for actionable suggestions */}
{ifElse(
derive(
analysis.result,
(result) => {
return (
result &&
(result.actionType === "edit-note" ||
result.actionType === "create-note")
);
},
),
,
null,
)}
{/* Dismiss button */}
,
null,
)}
);
})}