Open History to see the last commit
1import { memo } from "react";
2import { type PendingApproval } from "../../session-logic";
3import { cn } from "~/lib/utils";
4
5interface ComposerPendingApprovalPanelProps {
6 approval: PendingApproval;
7 pendingCount: number;
8 className?: string;
9}
10
11export const ComposerPendingApprovalPanel = memo(function ComposerPendingApprovalPanel({
12 approval,
13 pendingCount,
14 className,
15}: ComposerPendingApprovalPanelProps) {
16 const Detail = approval.requestKind === "mcp-elicitation" ? "span" : "code";
17 const fallbackLabel =
18 approval.requestKind === "mcp-elicitation"
19 ? "App access approval"
20 : approval.requestKind === "command"
21 ? "Command approval"
22 : approval.requestKind === "file-read"
23 ? "File read approval"
24 : "File change approval";
25 const detailAriaLabel =
26 approval.requestKind === "mcp-elicitation"
27 ? "App access request"
28 : approval.requestKind === "command"
29 ? "Command"
30 : approval.requestKind === "file-read"
31 ? "File to read"
32 : "File change";
33
34 return (
35 <span
36 aria-label={fallbackLabel}
37 className={cn("flex min-w-0 flex-1 flex-col items-start gap-1", className)}
38 role="group"
39 >
40 <span className="flex w-full min-w-0 items-center gap-2 text-[11px] text-muted-foreground">
41 <span className="shrink-0 font-medium text-warning">{fallbackLabel}</span>
42 {approval.appName ? <span className="min-w-0 truncate">{approval.appName}</span> : null}
43 {pendingCount > 1 ? (
44 <span className="ml-auto shrink-0 tabular-nums">1/{pendingCount}</span>
45 ) : null}
46 </span>
47 <Detail
48 aria-label={detailAriaLabel}
49 className={cn(
50 "block max-h-20 w-full min-w-0 overflow-auto text-xs text-foreground [scrollbar-width:thin] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70 [&::-webkit-scrollbar]:h-1.5",
51 approval.requestKind === "mcp-elicitation"
52 ? "whitespace-pre-wrap font-sans wrap-break-word"
53 : "whitespace-pre font-mono",
54 )}
55 data-approval-detail="complete"
56 tabIndex={0}
57 >
58 {approval.detail || fallbackLabel}
59 </Detail>
60 </span>
61 );
62});