import { StringRequest } from "@shared/proto/cline/common" import { RuleFileRequest } from "@shared/proto/index.cline" import { REMOTE_URI_SCHEME } from "@shared/remote-config/constants" import { EyeIcon, InfoIcon, PenIcon, Trash2Icon } from "lucide-react" import { Button } from "@/components/ui/button" import { Switch } from "@/components/ui/switch" import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" import { FileServiceClient } from "@/services/grpc-client" const RuleRow: React.FC<{ rulePath: string enabled: boolean isGlobal: boolean ruleType: string toggleRule: (rulePath: string, enabled: boolean) => void isRemote?: boolean alwaysEnabled?: boolean }> = ({ rulePath, enabled, isGlobal, toggleRule, ruleType, isRemote = false, alwaysEnabled = false }) => { // Check if the path type is Windows const win32Path = /^[a-zA-Z]:\\/.test(rulePath) // Get the filename from the path for display const displayName = rulePath.split(win32Path ? "\\" : "/").pop() || rulePath // For remote rules, the rulePath is already the display name const finalDisplayName = isRemote ? rulePath : displayName const isDisabled = isRemote && alwaysEnabled const getRuleTypeIcon = () => { switch (ruleType) { case "cursor": return ( ) case "windsurf": return ( ) case "agents": return ( ) default: return null } } const handleEditClick = () => { // For remote rules, use the special remote:// URI format const filePath = isRemote ? `${REMOTE_URI_SCHEME}${ruleType === "workflow" ? "workflow" : "rule"}/${rulePath}` : rulePath FileServiceClient.openFile(StringRequest.create({ value: filePath })).catch((err) => console.error("Failed to open file:", err), ) } const handleDeleteClick = () => { FileServiceClient.deleteRuleFile( RuleFileRequest.create({ rulePath, isGlobal, type: ruleType || "cline", }), ).catch((err) => console.error("Failed to delete rule file:", err)) } return (