(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;
})
| 732 | } |
| 733 | |
| 734 | function ToolLeafRow(props: { |
| 735 | buttonRef?: React.Ref<HTMLButtonElement>; |
| 736 | tool: ToolSummary; |
| 737 | depth: number; |
| 738 | active: boolean; |
| 739 | onSelect: () => void; |
| 740 | search: string; |
| 741 | onSetPolicy?: (pattern: string, action: ToolPolicyAction) => void; |
| 742 | onClearPolicy?: (pattern: string) => void; |
| 743 | patternForDisplay: (displayPattern: string) => string; |
| 744 | exactRule?: ToolPolicyAction; |
| 745 | }) { |
| 746 | const label = props.tool.name.split(".").pop() ?? props.tool.name; |
| 747 | const indicator = indicatorFor(props.tool.policy); |
| 748 | const showActions = !!props.onSetPolicy; |
| 749 | return ( |
| 750 | <div |
| 751 | className={cn( |
| 752 | "group/tt-row relative flex items-stretch", |
| 753 | props.active |
| 754 | ? "bg-primary/15 ring-1 ring-inset ring-primary/40 hover:bg-primary/20" |
| 755 | : "hover:bg-accent/60", |
| 756 | props.tool.policy.action === "block" && !props.active && "opacity-70", |
| 757 | )} |
| 758 | > |
| 759 | <Button |
| 760 | ref={props.buttonRef} |
| 761 | variant="ghost" |
| 762 | onClick={props.onSelect} |
| 763 | className={cn( |
| 764 | rowBaseClasses, |
| 765 | props.active |
| 766 | ? "text-foreground hover:bg-transparent" |
| 767 | : "text-foreground/80 hover:bg-transparent hover:text-foreground", |
| 768 | )} |
| 769 | style={{ |
| 770 | paddingLeft: rowIndent(props.depth) + 20, |
| 771 | paddingRight: showActions ? 36 : 12, |
| 772 | }} |
| 773 | > |
| 774 | <span className="flex-1 truncate text-left font-mono"> |
| 775 | {highlightMatch(label, props.search)} |
| 776 | </span> |
| 777 | {indicator && ( |
| 778 | <span |
| 779 | aria-label={indicator.label} |
| 780 | title={indicator.label} |
| 781 | className={cn("shrink-0 size-1.5 rounded-full", indicator.className)} |
| 782 | /> |
| 783 | )} |
| 784 | </Button> |
| 785 | {showActions && ( |
| 786 | <div |
| 787 | className={cn( |
| 788 | "absolute right-1.5 top-1/2 -translate-y-1/2 transition-opacity", |
| 789 | props.exactRule |
| 790 | ? "opacity-100" |
| 791 | : "opacity-0 group-hover/tt-row:opacity-100 focus-within:opacity-100", |
nothing calls this directly
no test coverage detected