From 1a4cee5815cf0b246b2ab71a72f6c141b9432982 Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Sun, 18 Oct 2026 00:10:28 +0800 Subject: [PATCH] fix(webui): align mention overlay spacing with the native caret --- webui/src/components/thread/ThreadComposer.tsx | 3 ++- webui/src/tests/thread-composer.test.tsx | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/webui/src/components/thread/ThreadComposer.tsx b/webui/src/components/thread/ThreadComposer.tsx index 86386c3dc..e0753aa79 100644 --- a/webui/src/components/thread/ThreadComposer.tsx +++ b/webui/src/components/thread/ThreadComposer.tsx @@ -2466,7 +2466,8 @@ export function ThreadComposer({ ) : null; const inputTextClasses = cn( - "w-full resize-none bg-transparent", + // Keep the overlay's CJK/Latin spacing aligned with the native textarea caret. + "w-full resize-none bg-transparent [text-autospace:no-autospace]", compactControls ? "min-h-[52px] px-4 pb-2 pt-3 text-[16px] leading-6" : isHero diff --git a/webui/src/tests/thread-composer.test.tsx b/webui/src/tests/thread-composer.test.tsx index bacbf6cfa..18e43f903 100644 --- a/webui/src/tests/thread-composer.test.tsx +++ b/webui/src/tests/thread-composer.test.tsx @@ -2484,6 +2484,21 @@ describe("ThreadComposer", () => { expect(input).toHaveValue("use @Blender tonight"); }); + it("keeps literal mixed-script spacing in both composer input layers", () => { + render(); + const input = screen.getByLabelText("Message input"); + const value = "定位原因, 提 @gimp issue, i并提"; + fireEvent.change(input, { target: { value, selectionStart: value.length } }); + + const display = "定位原因, 提 @\u00a0GIMP issue, i并提"; + 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]"); + }); + it("renders a CLI app mention logo inline without moving the text cursor slot", () => { render(