-
- {humanizeAction(approval.action_type)}
-
-
-
- Requested {formatTimestamp(approval.created_at)}
-
- {summaryLine ? (
- <>
- •
- {summaryLine}
- >
- ) : null}
-
+ ) : (
+ (() => {
+ const summary = approvalSummary(selectedApproval);
+ const titleRow = summary.rows.find(
+ (row) => row.label.toLowerCase() === "title"
+ );
+ const titleText = titleRow?.value?.trim() ?? "";
+ const descriptionText = summary.description?.trim() ?? "";
+ const reasoningText = summary.reason?.trim() ?? "";
+ const extraRows = summary.rows.filter((row) => {
+ const normalized = row.label.toLowerCase();
+ if (normalized === "title") return false;
+ if (normalized === "task") return false;
+ if (normalized === "assignee") return false;
+ return true;
+ });
+ const rubricEntries = Object.entries(
+ selectedApproval.rubric_scores ?? {}
+ ).map(([key, value]) => ({
+ label: key
+ .replace(/_/g, " ")
+ .replace(/\b\w/g, (char) => char.toUpperCase()),
+ value,
+ }));
+ const rubricTotal = rubricEntries.reduce(
+ (total, entry) => total + entry.value,
+ 0,
+ );
+ const hasRubric = rubricEntries.length > 0 && rubricTotal > 0;
+ const rubricChartData = rubricEntries.map((entry, index) => {
+ const percent = rubricTotal > 0 ? (entry.value / rubricTotal) * 100 : 0;
+ return {
+ key: entry.label.toLowerCase().replace(/[^a-z0-9]+/g, "_"),
+ name: entry.label,
+ value: entry.value,
+ percent,
+ percentLabel: `${percent.toFixed(1)}%`,
+ fill: rubricColors[index % rubricColors.length],
+ };
+ });
+ const rubricChartConfig = rubricChartData.reduce
(
+ (accumulator, entry) => {
+ accumulator[entry.key] = {
+ label: entry.name,
+ color: entry.fill,
+ };
+ return accumulator;
+ },
+ {},
+ );
+
+ return (
+
+
+
+
+ {humanizeAction(selectedApproval.action_type)}
+
+
+ Requested {formatTimestamp(selectedApproval.created_at)}
+
+
+
+
+ {selectedApproval.confidence}% confidence
+
+ {selectedApproval.status === "pending" ? (
+
+
+
-
-
- {approval.confidence}% confidence
-
-
- {approval.status}
-
-
-
- {summary.reason ? (
-
{summary.reason}
- ) : null}
- {summary.rows.length > 0 ? (
-
- {summary.rows.map((row) => (
-
-
-
- {row.label}
-
- -
- {row.value}
-
-
- ))}
-
- ) : null}
-
-
- JSON payload + rubric
-
- {isExpanded ? (
-
- {detailsPayload}
-
) : null}
- );
- })}
-
-