()
| 66 | } |
| 67 | |
| 68 | const ModesView = () => { |
| 69 | const { t } = useAppTranslation() |
| 70 | |
| 71 | const { |
| 72 | customModePrompts, |
| 73 | listApiConfigMeta, |
| 74 | currentApiConfigName, |
| 75 | mode, |
| 76 | customInstructions, |
| 77 | setCustomInstructions, |
| 78 | customModes, |
| 79 | mcpServers, |
| 80 | } = useExtensionState() |
| 81 | |
| 82 | // Use a local state to track the visually active mode |
| 83 | // This prevents flickering when switching modes rapidly by: |
| 84 | // 1. Updating the UI immediately when a mode is clicked |
| 85 | // 2. Not syncing with the backend mode state (which would cause flickering) |
| 86 | // 3. Still sending the mode change to the backend for persistence |
| 87 | const [visualMode, setVisualMode] = useState(mode) |
| 88 | |
| 89 | // Build modes fresh each render so search reflects inline rename updates immediately |
| 90 | const modes = getAllModes(customModes) |
| 91 | |
| 92 | const [isDialogOpen, setIsDialogOpen] = useState(false) |
| 93 | const [selectedPromptContent, setSelectedPromptContent] = useState("") |
| 94 | const [selectedPromptTitle, setSelectedPromptTitle] = useState("") |
| 95 | const [isToolsEditMode, setIsToolsEditMode] = useState(false) |
| 96 | const [showConfigMenu, setShowConfigMenu] = useState(false) |
| 97 | const [isCreateModeDialogOpen, setIsCreateModeDialogOpen] = useState(false) |
| 98 | const [isExporting, setIsExporting] = useState(false) |
| 99 | const [isImporting, setIsImporting] = useState(false) |
| 100 | const [showImportDialog, setShowImportDialog] = useState(false) |
| 101 | const [importLevel, setImportLevel] = useState<"global" | "project">("project") |
| 102 | const [hasRulesToExport, setHasRulesToExport] = useState<Record<string, boolean>>({}) |
| 103 | const [showDeleteConfirm, setShowDeleteConfirm] = useState(false) |
| 104 | const [modeToDelete, setModeToDelete] = useState<{ |
| 105 | slug: string |
| 106 | name: string |
| 107 | source?: string |
| 108 | rulesFolderPath?: string |
| 109 | } | null>(null) |
| 110 | |
| 111 | // State for mode selection popover and search |
| 112 | const [open, setOpen] = useState(false) |
| 113 | const [searchValue, setSearchValue] = useState("") |
| 114 | const searchInputRef = useRef<HTMLInputElement>(null) |
| 115 | |
| 116 | // removed unused local name state (replaced by inline rename UX) |
| 117 | |
| 118 | // Inline rename state for the mode dropdown row |
| 119 | const [isRenamingMode, setIsRenamingMode] = useState(false) |
| 120 | const [renameInputValue, setRenameInputValue] = useState("") |
| 121 | const renameInputRef = useRef<any>(null) |
| 122 | |
| 123 | // Optimistic rename map so search reflects new names immediately |
| 124 | const [localRenames, setLocalRenames] = useState<Record<string, string>>({}) |
| 125 | // Display list that overlays optimistic names |
nothing calls this directly
no test coverage detected