+
Access & activity
+ {grants.length > 0 && (
+
+ {grants.map((grant, index) => (
+
+
+ {employeeName(grant.employeeId)}
+
+
{accountHandle(grant.socialAccountId)}
+
{humanize(grant.role)}
+
{scopeSummary(grant.scopeJson)}
+
+ ))}
+
+ )}
+ {entries.length > 0 && (
+
+ {entries.map((entry, index) => (
+
+
{entry.label}
+
{accountHandle(entry.accountId)}
+
{humanize(entry.policyDecision)}
+
+ {entry.actorType === "agent" ? "agent" : employeeName(entry.actorId)} · {formatRelative(entry.createdAt)}
+
+
+ ))}
+
+ )}
+
+ );
+}
+
+function humanize(value: string): string {
+ if (!value) return value;
+ const spaced = value.replace(/_/g, " ");
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1);
+}
+
+function policyTone(decision: string): "green" | "amber" | "red" | undefined {
+ if (decision.includes("denied") || decision.includes("blocked")) return "red";
+ if (decision.includes("approval")) return "amber";
+ if (decision.includes("allowed")) return "green";
+ return undefined;
+}
+
+function scopeSummary(scopeJson: string): string {
+ try {
+ const parsed: unknown = JSON.parse(scopeJson);
+ if (parsed && typeof parsed === "object" && Array.isArray((parsed as { actions?: unknown }).actions)) {
+ const actions = (parsed as { actions: unknown[] }).actions.filter((item): item is string => typeof item === "string");
+ const ceiling = (parsed as { riskCeiling?: unknown }).riskCeiling;
+ const risk = typeof ceiling === "string" ? ` · ≤${ceiling}` : "";
+ return `${actions.length} action${actions.length === 1 ? "" : "s"}${risk}`;
+ }
+ } catch {
+ return "scoped";
+ }
+ return "scoped";
+}