feat(session): add cross-session references
This commit is contained in:
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
CliAppMentionToken,
|
||||
McpPresetMentionToken,
|
||||
SessionMentionToken,
|
||||
splitCapabilityMentionSegments,
|
||||
type CapabilityMentionSegment,
|
||||
} from "@/components/CliAppMentionText";
|
||||
@@ -11,7 +12,7 @@ import {
|
||||
INLINE_TOKEN_HIGHLIGHT_COLOR,
|
||||
InlineTokenHighlight,
|
||||
} from "@/components/InlineTokenHighlight";
|
||||
import type { CliAppInfo, McpPresetInfo } from "@/lib/types";
|
||||
import type { CliAppInfo, McpPresetInfo, SessionMention } from "@/lib/types";
|
||||
|
||||
type SkillReferenceSegment =
|
||||
| { kind: "text"; text: string }
|
||||
@@ -49,9 +50,15 @@ function splitUserMessageSegments(
|
||||
value: string,
|
||||
cliApps: CliAppInfo[],
|
||||
mcpPresets: McpPresetInfo[],
|
||||
sessionMentions: SessionMention[],
|
||||
): UserMessageSegment[] {
|
||||
const segments: UserMessageSegment[] = [];
|
||||
for (const segment of splitCapabilityMentionSegments(value, cliApps, mcpPresets)) {
|
||||
for (const segment of splitCapabilityMentionSegments(
|
||||
value,
|
||||
cliApps,
|
||||
mcpPresets,
|
||||
sessionMentions,
|
||||
)) {
|
||||
if (segment.kind === "text") {
|
||||
segments.push(...splitSkillReferenceSegments(segment.text));
|
||||
} else {
|
||||
@@ -65,13 +72,15 @@ export function UserMessageText({
|
||||
text,
|
||||
cliApps,
|
||||
mcpPresets,
|
||||
sessionMentions = [],
|
||||
}: {
|
||||
text: string;
|
||||
cliApps: CliAppInfo[];
|
||||
mcpPresets: McpPresetInfo[];
|
||||
sessionMentions?: SessionMention[];
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const segments = splitUserMessageSegments(text, cliApps, mcpPresets);
|
||||
const segments = splitUserMessageSegments(text, cliApps, mcpPresets, sessionMentions);
|
||||
return (
|
||||
<>
|
||||
{segments.map((segment, index) => {
|
||||
@@ -97,7 +106,7 @@ export function UserMessageText({
|
||||
variant="message"
|
||||
/>
|
||||
);
|
||||
return (
|
||||
if (segment.kind === "mcp") return (
|
||||
<McpPresetMentionToken
|
||||
key={`mcp-${segment.preset.name}-${index}`}
|
||||
preset={segment.preset}
|
||||
@@ -105,6 +114,14 @@ export function UserMessageText({
|
||||
variant="message"
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<SessionMentionToken
|
||||
key={`session-${segment.mention.session_key}-${index}`}
|
||||
mention={segment.mention}
|
||||
label={segment.text}
|
||||
variant="message"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user