Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8792 fix(ui): let keyboard users reach cut-off text behind a tooltip (#10147)

Jiayuan Zhang762790e812f8
diff --git a/apps/desktop/src/renderer/src/components/daemon-settings-tab.tsx b/apps/desktop/src/renderer/src/components/daemon-settings-tab.tsx
index d97432f3cb..f4719f6337 100644
--- a/apps/desktop/src/renderer/src/components/daemon-settings-tab.tsx
+++ b/apps/desktop/src/renderer/src/components/daemon-settings-tab.tsx
@@ -34,7 +34,7 @@ function DiagnosticsRow({
return (
<div className="grid grid-cols-[140px_minmax(0,1fr)] items-baseline gap-3 py-1.5">
<span className="text-caption text-muted-foreground">{label}</span>
- <TruncatedTooltip content={typeof value === "string" ? value : undefined}>
+ <TruncatedTooltip content={typeof value === "string" ? value : undefined} focusable>
<span
className={cn(
"min-w-0 truncate text-body",
diff --git a/apps/desktop/src/renderer/src/components/window-toolbar.tsx b/apps/desktop/src/renderer/src/components/window-toolbar.tsx
index 1df0127c46..cf766725c5 100644
--- a/apps/desktop/src/renderer/src/components/window-toolbar.tsx
+++ b/apps/desktop/src/renderer/src/components/window-toolbar.tsx
@@ -161,17 +161,17 @@ function HistoryMenuItem({
const { visual, title } = useTabPresentation(url, fallbackTitle);
return (
- <DropdownMenuItem
- className="h-8 min-w-0 gap-2 px-2"
- onClick={onSelect}
- >
- <ResourceLeadingVisual visual={visual} />
- <TruncatedTooltip content={title}>
+ <TruncatedTooltip content={title}>
+ <DropdownMenuItem
+ className="h-8 min-w-0 gap-2 px-2"
+ onClick={onSelect}
+ >
+ <ResourceLeadingVisual visual={visual} />
<span className="min-w-0 flex-1 truncate">
{title}
</span>
- </TruncatedTooltip>
- </DropdownMenuItem>
+ </DropdownMenuItem>
+ </TruncatedTooltip>
);
}
diff --git a/apps/desktop/test/setup.ts b/apps/desktop/test/setup.ts
index 9a43c1d79c..b5eaee490e 100644
--- a/apps/desktop/test/setup.ts
+++ b/apps/desktop/test/setup.ts
@@ -21,4 +21,14 @@ if (typeof window !== "undefined") {
dispatchEvent: () => false,
}) as MediaQueryList;
}
+
+ // jsdom doesn't provide ResizeObserver; a focusable TruncatedTooltip
+ // observes its trigger. Mirrors packages/views/test/setup.ts.
+ if (typeof globalThis.ResizeObserver === "undefined") {
+ globalThis.ResizeObserver = class ResizeObserver {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ } as unknown as typeof ResizeObserver;
+ }
}
diff --git a/packages/ui/components/common/__tests__/truncated-tooltip.test.tsx b/packages/ui/components/common/__tests__/truncated-tooltip.test.tsx
index 11fbc987c6..177f2bb364 100644
--- a/packages/ui/components/common/__tests__/truncated-tooltip.test.tsx
+++ b/packages/ui/components/common/__tests__/truncated-tooltip.test.tsx
@@ -1,5 +1,6 @@
import type { ReactNode } from "react";
import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import { afterEach, describe, expect, it, vi } from "vitest";
import { isContentTruncated, TruncatedTooltip } from "../truncated-tooltip";
import { TooltipProvider } from "../../ui/tooltip";
@@ -125,6 +126,45 @@ describe("TruncatedTooltip", () => {
expect(document.querySelector("[data-slot='tooltip-content']")).toBeNull();
});
+ it("opens when Tab reaches a control whose text is cut off", async () => {
+ const user = userEvent.setup();
+ renderWithTooltips(
+ <>
+ <button type="button">Before</button>
+ <Row label="A very long project name" />
+ </>,
+ );
+ setBox(screen.getByTestId("label"), { scrollWidth: 240, clientWidth: 120 });
+ screen.getByRole("button", { name: "Before" }).focus();
+
+ await user.tab();
+ expect(screen.getByRole("button", { name: "A very long project name" })).toHaveFocus();
+ expect(tooltipPopup()).toHaveTextContent("A very long project name");
+ });
+
+ it("leaves focus under a hovering pointer to the hover delay", async () => {
+ renderWithTooltips(<Row label="A very long project name" />);
+ setBox(screen.getByTestId("label"), { scrollWidth: 240, clientWidth: 120 });
+ const button = screen.getByRole("button");
+
+ // A menu moves focus to the item under the pointer.
+ vi.useFakeTimers();
+ try {
+ fireEvent.pointerEnter(button, { pointerType: "mouse" });
+ await act(async () => {
+ button.focus();
+ });
+ expect(tooltipPopup()).toBeNull();
+
+ await act(async () => {
+ vi.advanceTimersByTime(550);
+ });
+ expect(tooltipPopup()).toHaveTextContent("A very long project name");
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
it("renders the child alone without content", () => {
renderWithTooltips(
<TruncatedTooltip content="">
@@ -135,6 +175,111 @@ describe("TruncatedTooltip", () => {
});
});
+describe("TruncatedTooltip focusable", () => {
+ function Panel() {
+ return (
+ <>
+ <button type="button">Before</button>
+ <TruncatedTooltip content="feature/very-long-branch-name" focusable>
+ <span style={{ overflowX: "hidden" }}>feature/very-long-branch-name</span>
+ </TruncatedTooltip>
+ <TruncatedTooltip content="main" focusable>
+ <span style={{ overflowX: "hidden" }}>main</span>
+ </TruncatedTooltip>
+ <button type="button">After</button>
+ </>
+ );
+ }
+
+ // jsdom never resizes, so the test re-runs the measurement once it has
+ // given the text its widths.
+ function renderPanel() {
+ renderWithTooltips(<Panel />);
+ setBox(screen.getByText("feature/very-long-branch-name"), { scrollWidth: 240, clientWidth: 120 });
+ setBox(screen.getByText("main"), { scrollWidth: 30, clientWidth: 120 });
+ act(() => triggerResizeObservers());
+ }
+
+ it("reaches cut-off text with Tab and shows the full text until focus leaves", async () => {
+ const user = userEvent.setup();
+ renderPanel();
+ const text = screen.getByText("feature/very-long-branch-name");
+ screen.getByRole("button", { name: "Before" }).focus();
+
+ await user.tab();
+ expect(text).toHaveFocus();
+ expect(tooltipPopup()).toHaveTextContent("feature/very-long-branch-name");
+
+ await user.tab();
+ expect(screen.getByRole("button", { name: "After" })).toHaveFocus();
+ await waitFor(() => expect(tooltipPopup()).toBeNull());
+ });
+
+ it("still opens for Tab and Shift+Tab while the pointer rests on the text", async () => {
+ const user = userEvent.setup();
+ renderPanel();
+ const text = screen.getByText("feature/very-long-branch-name");
+ fireEvent.pointerEnter(text, { pointerType: "mouse" });
+ screen.getByRole("button", { name: "Before" }).focus();
+
+ await user.tab();
+ expect(text).toHaveFocus();
+ expect(tooltipPopup()).toHaveTextContent("feature/very-long-branch-name");
+
+ await user.tab();
+ await waitFor(() => expect(tooltipPopup()).toBeNull());
+
+ await user.tab({ shift: true });
+ expect(text).toHaveFocus();
+ expect(tooltipPopup()).toHaveTextContent("feature/very-long-branch-name");
+ });
+
+ it("keeps text that fits out of the tab order", async () => {
+ const user = userEvent.setup();
+ renderPanel();
+ expect(screen.getByText("main")).not.toHaveAttribute("tabindex");
+
+ screen.getByRole("button", { name: "Before" }).focus();
+ await user.tab();
+ await user.tab();
+ expect(screen.getByRole("button", { name: "After" })).toHaveFocus();
+ });
+
+ it("joins the tab order once a resize cuts the text off, and leaves it when the text fits again", () => {
+ renderPanel();
+ const text = screen.getByText("main");
+ expect(text).not.toHaveAttribute("tabindex");
+
+ setBox(text, { scrollWidth: 30, clientWidth: 20 });
+ act(() => triggerResizeObservers());
+ expect(text).toHaveAttribute("tabindex", "0");
+
+ setBox(text, { scrollWidth: 30, clientWidth: 120 });
+ act(() => triggerResizeObservers());
+ expect(text).not.toHaveAttribute("tabindex");
+ });
+
+ it("keeps the trigger's own ref and classes", () => {
+ let node: HTMLElement | null = null;
+ renderWithTooltips(
+ <TruncatedTooltip content="Name" focusable>
+ <span
+ ref={(el) => {
+ node = el;
+ }}
+ className="truncate rounded-md"
+ >
+ Name
+ </span>
+ </TruncatedTooltip>,
+ );
+ const text = screen.getByText("Name");
+ expect(node).toBe(text);
+ expect(text).toHaveClass("truncate", "rounded-md", "focus-visible:ring-3");
+ expect(text).not.toHaveClass("rounded-sm");
+ });
+});
+
describe("isContentTruncated", () => {
it("ignores overflow that is not clipped", () => {
const el = document.createElement("div");
diff --git a/packages/ui/components/common/deferred-tooltip.tsx b/packages/ui/components/common/deferred-tooltip.tsx
index 0a7423d0de..f1b1458dc0 100644
--- a/packages/ui/components/common/deferred-tooltip.tsx
+++ b/packages/ui/components/common/deferred-tooltip.tsx
@@ -16,6 +16,21 @@ import {
isTooltipInstantPhase,
} from "@multica/ui/components/ui/tooltip";
+// Counts key presses page-wide, so a focus can tell whether a key moved it.
+let keyPresses = 0;
+let keyListenerInstalled = false;
+function watchKeyPresses() {
+ if (keyListenerInstalled) return;
+ keyListenerInstalled = true;
+ document.addEventListener(
+ "keydown",
+ () => {
+ keyPresses += 1;
+ },
+ true,
+ );
+}
+
/**
* Tooltip whose machinery mounts only on first hover.
*
@@ -49,7 +64,8 @@ export function DeferredTooltip({
* tooltip stays closed when it returns false. */
shouldOpen?: (el: HTMLElement) => boolean;
/** Also open on keyboard focus (and close on blur), gated by the same
- * checks as hover. Focus that follows a pointer press stays closed. */
+ * checks as hover. Focus that follows a pointer press stays closed, and
+ * focus under a hovering pointer leaves the open to the hover delay. */
openOnFocus?: boolean;
contentClassName?: string;
}) {
@@ -59,6 +75,11 @@ export function DeferredTooltip({
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
// Set by a pointer press so the focus it causes is not treated as keyboard focus.
const pointerFocusRef = useRef(false);
+ // Menus move focus to the item under the pointer. Focus that arrives while
+ // hovering with no key pressed since the pointer entered waits for the
+ // hover delay; a Tab under a resting pointer still opens at once.
+ const hoveringRef = useRef(false);
+ const keyPressesAtHoverRef = useRef(0);
const clearTimer = () => {
if (timerRef.current !== null) {
@@ -90,6 +111,9 @@ export function DeferredTooltip({
},
onPointerEnter: (e: React.PointerEvent) => {
(trigger.props.onPointerEnter as ((e: React.PointerEvent) => void) | undefined)?.(e);
+ if (openOnFocus) watchKeyPresses();
+ hoveringRef.current = true;
+ keyPressesAtHoverRef.current = keyPresses;
setWarm(true);
clearTimer();
// Same delay as every other tooltip, and the same instant hand-off: when
@@ -103,6 +127,7 @@ export function DeferredTooltip({
},
onPointerLeave: (e: React.PointerEvent) => {
(trigger.props.onPointerLeave as ((e: React.PointerEvent) => void) | undefined)?.(e);
+ hoveringRef.current = false;
clearTimer();
setOpen(false);
},
@@ -123,7 +148,9 @@ export function DeferredTooltip({
(trigger.props.onFocus as ((e: React.FocusEvent) => void) | undefined)?.(e);
const fromPointer = pointerFocusRef.current;
pointerFocusRef.current = false;
- if (fromPointer) return;
+ const fromHover =
+ hoveringRef.current && keyPresses === keyPressesAtHoverRef.current;
+ if (fromPointer || fromHover) return;
setWarm(true);
clearTimer();
if (canOpen()) setOpen(true);
diff --git a/packages/ui/components/common/truncated-tooltip.tsx b/packages/ui/components/common/truncated-tooltip.tsx
index fdf1f72641..9ea1b5635d 100644
--- a/packages/ui/components/common/truncated-tooltip.tsx
+++ b/packages/ui/components/common/truncated-tooltip.tsx
@@ -1,6 +1,16 @@
"use client";
-import type { ReactElement, ReactNode } from "react";
+import {
+ cloneElement,
+ useEffect,
+ useRef,
+ useState,
+ type ReactElement,
+ type ReactNode,
+ type Ref,
+ type RefObject,
+} from "react";
+import { cn } from "@multica/ui/lib/utils";
import { DeferredTooltip } from "./deferred-tooltip";
/**
@@ -32,6 +42,31 @@ export function isContentTruncated(el: HTMLElement | null): boolean {
return false;
}
+/** Whether `ref`'s content is cut off, re-checked when it resizes or web fonts finish loading. */
+function useIsTruncated(ref: RefObject<HTMLElement | null>, content: ReactNode) {
+ const [truncated, setTruncated] = useState(false);
+ useEffect(() => {
+ const el = ref.current;
+ if (!el) return;
+ let active = true;
+ const check = () => {
+ if (active) setTruncated(isContentTruncated(el));
+ };
+ check();
+ void document.fonts?.ready.then(check);
+ const observer = new ResizeObserver(check);
+ observer.observe(el);
+ return () => {
+ active = false;
+ observer.disconnect();
+ };
+ }, [ref, content]);
+ return truncated;
+}
+
+type Side = "top" | "bottom" | "left" | "right";
+type TriggerElement = ReactElement<Record<string, unknown>>;
+
/**
* Tooltip that reveals the full text only when the trigger's text is actually
* cut off. Built on `DeferredTooltip` (shared tooltip styling and open delay):
@@ -41,6 +76,10 @@ export function isContentTruncated(el: HTMLElement | null): boolean {
* nothing overflows. Measuring at open time keeps it correct across resizes
* and content changes without observers.
*
+ * Keyboard users reach the full text by focusing the trigger. When the text
+ * sits inside a button, link or other focusable control, wrap that control
+ * instead of the text. When the text stands on its own, pass `focusable`.
+ *
* Use it for tooltips whose content repeats the trigger's own text. Tooltips
* that add information (icon labels, disabled reasons, a URL behind a short
* label) keep using `Tooltip`.
@@ -48,19 +87,44 @@ export function isContentTruncated(el: HTMLElement | null): boolean {
function TruncatedTooltip({
content,
side = "top",
+ focusable = false,
children,
}: {
/** Full text shown when the trigger is truncated. Empty renders the child alone. */
content: ReactNode;
- side?: "top" | "bottom" | "left" | "right";
+ side?: Side;
+ /** Make a trigger that can't take focus on its own (plain text) a tab stop
+ * while it is cut off, with a focus ring. Text that fits stays out of the
+ * tab order. It observes the trigger's size, so leave it off in dense
+ * lists. */
+ focusable?: boolean;
/** The trigger element. Cloned with hover handlers and a ref; its own props
* and element type are preserved, so it must forward both. */
- children: ReactElement<Record<string, unknown>>;
+ children: TriggerElement;
}) {
if (content == null || content === false || content === "") return children;
+ if (focusable) {
+ return (
+ <FocusableWhenTruncated content={content} side={side}>
+ {children}
+ </FocusableWhenTruncated>
+ );
+ }
+ return <TruncationTooltip trigger={children} content={content} side={side} />;
+}
+
+function TruncationTooltip({
+ trigger,
+ content,
+ side,
+}: {
+ trigger: TriggerElement;
+ content: ReactNode;
+ side: Side;
+}) {
return (
<DeferredTooltip
- trigger={children}
+ trigger={trigger}
content={content}
side={side}
shouldOpen={isContentTruncated}
@@ -72,4 +136,32 @@ function TruncatedTooltip({
);
}
+function FocusableWhenTruncated({
+ content,
+ side,
+ children,
+}: {
+ content: ReactNode;
+ side: Side;
+ children: TriggerElement;
+}) {
+ const triggerRef = useRef<HTMLElement | null>(null);
+ const truncated = useIsTruncated(triggerRef, content);
+ const childRef = children.props.ref as Ref<HTMLElement> | undefined;
+ const trigger = cloneElement(children, {
+ ref: (el: HTMLElement | null) => {
+ triggerRef.current = el;
+ if (typeof childRef === "function") childRef(el);
+ else if (childRef) (childRef as { current: HTMLElement | null }).current = el;
+ },
+ tabIndex: truncated ? 0 : children.props.tabIndex,
+ // The trigger's own rounding wins over the ring's default.
+ className: cn(
+ "rounded-sm outline-none focus-visible:ring-3 focus-visible:ring-ring/50",
+ children.props.className as string | undefined,
+ ),
+ });
+ return <TruncationTooltip trigger={trigger} content={content} side={side} />;
+}
+
export { TruncatedTooltip };
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 452dcae0c2..a929006056 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -70,6 +70,7 @@
"@multica/vitest-setup": "workspace:*",
"@testing-library/jest-dom": "catalog:",
"@testing-library/react": "catalog:",
+ "@testing-library/user-event": "catalog:",
"@types/linkify-it": "^5.0.0",
"@types/mdast": "catalog:",
"@types/react": "catalog:",
diff --git a/packages/views/autopilots/components/webhook-deliveries-section.tsx b/packages/views/autopilots/components/webhook-deliveries-section.tsx
index ed8a48ec07..fdced29c6c 100644
--- a/packages/views/autopilots/components/webhook-deliveries-section.tsx
+++ b/packages/views/autopilots/components/webhook-deliveries-section.tsx
@@ -373,7 +373,7 @@ function MetaRow({
return (
<div className="flex flex-col">
<dt className="text-muted-foreground">{label}</dt>
- <TruncatedTooltip content={value}>
+ <TruncatedTooltip content={value} focusable>
<dd
className={cn(
"truncate text-foreground",
diff --git a/packages/views/editor/table-preview.tsx b/packages/views/editor/table-preview.tsx
index f198675a2e..fac7640282 100644
--- a/packages/views/editor/table-preview.tsx
+++ b/packages/views/editor/table-preview.tsx
@@ -245,30 +245,30 @@ export function SortHeader({
}) {
const Icon = sorted === "asc" ? ArrowUp : sorted === "desc" ? ArrowDown : ArrowUpDown;
return (
- <button
- type="button"
- onClick={onToggle}
- className={cn(
- // The table header's spreadsheet casing is for labels the app wrote;
- // these are the file's own column names and show as written.
- "group/sort flex w-full min-w-0 items-center gap-1 rounded-sm normal-case tracking-normal text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
- numeric && "flex-row-reverse",
- )}
- >
- <TruncatedTooltip content={title}>
+ <TruncatedTooltip content={title}>
+ <button
+ type="button"
+ onClick={onToggle}
+ className={cn(
+ // The table header's spreadsheet casing is for labels the app wrote;
+ // these are the file's own column names and show as written.
+ "group/sort flex w-full min-w-0 items-center gap-1 rounded-sm normal-case tracking-normal text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ numeric && "flex-row-reverse",
+ )}
+ >
<span className="truncate font-medium">
{title}
</span>
- </TruncatedTooltip>
- <Icon
- aria-hidden
- className={cn(
- "size-3.5 shrink-0",
- sorted
- ? "text-foreground"
- : "text-muted-foreground opacity-0 transition-opacity group-hover/sort:opacity-100 group-focus-visible/sort:opacity-100",
- )}
- />
- </button>
+ <Icon
+ aria-hidden
+ className={cn(
+ "size-3.5 shrink-0",
+ sorted
+ ? "text-foreground"
+ : "text-muted-foreground opacity-0 transition-opacity group-hover/sort:opacity-100 group-focus-visible/sort:opacity-100",
+ )}
+ />
+ </button>
+ </TruncatedTooltip>
);
}
diff --git a/packages/views/issues/components/inline-comment-run.test.tsx b/packages/views/issues/components/inline-comment-run.test.tsx
index b6bcb13a50..9b67dc41cf 100644
--- a/packages/views/issues/components/inline-comment-run.test.tsx
+++ b/packages/views/issues/components/inline-comment-run.test.tsx
@@ -1,7 +1,7 @@
import { act, cleanup, fireEvent, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { afterEach, describe, expect, it, vi } from "vitest";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { ReactNode } from "react";
import { api } from "@multica/core/api";
import { chatKeys } from "@multica/core/chat/queries";
@@ -460,4 +460,59 @@ describe("InlineCommentRun", () => {
rerender(task({ status: "cancelled", completed_at: "2026-09-07T00:01:23Z" }));
expect(screen.getByText("Cancelled")).toBeInTheDocument();
});
+
+ describe("cut-off status text", () => {
+ // jsdom has no layout or Tailwind: make every `truncate` element report
+ // clipped overflow, as the sr-only status line does while a run is live.
+ const originalComputedStyle = window.getComputedStyle;
+ const descriptors = {
+ scrollWidth: Object.getOwnPropertyDescriptor(Element.prototype, "scrollWidth"),
+ clientWidth: Object.getOwnPropertyDescriptor(Element.prototype, "clientWidth"),
+ };
+ const clipped = (el: Element) => el.classList.contains("truncate");
+ beforeEach(() => {
+ Object.defineProperty(Element.prototype, "scrollWidth", {
+ configurable: true,
+ get(this: Element) { return clipped(this) ? 200 : 0; },
+ });
+ Object.defineProperty(Element.prototype, "clientWidth", {
+ configurable: true,
+ get(this: Element) { return clipped(this) ? 1 : 0; },
+ });
+ vi.spyOn(window, "getComputedStyle").mockImplementation((el, pseudo) => {
+ const style = originalComputedStyle(el, pseudo);
+ if (!clipped(el)) return style;
+ return { overflowX: "hidden", overflowY: "hidden" } as CSSStyleDeclaration;
+ });
+ });
+ afterEach(() => {
+ vi.mocked(window.getComputedStyle).mockRestore();
+ for (const [key, descriptor] of Object.entries(descriptors)) {
+ if (descriptor) Object.defineProperty(Element.prototype, key, descriptor);
+ }
+ });
+
+ it("keeps a live run's hidden status out of the tab order and adds it once the run ends", async () => {
+ vi.mocked(api.listTaskMessages).mockResolvedValue(messages);
+ const user = userEvent.setup();
+ const current = task();
+ const { rerender } = setup(current);
+ await screen.findByText("pnpm test");
+ const status = () => document.querySelector("[data-run-status] .truncate")!;
+ expect(status()).not.toHaveAttribute("tabindex");
+
+ await user.tab();
+ expect(screen.getByRole("button", { name: /View activity/ })).toHaveFocus();
+
+ rerender({ ...current, status: "completed", completed_at: "2026-09-07T00:01:23Z" }, true);
+ await screen.findByText("Completed");
+ expect(status()).toHaveAttribute("tabindex", "0");
+
+ (document.activeElement as HTMLElement).blur();
+ await user.tab();
+ expect(status()).toHaveFocus();
+ await user.tab();
+ expect(screen.getByRole("button", { name: /View activity/ })).toHaveFocus();
+ });
+ });
});
diff --git a/packages/views/issues/components/inline-comment-run.tsx b/packages/views/issues/components/inline-comment-run.tsx
index 03ef2dc288..1a650225fb 100644
--- a/packages/views/issues/components/inline-comment-run.tsx
+++ b/packages/views/issues/components/inline-comment-run.tsx
@@ -181,7 +181,7 @@ export function InlineCommentRun({ run, className, viewState, showIdentity = fal
<div ref={animationVisibility.ref} className="flex min-h-7 min-w-0 items-center gap-2" data-run-summary-row>
{showIdentity && <>
<ActorAvatar actorType="agent" actorId={task.agent_id} size="md" enableHoverCard showStatusDot />
- <TruncatedTooltip content={name}>
+ <TruncatedTooltip content={name} focusable>
<span className="max-w-[30%] shrink-0 truncate text-body font-medium">{name}</span>
</TruncatedTooltip>
{!active && task.completed_at && <Tooltip>
@@ -202,7 +202,7 @@ export function InlineCommentRun({ run, className, viewState, showIdentity = fal
<span>{statusText}</span>
<span className="break-all font-mono text-muted-foreground">{rawError}</span>
</TooltipContent>
- </Tooltip> : <TruncatedTooltip content={statusText}>
+ </Tooltip> : <TruncatedTooltip content={statusText} focusable={!showProgress}>
<span className="truncate">{statusText}</span>
</TruncatedTooltip>}
</span>
@@ -234,7 +234,7 @@ export function InlineCommentRun({ run, className, viewState, showIdentity = fal
<div className={cn(showIdentity && "pl-8")}>
{replyTo}
{output && <div className="mt-2 text-body"><ReadonlyContent content={redactSecrets(output)} /></div>}
- {needsAction && rawError && <TruncatedTooltip content={rawError}>
+ {needsAction && rawError && <TruncatedTooltip content={rawError} focusable>
<p
className="mt-1.5 line-clamp-4 whitespace-pre-wrap break-words rounded-md border bg-muted/50 px-2.5 py-1.5 font-mono text-caption text-muted-foreground">
{rawError}
@@ -349,17 +349,17 @@ function InlineStep({ row, live, formatText }: { row: TraceRow; live: boolean; f
: row.kind === "thinking" ? thinkingPreview(row.item.content, formatText) || t(($) => $.inline_run.thinking)
: t(($) => $.inline_run.error);
return <details className="min-w-0 text-caption" onToggle={onToggle}>
- <summary onClick={disclosure.onTrigger} className="flex cursor-pointer list-none items-center gap-2 rounded-xs py-1.5 hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden">
- {pending ? <Loader2 aria-hidden className="size-3.5 shrink-0 animate-spin text-info motion-reduce:animate-none" />
- : <Icon aria-hidden className={cn("size-3.5 shrink-0", error ? "text-destructive" : "text-muted-foreground")} />}
- <TruncatedTooltip content={summary}>
+ <TruncatedTooltip content={summary}>
+ <summary onClick={disclosure.onTrigger} className="flex cursor-pointer list-none items-center gap-2 rounded-xs py-1.5 hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden">
+ {pending ? <Loader2 aria-hidden className="size-3.5 shrink-0 animate-spin text-info motion-reduce:animate-none" />
+ : <Icon aria-hidden className={cn("size-3.5 shrink-0", error ? "text-destructive" : "text-muted-foreground")} />}
<span className={cn("min-w-0 flex-1 truncate", error && "text-destructive")}>{summary}</span>
- </TruncatedTooltip>
- {(grouped || call) && <span className="shrink-0 text-micro text-muted-foreground">
- {grouped ? t(($) => $.inline_run.steps, { count: row.steps.length }) : row.tool}
- </span>}
- <ChevronRight ref={disclosure.chevronRef} aria-hidden className={cn("size-3 shrink-0 text-muted-foreground", open && "rotate-90")} />
- </summary>
+ {(grouped || call) && <span className="shrink-0 text-micro text-muted-foreground">
+ {grouped ? t(($) => $.inline_run.steps, { count: row.steps.length }) : row.tool}
+ </span>}
+ <ChevronRight ref={disclosure.chevronRef} aria-hidden className={cn("size-3 shrink-0 text-muted-foreground", open && "rotate-90")} />
+ </summary>
+ </TruncatedTooltip>
{open && <div className="min-w-0 space-y-2 overflow-hidden pl-5.5">
{grouped ? <>
{row.steps.length > limit && <button type="button" className="py-1 text-muted-foreground" onClick={() => setLimit((value) => value + 12)}>
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index 9f6230e12a..dac58cf695 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -2964,21 +2964,20 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
<>
<div className="my-1 h-px bg-border" />
{addable.map((p) => (
- <button
- key={p.id}
- type="button"
- onClick={() => addCustomProp(p.id)}
- className="flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-caption text-foreground transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none"
- >
- {p.icon ? (
- <PropertyIcon property={p} className="size-3.5 text-caption" />
- ) : (
- <SlidersHorizontal className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
- )}
- <TruncatedTooltip content={p.name}>
+ <TruncatedTooltip key={p.id} content={p.name}>
+ <button
+ type="button"
+ onClick={() => addCustomProp(p.id)}
+ className="flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-caption text-foreground transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none"
+ >
+ {p.icon ? (
+ <PropertyIcon property={p} className="size-3.5 text-caption" />
+ ) : (
+ <SlidersHorizontal className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ )}
<span className="line-clamp-2 min-w-0 break-words [overflow-wrap:anywhere]">{p.name}</span>
- </TruncatedTooltip>
- </button>
+ </button>
+ </TruncatedTooltip>
))}
</>
);
@@ -3086,7 +3085,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
label={
<>
<PropertyIcon property={p} className="size-3.5 text-caption" />
- <TruncatedTooltip content={p.name}>
+ <TruncatedTooltip content={p.name} focusable>
<span className="line-clamp-2 min-w-0 break-words [overflow-wrap:anywhere]">{p.name}</span>
</TruncatedTooltip>
</>
diff --git a/packages/views/issues/components/issue-runs-dialog.tsx b/packages/views/issues/components/issue-runs-dialog.tsx
index 6396d62633..8561a6f9aa 100644
--- a/packages/views/issues/components/issue-runs-dialog.tsx
+++ b/packages/views/issues/components/issue-runs-dialog.tsx
@@ -1102,7 +1102,7 @@ function RunDetails({ id, run, reason }: { id: string; run: TimelineRun; reason:
{run.task.branch_name && (
<>
<dt className="text-muted-foreground">{t(($) => $.runs_timeline.detail_branch)}</dt>
- <TruncatedTooltip content={run.task.branch_name}>
+ <TruncatedTooltip content={run.task.branch_name} focusable>
<dd className="min-w-0 truncate font-mono text-micro">
{run.task.branch_name}
</dd>
diff --git a/packages/views/issues/components/system-wakeup-row.tsx b/packages/views/issues/components/system-wakeup-row.tsx
index 1462f27631..c165f5d3fe 100644
--- a/packages/views/issues/components/system-wakeup-row.tsx
+++ b/packages/views/issues/components/system-wakeup-row.tsx
@@ -185,7 +185,7 @@ function InstructionEditor({
) : (
<div className="text-caption text-muted-foreground">
<p>{t(($) => $.wakeups.system.instruction_default)}</p>
- <TruncatedTooltip content={rule.default_instruction}>
+ <TruncatedTooltip content={rule.default_instruction} focusable>
<p className="mt-1 line-clamp-4 whitespace-pre-wrap break-words">
{rule.default_instruction}
</p>
diff --git a/packages/views/layout/object-page.tsx b/packages/views/layout/object-page.tsx
index ff24e0ea03..5855af6b6e 100644
--- a/packages/views/layout/object-page.tsx
+++ b/packages/views/layout/object-page.tsx
@@ -8,13 +8,12 @@ import {
type ComponentProps,
type ReactNode,
type Ref,
- type RefObject,
} from "react";
import { useDefaultLayout, usePanelRef } from "react-resizable-panels";
import { ChevronRight, PanelRight, type IconComponent } from "@multica/ui/icons";
import { Button } from "@multica/ui/components/ui/button";
import { IconButton } from "@multica/ui/components/common/icon-button";
-import { isContentTruncated, TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";
+import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";
import {
ResizableHandle,
ResizablePanel,
@@ -362,44 +361,12 @@ export function ObjectPanelSection({
);
}
-/** Whether `ref`'s content is cut off, re-checked when it resizes or web fonts finish loading. */
-function useIsTruncated(ref: RefObject<HTMLElement | null>, content: ReactNode) {
- const [truncated, setTruncated] = useState(false);
- useEffect(() => {
- const el = ref.current;
- if (!el) return;
- let active = true;
- const check = () => {
- if (active) setTruncated(isContentTruncated(el));
- };
- check();
- void document.fonts?.ready.then(check);
- const observer = new ResizeObserver(check);
- observer.observe(el);
- return () => {
- active = false;
- observer.disconnect();
- };
- }, [ref, content]);
- return truncated;
-}
-
/** One label and value in the properties panel; the value may be a picker. */
export function ObjectProperty({ label, children }: { label: ReactNode; children: ReactNode }) {
- const labelRef = useRef<HTMLSpanElement>(null);
- // A cut-off label takes keyboard focus so its tooltip can show the full text;
- // a label that fits stays out of the tab order.
- const truncated = useIsTruncated(labelRef, label);
return (
<div className="-mx-2 flex min-h-8 items-center gap-2 rounded-md px-2 transition-colors hover:bg-accent/50">
- <TruncatedTooltip content={label}>
- <span
- ref={labelRef}
- tabIndex={truncated ? 0 : undefined}
- className="w-20 shrink-0 truncate rounded-sm text-caption text-muted-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
- >
- {label}
- </span>
+ <TruncatedTooltip content={label} focusable>
+ <span className="w-20 shrink-0 truncate text-caption text-muted-foreground">{label}</span>
</TruncatedTooltip>
<div className="flex min-w-0 flex-1 items-center gap-1.5 truncate text-caption">{children}</div>
</div>
diff --git a/packages/views/runtimes/components/runtime-detail.tsx b/packages/views/runtimes/components/runtime-detail.tsx
index 13d8ecd5b1..679aa705fb 100644
--- a/packages/views/runtimes/components/runtime-detail.tsx
+++ b/packages/views/runtimes/components/runtime-detail.tsx
@@ -358,8 +358,9 @@ function RuntimeProperties({
</ObjectProperty>
<ObjectProperty label={t(($) => $.detail.fact_device)}>
{device?.hostname ? (
- <TruncatedTooltip content={device.hostname}>
- <span className="block truncate font-mono">{device.hostname}</span>
+ <TruncatedTooltip content={device.hostname} focusable>
+ {/* The value column clips, so the focus ring draws inside. */}
+ <span className="block truncate font-mono focus-visible:ring-2 focus-visible:ring-inset">{device.hostname}</span>
</TruncatedTooltip>
) : (
<span className="text-muted-foreground">—</span>
diff --git a/packages/views/settings/components/members-tab.tsx b/packages/views/settings/components/members-tab.tsx
index 81525ac780..05ddc93c7c 100644
--- a/packages/views/settings/components/members-tab.tsx
+++ b/packages/views/settings/components/members-tab.tsx
@@ -379,7 +379,7 @@ function ShareLinkRow({
<span>{t(($) => $.members.share_link_uses, { used: link.use_count, max: link.max_uses ?? "∞" })}</span>
{link.expires_at && <span>· {t(($) => $.members.share_link_expires, { date: new Date(link.expires_at).toLocaleDateString(locale) })}</span>}
</div>
- <TruncatedTooltip content={joinUrl}>
+ <TruncatedTooltip content={joinUrl} focusable>
<div
className="truncate font-mono text-caption text-muted-foreground"
>
diff --git a/packages/views/settings/components/repositories-section.tsx b/packages/views/settings/components/repositories-section.tsx
index fc81db4cc9..634c695784 100644
--- a/packages/views/settings/components/repositories-section.tsx
+++ b/packages/views/settings/components/repositories-section.tsx
@@ -453,7 +453,7 @@ export function RepositoriesSection() {
)}
</span>
<div className="min-w-0 flex-1">
- <TruncatedTooltip content={repository.url}>
+ <TruncatedTooltip content={repository.url} focusable>
<p className="truncate font-mono text-label">
{repository.url}
</p>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0b412b98bc..a3cdac6cf8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -937,6 +937,9 @@ importers:
'@testing-library/react':
specifier: 'catalog:'
+ '@testing-library/user-event':
+ specifier: 'catalog:'
+ version: 14.6.1(@testing-library/[email protected])
'@types/linkify-it':
specifier: ^5.0.0
version: 5.0.0