diff --git a/apps/web/app/settings/agent/[id]/page.tsx b/apps/web/app/settings/agent/[id]/page.tsx index 10eb9c4560..de991215af 100644 --- a/apps/web/app/settings/agent/[id]/page.tsx +++ b/apps/web/app/settings/agent/[id]/page.tsx @@ -1,11 +1,13 @@ "use client"; import { useEffect } from "react"; +import { useTranslation } from "react-i18next"; import { useRouter } from "@/lib/routing/client-router"; import { Card, CardContent } from "@kandev/ui/card"; import { Button } from "@kandev/ui/button"; export default function AgentEditPage() { + const { t } = useTranslation(); const router = useRouter(); useEffect(() => { @@ -15,9 +17,9 @@ export default function AgentEditPage() { return ( -

Manage agents from the main Agents page.

+

{t("agents:manageAgentsFromMainPage")}

diff --git a/apps/web/app/settings/agents/[agentId]/agent-save-helpers.ts b/apps/web/app/settings/agents/[agentId]/agent-save-helpers.ts index e9ea2b0879..6af27c0bd6 100644 --- a/apps/web/app/settings/agents/[agentId]/agent-save-helpers.ts +++ b/apps/web/app/settings/agents/[agentId]/agent-save-helpers.ts @@ -17,8 +17,13 @@ import type { import { arePermissionsDirty, permissionsToProfilePatch } from "@/lib/agent-permissions"; import { areCLIFlagsEqual } from "@/lib/cli-flags"; import { areConfigOptionsEqual } from "@/lib/config-options"; +import { t } from "@/lib/i18n"; import type { ProfileFormData } from "@/components/settings/profile-form-fields"; +// The JSON key the MCP editor validates against — an identifier, interpolated +// into the parse error rather than written into the catalog. +const MCP_SERVERS_KEY = "mcpServers"; + /** * Translates a ProfileFormData patch (snake_case form keys) into a * Partial (camelCase). Profiles in client state use the @@ -82,12 +87,12 @@ export const parseProfileMcpServers = (raw: string): Record; } diff --git a/apps/web/app/settings/agents/[agentId]/agent-setup-parts.tsx b/apps/web/app/settings/agents/[agentId]/agent-setup-parts.tsx index eb113edac8..6e1d9110ac 100644 --- a/apps/web/app/settings/agents/[agentId]/agent-setup-parts.tsx +++ b/apps/web/app/settings/agents/[agentId]/agent-setup-parts.tsx @@ -1,5 +1,6 @@ "use client"; +import { useTranslation } from "react-i18next"; import { IconPlus, IconTrash } from "@tabler/icons-react"; import { AlertDialog, @@ -61,19 +62,18 @@ export function AgentHeader({ savedAgent, onDelete, }: AgentHeaderProps) { + const { t } = useTranslation(); return (

{displayName}

- {matchedPath ?? "Installation not detected"} + {matchedPath ?? t("agents:installationNotDetected")}

- {isCreateMode - ? "Create a new profile for this agent." - : "Configure profiles and defaults for this agent."} + {isCreateMode ? t("agents:createProfileIntro") : t("agents:configureProfilesIntro")}

{savedAgent?.tui_config && onDelete && ( @@ -81,21 +81,20 @@ export function AgentHeader({ - Delete {displayName}? - - This will permanently remove the agent and all its profiles. This action cannot be - undone. - + + {t("agents:deleteAgentTitle", { name: displayName })} + + {t("agents:deleteAgentDescription")} - Cancel + {t("common:cancel")} - Delete + {t("agents:delete")} @@ -221,15 +220,18 @@ export function ProfilesCard({ onRemoveProfile, onToastError, }: ProfilesCardProps) { + const { t } = useTranslation(); return ( - {isCreateMode ? `Create ${displayName} Profile` : `${displayName} Profiles`} + {isCreateMode + ? t("agents:createAgentProfileTitle", { name: displayName }) + : t("agents:agentProfilesTitle", { name: displayName })} diff --git a/apps/web/app/settings/agents/[agentId]/page.tsx b/apps/web/app/settings/agents/[agentId]/page.tsx index 7768b940ac..895648b378 100644 --- a/apps/web/app/settings/agents/[agentId]/page.tsx +++ b/apps/web/app/settings/agents/[agentId]/page.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect, useMemo, useState } from "react"; +import { useTranslation } from "react-i18next"; import Link from "@/components/routing/app-link"; import { useParams, useRouter, useSearchParams } from "@/lib/routing/client-router"; import { Button } from "@kandev/ui/button"; @@ -207,17 +208,18 @@ function useAgentSaveHandlers({ onToastError, replaceRoute, }: AgentSaveHandlersProps) { + const { t } = useTranslation(); const handleSave = async () => { if (draftAgent.profiles.some((p) => !p.name.trim())) { - onToastError(new Error("Profile name is required.")); + onToastError(new Error(t("agents:profileNameRequired"))); return; } if (draftAgent.profiles.some((p) => !p.model.trim())) { - onToastError(new Error("Model is required for all profiles.")); + onToastError(new Error(t("agents:modelRequiredForAllProfiles"))); return; } if (hasInvalidMcpConfig) { - onToastError(new Error("Fix invalid MCP JSON before saving.")); + onToastError(new Error(t("agents:fixInvalidMcpJson"))); return; } setSaveStatus("loading"); @@ -367,6 +369,7 @@ function AgentSetupForm({ onToastError, isCreateMode = false, }: AgentSetupFormProps) { + const { t } = useTranslation(); const router = useRouter(); const availableAgents = useAvailableAgents().items; const { upsertAgent } = useAgentStoreSync(); @@ -417,8 +420,8 @@ function AgentSetupForm({ }; const profilesValid = areAgentProfilesValid(draftAgent); let saveInvalidReason: string | undefined; - if (!profilesValid) saveInvalidReason = "Every profile needs a name and model."; - else if (hasInvalidMcpConfig) saveInvalidReason = "Fix invalid MCP configuration before saving."; + if (!profilesValid) saveInvalidReason = t("agents:everyProfileNeedsNameAndModel"); + else if (hasInvalidMcpConfig) saveInvalidReason = t("agents:fixInvalidMcpConfig"); useSettingsSaveContributor({ id: `agent:${draftAgent.id}`, revision: saveRevision.revision, @@ -462,6 +465,7 @@ function AgentSetupForm({ } export default function AgentSetupPage() { + const { t } = useTranslation(); const { toast } = useToast(); const params = useParams(); const searchParams = useSearchParams(); @@ -531,9 +535,9 @@ export default function AgentSetupPage() { return ( -

Agent not found.

+

{t("agents:agentNotFound")}

@@ -544,8 +548,8 @@ export default function AgentSetupPage() { const handleToastError = (error: unknown) => { toast({ - title: "Failed to save agent", - description: error instanceof Error ? error.message : "Request failed", + title: t("agents:failedToSaveAgent"), + description: error instanceof Error ? error.message : t("agents:requestFailed"), variant: "error", }); }; diff --git a/apps/web/app/settings/agents/[agentId]/profile-mcp-config-card.tsx b/apps/web/app/settings/agents/[agentId]/profile-mcp-config-card.tsx index c0e8f18db4..4033c6cf87 100644 --- a/apps/web/app/settings/agents/[agentId]/profile-mcp-config-card.tsx +++ b/apps/web/app/settings/agents/[agentId]/profile-mcp-config-card.tsx @@ -1,5 +1,6 @@ "use client"; +import { useTranslation } from "react-i18next"; import { CardContent, CardHeader, CardTitle } from "@kandev/ui/card"; import { Label } from "@kandev/ui/label"; import { Switch } from "@kandev/ui/switch"; @@ -7,6 +8,10 @@ import { Textarea } from "@kandev/ui/textarea"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { useSettingsSaveContributor } from "@/components/settings/settings-save-provider"; import { SettingsCard } from "@/components/settings/settings-card"; +// `validateDraftServers` runs outside React (from an onChange handler and from +// the parent's draft state), so it uses the module-level `t`, which resolves at +// call time. Components in this file use the `useTranslation()` hook. +import { t as translate } from "@/lib/i18n"; import { useProfileMcpConfig } from "./use-profile-mcp-config"; import type { AgentProfileMcpConfig } from "@/lib/types/http"; @@ -69,8 +74,24 @@ const POPULAR_SERVERS: Record> = { }, }; -const KANDEV_TOOLS_DESCRIPTION = - "Tools: list_workspaces, list_boards, list_workflow_steps, list_tasks, create_task, update_task"; +// Tool names and MCP-server product names are identifiers, not copy: they are +// interpolated as values so the pseudo-locale cannot turn them into something +// the user cannot type or look up. +const KANDEV_MCP_NAME = "Kandev MCP"; + +const KANDEV_TOOL_NAMES = + "list_workspaces, list_boards, list_workflow_steps, list_tasks, create_task, update_task"; + +const POPULAR_SERVER_NAMES: Record = { + playwright: "Playwright MCP", + "chrome-devtools": "Chrome DevTools MCP", + context7: "Context7 MCP", + github: "GitHub MCP", +}; + +// The JSON key the editor validates against. Interpolated into the error +// messages below rather than written into the catalog. +const MCP_SERVERS_KEY = "mcpServers"; type PopularServerButtonProps = { label: string; @@ -129,16 +150,16 @@ function validateDraftServers(value: string): string | null { try { const parsed = JSON.parse(value); if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) { - return "MCP servers config must be a JSON object"; + return translate("agents:mcpConfigMustBeJsonObject"); } - if ("mcpServers" in parsed) { + if (MCP_SERVERS_KEY in parsed) { const nested = (parsed as { mcpServers?: unknown }).mcpServers; if (!nested || typeof nested !== "object" || Array.isArray(nested)) { - return "mcpServers must be a JSON object"; + return translate("agents:mcpKeyMustBeJsonObject", { key: MCP_SERVERS_KEY }); } } } catch { - return "Invalid JSON"; + return translate("agents:invalidJson"); } return null; } @@ -150,10 +171,11 @@ function PassthroughMcpInjectionHint({ cliPassthrough?: boolean; mcpInjection?: string; }) { + const { t } = useTranslation(); if (!cliPassthrough || !mcpInjection) return null; return (

- In CLI passthrough mode, kandev injects these MCP servers via {mcpInjection}. + {t("agents:mcpPassthroughInjectionHint", { mechanism: mcpInjection })}

); } @@ -183,6 +205,7 @@ function McpServersEditor({ onDraftStateChange, handleMcpServersChange, }: McpServersEditorProps) { + const { t } = useTranslation(); const handleApplyServer = (label: string) => { applyPopularServerToJson( currentServers, @@ -201,7 +224,7 @@ function McpServersEditor({ return (
- +