MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ToolLeafRow

Function ToolLeafRow

packages/react/src/components/tool-tree.tsx:691–762  ·  view source on GitHub ↗
(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;
})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

cnFunction · 0.90
indicatorForFunction · 0.85
rowIndentFunction · 0.85
highlightMatchFunction · 0.85

Tested by

no test coverage detected