Translated names for tools in tool tips

This commit is contained in:
Connor Yoh 2025-08-26 15:49:09 +01:00
parent c432ec49a7
commit 6a5f771fd5
3 changed files with 24 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import EditIcon from '@mui/icons-material/Edit';
import DeleteIcon from '@mui/icons-material/Delete'; import DeleteIcon from '@mui/icons-material/Delete';
import ContentCopyIcon from '@mui/icons-material/ContentCopy'; import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import { Tooltip } from '../../shared/Tooltip'; import { Tooltip } from '../../shared/Tooltip';
import { ToolRegistryEntry } from '../../../data/toolsTaxonomy';
interface AutomationEntryProps { interface AutomationEntryProps {
/** Optional title for the automation (usually for custom ones) */ /** Optional title for the automation (usually for custom ones) */
@ -28,6 +29,8 @@ interface AutomationEntryProps {
onDelete?: () => void; onDelete?: () => void;
/** Copy handler (for suggested automations) */ /** Copy handler (for suggested automations) */
onCopy?: () => void; onCopy?: () => void;
/** Tool registry to resolve operation names */
toolRegistry?: Record<string, ToolRegistryEntry>;
} }
export default function AutomationEntry({ export default function AutomationEntry({
@ -40,7 +43,8 @@ export default function AutomationEntry({
showMenu = false, showMenu = false,
onEdit, onEdit,
onDelete, onDelete,
onCopy onCopy,
toolRegistry
}: AutomationEntryProps) { }: AutomationEntryProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const [isHovered, setIsHovered] = useState(false); const [isHovered, setIsHovered] = useState(false);
@ -49,6 +53,15 @@ export default function AutomationEntry({
// Keep item in hovered state if menu is open // Keep item in hovered state if menu is open
const shouldShowHovered = isHovered || isMenuOpen; const shouldShowHovered = isHovered || isMenuOpen;
// Helper function to resolve tool display names
const getToolDisplayName = (operation: string): string => {
if (toolRegistry?.[operation]?.name) {
return toolRegistry[operation].name;
}
// Fallback to translation or operation key
return t(`${operation}.title`, operation);
};
// Create tooltip content with description and tool chain // Create tooltip content with description and tool chain
const createTooltipContent = () => { const createTooltipContent = () => {
if (!description) return null; if (!description) return null;
@ -68,7 +81,7 @@ export default function AutomationEntry({
whiteSpace: 'nowrap' whiteSpace: 'nowrap'
}} }}
> >
{t(`${op}.title`, op)} {getToolDisplayName(op)}
</Text> </Text>
{index < operations.length - 1 && ( {index < operations.length - 1 && (
<Text component="span" size="sm" mx={4}> <Text component="span" size="sm" mx={4}>
@ -122,7 +135,7 @@ export default function AutomationEntry({
{operations.map((op, index) => ( {operations.map((op, index) => (
<React.Fragment key={`${op}-${index}`}> <React.Fragment key={`${op}-${index}`}>
<Text size="xs" style={{ color: 'var(--mantine-color-text)' }}> <Text size="xs" style={{ color: 'var(--mantine-color-text)' }}>
{t(`${op}.title`, op)} {getToolDisplayName(op)}
</Text> </Text>
{index < operations.length - 1 && ( {index < operations.length - 1 && (

View File

@ -7,6 +7,7 @@ import AutomationEntry from "./AutomationEntry";
import { useSuggestedAutomations } from "../../../hooks/tools/automate/useSuggestedAutomations"; import { useSuggestedAutomations } from "../../../hooks/tools/automate/useSuggestedAutomations";
import { AutomationConfig, SuggestedAutomation } from "../../../types/automation"; import { AutomationConfig, SuggestedAutomation } from "../../../types/automation";
import { iconMap } from './iconMap'; import { iconMap } from './iconMap';
import { ToolRegistryEntry } from '../../../data/toolsTaxonomy';
interface AutomationSelectionProps { interface AutomationSelectionProps {
savedAutomations: AutomationConfig[]; savedAutomations: AutomationConfig[];
@ -15,6 +16,7 @@ interface AutomationSelectionProps {
onEdit: (automation: AutomationConfig) => void; onEdit: (automation: AutomationConfig) => void;
onDelete: (automation: AutomationConfig) => void; onDelete: (automation: AutomationConfig) => void;
onCopyFromSuggested: (automation: SuggestedAutomation) => void; onCopyFromSuggested: (automation: SuggestedAutomation) => void;
toolRegistry: Record<string, ToolRegistryEntry>;
} }
export default function AutomationSelection({ export default function AutomationSelection({
@ -23,7 +25,8 @@ export default function AutomationSelection({
onRun, onRun,
onEdit, onEdit,
onDelete, onDelete,
onCopyFromSuggested onCopyFromSuggested,
toolRegistry
}: AutomationSelectionProps) { }: AutomationSelectionProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const suggestedAutomations = useSuggestedAutomations(); const suggestedAutomations = useSuggestedAutomations();
@ -41,6 +44,7 @@ export default function AutomationSelection({
operations={[]} operations={[]}
onClick={onCreateNew} onClick={onCreateNew}
keepIconColor={true} keepIconColor={true}
toolRegistry={toolRegistry}
/> />
{/* Saved Automations */} {/* Saved Automations */}
{savedAutomations.map((automation) => { {savedAutomations.map((automation) => {
@ -55,6 +59,7 @@ export default function AutomationSelection({
showMenu={true} showMenu={true}
onEdit={() => onEdit(automation)} onEdit={() => onEdit(automation)}
onDelete={() => onDelete(automation)} onDelete={() => onDelete(automation)}
toolRegistry={toolRegistry}
/> />
); );
})} })}
@ -76,6 +81,7 @@ export default function AutomationSelection({
onClick={() => onRun(automation)} onClick={() => onRun(automation)}
showMenu={true} showMenu={true}
onCopy={() => onCopyFromSuggested(automation)} onCopy={() => onCopyFromSuggested(automation)}
toolRegistry={toolRegistry}
/> />
))} ))}
</Stack> </Stack>

View File

@ -88,6 +88,7 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
onError?.(`Failed to copy automation: ${suggestedAutomation.name}`); onError?.(`Failed to copy automation: ${suggestedAutomation.name}`);
} }
}} }}
toolRegistry={toolRegistry}
/> />
); );