9b30f681c6
- React+antd+zustand,注册表驱动路由/菜单/权限 - Tauri 桌面壳、后端托管 SPA、跨标签页消息队列
24 lines
883 B
TypeScript
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;
|
|
}
|