mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-04 08:28:36 +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";
|
||||
}) {
|
||||
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({
|
||||
|
||||
@ -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 () => {
|
||||
|
||||
@ -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" }));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user