diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx index caf6b33aa..46a2ab735 100644 --- a/webui/browser/fixture.tsx +++ b/webui/browser/fixture.tsx @@ -23,6 +23,7 @@ import { NewChatSkeletonFixture } from "./new-chat-skeleton-fixture"; import "../src/globals.css"; import { DiagramFixture } from "./diagram-fixture"; import { TypographyFixture } from "./typography-fixture"; +import { InlineReferencesFixture } from "./inline-references-fixture"; import { MarkdownEmphasisFixture } from "./markdown-emphasis-fixture"; import { HistoryBoundaryFixture } from "./history-boundary-fixture"; import { ChatFailureFixture } from "./chat-failure-fixture"; @@ -244,6 +245,8 @@ createRoot(document.getElementById("root")!).render( ? : parameters.get("case") === "typography" ? + : parameters.get("case") === "inline-references" + ? : parameters.get("case") === "idle-compaction" ? : parameters.get("case") === "history-hydration" diff --git a/webui/browser/inline-references-fixture.tsx b/webui/browser/inline-references-fixture.tsx new file mode 100644 index 000000000..8719937c8 --- /dev/null +++ b/webui/browser/inline-references-fixture.tsx @@ -0,0 +1,32 @@ +import { useState } from "react"; + +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"; + +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 answer: UIMessage = { + id: "reference-answer", role: "assistant", createdAt: 1, + content: "[相关会话](#session/websocket%3Atypography) · [外部文档](https://example.com/reference)", +}; + +export function InlineReferencesFixture() { + useReadingTypography(); + const { theme } = useTheme(); + const [sent, setSent] = useState([]); + return +
+ {[answer, ...sent].map(message => )} + setSent(current => [...current, { + id: `sent-${current.length}`, role: "user", content: text, createdAt: current.length + 2, + }])} /> +
+
; +} diff --git a/webui/browser/inline-references.spec.ts b/webui/browser/inline-references.spec.ts new file mode 100644 index 000000000..0f5fd72e1 --- /dev/null +++ b/webui/browser/inline-references.spec.ts @@ -0,0 +1,126 @@ +import { expect, test, type Locator } from "@playwright/test"; + +async function expectMatchingInputLayers(input: Locator) { + const metrics = await input.evaluate((node: HTMLTextAreaElement) => { + const overlay = node.previousElementSibling as HTMLElement; + const readStyle = (element: Element) => { + const style = getComputedStyle(element); + return { + fontFamily: style.fontFamily, fontSize: style.fontSize, fontWeight: style.fontWeight, + lineHeight: style.lineHeight, letterSpacing: style.letterSpacing, + padding: style.padding, autospace: style.getPropertyValue("text-autospace"), + }; + }; + const glyphs = (element: Element) => { + const origin = element.getBoundingClientRect(); + const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT); + const result: number[][] = []; + while (walker.nextNode()) { + const text = walker.currentNode; + for (let index = 0; index < (text.textContent?.length ?? 0); index++) { + const range = document.createRange(); + range.setStart(text, index); + range.setEnd(text, index + 1); + const rect = range.getBoundingClientRect(); + result.push([rect.x - origin.x, rect.y - origin.y, rect.width, rect.height]); + } + } + return result; + }; + const plain = overlay.cloneNode(false) as HTMLElement; + plain.style.visibility = "hidden"; + plain.textContent = overlay.textContent; + overlay.parentElement!.append(plain); + plain.scrollTop = overlay.scrollTop; + try { + return { + inputStyle: readStyle(node), overlayStyle: readStyle(overlay), + overlayText: overlay.textContent, value: node.value, + decoratedGlyphs: glyphs(overlay), plainGlyphs: glyphs(plain), + }; + } finally { + plain.remove(); + } + }); + expect(metrics.overlayStyle).toEqual(metrics.inputStyle); + expect(metrics.overlayText).toBe(metrics.value); + expect(metrics.decoratedGlyphs.length).toBe(metrics.plainGlyphs.length); + for (let index = 0; index < metrics.plainGlyphs.length; index++) { + for (let dimension = 0; dimension < 4; dimension++) { + expect(Math.abs(metrics.decoratedGlyphs[index][dimension] - metrics.plainGlyphs[index][dimension])).toBeLessThanOrEqual(0.5); + } + } +} + +for (const narrow of [false, true]) { + for (const theme of ["light", "dark"]) { + test(`inline references preserve native editing: ${narrow ? "narrow" : "desktop"}, ${theme}`, async ({ page }, info) => { + await page.setViewportSize(narrow ? { width: 390, height: 844 } : { width: 1440, height: 1000 }); + await page.context().grantPermissions(["clipboard-read", "clipboard-write"]); + await page.addInitScript(theme => { + localStorage.setItem("nanobot.locale", "en"); + localStorage.setItem("nanobot-webui.theme", theme); + }, theme); + const errors: string[] = []; + page.on("pageerror", error => errors.push(error.message)); + await page.goto("/browser/fixture.html?case=inline-references"); + + const sessionLink = page.getByRole("link", { name: "相关会话", exact: true }); + await sessionLink.waitFor({ state: "visible", timeout: 15_000 }); + await expect(sessionLink).toHaveAttribute("href", "#/chat/websocket%3Atypography"); + await expect(sessionLink.locator("span")).toHaveCSS("color", "rgb(244, 169, 73)"); + await sessionLink.click(); + await expect(page).toHaveURL(/#\/chat\/websocket%3Atypography$/); + const externalLink = page.getByRole("link", { name: "外部文档", exact: true }); + await expect(externalLink).toHaveAttribute("href", "https://example.com/reference"); + await expect(externalLink).toHaveAttribute("target", "_blank"); + await expect(externalLink).toHaveCSS("color", theme === "light" ? "rgb(59, 130, 246)" : "rgb(147, 197, 253)"); + + 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 与换行。"; + await input.focus(); + await input.pressSequentially(text); + const skill = page.getByTestId("composer-skill-reference-workflow"); + await expect(skill).toHaveText("$workflow"); + await expect(skill).toHaveCSS("color", "rgb(244, 169, 73)"); + await expect(skill).toHaveCSS("font-weight", "400"); + expect(await skill.getAttribute("title")).toBeNull(); + await expectMatchingInputLayers(input); + + const start = text.indexOf("workflow") + 1; + const end = start + 4; + await input.evaluate((node: HTMLTextAreaElement, range) => node.setSelectionRange(range.start, range.end), { start, end }); + await input.press("ControlOrMeta+c"); + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(text.slice(start, end)); + await input.press("ControlOrMeta+x"); + await expect(input).toHaveValue(text.slice(0, start) + text.slice(end)); + await input.press("ControlOrMeta+z"); + await expect(input).toHaveValue(text); + expect(await input.evaluate((node: HTMLTextAreaElement) => [node.selectionStart, node.selectionEnd])).toEqual([start, end]); + + const mixed = "粘贴 $workflow 与 @typography,继续输入。"; + await input.fill(""); + await page.evaluate(text => navigator.clipboard.writeText(text), mixed); + await input.press("ControlOrMeta+v"); + await expect(input).toHaveValue(mixed); + await expect(skill).toHaveText("$workflow"); + await expect(page.getByTestId("composer-session-mention-typography")).toHaveText("@typography"); + await expect(overlay).toHaveText(mixed); + + const multiline = Array.from({ length: 18 }, (_, index) => `第 ${index + 1} 行 $workflow 中文 English 光标与装饰层保持一致。`).join("\n"); + await input.fill(multiline); + await input.press("ControlOrMeta+End"); + await expect.poll(async () => Math.abs(await input.evaluate(node => node.scrollTop) - await overlay.evaluate(node => node.scrollTop))).toBeLessThanOrEqual(1); + await expectMatchingInputLayers(input); + await input.fill(text); + await input.press("End"); + await page.screenshot({ path: info.outputPath("composer-skills.png") }); + 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)"); + await expect(page.locator("[data-user-text-bubble]").last().locator("p")).toHaveText(text); + expect(errors).toEqual([]); + }); + } +} diff --git a/webui/src/components/InlineTokenHighlight.tsx b/webui/src/components/InlineTokenHighlight.tsx index e27bbbe05..664625876 100644 --- a/webui/src/components/InlineTokenHighlight.tsx +++ b/webui/src/components/InlineTokenHighlight.tsx @@ -3,6 +3,7 @@ import type { ReactNode } from "react"; import { cn } from "@/lib/utils"; export const INLINE_TOKEN_HIGHLIGHT_COLOR = "var(--inline-token-highlight)"; +export const INLINE_REFERENCE_HIGHLIGHT_COLOR = "var(--inline-reference-highlight)"; export function InlineTokenHighlight({ children, diff --git a/webui/src/components/MarkdownTextRenderer.tsx b/webui/src/components/MarkdownTextRenderer.tsx index 8fd369566..5f7012602 100644 --- a/webui/src/components/MarkdownTextRenderer.tsx +++ b/webui/src/components/MarkdownTextRenderer.tsx @@ -24,7 +24,7 @@ import { MarkdownCodeBlock } from "@/components/markdown-diagrams/MarkdownCodeBl import { MarkdownCodeContext } from "@/components/markdown-diagrams/context"; import { WebLink } from "@/components/WebLink"; import { - INLINE_TOKEN_HIGHLIGHT_COLOR, + INLINE_REFERENCE_HIGHLIGHT_COLOR, InlineTokenHighlight, } from "@/components/InlineTokenHighlight"; import { @@ -629,9 +629,9 @@ export default function MarkdownTextRenderer({ - + {markdownChildren} diff --git a/webui/src/components/SkillReferenceText.tsx b/webui/src/components/SkillReferenceText.tsx new file mode 100644 index 000000000..6e74182aa --- /dev/null +++ b/webui/src/components/SkillReferenceText.tsx @@ -0,0 +1,43 @@ +import { + INLINE_REFERENCE_HIGHLIGHT_COLOR, + InlineTokenHighlight, +} from "@/components/InlineTokenHighlight"; +import type { CapabilityMentionSegment } from "@/lib/composer-mention-text"; + +export type InlineReferenceSegment = + | CapabilityMentionSegment + | { kind: "skill"; text: string; name: string }; + +export function withSkillReferences(segments: CapabilityMentionSegment[]): InlineReferenceSegment[] { + const result: InlineReferenceSegment[] = []; + for (const segment of segments) { + if (segment.kind !== "text") { + result.push(segment); + continue; + } + let cursor = 0; + for (const match of segment.text.matchAll(/\$([A-Za-z0-9_-]+)/g)) { + if (match.index > cursor) { + result.push({ kind: "text", text: segment.text.slice(cursor, match.index) }); + } + result.push({ kind: "skill", text: match[0], name: match[0].slice(1) }); + cursor = match.index + match[0].length; + } + if (cursor < segment.text.length) { + result.push({ kind: "text", text: segment.text.slice(cursor) }); + } + } + return result; +} + +export function SkillReferenceToken({ name, testId }: { name: string; testId: string }) { + return ( + + ${name} + + ); +} diff --git a/webui/src/components/UserMessageText.tsx b/webui/src/components/UserMessageText.tsx index 6aae352e7..5c89cb821 100644 --- a/webui/src/components/UserMessageText.tsx +++ b/webui/src/components/UserMessageText.tsx @@ -1,70 +1,11 @@ import { Fragment } from "react"; -import { useTranslation } from "react-i18next"; import { CapabilityMentionToken, splitCapabilityMentionSegments, } from "@/components/CliAppMentionText"; -import { - INLINE_TOKEN_HIGHLIGHT_COLOR, - InlineTokenHighlight, -} from "@/components/InlineTokenHighlight"; +import { SkillReferenceToken, withSkillReferences } from "@/components/SkillReferenceText"; import type { CliAppInfo, McpPresetInfo, SessionMention } from "@/lib/types"; -import type { CapabilityMentionSegment } from "@/lib/composer-mention-text"; - -type SkillReferenceSegment = - | { kind: "text"; text: string } - | { kind: "skill"; text: string; name: string }; - -type UserMessageSegment = - | CapabilityMentionSegment - | { kind: "skill"; text: string; name: string }; - -function splitSkillReferenceSegments(value: string): SkillReferenceSegment[] { - if (!value) return []; - const segments: SkillReferenceSegment[] = []; - const referenceRe = /\$([A-Za-z0-9_-]+)/g; - let cursor = 0; - let match: RegExpExecArray | null; - while ((match = referenceRe.exec(value)) !== null) { - const name = match[1] ?? ""; - if (match.index > cursor) { - segments.push({ kind: "text", text: value.slice(cursor, match.index) }); - } - segments.push({ - kind: "skill", - text: value.slice(match.index, referenceRe.lastIndex), - name, - }); - cursor = referenceRe.lastIndex; - } - if (cursor < value.length) { - segments.push({ kind: "text", text: value.slice(cursor) }); - } - return segments.length ? segments : [{ kind: "text", text: value }]; -} - -function splitUserMessageSegments( - value: string, - cliApps: CliAppInfo[], - mcpPresets: McpPresetInfo[], - sessionMentions: SessionMention[], -): UserMessageSegment[] { - const segments: UserMessageSegment[] = []; - for (const segment of splitCapabilityMentionSegments( - value, - cliApps, - mcpPresets, - sessionMentions, - )) { - if (segment.kind === "text") { - segments.push(...splitSkillReferenceSegments(segment.text)); - } else { - segments.push(segment); - } - } - return segments; -} export function UserMessageText({ text, @@ -77,8 +18,9 @@ export function UserMessageText({ mcpPresets: McpPresetInfo[]; sessionMentions?: SessionMention[]; }) { - const { t } = useTranslation(); - const segments = splitUserMessageSegments(text, cliApps, mcpPresets, sessionMentions); + const segments = withSkillReferences( + splitCapabilityMentionSegments(text, cliApps, mcpPresets, sessionMentions), + ); return ( <> {segments.map((segment, index) => { @@ -86,14 +28,11 @@ export function UserMessageText({ return {segment.text}; } if (segment.kind === "skill") return ( - - {segment.text} - + /> ); return ( 0; const showAnyPalette = showSlashMenu || showCliAppMenu; - const hasMentionDecorations = displayMentionSegments.some( - (segment) => segment.kind !== "text", + const inlineSegments = useMemo( + () => withSkillReferences(displayMentionSegments), + [displayMentionSegments], ); + const hasInlineDecorations = inlineSegments.some((segment) => segment.kind !== "text"); const activeCliMentionApps = useMemo(() => { const seen = new Set(); return mentionSegments.flatMap((segment) => { @@ -2705,10 +2711,10 @@ export function ThreadComposer({ ) : null}
- {hasMentionDecorations ? ( -
@@ -2989,7 +2995,7 @@ function QueuedPromptPreview({ ); } -function ComposerCliMentionOverlay({ +function ComposerInlineReferenceOverlay({ overlayRef, segments, isHero, @@ -2998,7 +3004,7 @@ function ComposerCliMentionOverlay({ ghostRange, }: { overlayRef: Ref; - segments: CapabilityMentionSegment[]; + segments: InlineReferenceSegment[]; isHero: boolean; isComposing: boolean; className: string; @@ -3023,6 +3029,13 @@ function ComposerCliMentionOverlay({ if (segment.kind === "text") { return {segment.text}; } + if (segment.kind === "skill") { + return ; + } const isGhost = ghostRange?.start === start && ghostRange.end === offset; const identity = `${segment.kind}-${segment.kind === "cli" ? segment.app.name : segment.kind === "mcp" ? segment.preset.name : segment.mention.session_key}`; diff --git a/webui/src/globals.css b/webui/src/globals.css index 9e4807087..71d807460 100644 --- a/webui/src/globals.css +++ b/webui/src/globals.css @@ -54,6 +54,7 @@ --input: 40 8% 90.5%; --ring: 0 0% 3.9%; --inline-token-highlight: #ad450b; + --inline-reference-highlight: rgb(244 169 73); --code-comment: #62626b; --code-string: #166534; --code-keyword: #7e22ce; @@ -139,6 +140,7 @@ --input: var(--border); --ring: 0 0% 83.1%; --inline-token-highlight: #ef8e30; + --inline-reference-highlight: rgb(244 169 73); --code-comment: #c8c8d0; --code-string: #b5d99c; --code-keyword: #e3a5f7; @@ -1445,7 +1447,7 @@ .automation-create-composer .thread-composer-surface { max-inline-size: none; } - .automation-create-composer .thread-composer-input textarea { + .automation-create-composer .thread-composer-input > :is(textarea, [aria-hidden]) { padding-inline: var(--settings-inset); } .automation-view-switch .segmented-control button { @@ -1489,7 +1491,7 @@ white-space: nowrap; text-overflow: ellipsis; } - .thread-composer-collapsible[data-compact] .thread-composer-input textarea { + .thread-composer-collapsible[data-compact] .thread-composer-input > :is(textarea, [aria-hidden]) { display: block; block-size: 3.125rem !important; } @@ -1497,7 +1499,7 @@ .thread-composer-collapsible .thread-composer-input { inline-size: 100%; } - .thread-composer-collapsible .thread-composer-input textarea { + .thread-composer-collapsible .thread-composer-input > :is(textarea, [aria-hidden]) { display: block; min-block-size: 3.5rem; padding-block: 1.125rem; @@ -1505,7 +1507,7 @@ .thread-composer-collapsible[data-compact] .thread-composer-input { inline-size: max(0px, calc(100% - var(--composer-compact-controls-width, 15rem) - 1.5rem)); } - .thread-composer-collapsible[data-compact] .thread-composer-input textarea { + .thread-composer-collapsible[data-compact] .thread-composer-input > :is(textarea, [aria-hidden]) { display: block; block-size: 3.5rem !important; min-block-size: 3.5rem; diff --git a/webui/src/tests/markdown-text-renderer.test.tsx b/webui/src/tests/markdown-text-renderer.test.tsx index b2f92d032..529f69e20 100644 --- a/webui/src/tests/markdown-text-renderer.test.tsx +++ b/webui/src/tests/markdown-text-renderer.test.tsx @@ -21,10 +21,10 @@ describe("MarkdownTextRenderer", () => { expect(link).toHaveClass("text-blue-500", "dark:text-blue-300"); }); - it("renders canonical session references as same-tab links", () => { + it.each(["#session/", "#/chat/"])("renders %s session references as same-tab links", (prefix) => { render( - {"We discussed this in [收费设计](#session/websocket%3Apricing)."} + {`We discussed this in [收费设计](${prefix}websocket%3Apricing).`} , ); @@ -32,7 +32,10 @@ describe("MarkdownTextRenderer", () => { expect(link).toHaveAttribute("href", "#/chat/websocket%3Apricing"); expect(link).not.toHaveAttribute("target"); expect(link.getAttribute("style")).toContain( - "text-decoration-color: var(--inline-token-highlight)", + "text-decoration-color: var(--inline-reference-highlight)", + ); + expect(link.firstElementChild?.getAttribute("style")).toContain( + "color: var(--inline-reference-highlight)", ); }); diff --git a/webui/src/tests/message-bubble.test.tsx b/webui/src/tests/message-bubble.test.tsx index 0fce66124..1521d4bd6 100644 --- a/webui/src/tests/message-bubble.test.tsx +++ b/webui/src/tests/message-bubble.test.tsx @@ -509,13 +509,14 @@ describe("MessageBubble", () => { const skill = screen.getByTestId("message-skill-reference-github"); expect(skill).toHaveTextContent(/^\$github$/); expect(skill).toHaveClass( - "font-[550]", + "font-normal", "transition-colors", "duration-150", ); expect(skill.getAttribute("style")).not.toContain("text-shadow"); - expect(skill.getAttribute("style")).toContain("var(--inline-token-highlight)"); + expect(skill.getAttribute("style")).toContain("var(--inline-reference-highlight)"); expect(skill.className).not.toMatch(/(?:^|\s)(?:bg-|border|ring|rounded)/); + expect(skill).not.toHaveAttribute("title"); expect(screen.getByTestId("message-cli-mention-zoom")).toHaveTextContent("@Zoom"); expect(skill.parentElement).toHaveTextContent("Ask $github to review this with @Zoom"); }); diff --git a/webui/src/tests/thread-composer.test.tsx b/webui/src/tests/thread-composer.test.tsx index db1dec50f..13e4ef83e 100644 --- a/webui/src/tests/thread-composer.test.tsx +++ b/webui/src/tests/thread-composer.test.tsx @@ -2562,6 +2562,54 @@ describe("ThreadComposer", () => { }]); }); + it("highlights literal skill references while preserving partial edits, clipboard text and sending", () => { + const onSend = vi.fn(); + render(); + const input = screen.getByLabelText("Message input") as HTMLTextAreaElement; + const text = "like $workflow 与 $skill-creator,$"; + fireEvent.change(input, { target: { value: text, selectionStart: text.length } }); + + expect(screen.getByTestId("composer-skill-reference-workflow")).toHaveTextContent(/^\$workflow$/); + expect(screen.getByTestId("composer-skill-reference-skill-creator")).toHaveTextContent(/^\$skill-creator$/); + expect(input).toHaveValue(text); + expect(input.previousElementSibling).toHaveAttribute("aria-hidden", "true"); + expect(input.previousElementSibling?.textContent).toBe(text); + + const start = text.indexOf("workflow") + 1; + const end = start + 4; + input.setSelectionRange(start, end); + const setData = vi.fn(); + fireEvent.copy(input, { clipboardData: { setData } }); + expect(setData).toHaveBeenCalledWith("text/plain", text.slice(start, end)); + fireEvent.cut(input, { clipboardData: { setData } }); + expect(input).toHaveValue(text.slice(0, start) + text.slice(end)); + fireEvent.keyDown(input, { key: "z", ctrlKey: true }); + expect(input).toHaveValue(text); + expect(input.selectionStart).toBe(start); + expect(input.selectionEnd).toBe(end); + + fireEvent.click(screen.getByRole("button", { name: "Send message" })); + expect(onSend).toHaveBeenCalledWith(text, undefined, undefined); + }); + + it("mirrors skill references during composition without submitting the IME confirmation", () => { + const onSend = vi.fn(); + render(); + const input = screen.getByLabelText("Message input") as HTMLTextAreaElement; + fireEvent.change(input, { target: { value: "$workflow " } }); + fireEvent.compositionStart(input); + fireEvent.change(input, { target: { value: "$workflow zhong" } }); + expect(screen.getByTestId("composer-skill-reference-workflow")).toHaveTextContent(/^\$workflow$/); + expect(input.previousElementSibling?.textContent).toBe(input.value); + expect(input.previousElementSibling).toHaveClass("z-20"); + fireEvent.keyDown(input, { key: "Enter", isComposing: true }); + expect(onSend).not.toHaveBeenCalled(); + fireEvent.change(input, { target: { value: "$workflow 中" } }); + fireEvent.compositionEnd(input, { data: "中" }); + fireEvent.click(screen.getByRole("button", { name: "Send message" })); + expect(onSend).toHaveBeenCalledWith("$workflow 中", undefined, undefined); + }); + it("opens skills only from a $ reference and prioritizes the skill name", () => { const skillName = "arxiv-intelligence-filter"; render( @@ -2613,6 +2661,8 @@ describe("ThreadComposer", () => { fireEvent.keyDown(input, { key: "Tab" }); expect(input).toHaveValue(`please use $${skillName} `); + expect(screen.getByTestId(`composer-skill-reference-${skillName}`)) + .toHaveTextContent(`$${skillName}`); }); it("ranks skill name matches ahead of earlier description matches", () => { @@ -2737,16 +2787,17 @@ describe("ThreadComposer", () => { it("keeps literal mixed-script spacing in both composer input layers", () => { render(); const input = screen.getByLabelText("Message input"); - const value = "定位原因, 提 @gimp issue, i并提"; + const value = "定位原因, 提 @gimp issue, i并提 $workflow"; fireEvent.change(input, { target: { value, selectionStart: value.length } }); - const display = "定位原因, 提 @\u00a0GIMP issue, i并提"; + const display = "定位原因, 提 @\u00a0GIMP issue, i并提 $workflow"; const overlay = input.previousElementSibling; expect(input).toHaveValue(display); expect(overlay).toHaveAttribute("aria-hidden", "true"); expect(overlay?.textContent).toBe(display); expect(input).toHaveClass("[text-autospace:no-autospace]"); expect(overlay).toHaveClass("[text-autospace:no-autospace]"); + expect(screen.getByTestId("composer-skill-reference-workflow")).toHaveTextContent("$workflow"); }); it("renders a CLI app mention logo inline without moving the text cursor slot", () => {