feat(webui): link session mentions

This commit is contained in:
Xubin Ren 2026-08-02 23:15:54 +08:00
parent 5dd3dc5450
commit cf01978e71
3 changed files with 14 additions and 4 deletions

View File

@ -162,7 +162,7 @@ export function SessionMentionToken({
variant: "composer" | "message";
}) {
const testIdPrefix = variant === "composer" ? "composer" : "message";
return (
const token = (
<InlineTokenHighlight
testId={`${testIdPrefix}-session-mention-${mention.name}`}
title={`Session: ${mention.title || mention.name}`}
@ -171,6 +171,15 @@ export function SessionMentionToken({
{label}
</InlineTokenHighlight>
);
if (variant === "composer") return token;
return (
<a
href={`#/chat/${encodeURIComponent(mention.session_key)}`}
className="rounded-sm underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60"
>
{token}
</a>
);
}
export function CliAppMentionToken({

View File

@ -530,6 +530,7 @@ describe("MessageBubble", () => {
const token = screen.getByTestId("message-session-mention-收费设计");
expect(token).toHaveTextContent("@收费设计");
expect(token).toHaveAttribute("title", "Session: 收费设计");
expect(token.closest("a")).toHaveAttribute("href", "#/chat/websocket%3Apricing");
});
it("copies completed assistant replies from the action row", async () => {

View File

@ -1564,9 +1564,9 @@ describe("ThreadComposer", () => {
fireEvent.keyDown(input, { key: "Tab" });
expect(input).toHaveValue("参考 @收费设计 ");
expect(screen.getByTestId("composer-session-mention-收费设计")).toHaveTextContent(
"@收费设计",
);
const mention = screen.getByTestId("composer-session-mention-收费设计");
expect(mention).toHaveTextContent("@收费设计");
expect(mention.closest("a")).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Send message" }));