2026-07-21 18:42:25 +08:00
|
|
|
import { Fragment } from "react";
|
|
|
|
|
|
|
|
|
|
import {
|
2026-08-04 00:38:40 +08:00
|
|
|
CapabilityMentionToken,
|
2026-07-21 18:42:25 +08:00
|
|
|
splitCapabilityMentionSegments,
|
|
|
|
|
} from "@/components/CliAppMentionText";
|
2026-10-25 21:42:53 +08:00
|
|
|
import { SkillReferenceToken, withSkillReferences } from "@/components/SkillReferenceText";
|
2026-08-18 18:28:19 +08:00
|
|
|
import type { CliAppInfo, McpPresetInfo, SessionMention } from "@/lib/types";
|
2026-07-21 18:42:25 +08:00
|
|
|
|
2026-07-21 18:29:57 +08:00
|
|
|
export function UserMessageText({
|
|
|
|
|
text,
|
|
|
|
|
cliApps,
|
|
|
|
|
mcpPresets,
|
2026-08-02 22:04:59 +08:00
|
|
|
sessionMentions = [],
|
2026-07-21 18:29:57 +08:00
|
|
|
}: {
|
|
|
|
|
text: string;
|
|
|
|
|
cliApps: CliAppInfo[];
|
|
|
|
|
mcpPresets: McpPresetInfo[];
|
2026-08-02 22:04:59 +08:00
|
|
|
sessionMentions?: SessionMention[];
|
2026-07-21 18:29:57 +08:00
|
|
|
}) {
|
2026-10-25 21:42:53 +08:00
|
|
|
const segments = withSkillReferences(
|
|
|
|
|
splitCapabilityMentionSegments(text, cliApps, mcpPresets, sessionMentions),
|
|
|
|
|
);
|
2026-07-21 18:29:57 +08:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{segments.map((segment, index) => {
|
|
|
|
|
if (segment.kind === "text") {
|
2026-07-21 18:42:25 +08:00
|
|
|
return <Fragment key={`text-${index}`}>{segment.text}</Fragment>;
|
2026-07-21 18:29:57 +08:00
|
|
|
}
|
2026-07-21 18:42:25 +08:00
|
|
|
if (segment.kind === "skill") return (
|
2026-10-25 21:42:53 +08:00
|
|
|
<SkillReferenceToken
|
2026-07-21 18:42:25 +08:00
|
|
|
key={`skill-${segment.name}-${index}`}
|
2026-10-25 21:42:53 +08:00
|
|
|
name={segment.name}
|
2026-07-21 18:42:25 +08:00
|
|
|
testId={`message-skill-reference-${segment.name.toLowerCase()}`}
|
2026-10-25 21:42:53 +08:00
|
|
|
/>
|
2026-07-21 18:29:57 +08:00
|
|
|
);
|
2026-08-02 22:04:59 +08:00
|
|
|
return (
|
2026-08-04 00:38:40 +08:00
|
|
|
<CapabilityMentionToken
|
|
|
|
|
key={`${segment.kind}-${index}`}
|
|
|
|
|
segment={segment}
|
2026-08-02 22:04:59 +08:00
|
|
|
variant="message"
|
|
|
|
|
/>
|
|
|
|
|
);
|
2026-07-21 18:29:57 +08:00
|
|
|
})}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|