Files
agent-desktop/console/src/utils/agentDisplayName.ts
T
Pine 9b30f681c6 feat: 智能体控制台前端(console)
- React+antd+zustand,注册表驱动路由/菜单/权限
- Tauri 桌面壳、后端托管 SPA、跨标签页消息队列
2026-08-23 22:43:18 +08:00

24 lines
883 B
TypeScript

import type { TFunction } from "i18next";
import type { AgentSummary } from "../api/types/agents";
export const DEFAULT_AGENT_ID = "default";
export const DEFAULT_AGENT_DISPLAY_NAME = "Default Agent";
/** UI label for an agent; `default` id uses i18n, others use API `name` (fallback: id). */
export function getAgentDisplayName(
agent: Pick<AgentSummary, "id" | "name">,
t: TFunction,
): string {
// For default agent, preserve i18n unless explicitly customized
if (agent.id === DEFAULT_AGENT_ID) {
// If name is customized (not the default placeholder), show custom name
if (agent.name && agent.name !== DEFAULT_AGENT_DISPLAY_NAME) {
return agent.name;
}
// Otherwise, fall back to localized default name
return t("agent.defaultDisplayName");
}
// For other agents, use user-defined name or fallback to id
return agent.name || agent.id;
}