Skip to content

Your lightweight open-source personal agent.

fix(webui): align mention overlay spacing with the native caret

chengyongru1a4cee5815cf
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({
<ComposerUsagePopover context={contextUsage} rounds={recentRoundUsage} showLabel={compactControls} bottomSheet={compactControls} />
) : 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(<ThreadComposer onSend={vi.fn()} cliApps={CLI_APPS} />);
+ 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(
<ThreadComposer