mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-06 09:28:34 +00:00
feat(webui): link session mentions
This commit is contained in:
parent
5dd3dc5450
commit
cf01978e71
@ -162,7 +162,7 @@ export function SessionMentionToken({
|
|||||||
variant: "composer" | "message";
|
variant: "composer" | "message";
|
||||||
}) {
|
}) {
|
||||||
const testIdPrefix = variant === "composer" ? "composer" : "message";
|
const testIdPrefix = variant === "composer" ? "composer" : "message";
|
||||||
return (
|
const token = (
|
||||||
<InlineTokenHighlight
|
<InlineTokenHighlight
|
||||||
testId={`${testIdPrefix}-session-mention-${mention.name}`}
|
testId={`${testIdPrefix}-session-mention-${mention.name}`}
|
||||||
title={`Session: ${mention.title || mention.name}`}
|
title={`Session: ${mention.title || mention.name}`}
|
||||||
@ -171,6 +171,15 @@ export function SessionMentionToken({
|
|||||||
{label}
|
{label}
|
||||||
</InlineTokenHighlight>
|
</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({
|
export function CliAppMentionToken({
|
||||||
|
|||||||
@ -530,6 +530,7 @@ describe("MessageBubble", () => {
|
|||||||
const token = screen.getByTestId("message-session-mention-收费设计");
|
const token = screen.getByTestId("message-session-mention-收费设计");
|
||||||
expect(token).toHaveTextContent("@收费设计");
|
expect(token).toHaveTextContent("@收费设计");
|
||||||
expect(token).toHaveAttribute("title", "Session: 收费设计");
|
expect(token).toHaveAttribute("title", "Session: 收费设计");
|
||||||
|
expect(token.closest("a")).toHaveAttribute("href", "#/chat/websocket%3Apricing");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("copies completed assistant replies from the action row", async () => {
|
it("copies completed assistant replies from the action row", async () => {
|
||||||
|
|||||||
@ -1564,9 +1564,9 @@ describe("ThreadComposer", () => {
|
|||||||
fireEvent.keyDown(input, { key: "Tab" });
|
fireEvent.keyDown(input, { key: "Tab" });
|
||||||
|
|
||||||
expect(input).toHaveValue("参考 @收费设计 ");
|
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" }));
|
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user