From 11f738f0fe1b9b68c93ff436309bfd310466c760 Mon Sep 17 00:00:00 2001 From: chengyongru Date: Fri, 6 Nov 2026 13:45:04 +0800 Subject: [PATCH] fix(webui): remove composer placeholder tooltip --- webui/browser/composer-action.spec.ts | 21 +-- .../src/components/thread/ThreadComposer.tsx | 128 +++++------------- 2 files changed, 35 insertions(+), 114 deletions(-) diff --git a/webui/browser/composer-action.spec.ts b/webui/browser/composer-action.spec.ts index 8926afb40..41a6d133f 100644 --- a/webui/browser/composer-action.spec.ts +++ b/webui/browser/composer-action.spec.ts @@ -149,7 +149,7 @@ test("idle voice and ready send remain distinct from the composer in both themes }); -test("a compact mobile placeholder keeps the full hint available without shifting the composer", async ({ browser, baseURL }) => { +test("a compact mobile composer preserves its placeholder, focus, and sizing", async ({ browser, baseURL }) => { const context = await browser.newContext({ baseURL, viewport: { width: 314, height: 844 }, hasTouch: true, isMobile: true, reducedMotion: "reduce" }); try { const page = await context.newPage(); @@ -162,41 +162,24 @@ test("a compact mobile placeholder keeps the full hint available without shiftin await expect.poll(() => input.evaluate(node => node.scrollWidth <= node.clientWidth)).toBe(true); const placeholder = (await input.getAttribute("aria-description"))!; expect(placeholder).toContain("compétences"); - await expect(page.getByRole("tooltip")).toHaveCount(0); const before = (await action.boundingBox())!; const initialHeight = await input.evaluate(node => node.clientHeight); await input.tap(); - const hint = page.getByRole("tooltip"); - await expect(hint).toHaveText(placeholder); - const hintSurface = page.locator('[data-radix-popper-content-wrapper] [data-side]').first(); - const composer = page.locator(".thread-composer-form"); - await expect.poll(async () => { - const [hintBox, composerBox] = await Promise.all([hintSurface.boundingBox(), composer.boundingBox()]); - return !!hintBox && !!composerBox && (hintBox.y + hintBox.height <= composerBox.y || hintBox.y >= composerBox.y + composerBox.height); - }).toBe(true); + await expect(input).toBeFocused(); expect(await action.boundingBox()).toEqual(before); await input.fill("Bonjour"); - await expect(hint).toHaveCount(0); expect(await action.boundingBox()).toEqual(before); await input.fill("Première ligne\nDeuxième ligne\nTroisième ligne"); await expect.poll(() => input.evaluate(node => node.clientHeight)).toBeGreaterThan(initialHeight); await input.fill(""); - await expect(hint).toHaveText(placeholder); await expect.poll(() => input.evaluate(node => node.clientHeight)).toBe(initialHeight); expect(await action.boundingBox()).toEqual(before); - await input.press("Escape"); - await expect(hint).toHaveCount(0); await page.locator(".thread-composer-footer button").first().focus(); await page.keyboard.press("Shift+Tab"); await expect(input).toBeFocused(); - await expect(hint).toHaveText(placeholder); - const box = (await input.boundingBox())!; - await page.mouse.move(box.x + 5, box.y + 5); - await page.mouse.move(1, 800); - await expect(hint).toHaveCount(0); } finally { await context.close(); } diff --git a/webui/src/components/thread/ThreadComposer.tsx b/webui/src/components/thread/ThreadComposer.tsx index 974841c1a..51cde5898 100644 --- a/webui/src/components/thread/ThreadComposer.tsx +++ b/webui/src/components/thread/ThreadComposer.tsx @@ -831,9 +831,6 @@ export function ThreadComposer({ const [value, setValue] = useState(initialDraft?.text ?? ""); const [composerFocused, setComposerFocused] = useState(false); const [compactPlaceholder, setCompactPlaceholder] = useState(false); - const [placeholderHintRequested, setPlaceholderHintRequested] = useState(false); - const [placeholderHintOpen, setPlaceholderHintOpen] = useState(false); - const [placeholderHintBottomGap, setPlaceholderHintBottomGap] = useState(0); const blurFrame = useRef(null); const [boundSessionMentions, setBoundSessionMentions] = useState( initialDraft?.sessionMentions ?? [], @@ -952,21 +949,8 @@ export function ThreadComposer({ const placeholderMeasureRef = useRef(null); const mentionOverlayRef = useRef(null); const formRef = useRef(null); - const tabFocusRequested = useRef(false); const [compactControls, setCompactControls] = useState(false); - useEffect(() => { - // Automatic session focus should not open the hint; keyboard navigation should. - const onKeyDown = (event: KeyboardEvent) => { tabFocusRequested.current = event.key === "Tab"; }; - const onPointerDown = () => { tabFocusRequested.current = false; }; - document.addEventListener("keydown", onKeyDown, true); - document.addEventListener("pointerdown", onPointerDown, true); - return () => { - document.removeEventListener("keydown", onKeyDown, true); - document.removeEventListener("pointerdown", onPointerDown, true); - }; - }, []); - useLayoutEffect(() => { const form = formRef.current; if (!form) return; @@ -1628,26 +1612,6 @@ export function ThreadComposer({ if (input) autosizeTextarea(input); }, [readingTextSize, customReadingTextSize]); - useLayoutEffect(() => { - const input = textareaRef.current; - if (!input || document.activeElement !== input || !placeholderHintRequested || input.value || !input.placeholder) { - setPlaceholderHintOpen(false); - return; - } - const form = formRef.current!; - const measure = () => { - setPlaceholderHintOpen(showCompactPlaceholder || input.scrollWidth > input.clientWidth); - setPlaceholderHintBottomGap(form.getBoundingClientRect().bottom - input.getBoundingClientRect().bottom); - }; - measure(); - const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure); - observer?.observe(input); - observer?.observe(form); - let active = true; - void document.fonts?.ready.then(() => { if (active) measure(); }); - return () => { active = false; observer?.disconnect(); }; - }, [placeholderHintRequested, mentionInput.value, resolvedPlaceholder, showCompactPlaceholder, sessionDragPreview, readingTextSize, customReadingTextSize]); - // Runs before paint so switching sessions never flashes stale draft text. useLayoutEffect(() => { if (previousPendingQueueKeyRef.current === pendingQueueKey) return; @@ -2459,65 +2423,39 @@ export function ThreadComposer({ : null} /> ) : null} - - - -