fix(webui): match slash command highlighting to skills
This commit is contained in:
1 parent
dfb3843b4d
commit
3230013963
6 files changed
+97
-21
No files matched your search
@@ -4,13 +4,17 @@ import { MessageBubble } from "@/components/MessageBubble";
|
||||
import { ThreadComposer } from "@/components/thread/ThreadComposer";
|
||||
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
|
||||
import { useReadingTypography } from "@/hooks/useReadingTypography";
|
||||
import type { ChatSummary, UIMessage } from "@/lib/types";
|
||||
import type { ChatSummary, SlashCommand, UIMessage } from "@/lib/types";
|
||||
|
||||
const session: ChatSummary = {
|
||||
key: "websocket:typography", channel: "websocket", chatId: "typography",
|
||||
createdAt: null, updatedAt: null, title: "Reference target", preview: "",
|
||||
handle: { id: "handle_12345678901234567890123456789012", name: "typography" },
|
||||
};
|
||||
const commands: SlashCommand[] = [{
|
||||
command: "/goal", title: "Start a goal", description: "Start a sustained goal.",
|
||||
icon: "activity", lifecycle: "agent_turn_with_args", acceptsArgs: true,
|
||||
}];
|
||||
const answer: UIMessage = {
|
||||
id: "reference-answer", role: "assistant", createdAt: 1,
|
||||
content: "[相关会话](#session/websocket%3Atypography) · [外部文档](https://example.com/reference)",
|
||||
@@ -22,8 +26,8 @@ export function InlineReferencesFixture() {
|
||||
const [sent, setSent] = useState<UIMessage[]>([]);
|
||||
return <ThemeProvider theme={theme}>
|
||||
<main className="mx-auto h-full max-w-[var(--content-column-width)] space-y-6 overflow-y-auto p-4">
|
||||
{[answer, ...sent].map(message => <MessageBubble key={message.id} message={message} />)}
|
||||
<ThreadComposer compactWhenIdle sessions={[session]} modelLabel="Fixture" persistDraft={false}
|
||||
{[answer, ...sent].map(message => <MessageBubble key={message.id} message={message} slashCommands={commands} />)}
|
||||
<ThreadComposer compactWhenIdle sessions={[session]} modelLabel="Fixture" persistDraft={false} slashCommands={commands}
|
||||
onSend={text => setSent(current => [...current, {
|
||||
id: `sent-${current.length}`, role: "user", content: text, createdAt: current.length + 2,
|
||||
}])} />
|
||||
|
||||
@@ -78,9 +78,15 @@ for (const narrow of [false, true]) {
|
||||
|
||||
const input = page.getByRole("textbox", { name: "Message input", exact: true });
|
||||
const overlay = page.locator(".thread-composer-input > div[aria-hidden]");
|
||||
const text = "like $workflow 和 $skill-creator,检查中文 English 与换行。";
|
||||
const text = "/goal like $workflow 和 $skill-creator,检查中文 English 与换行。";
|
||||
await input.focus();
|
||||
await input.pressSequentially(text);
|
||||
await input.pressSequentially("/goal ");
|
||||
const composerCommand = page.getByTestId("composer-slash-command");
|
||||
await expect(composerCommand).toHaveText("/goal");
|
||||
await expect(composerCommand).toHaveCSS("color", "rgb(244, 169, 73)");
|
||||
await expect(composerCommand).toHaveCSS("font-weight", "400");
|
||||
await expectMatchingInputLayers(input);
|
||||
await input.pressSequentially(text.slice("/goal ".length));
|
||||
const skill = page.getByTestId("composer-skill-reference-workflow");
|
||||
await expect(skill).toHaveText("$workflow");
|
||||
await expect(skill).toHaveCSS("color", "rgb(244, 169, 73)");
|
||||
@@ -119,7 +125,15 @@ for (const narrow of [false, true]) {
|
||||
await page.getByRole("button", { name: "Send message", exact: true }).click();
|
||||
await expect(page.getByTestId("message-skill-reference-workflow")).toHaveText("$workflow");
|
||||
await expect(page.getByTestId("message-skill-reference-workflow")).toHaveCSS("color", "rgb(244, 169, 73)");
|
||||
const command = page.getByTestId("message-slash-command");
|
||||
const sentSkill = page.getByTestId("message-skill-reference-workflow");
|
||||
await expect(command).toHaveText("/goal");
|
||||
await expect(command).toHaveCSS("color", await sentSkill.evaluate(node => getComputedStyle(node).color));
|
||||
await expect(command).toHaveCSS("font-weight", "400");
|
||||
await expect(command.locator("span")).toHaveText("/");
|
||||
await expect(command.locator("span")).toHaveCSS("opacity", "0.9");
|
||||
await expect(page.locator("[data-user-text-bubble]").last().locator("p")).toHaveText(text);
|
||||
await page.screenshot({ path: info.outputPath("slash-command-and-skill.png") });
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user