Skip to content

Your lightweight open-source personal agent.

fix(webui): emphasize mention brand names without shifting caret

Xubin Ren902e2b87b4cb
diff --git a/webui/src/components/CliAppMentionText.tsx b/webui/src/components/CliAppMentionText.tsx
index ce170b96b..dec5db890 100644
--- a/webui/src/components/CliAppMentionText.tsx
+++ b/webui/src/components/CliAppMentionText.tsx
@@ -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>
);
}
diff --git a/webui/src/tests/message-bubble.test.tsx b/webui/src/tests/message-bubble.test.tsx
index cb4ef3dcc..39e2aa01e 100644
--- a/webui/src/tests/message-bubble.test.tsx
+++ b/webui/src/tests/message-bubble.test.tsx
@@ -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`);
},
);
diff --git a/webui/src/tests/thread-composer.test.tsx b/webui/src/tests/thread-composer.test.tsx
index 3c3c7558b..5115814a2 100644
--- a/webui/src/tests/thread-composer.test.tsx
+++ b/webui/src/tests/thread-composer.test.tsx
@@ -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 = {