fix(webui): emphasize mention brand names without shifting caret
This commit is contained in:
1 parent
b6122b9018
commit
902e2b87b4
3 files changed
+32
-3
No files matched your search
@@ -21,6 +21,9 @@ export type CapabilityMentionSegment =
|
||||
| { kind: "mcp"; text: string; preset: McpPresetInfo }
|
||||
| { kind: "session"; text: string; mention: SessionMention };
|
||||
|
||||
// Paint-only weight keeps the native textarea's regular-width caret and wrapping in sync.
|
||||
const COMPOSER_BRAND_NAME_CLASS = "[-webkit-text-stroke:0.4px_currentColor]";
|
||||
|
||||
export function cliAppInitials(app: CliAppInfo): string {
|
||||
const value = app.display_name || app.name;
|
||||
return (
|
||||
@@ -237,7 +240,9 @@ function CliAppMentionToken({
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
{variant === "message" ? <span className="min-w-0">{mentionName}</span> : mentionName}
|
||||
<span className={variant === "message" ? "min-w-0 font-semibold" : COMPOSER_BRAND_NAME_CLASS}>
|
||||
{mentionName}
|
||||
</span>
|
||||
</InlineTokenHighlight>
|
||||
);
|
||||
}
|
||||
@@ -306,7 +311,9 @@ function McpPresetMentionToken({
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
{variant === "message" ? <span className="min-w-0">{mentionName}</span> : mentionName}
|
||||
<span className={variant === "message" ? "min-w-0 font-semibold" : COMPOSER_BRAND_NAME_CLASS}>
|
||||
{mentionName}
|
||||
</span>
|
||||
</InlineTokenHighlight>
|
||||
);
|
||||
}
|
||||
@@ -690,7 +690,7 @@ describe("MessageBubble", () => {
|
||||
expect(token).toHaveAttribute("title", `${kind === "cli" ? "CLI app" : "MCP server"}: ${expected} (@${name})`);
|
||||
expect(token).toHaveClass("inline-flex", "items-baseline", "max-w-full", "[overflow-wrap:anywhere]");
|
||||
expect(token.firstElementChild).toHaveClass("shrink-0");
|
||||
expect(token.lastElementChild).toHaveClass("min-w-0");
|
||||
expect(token.lastElementChild).toHaveClass("min-w-0", "font-semibold");
|
||||
expect(message.content).toBe(`Use @${name} please`);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -2241,6 +2241,28 @@ describe("ThreadComposer", () => {
|
||||
expect(logo.parentElement?.className).not.toMatch(/(?:^|\s)(?:w-|m[rlx]-|p[rlx]-)/);
|
||||
});
|
||||
|
||||
it.each(["cli", "mcp"] as const)("emphasizes the %s brand without changing composer text metrics", (kind) => {
|
||||
render(<ThreadComposer
|
||||
onSend={vi.fn()}
|
||||
cliApps={kind === "cli" ? [{ ...CLI_APPS[0], name: "linear", display_name: "Linear" }] : []}
|
||||
mcpPresets={kind === "mcp" ? [{ ...MCP_PRESETS[0], name: "linear", display_name: "Linear" }] : []}
|
||||
/>);
|
||||
const input = screen.getByLabelText("Message input");
|
||||
fireEvent.change(input, { target: { value: "@linear 帮我查看", selectionStart: 12 } });
|
||||
const token = screen.getByTestId(`composer-${kind}-mention-linear`);
|
||||
const name = token.lastElementChild!;
|
||||
expect(name).toHaveTextContent("Linear");
|
||||
expect(name).toHaveClass("[-webkit-text-stroke:0.4px_currentColor]");
|
||||
expect(token).toHaveClass("font-normal");
|
||||
expect(token.firstElementChild).not.toHaveClass("[-webkit-text-stroke:0.4px_currentColor]");
|
||||
expect(input).toHaveValue("@\u00a0Linear 帮我查看");
|
||||
expect(input).not.toHaveClass("font-semibold");
|
||||
fireEvent.compositionStart(input);
|
||||
fireEvent.change(input, { target: { value: "@\u00a0Linear 帮我查看n" } });
|
||||
expect(token.lastElementChild).toBe(name);
|
||||
expect(name).toHaveClass("[-webkit-text-stroke:0.4px_currentColor]");
|
||||
});
|
||||
|
||||
it("uses the shared accent when an installed CLI app has no brand metadata", () => {
|
||||
const mention = "@obsidian-agent-cli";
|
||||
const app: CliAppInfo = {
|
||||
|
||||
Reference in new issue
Block a user