| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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 点名是哪个子代理在问(动态工作流子代理为 `<名字> (<siteId>@<ordinal>)`,
- // 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 (
- <Badge
- variant="outline"
- title={title}
- data-interaction-origin-badge="subagent"
- className={cn("max-w-40 align-baseline text-ui-base truncate", className)}
- >
- {label}
- </Badge>
- );
- }
|