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

Function ToolLeafRow

packages/react/src/components/tool-tree.tsx:687–758  ·  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

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