Skip to content

Your lightweight open-source personal agent.

fix(webui): remove composer placeholder tooltip

chengyongru11f738f0fe1b
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<number | null>(null);
const [boundSessionMentions, setBoundSessionMentions] = useState<SessionMention[]>(
initialDraft?.sessionMentions ?? [],
@@ -952,21 +949,8 @@ export function ThreadComposer({
const placeholderMeasureRef = useRef<HTMLSpanElement>(null);
const mentionOverlayRef = useRef<HTMLDivElement>(null);
const formRef = useRef<HTMLFormElement>(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}
- <TooltipProvider>
- <Tooltip open={placeholderHintOpen}>
- <TooltipTrigger asChild>
- <textarea
- ref={textareaRef}
- value={mentionInput.value}
- onFocus={(event) => {
- if (tabFocusRequested.current && !event.currentTarget.value) setPlaceholderHintRequested(true);
- tabFocusRequested.current = false;
- if (compactWhenIdle) setComposerFocused(true);
- }}
- onBlur={() => {
- if (placeholderHintRequested) setPlaceholderHintRequested(false);
- }}
- onPointerLeave={(event) => {
- if (event.pointerType === "mouse" && placeholderHintRequested) setPlaceholderHintRequested(false);
- }}
- onChange={mentionInput.onChange}
- onCompositionStart={mentionInput.onCompositionStart}
- onCompositionEnd={mentionInput.onCompositionEnd}
- onKeyDown={onKeyDown}
- onKeyUp={() => setCursorPosition(rawSelection().start)}
- onSelect={() => setCursorPosition(rawSelection().start)}
- onClick={(event) => {
- setCursorPosition(rawSelection().start);
- if (!event.currentTarget.value) setPlaceholderHintRequested(true);
- }}
- onCopy={mentionInput.onCopy}
- onCut={mentionInput.onCut}
- onScroll={(e) => {
- if (mentionOverlayRef.current) mentionOverlayRef.current.scrollTop = e.currentTarget.scrollTop;
- }}
- onPaste={onPaste}
- rows={1}
- enterKeyHint={hasCoarsePointer ? "enter" : undefined}
- placeholder={sessionDragPreview ? "" : displayedPlaceholder}
- disabled={interactionDisabled}
- aria-label={inputAriaLabel ?? t("thread.composer.inputAria")}
- aria-description={sessionDragPreview ? undefined : resolvedPlaceholder}
- className={cn(
- inputTextClasses,
- "relative z-10 block caret-foreground placeholder:text-muted-foreground",
- "focus:outline-none focus-visible:outline-none",
- "disabled:cursor-not-allowed",
- hasInlineDecorations && "text-transparent selection:bg-primary/20",
- )}
- />
- </TooltipTrigger>
- {placeholderHintOpen ? (
- <TooltipContent side="top" align="start" onEscapeKeyDown={() => {
- setPlaceholderHintOpen(false);
- setPlaceholderHintRequested(false);
- }} style={{ "--placeholder-hint-bottom-gap": `${placeholderHintBottomGap}px` } as CSSProperties}
- className="pointer-events-none max-w-[min(24rem,calc(100vw-2rem))] whitespace-normal break-words text-sm data-[side=bottom]:mt-[var(--placeholder-hint-bottom-gap)]">
- {resolvedPlaceholder}
- </TooltipContent>
- ) : null}
- </Tooltip>
- </TooltipProvider>
+ <textarea
+ ref={textareaRef}
+ value={mentionInput.value}
+ onFocus={() => {
+ if (compactWhenIdle) setComposerFocused(true);
+ }}
+ onChange={mentionInput.onChange}
+ onCompositionStart={mentionInput.onCompositionStart}
+ onCompositionEnd={mentionInput.onCompositionEnd}
+ onKeyDown={onKeyDown}
+ onKeyUp={() => setCursorPosition(rawSelection().start)}
+ onSelect={() => setCursorPosition(rawSelection().start)}
+ onClick={() => setCursorPosition(rawSelection().start)}
+ onCopy={mentionInput.onCopy}
+ onCut={mentionInput.onCut}
+ onScroll={(e) => {
+ if (mentionOverlayRef.current) mentionOverlayRef.current.scrollTop = e.currentTarget.scrollTop;
+ }}
+ onPaste={onPaste}
+ rows={1}
+ enterKeyHint={hasCoarsePointer ? "enter" : undefined}
+ placeholder={sessionDragPreview ? "" : displayedPlaceholder}
+ disabled={interactionDisabled}
+ aria-label={inputAriaLabel ?? t("thread.composer.inputAria")}
+ aria-description={sessionDragPreview ? undefined : resolvedPlaceholder}
+ className={cn(
+ inputTextClasses,
+ "relative z-10 block caret-foreground placeholder:text-muted-foreground",
+ "focus:outline-none focus-visible:outline-none",
+ "disabled:cursor-not-allowed",
+ hasInlineDecorations && "text-transparent selection:bg-primary/20",
+ )}
+ />
</div>
{inlineError ? (
<div