(props: {
buttonRef?: React.Ref<HTMLButtonElement>;
tool: ToolSummary;
depth: number;
active: boolean;
onSelect: () => void;
search: string;
onSetPolicy?: (pattern: string, action: ToolPolicyAction) => void;
onClearPolicy?: (pattern: string) => void;
patternForDisplay: (displayPattern: string) => string;
exactRule?: ToolPolicyAction;
})
| 701 | } |
| 702 | |
| 703 | function ToolLeafRow(props: { |
| 704 | buttonRef?: React.Ref<HTMLButtonElement>; |
| 705 | tool: ToolSummary; |
| 706 | depth: number; |
| 707 | active: boolean; |
| 708 | onSelect: () => void; |
| 709 | search: string; |
| 710 | onSetPolicy?: (pattern: string, action: ToolPolicyAction) => void; |
| 711 | onClearPolicy?: (pattern: string) => void; |
| 712 | patternForDisplay: (displayPattern: string) => string; |
| 713 | exactRule?: ToolPolicyAction; |
| 714 | }) { |
| 715 | const label = props.tool.name.split(".").pop() ?? props.tool.name; |
| 716 | const indicator = indicatorFor(props.tool.policy); |
| 717 | const showActions = !!props.onSetPolicy; |
| 718 | return ( |
| 719 | <div |
| 720 | className={cn( |
| 721 | "group/tt-row relative flex items-stretch", |
| 722 | props.active |
| 723 | ? "bg-primary/15 ring-1 ring-inset ring-primary/40 hover:bg-primary/20" |
| 724 | : "hover:bg-accent/60", |
| 725 | props.tool.policy.action === "block" && !props.active && "opacity-70", |
| 726 | )} |
| 727 | > |
| 728 | <Button |
| 729 | ref={props.buttonRef} |
| 730 | variant="ghost" |
| 731 | onClick={props.onSelect} |
| 732 | className={cn( |
| 733 | rowBaseClasses, |
| 734 | props.active |
| 735 | ? "text-foreground hover:bg-transparent" |
| 736 | : "text-foreground/80 hover:bg-transparent hover:text-foreground", |
| 737 | )} |
| 738 | style={{ |
| 739 | paddingLeft: rowIndent(props.depth) + 20, |
| 740 | paddingRight: showActions ? 36 : 12, |
| 741 | }} |
| 742 | > |
| 743 | <span className="flex-1 truncate text-left font-mono"> |
| 744 | {highlightMatch(label, props.search)} |
| 745 | </span> |
| 746 | {indicator && ( |
| 747 | <span |
| 748 | aria-label={indicator.label} |
| 749 | title={indicator.label} |
| 750 | className={cn("shrink-0 size-1.5 rounded-full", indicator.className)} |
| 751 | /> |
| 752 | )} |
| 753 | </Button> |
| 754 | {showActions && ( |
| 755 | <div |
| 756 | className={cn( |
| 757 | "absolute right-1.5 top-1/2 -translate-y-1/2 transition-opacity", |
| 758 | props.exactRule |
| 759 | ? "opacity-100" |
| 760 | : "opacity-0 group-hover/tt-row:opacity-100 focus-within:opacity-100", |
nothing calls this directly
no test coverage detected