feat(lint): ban native title tooltips and migrate to styled Tooltip (#7209)

This commit is contained in:
Utkarsh Patil authored and GitHub committed 2026-08-16 21:05:18 +02:00
1 parent bab4b6f02b
commit fee10def1a
27 files changed
+730 -355

No files matched your search

+29 -20
View File
@@ -12,6 +12,7 @@ import { useState } from "react";
import { Button } from "~/components/ui/button";
import { Input } from "~/components/ui/input";
import { Tooltip, TooltipPopup, TooltipTrigger } from "~/components/ui/tooltip";
import {
Select,
SelectGroup,
@@ -296,26 +297,34 @@ export function BrowserDeviceToolbar({
/>
</form>
<Button
variant="ghost"
size="icon-xs"
type="button"
aria-label={
aspectRatio === null ? "Lock viewport aspect ratio" : "Unlock viewport aspect ratio"
}
aria-pressed={aspectRatio !== null}
title={aspectRatio === null ? "Lock aspect ratio" : "Unlock aspect ratio"}
className={cn(aspectRatio !== null && "bg-accent text-foreground")}
disabled={pending || !customValid}
onPointerDown={(event) => event.preventDefault()}
onClick={toggleAspectRatio}
>
{aspectRatio === null ? (
<Unlink2 className={cn(aspectRatio !== null && "text-foreground")} />
) : (
<Link2 className={cn(aspectRatio !== null && "text-foreground")} />
)}
</Button>
<Tooltip>
<TooltipTrigger
render={
<Button
variant="ghost"
size="icon-xs"
type="button"
aria-label={
aspectRatio === null ? "Lock viewport aspect ratio" : "Unlock viewport aspect ratio"
}
aria-pressed={aspectRatio !== null}
className={cn(aspectRatio !== null && "bg-accent text-foreground")}
disabled={pending || !customValid}
onPointerDown={(event) => event.preventDefault()}
onClick={toggleAspectRatio}
/>
}
>
{aspectRatio === null ? (
<Unlink2 className={cn(aspectRatio !== null && "text-foreground")} />
) : (
<Link2 className={cn(aspectRatio !== null && "text-foreground")} />
)}
</TooltipTrigger>
<TooltipPopup side="top">
{aspectRatio === null ? "Lock aspect ratio" : "Unlock aspect ratio"}
</TooltipPopup>
</Tooltip>
<Button
variant="ghost"
size="icon-xs"
-1
View File
@@ -6348,7 +6348,6 @@ function ChatViewContent(props: ChatViewProps) {
>
<Button
aria-label="Scroll to end"
title="Scroll to end"
onClick={() => scrollToEnd(true)}
className="pointer-events-auto gap-1.5 rounded-full px-3 text-muted-foreground hover:text-foreground"
size="xs"
@@ -59,7 +59,6 @@ export function ConnectionStatusDot({
const dot = (
<button
type="button"
title={tooltipText}
aria-label={tooltipText}
className="relative flex size-3 shrink-0 cursor-help items-center justify-center rounded-full outline-hidden"
>
+25 -9
View File
@@ -583,11 +583,19 @@ export default function DiffPanel({
{selectedTurnId === null && selectedGitScope === "branch" && selectedGitSource?.baseRef && (
<div
className="flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground"
title={`${selectedGitSource.headRef ?? "HEAD"} → ${selectedGitSource.baseRef}`}
aria-label={`Comparing ${selectedGitSource.headRef ?? "HEAD"} against ${selectedGitSource.baseRef}`}
>
<span className="min-w-0 max-w-48 truncate">{selectedGitSource.headRef ?? "HEAD"}</span>
<ArrowRightIcon className="size-3.5 shrink-0 opacity-70" />
<Tooltip>
<TooltipTrigger render={<span className="flex min-w-0 items-center gap-2" />}>
<span className="min-w-0 max-w-48 truncate">
{selectedGitSource.headRef ?? "HEAD"}
</span>
<ArrowRightIcon className="size-3.5 shrink-0 opacity-70" />
</TooltipTrigger>
<TooltipPopup side="top">
{`${selectedGitSource.headRef ?? "HEAD"} → ${selectedGitSource.baseRef}`}
</TooltipPopup>
</Tooltip>
<Combobox
items={baseRefItems}
filteredItems={filteredBaseRefItems}
@@ -677,12 +685,20 @@ export default function DiffPanel({
/>
</div>
) : choice.remote ? (
<span
className="flex justify-end text-muted-foreground"
title="Remote only"
>
<CheckIcon aria-hidden="true" className="size-3" />
</span>
<Tooltip>
<TooltipTrigger
render={
<span className="flex justify-end text-muted-foreground">
<CheckIcon
role="img"
aria-label="Remote only"
className="size-3"
/>
</span>
}
/>
<TooltipPopup side="top">Remote only</TooltipPopup>
</Tooltip>
) : null}
</div>
</ComboboxItem>
@@ -11,6 +11,7 @@ import { useAtomCommand } from "~/state/use-atom-command";
import { manualServerUpdateCommand } from "~/versionSkew";
import { Button } from "./ui/button";
import { toastManager } from "./ui/toast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
// The wire "installing" stage is a sub-second launcher handoff, so the UI
// folds it into the download phase; everything after the handoff is the
@@ -45,9 +46,12 @@ export function ServerUpdateProgress({
return (
<div className="mt-1 flex min-w-0 items-center gap-2 text-xs text-destructive" role="alert">
<span className="size-1.5 shrink-0 rounded-full bg-destructive" aria-hidden="true" />
<span className="min-w-0 truncate" title={state.message}>
{state.message}
</span>
<Tooltip>
<TooltipTrigger render={<span className="min-w-0 truncate">{state.message}</span>} />
<TooltipPopup side="top" className="max-w-80">
{state.message}
</TooltipPopup>
</Tooltip>
</div>
);
}
+50 -32
View File
@@ -537,15 +537,21 @@ const SidebarDraftRow = memo(function SidebarDraftRow(props: {
{props.projectTitle}
</span>
<span className="ml-auto flex h-5 min-w-5 shrink-0 items-center justify-end">
<button
type="button"
aria-label="Discard draft"
title="Discard draft"
onClick={handleDiscard}
className="pointer-events-none inline-flex cursor-pointer items-center rounded-md bg-transparent px-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/sidebar-row:pointer-events-auto group-hover/sidebar-row:opacity-100"
>
<XIcon className="size-3" />
</button>
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
aria-label="Discard draft"
onClick={handleDiscard}
className="pointer-events-none inline-flex cursor-pointer items-center rounded-md bg-transparent px-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/sidebar-row:pointer-events-auto group-hover/sidebar-row:opacity-100"
>
<XIcon className="size-3" />
</button>
}
/>
<TooltipPopup side="top">Discard draft</TooltipPopup>
</Tooltip>
</span>
</div>
<div className="mt-0.5 truncate text-sm font-medium text-foreground/90">{preview}</div>
@@ -1247,16 +1253,22 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
) : isWoke ? (
// A wake can land straight in the settled tail (e.g. PR
// merged while snoozed); the signal must survive the trip.
<button
type="button"
aria-label="Dismiss Woke notification"
title="Dismiss Woke notification"
onClick={handleAcknowledgeWokeClick}
className="inline-flex cursor-pointer items-center gap-1 rounded-sm text-xs font-medium text-amber-700 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring dark:text-amber-300"
>
<AlarmClockIcon aria-hidden className="size-3" />
<span role="status">Woke</span>
</button>
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
aria-label="Dismiss Woke notification"
onClick={handleAcknowledgeWokeClick}
className="inline-flex cursor-pointer items-center gap-1 rounded-sm text-xs font-medium text-amber-700 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring dark:text-amber-300"
>
<AlarmClockIcon aria-hidden className="size-3" />
<span role="status">Woke</span>
</button>
}
/>
<TooltipPopup side="top">Dismiss Woke notification</TooltipPopup>
</Tooltip>
) : (
<span className="text-xs">
{variantAction === "unsettle"
@@ -1414,19 +1426,25 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
>
{topStatus ? (
isWokeStatus ? (
<button
type="button"
aria-label="Dismiss Woke notification"
title="Dismiss Woke notification"
onClick={handleAcknowledgeWokeClick}
className={cn(
"inline-flex cursor-pointer items-center gap-1 rounded-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",
topStatus.className,
)}
>
<AlarmClockIcon aria-hidden className="size-4 shrink-0" />
<span role="status">{topStatus.label}</span>
</button>
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
aria-label="Dismiss Woke notification"
onClick={handleAcknowledgeWokeClick}
className={cn(
"inline-flex cursor-pointer items-center gap-1 rounded-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",
topStatus.className,
)}
>
<AlarmClockIcon aria-hidden className="size-4 shrink-0" />
<span role="status">{topStatus.label}</span>
</button>
}
/>
<TooltipPopup side="top">Dismiss Woke notification</TooltipPopup>
</Tooltip>
) : (
<span
className={cn(
@@ -174,21 +174,26 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
</p>
<div className="mt-2 flex flex-wrap items-center gap-1.5">
{previewFiles.map((file) => (
<button
key={file.path}
type="button"
title={file.path}
className="inline-flex max-w-48 items-center gap-1 rounded-md border border-border/70 bg-background/45 px-1.5 py-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
onClick={() => onOpenTurnDiff(turnId, file.path)}
>
<PierreEntryIcon
pathValue={file.path}
kind="file"
theme={resolvedTheme}
className="size-3 shrink-0 text-muted-foreground/70"
/>
<span className="truncate">{changedFileName(file.path)}</span>
</button>
<Tooltip key={file.path}>
<TooltipTrigger
render={
<button
type="button"
className="inline-flex max-w-48 items-center gap-1 rounded-md border border-border/70 bg-background/45 px-1.5 py-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
onClick={() => onOpenTurnDiff(turnId, file.path)}
/>
}
>
<PierreEntryIcon
pathValue={file.path}
kind="file"
theme={resolvedTheme}
className="size-3 shrink-0 text-muted-foreground/70"
/>
<span className="truncate">{changedFileName(file.path)}</span>
</TooltipTrigger>
<TooltipPopup side="top">{file.path}</TooltipPopup>
</Tooltip>
))}
<button
type="button"
@@ -37,8 +37,9 @@ describe("ComposerPreviewAnnotationCards", () => {
);
expect(markup).toContain("Make this headline feel intentional.");
expect(markup).toContain('title="1 region"');
expect(markup).toContain('title="1 style change"');
expect(markup.match(/data-slot="tooltip-trigger"/g)).toHaveLength(2);
expect(markup).not.toContain('title="1 region"');
expect(markup).not.toContain('title="1 style change"');
expect(markup).not.toContain("Welcome");
expect(markup).not.toContain("localhost:3000");
expect(markup).not.toContain("Preview annotation");
@@ -6,6 +6,7 @@ import type { ComposerImageAttachment } from "~/composerDraftStore";
import { formatElementContextLabel, normalizeElementContextSelection } from "~/lib/elementContext";
import { cn } from "~/lib/utils";
import { Button } from "../ui/button";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
interface ComposerPreviewAnnotationCardsProps {
annotations: ReadonlyArray<PreviewAnnotationPayload>;
@@ -16,14 +17,19 @@ interface ComposerPreviewAnnotationCardsProps {
}
function TargetStat(props: { icon: ReactNode; count: number; label: string }) {
const tooltipText = `${props.count} ${props.label}${props.count === 1 ? "" : "s"}`;
return (
<span
className="inline-flex items-center gap-1 text-[10px] font-medium text-muted-foreground"
title={`${props.count} ${props.label}${props.count === 1 ? "" : "s"}`}
>
{props.icon}
{props.count}
</span>
<Tooltip>
<TooltipTrigger
render={
<span className="inline-flex items-center gap-1 text-[10px] font-medium text-muted-foreground">
{props.icon}
{props.count}
</span>
}
/>
<TooltipPopup side="top">{tooltipText}</TooltipPopup>
</Tooltip>
);
}
@@ -23,6 +23,7 @@ import {
MenuSeparator,
MenuTrigger,
} from "../ui/menu";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
interface DraftHeroHeadlineProps {
readonly activeProjectRef: ScopedProjectRef | null;
@@ -99,13 +100,23 @@ export function DraftHeroHeadline({
const projectSelector = shouldShowProjectMenu ? (
<Menu>
<MenuTrigger
aria-label={hasResolvedProject ? "Change project" : "Choose a project"}
className="pointer-events-auto inline-block max-w-64 truncate border-foreground/60 border-b border-dotted align-baseline text-foreground transition-colors hover:border-foreground/80 focus-visible:rounded-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
title={activeProjectDisplayName ?? undefined}
>
{activeProjectDisplayName ?? "Choose a project"}
</MenuTrigger>
<Tooltip>
<TooltipTrigger
render={
<MenuTrigger
aria-label={hasResolvedProject ? "Change project" : "Choose a project"}
className="pointer-events-auto inline-block max-w-64 truncate border-foreground/60 border-b border-dotted align-baseline text-foreground transition-colors hover:border-foreground/80 focus-visible:rounded-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
/>
}
>
{activeProjectDisplayName ?? "Choose a project"}
</TooltipTrigger>
{activeProjectDisplayName ? (
<TooltipPopup side="top" className="max-w-80">
{activeProjectDisplayName}
</TooltipPopup>
) : null}
</Tooltip>
<MenuPopup align="center" className="max-h-80 min-w-40! w-max max-w-64 overflow-y-auto">
<MenuRadioGroup
value={activeProjectKey}
@@ -126,9 +137,14 @@ export function DraftHeroHeadline({
{projectPickerEntries.map(({ group }) => {
return (
<MenuRadioItem key={group.projectKey} value={group.projectKey} closeOnClick>
<span className="block min-w-0 truncate" title={group.displayName}>
{group.displayName}
</span>
<Tooltip>
<TooltipTrigger render={<span className="block min-w-0 truncate" />}>
{group.displayName}
</TooltipTrigger>
<TooltipPopup side="top" className="max-w-80">
{group.displayName}
</TooltipPopup>
</Tooltip>
</MenuRadioItem>
);
})}
@@ -880,17 +880,25 @@ export default function FilePreviewPanel({
{index > 0 ? (
<ChevronRight className="mx-1 size-3.5 shrink-0 text-muted-foreground/60" />
) : null}
<span
className={cn(
"max-w-40 truncate",
crumb.kind === "file"
? "font-medium text-foreground"
: "text-muted-foreground",
)}
title={crumb.path || projectName}
>
{crumb.label}
</span>
<Tooltip>
<TooltipTrigger
render={
<span
className={cn(
"max-w-40 truncate",
crumb.kind === "file"
? "font-medium text-foreground"
: "text-muted-foreground",
)}
/>
}
>
{crumb.label}
</TooltipTrigger>
<TooltipPopup side="top" className="max-w-80">
{crumb.path || projectName}
</TooltipPopup>
</Tooltip>
</div>
))}
</div>
@@ -8,6 +8,7 @@ import { BrowserSurfaceSlot } from "~/browser/BrowserSurfaceSlot";
import { previewRuntimeTabId } from "~/browser/previewRuntimeTabId";
import { Button } from "~/components/ui/button";
import { toastManager } from "~/components/ui/toast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "~/components/ui/tooltip";
import { useThreadPreviewState } from "~/previewStateStore";
import { selectThreadPreviewMiniPlayer, usePreviewMiniPlayerStore } from "~/previewMiniPlayerStore";
import { useRightPanelStore } from "~/rightPanelStore";
@@ -254,45 +255,63 @@ export function ThreadPreviewMiniPlayer({ threadRef, tabId, bottomInset }: Props
onPointerUp={endDrag}
onPointerCancel={endDrag}
>
<Button
variant="ghost"
size="icon-xs"
aria-label="Open preview in right panel"
title="Open in right panel"
onPointerDown={(event) => event.stopPropagation()}
onClick={openInPanel}
>
<PanelRightIcon />
</Button>
<Button
variant={desktopOverlay?.pictureInPicture ? "secondary" : "ghost"}
size="icon-xs"
aria-label={
desktopOverlay?.pictureInPicture
? "Close popped-out preview"
: "Pop preview into separate window"
}
title={
desktopOverlay?.pictureInPicture
<Tooltip>
<TooltipTrigger
render={
<Button
variant="ghost"
size="icon-xs"
aria-label="Open preview in right panel"
onPointerDown={(event) => event.stopPropagation()}
onClick={openInPanel}
/>
}
>
<PanelRightIcon />
</TooltipTrigger>
<TooltipPopup side="top">Open in right panel</TooltipPopup>
</Tooltip>
<Tooltip>
<TooltipTrigger
render={
<Button
variant={desktopOverlay?.pictureInPicture ? "secondary" : "ghost"}
size="icon-xs"
aria-label={
desktopOverlay?.pictureInPicture
? "Close popped-out preview"
: "Pop preview into separate window"
}
disabled={!desktopOverlay?.hasWebContents}
onPointerDown={(event) => event.stopPropagation()}
onClick={toggleNativePictureInPicture}
/>
}
>
<PictureInPicture2 />
</TooltipTrigger>
<TooltipPopup side="top">
{desktopOverlay?.pictureInPicture
? "Close separate window"
: "Pop into separate window"
}
disabled={!desktopOverlay?.hasWebContents}
onPointerDown={(event) => event.stopPropagation()}
onClick={toggleNativePictureInPicture}
>
<PictureInPicture2 />
</Button>
<Button
variant="ghost"
size="icon-xs"
aria-label="Close floating preview"
title="Close floating preview"
onPointerDown={(event) => event.stopPropagation()}
onClick={close}
>
<XIcon />
</Button>
: "Pop into separate window"}
</TooltipPopup>
</Tooltip>
<Tooltip>
<TooltipTrigger
render={
<Button
variant="ghost"
size="icon-xs"
aria-label="Close floating preview"
onPointerDown={(event) => event.stopPropagation()}
onClick={close}
/>
}
>
<XIcon />
</TooltipTrigger>
<TooltipPopup side="top">Close floating preview</TooltipPopup>
</Tooltip>
</div>
</div>
@@ -319,7 +338,6 @@ export function ThreadPreviewMiniPlayer({ threadRef, tabId, bottomInset }: Props
<button
type="button"
aria-label="Resize floating preview"
title="Resize floating preview"
className="pointer-events-auto absolute bottom-0 right-0 z-[33] size-5 cursor-nwse-resize rounded-br-xl after:absolute after:bottom-1 after:right-1 after:size-2 after:border-b after:border-r after:border-foreground/45"
onPointerDown={handleResizePointerDown}
onPointerMove={handleResizePointerMove}
@@ -11,6 +11,7 @@ import { pullRequestEnvironment } from "~/state/pullRequests";
import { useEnvironmentQuery } from "~/state/query";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import {
PullRequestCheckStatusIcon,
pullRequestCheckStatusLabel,
@@ -57,9 +58,12 @@ function ChecksBody({ checks }: { checks: ReadonlyArray<PullRequestCheck> }) {
{checks.map((check, index) => (
<li key={`${index}:${check.name}`} className="flex items-center gap-2 text-xs">
<PullRequestCheckStatusIcon status={check.status} />
<span className="min-w-0 flex-1 truncate" title={check.description ?? check.name}>
{check.name}
</span>
<Tooltip>
<TooltipTrigger
render={<span className="min-w-0 flex-1 truncate">{check.name}</span>}
/>
<TooltipPopup side="top">{check.description ?? check.name}</TooltipPopup>
</Tooltip>
<span className="shrink-0 text-muted-foreground">
{pullRequestCheckStatusLabel(check.status)}
</span>
@@ -1006,9 +1006,12 @@ export function PullRequestCodeTab({
>
{/* Headlines run long, and the abbreviated oid after one is what a reader
matches against the commit list on the host. */}
<span className="min-w-0 truncate" title={entry.messageHeadline}>
{entry.messageHeadline}
</span>
<Tooltip>
<TooltipTrigger
render={<span className="min-w-0 truncate">{entry.messageHeadline}</span>}
/>
<TooltipPopup side="top">{entry.messageHeadline}</TooltipPopup>
</Tooltip>
<span className="ml-auto shrink-0 font-mono text-xs text-muted-foreground">
{entry.oid.slice(0, 7)}
</span>
@@ -1264,9 +1267,14 @@ export function PullRequestCodeTab({
<div className="max-h-64 space-y-3 overflow-auto px-4 pb-3">
{[...orphanFiles].map(([path, threads]) => (
<div key={path}>
<p className="truncate px-3 text-xs text-muted-foreground" title={path}>
{path}
</p>
<Tooltip>
<TooltipTrigger
render={
<p className="truncate px-3 text-xs text-muted-foreground">{path}</p>
}
/>
<TooltipPopup side="top">{path}</TooltipPopup>
</Tooltip>
<div className="mt-1 space-y-2">
{threads.map((thread) => (
<div key={thread.id}>
@@ -85,6 +85,7 @@ import {
} from "../ui/menu";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { toastManager } from "../ui/toast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { PullRequestDetailGhost, PullRequestTimelineGhost } from "./PullRequestGhosts";
import { PullRequestActivityUnavailableState } from "./PullRequestActivityUnavailableState";
import { DiffPanelLoadingState } from "../DiffPanelShell";
@@ -1086,22 +1087,31 @@ export function PullRequestDetailPanel({
>
{detail && statePresentation ? (
<>
<span className="min-w-0 truncate" title={detail.repository}>
{detail.repository}
</span>
<button
type="button"
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
onContextMenu={(event) => openNumberContextMenu(event, detail)}
className={cn(
"shrink-0 font-medium underline-offset-2 hover:underline",
statePresentation.toneClassName,
)}
title={openOnHostLabel(detail.provider)}
aria-label={`Open pull request #${detail.number} on host`}
>
#{detail.number}
</button>
<Tooltip>
<TooltipTrigger
render={<span className="min-w-0 truncate">{detail.repository}</span>}
/>
<TooltipPopup side="top">{detail.repository}</TooltipPopup>
</Tooltip>
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
onContextMenu={(event) => openNumberContextMenu(event, detail)}
className={cn(
"shrink-0 font-medium underline-offset-2 hover:underline",
statePresentation.toneClassName,
)}
aria-label={`Open pull request #${detail.number} on host`}
>
#{detail.number}
</button>
}
/>
<TooltipPopup side="top">{openOnHostLabel(detail.provider)}</TooltipPopup>
</Tooltip>
</>
) : null}
</div>
@@ -1117,23 +1127,36 @@ export function PullRequestDetailPanel({
>
{detail && statePresentation ? (
<>
<button
type="button"
tabIndex={condensed ? 0 : -1}
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
onContextMenu={(event) => openNumberContextMenu(event, detail)}
className={cn(
"shrink-0 font-medium underline-offset-2 hover:underline",
statePresentation.toneClassName,
)}
title={openOnHostLabel(detail.provider)}
aria-label={`Open pull request #${detail.number} on host`}
>
#{detail.number}
</button>
<span className="min-w-0 truncate font-medium text-foreground" title={detail.title}>
{detail.title}
</span>
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
tabIndex={condensed ? 0 : -1}
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
onContextMenu={(event) => openNumberContextMenu(event, detail)}
className={cn(
"shrink-0 font-medium underline-offset-2 hover:underline",
statePresentation.toneClassName,
)}
aria-label={`Open pull request #${detail.number} on host`}
>
#{detail.number}
</button>
}
/>
<TooltipPopup side="top">{openOnHostLabel(detail.provider)}</TooltipPopup>
</Tooltip>
<Tooltip>
<TooltipTrigger
render={
<span className="min-w-0 truncate font-medium text-foreground">
{detail.title}
</span>
}
/>
<TooltipPopup side="top">{detail.title}</TooltipPopup>
</Tooltip>
{conflicting ? (
<Badge
variant="error"
@@ -1385,14 +1408,22 @@ export function PullRequestDetailPanel({
{/* Said where the Merge button is, because it is the answer to why nobody has
pressed it: the merge is already asked for, and the host is holding it. */}
{autoMergeArmed ? (
<Badge
variant="info"
className="h-5 shrink-0 gap-1 rounded px-1.5 text-[10px]"
title="The host will merge this on its own once its requirements are met"
>
<GitMergeIcon aria-hidden className="size-3" />
Auto-merge
</Badge>
<Tooltip>
<TooltipTrigger
render={
<Badge
variant="info"
className="h-5 shrink-0 gap-1 rounded px-1.5 text-[10px]"
>
<GitMergeIcon aria-hidden className="size-3" />
Auto-merge
</Badge>
}
/>
<TooltipPopup side="top">
The host will merge this on its own once its requirements are met
</TooltipPopup>
</Tooltip>
) : null}
{primaryAction === "ready" ? (
<Button size="xs" disabled={actionPending} onClick={() => void perform("ready")}>
@@ -1465,11 +1496,13 @@ export function PullRequestDetailPanel({
</button>
))}
</nav>
<span
className="ml-auto inline-flex min-w-0 shrink items-center gap-1 font-mono text-[11px] text-muted-foreground"
title={`${detail.baseBranch} ← ${detail.headBranch}`}
>
<span className="truncate">{detail.baseBranch}</span>
<span className="ml-auto inline-flex min-w-0 shrink items-center gap-1 font-mono text-[11px] text-muted-foreground">
<Tooltip>
<TooltipTrigger render={<span className="truncate" />}>
{detail.baseBranch}
</TooltipTrigger>
<TooltipPopup side="top">{`${detail.baseBranch} ← ${detail.headBranch}`}</TooltipPopup>
</Tooltip>
{freshness ? (
<PullRequestBaseFreshnessWarning
baseBranch={detail.baseBranch}
@@ -1480,7 +1513,12 @@ export function PullRequestDetailPanel({
/>
) : null}
<ArrowLeftIcon aria-label="receives changes from" className="size-3 shrink-0" />
<span className="truncate">{detail.headBranch}</span>
<Tooltip>
<TooltipTrigger render={<span className="truncate" />}>
{detail.headBranch}
</TooltipTrigger>
<TooltipPopup side="top">{`${detail.baseBranch} ← ${detail.headBranch}`}</TooltipPopup>
</Tooltip>
</span>
<span className="ml-2 inline-flex shrink-0 items-center gap-2 text-[11px] text-muted-foreground">
<span className="inline-flex items-center gap-1 tabular-nums">
@@ -1594,12 +1632,16 @@ export function PullRequestDetailPanel({
</PullRequestMetaLine>
<div className="mt-4 flex min-w-0 items-center gap-2 text-xs text-muted-foreground">
<code
className="min-w-0 max-w-48 shrink truncate rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground"
title={detail.baseBranch}
>
{detail.baseBranch}
</code>
<Tooltip>
<TooltipTrigger
render={
<code className="min-w-0 max-w-48 shrink truncate rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground">
{detail.baseBranch}
</code>
}
/>
<TooltipPopup side="top">{detail.baseBranch}</TooltipPopup>
</Tooltip>
{freshness ? (
<PullRequestBaseFreshnessWarning
baseBranch={detail.baseBranch}
@@ -1609,32 +1651,41 @@ export function PullRequestDetailPanel({
/>
) : null}
<ArrowLeftIcon aria-label="receives changes from" className="size-4 shrink-0" />
<button
type="button"
className="grid min-w-0 max-w-64 shrink cursor-pointer rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
aria-label={isBranchCopied ? "Branch name copied" : "Copy pull request branch"}
title={isBranchCopied ? "Copied" : "Copy pull request branch"}
onClick={() => copyBranchToClipboard(detail.headBranch)}
>
<code
className={cn(
"col-start-1 row-start-1 min-w-0 truncate transition-opacity duration-150 motion-reduce:transition-none",
isBranchCopied ? "opacity-0" : "opacity-100",
)}
title={detail.headBranch}
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
className="grid min-w-0 max-w-64 shrink cursor-pointer rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
aria-label={
isBranchCopied ? "Branch name copied" : "Copy pull request branch"
}
onClick={() => copyBranchToClipboard(detail.headBranch)}
/>
}
>
{detail.headBranch}
</code>
<span
aria-hidden="true"
className={cn(
"col-start-1 row-start-1 truncate text-center transition-opacity duration-150 motion-reduce:transition-none",
isBranchCopied ? "opacity-100" : "opacity-0",
)}
>
Copied
</span>
</button>
<code
className={cn(
"col-start-1 row-start-1 min-w-0 truncate transition-opacity duration-150 motion-reduce:transition-none",
isBranchCopied ? "opacity-0" : "opacity-100",
)}
>
{detail.headBranch}
</code>
<span
aria-hidden="true"
className={cn(
"col-start-1 row-start-1 truncate text-center transition-opacity duration-150 motion-reduce:transition-none",
isBranchCopied ? "opacity-100" : "opacity-0",
)}
>
Copied
</span>
</TooltipTrigger>
<TooltipPopup side="top">
{`${isBranchCopied ? "Copied" : "Copy pull request branch"}: ${detail.headBranch}`}
</TooltipPopup>
</Tooltip>
<span className="ml-auto inline-flex shrink-0 items-center justify-end gap-2">
<span className="inline-flex items-center gap-1.5 tabular-nums">
<FileDiffIcon className="size-3.5" />
@@ -35,6 +35,7 @@ import {
MenuSeparator,
MenuTrigger,
} from "../ui/menu";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
export interface PullRequestFilterOption<Value extends string> {
readonly value: Value;
@@ -156,21 +157,32 @@ function PullRequestFilterRadioGroup<Value extends string>({
}}
>
<MenuGroupLabel>{label}</MenuGroupLabel>
{options.map((option) => (
<MenuRadioItem
key={option.value}
value={option.value}
// A host the server has already said it cannot read is not a choice here: offering
// it would answer the press by replacing a working list with that failure.
disabled={option.unavailable !== undefined}
title={option.unavailable}
>
<span className="flex min-w-0 items-center gap-2">
<option.Icon aria-hidden className="size-3.5" />
{option.label}
</span>
</MenuRadioItem>
))}
{options.map((option) => {
// A host the server has already said it cannot read is not a choice here: offering
// it would answer the press by replacing a working list with that failure.
const item = (
<MenuRadioItem
key={option.value}
value={option.value}
className={option.unavailable ? "data-disabled:pointer-events-auto" : undefined}
disabled={option.unavailable !== undefined}
>
<span className="flex min-w-0 items-center gap-2">
<option.Icon aria-hidden className="size-3.5" />
{option.label}
</span>
</MenuRadioItem>
);
if (!option.unavailable) return item;
return (
<Tooltip key={option.value}>
<TooltipTrigger render={item} />
<TooltipPopup side="top" className="max-w-80">
{option.unavailable}
</TooltipPopup>
</Tooltip>
);
})}
</MenuRadioGroup>
);
}
@@ -375,12 +387,12 @@ export function PullRequestFiltersMenu({
)
.map((project) => {
const reason = unavailable.get(pullRequestProjectKey(project));
return (
const item = (
<MenuRadioItem
key={pullRequestProjectKey(project)}
value={pullRequestProjectKey(project)}
className={reason !== undefined ? "data-disabled:pointer-events-auto" : undefined}
disabled={reason !== undefined}
title={reason}
>
<span className="flex min-w-0 flex-1 items-center gap-2">
<ProjectFavicon
@@ -398,6 +410,15 @@ export function PullRequestFiltersMenu({
</span>
</MenuRadioItem>
);
if (reason === undefined) return item;
return (
<Tooltip key={pullRequestProjectKey(project)}>
<TooltipTrigger render={item} />
<TooltipPopup side="top" className="max-w-80">
{reason}
</TooltipPopup>
</Tooltip>
);
})}
</MenuRadioGroup>
</MenuPopup>
@@ -172,9 +172,14 @@ function CollapsedComment({
{open ? (
<div className="px-3 pb-3">
{comment.path ? (
<p className="truncate text-xs text-muted-foreground" title={comment.path}>
{comment.path}
</p>
<Tooltip>
<TooltipTrigger
render={
<p className="truncate text-xs text-muted-foreground">{comment.path}</p>
}
/>
<TooltipPopup side="top">{comment.path}</TooltipPopup>
</Tooltip>
) : null}
<CommentBody className="mt-2" comment={comment} editing={editing} />
{reactionBar}
@@ -475,6 +480,7 @@ export function PullRequestSummaryTab({
>
<PullRequestActorLabel
actor={actor}
tooltip={false}
className="gap-0 [&>img]:ring-2 [&>img]:ring-background [&>span:first-child]:ring-2 [&>span:first-child]:ring-background [&>span:last-child]:sr-only"
/>
</TooltipTrigger>
@@ -754,12 +760,16 @@ export function PullRequestSummaryTab({
) : null}
</div>
{comment.path ? (
<p
className="mt-1 truncate text-xs text-muted-foreground"
title={comment.path}
>
{comment.path}
</p>
<Tooltip>
<TooltipTrigger
render={
<p className="mt-1 truncate text-xs text-muted-foreground">
{comment.path}
</p>
}
/>
<TooltipPopup side="top">{comment.path}</TooltipPopup>
</Tooltip>
) : null}
<CommentBody className="mt-2" comment={comment} editing={commentEditing} />
<PullRequestReactionBar
@@ -226,16 +226,31 @@ export function PullRequestActorAvatar({
export function PullRequestActorLabel({
actor,
className,
tooltip = true,
}: {
actor: PullRequestActor | null;
className?: string;
tooltip?: boolean;
}) {
const login = actor?.login ?? "ghost";
return (
<span className={cn("flex min-w-0 items-center gap-1.5", className)} title={login}>
const label = (
<>
<PullRequestActorAvatar actor={actor} />
<span className="truncate">{login}</span>
</span>
</>
);
if (!tooltip) {
return <span className={cn("flex min-w-0 items-center gap-1.5", className)}>{label}</span>;
}
return (
<Tooltip>
<TooltipTrigger
render={<span className={cn("flex min-w-0 items-center gap-1.5", className)} />}
>
{label}
</TooltipTrigger>
<TooltipPopup side="top">{login}</TooltipPopup>
</Tooltip>
);
}
@@ -12,6 +12,7 @@ import { PierreEntryIcon } from "../chat/PierreEntryIcon";
import { CommandPaletteContent } from "../CommandPaletteContent";
import { ScrollArea } from "../ui/scroll-area";
import { Toggle } from "../ui/toggle";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { HighlightedSearchLine } from "./HighlightedSearchLine";
interface ProjectContentSearchDialogProps {
@@ -59,17 +60,23 @@ function SearchOptionButton(props: {
readonly children: ReactNode;
}) {
return (
<Toggle
aria-label={props.label}
pressed={props.active}
title={props.label}
className="size-8 rounded-[5px] font-mono text-muted-foreground data-pressed:text-foreground sm:size-7"
size="compact"
variant="ghost"
onClick={props.onClick}
>
{props.children}
</Toggle>
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={props.label}
pressed={props.active}
className="size-8 rounded-[5px] font-mono text-muted-foreground data-pressed:text-foreground sm:size-7"
size="compact"
variant="ghost"
onClick={props.onClick}
/>
}
>
{props.children}
</TooltipTrigger>
<TooltipPopup side="top">{props.label}</TooltipPopup>
</Tooltip>
);
}
@@ -692,8 +692,13 @@ const PairingLinkListRow = memo(function PairingLinkListRow({
/>
<h3 className="text-sm font-medium text-foreground">{primaryLabel}</h3>
</div>
<p className="text-xs text-muted-foreground" title={expiresAbsolute}>
{formatExpiresInLabel(pairingLink.expiresAt, nowMs)}
<p className="text-xs text-muted-foreground">
<Tooltip>
<TooltipTrigger render={<span />}>
{formatExpiresInLabel(pairingLink.expiresAt, nowMs)}
</TooltipTrigger>
<TooltipPopup side="top">{expiresAbsolute}</TooltipPopup>
</Tooltip>
<span aria-hidden> · </span>
<AccessScopeSummary scopes={pairingLink.scopes} label="Pairing link scopes" />
</p>
@@ -840,12 +845,18 @@ const PairingLinkListRow = memo(function PairingLinkListRow({
</div>
) : null}
<div className="flex items-center gap-2 rounded-lg border border-border/60 bg-muted/30 px-2.5 py-1.5">
<code
title={qrPairingUrl}
className="min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground"
>
{qrPairingUrl}
</code>
<Tooltip>
<TooltipTrigger
render={
<code className="min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground">
{qrPairingUrl}
</code>
}
/>
<TooltipPopup side="top" className="max-w-80 break-all">
{qrPairingUrl}
</TooltipPopup>
</Tooltip>
<Button
size="xs"
variant="ghost"
@@ -1234,12 +1245,18 @@ const AdvertisedEndpointListRow = memo(function AdvertisedEndpointListRow({
{endpoint.label}
</h3>
{shouldShowEndpointUrl ? (
<p
className="min-w-0 truncate text-xs leading-5 text-muted-foreground"
title={endpoint.httpBaseUrl}
>
{endpoint.httpBaseUrl}
</p>
<Tooltip>
<TooltipTrigger
render={
<p className="min-w-0 truncate text-xs leading-5 text-muted-foreground">
{endpoint.httpBaseUrl}
</p>
}
/>
<TooltipPopup side="top" className="max-w-80">
{endpoint.httpBaseUrl}
</TooltipPopup>
</Tooltip>
) : null}
{!isAvailable ? (
<span className="shrink-0 rounded-md border border-border/70 px-1 py-0.5 text-[10px] text-muted-foreground">
@@ -3313,12 +3330,20 @@ export function ConnectionsSettings() {
) : null}
<div className="rounded-md border border-border/70 bg-muted/20 px-3 py-2">
<p className="text-xs font-medium text-muted-foreground">HTTPS endpoint</p>
<p
className="mt-1 truncate text-sm text-foreground"
title={pendingTailscaleServeBaseUrl ?? undefined}
>
{pendingTailscaleServeBaseUrl ?? "Pending MagicDNS endpoint"}
</p>
<Tooltip>
<TooltipTrigger
render={
<p className="mt-1 truncate text-sm text-foreground">
{pendingTailscaleServeBaseUrl ?? "Pending MagicDNS endpoint"}
</p>
}
/>
{pendingTailscaleServeBaseUrl ? (
<TooltipPopup side="top" className="max-w-80">
{pendingTailscaleServeBaseUrl}
</TooltipPopup>
) : null}
</Tooltip>
</div>
</DialogPanel>
<DialogFooter>
@@ -97,6 +97,7 @@ import {
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { SidebarInset } from "../ui/sidebar";
import { stackedThreadToast, toastManager } from "../ui/toast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import {
WorkspaceBreadcrumb,
WorkspaceBreadcrumbItem,
@@ -937,22 +938,28 @@ function ProjectDetail({ group }: { group: SidebarProjectSnapshot }) {
>
<div className="px-3 py-2 sm:px-4">
<div className="flex min-w-0 items-center rounded-lg bg-muted/30 p-1 text-base text-muted-foreground sm:text-sm">
<button
aria-label="Copy checkout path"
className="group flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-left outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
title="Copy path"
type="button"
onClick={() =>
copyPathToClipboard(selectedCheckout.workspaceRoot, {
path: selectedCheckout.workspaceRoot,
})
}
>
<code className="min-w-0 flex-1 truncate font-mono">
{selectedCheckout.workspaceRoot}
</code>
<CopyIcon className="size-4 shrink-0 opacity-60 group-hover:opacity-100" />
</button>
<Tooltip>
<TooltipTrigger
render={
<button
aria-label="Copy checkout path"
className="group flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-left outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
type="button"
onClick={() =>
copyPathToClipboard(selectedCheckout.workspaceRoot, {
path: selectedCheckout.workspaceRoot,
})
}
>
<code className="min-w-0 flex-1 truncate font-mono">
{selectedCheckout.workspaceRoot}
</code>
<CopyIcon className="size-4 shrink-0 opacity-60 group-hover:opacity-100" />
</button>
}
/>
<TooltipPopup side="top">Copy path</TooltipPopup>
</Tooltip>
<div className="shrink-0 border-l border-border/60 px-2 tabular-nums">
{selectedCheckoutThreadCount === 1
? "1 thread"
@@ -4,6 +4,7 @@ import { isThemeColor, themeColorToHex, type ThemeColorRole } from "../../themeP
import { cn } from "../../lib/utils";
import { Input } from "../ui/input";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
export function getThemeRoleLabel(role: ThemeColorRole): string {
const labels: Partial<Record<ThemeColorRole, string>> = {
canvas: "Background",
@@ -434,23 +435,29 @@ function ThemeColorPicker({
}) {
return (
<Popover>
<PopoverTrigger
render={
<button
aria-label={`Choose ${label} color`}
className="relative flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border border-foreground/30 transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
onFocus={onInteract}
onPointerDown={onInteract}
title={`Choose ${label} color`}
type="button"
>
<span
className="absolute inset-0 rounded-full shadow-sm"
style={{ backgroundColor: value }}
<Tooltip>
<TooltipTrigger
render={
<PopoverTrigger
render={
<button
aria-label={`Choose ${label} color`}
className="relative flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border border-foreground/30 transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
onFocus={onInteract}
onPointerDown={onInteract}
type="button"
>
<span
className="absolute inset-0 rounded-full shadow-sm"
style={{ backgroundColor: value }}
/>
</button>
}
/>
</button>
}
/>
}
/>
<TooltipPopup side="top">{`Choose ${label} color`}</TooltipPopup>
</Tooltip>
<PopoverPopup
align="end"
className="overflow-hidden rounded-2xl border border-border/70 p-0 shadow-2xl [--viewport-inline-padding:0px] [&_[data-slot=popover-viewport]]:p-0"
@@ -496,16 +503,22 @@ export const ThemeColorField = memo(function ThemeColorField({
)}
data-theme-color-role={role}
>
<button
aria-label={`${selected ? "Hide" : "Show"} ${label} usage`}
aria-pressed={selected}
className="flex min-w-0 flex-1 cursor-pointer items-center rounded-md text-left text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
onClick={() => onToggleSelected?.(role)}
title={`${selected ? "Hide" : "Show"} where ${label} is used`}
type="button"
>
<span className="min-w-0 flex-1 truncate">{label}</span>
</button>
<Tooltip>
<TooltipTrigger
render={
<button
aria-label={`${selected ? "Hide" : "Show"} ${label} usage`}
aria-pressed={selected}
className="flex min-w-0 flex-1 cursor-pointer items-center rounded-md text-left text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
onClick={() => onToggleSelected?.(role)}
type="button"
>
<span className="min-w-0 flex-1 truncate">{label}</span>
</button>
}
/>
<TooltipPopup side="top">{`${selected ? "Hide" : "Show"} where ${label} is used`}</TooltipPopup>
</Tooltip>
<div className="ml-auto flex shrink-0 items-center gap-2">
<ThemeColorPicker
label={label}
+28 -16
View File
@@ -78,6 +78,7 @@ import { PanelLayoutControls } from "../components/chat/PanelLayoutControls";
import { Button } from "../components/ui/button";
import { Menu, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "../components/ui/menu";
import { SidebarInset } from "../components/ui/sidebar";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../components/ui/tooltip";
import { useLiveRefresh } from "../hooks/useLiveRefresh";
import {
selectActiveRightPanelSurface,
@@ -1639,22 +1640,33 @@ function CompactFilterMenu<Value extends string>({
</MenuTrigger>
<MenuPopup align="start" side="bottom" className="min-w-40">
<MenuRadioGroup value={value} onValueChange={(next) => onChange(next as Value)}>
{options.map((option) => (
<MenuRadioItem
key={option.value}
value={option.value}
// A host the server has already said it cannot read is not a choice here either.
// The pills disable it; a menu that offers it would answer the press by replacing
// a working list with the same failure the pill row exists to explain.
disabled={option.unavailable !== undefined}
title={option.unavailable}
>
<span className="flex min-w-0 items-center gap-2">
<option.Icon aria-hidden className="size-3.5" />
{option.label}
</span>
</MenuRadioItem>
))}
{options.map((option) => {
// A host the server has already said it cannot read is not a choice here either.
// The pills disable it; a menu that offers it would answer the press by replacing
// a working list with the same failure the pill row exists to explain.
const item = (
<MenuRadioItem
key={option.value}
value={option.value}
className={option.unavailable ? "data-disabled:pointer-events-auto" : undefined}
disabled={option.unavailable !== undefined}
>
<span className="flex min-w-0 items-center gap-2">
<option.Icon aria-hidden className="size-3.5" />
{option.label}
</span>
</MenuRadioItem>
);
if (!option.unavailable) return item;
return (
<Tooltip key={option.value}>
<TooltipTrigger render={item} />
<TooltipPopup side="top" className="max-w-80">
{option.unavailable}
</TooltipPopup>
</Tooltip>
);
})}
</MenuRadioGroup>
</MenuPopup>
</Menu>
+2
View File
@@ -4,6 +4,7 @@ import namespaceNodeImports from "./rules/namespace-node-imports.ts";
import noGlobalProcessRuntime from "./rules/no-global-process-runtime.ts";
import noInlineSchemaCompile from "./rules/no-inline-schema-compile.ts";
import noManualEffectRuntimeInTests from "./rules/no-manual-effect-runtime-in-tests.ts";
import noNativeTitleTooltip from "./rules/no-native-title-tooltip.ts";
export default definePlugin({
meta: {
@@ -14,5 +15,6 @@ export default definePlugin({
"no-global-process-runtime": noGlobalProcessRuntime,
"no-inline-schema-compile": noInlineSchemaCompile,
"no-manual-effect-runtime-in-tests": noManualEffectRuntimeInTests,
"no-native-title-tooltip": noNativeTitleTooltip,
},
});
@@ -0,0 +1,61 @@
import { assert, describe } from "@effect/vitest";
import { createOxlintRuleHarness } from "../test/utils.ts";
const rule = createOxlintRuleHarness("t3code/no-native-title-tooltip", {
filename: "fixture.tsx",
});
describe("t3code/no-native-title-tooltip", () => {
rule.valid(
"allows intrinsic elements without a title attribute",
`const el = <span className="truncate">Truncated text</span>;`,
);
rule.valid(
"allows title props on custom components",
`const el = <SettingsRow id="word-wrap" title="Word wrap" description="Wrap long lines." />;`,
);
rule.valid(
"allows title on member expression components",
`const el = <Foo.Bar title="Not a native tooltip" />;`,
);
rule.valid(
"allows title as an accessible name on embedded content",
`const el = <iframe title="Embedded widget" src="https://example.com" />;`,
);
rule.valid("allows the svg title child element", `const el = <svg><title>QR code</title></svg>;`);
rule.valid("allows document.title assignments", `document.title = "Thread · T3 Code";`);
rule.invalid(
"reports title on a truncating span",
`const el = <span className="min-w-0 truncate" title="Full repository name">Repo</span>;`,
(output) => {
assert.match(output, /native title attribute/);
},
);
rule.invalid(
"reports title on a button",
`const el = <button type="button" aria-label="Scroll to end" title="Scroll to end" />;`,
(output) => {
assert.match(output, /Tooltip \+ TooltipTrigger \+ TooltipPopup/);
},
);
rule.invalid(
"reports title on a paragraph",
`const el = <p className="truncate text-xs" title={path}>src/main.ts</p>;`,
);
rule.invalid(
"reports title on a code element",
`const el = <code className="truncate" title={pairingUrl}>abc</code>;`,
);
rule.invalid("reports title on an anchor", `const el = <a href="#" title="Learn more">More</a>;`);
});
@@ -0,0 +1,39 @@
import { defineRule } from "@oxlint/plugins";
const INTRINSIC_ELEMENT_PATTERN = /^[a-z]/u;
// On these elements the title attribute names the embedded content for
// accessibility (and does not reliably produce a hover tooltip), so the styled
// Tooltip component is not a drop-in replacement.
const TITLE_IS_AN_ACCESSIBLE_NAME = new Set(["embed", "frame", "iframe", "math", "object"]);
export default defineRule({
meta: {
type: "problem",
docs: {
description:
"Disallow the native title attribute as a tooltip on intrinsic elements; use the styled Tooltip component.",
},
},
create(context) {
return {
JSXOpeningElement(node) {
if (node.name.type !== "JSXIdentifier") return;
if (!INTRINSIC_ELEMENT_PATTERN.test(node.name.name)) return;
if (TITLE_IS_AN_ACCESSIBLE_NAME.has(node.name.name)) return;
for (const attribute of node.attributes) {
if (attribute.type !== "JSXAttribute") continue;
if (attribute.name.type !== "JSXIdentifier") continue;
if (attribute.name.name !== "title") continue;
context.report({
node: attribute,
message:
"Do not use the native title attribute as a tooltip. Use Tooltip + TooltipTrigger + TooltipPopup from components/ui/tooltip.",
});
}
},
};
},
});
+1
View File
@@ -121,6 +121,7 @@ export default defineConfig({
"t3code/no-global-process-runtime": "error",
"t3code/no-inline-schema-compile": "warn",
"t3code/no-manual-effect-runtime-in-tests": "error",
"t3code/no-native-title-tooltip": "error",
"t3code/namespace-node-imports": "error",
},
options: {