import type { ZCodeInteractionRequestOrigin } from "@zcode/shared"; import { cn } from "@/components/lib/utils.js"; import { Badge } from "@/components/ui/badge.js"; import { useZCodeIntl } from "@/i18n/IntlProvider.js"; export function InteractionRequestOriginBadge({ className, origin, }: { className?: string; origin?: ZCodeInteractionRequestOrigin; }) { const { intl } = useZCodeIntl(); if (origin?.kind !== "subagent") { return null; } // description 点名是哪个子代理在问(动态工作流子代理为 `<名字> (@)`, // docs/dynamic-workflow/launch.md「Permissions inside a run」);徽标截断,完整文本留在 tooltip。 const description = origin.description?.trim(); const label = description ? intl.formatMessage({ id: "chat.interactionOrigin.subagent.named" }, { description }) : intl.formatMessage({ id: "chat.interactionOrigin.subagent" }); const title = !origin.agentType ? label : description ? intl.formatMessage( { id: "chat.interactionOrigin.subagent.titleNamed" }, { agentType: origin.agentType, description }, ) : intl.formatMessage( { id: "chat.interactionOrigin.subagent.title" }, { agentType: origin.agentType }, ); return ( {label} ); }