Skip to content
TypeScript

fix(web): align compact button touch targets (#17748)

Yash Singhc77a7b7eebd6
diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx
index 1d4185b9092..7af46f2d47a 100644
--- a/apps/web/src/components/BranchToolbarBranchSelector.tsx
+++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx
@@ -779,7 +779,11 @@ export function BranchToolbarBranchSelector({
)}
/>
<ComposerContextLabel displayMode={displayMode}>
- <MiddleTruncate value={triggerLabel} className="w-full" />
+ <MiddleTruncate
+ value={triggerLabel}
+ variant={displayMode === "panel" ? "cap-aligned" : "default"}
+ className="w-full"
+ />
</ComposerContextLabel>
{displayMode !== "panel" ? (
<ChevronDownIcon className="size-3 shrink-0 opacity-50" />
diff --git a/apps/web/src/components/ComposerContextLabel.tsx b/apps/web/src/components/ComposerContextLabel.tsx
index 1abecfdf8ca..8efcba43a75 100644
--- a/apps/web/src/components/ComposerContextLabel.tsx
+++ b/apps/web/src/components/ComposerContextLabel.tsx
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import { cn } from "../lib/utils";
+import { THREAD_DETAILS_PANEL_LABEL_CLASS } from "./chat/threadDetailsPanelStyles";
/** Keeps text measurable while the composer's outer label box collapses. */
export function ComposerContextLabel({
@@ -16,7 +17,7 @@ export function ComposerContextLabel({
className={cn(
"min-w-0",
displayMode === "panel"
- ? "flex-1 truncate text-left"
+ ? "flex-1 overflow-x-clip overflow-y-visible text-left"
: "max-w-[240px] group-data-[compact]/composer-context:max-w-0",
)}
>
@@ -24,6 +25,7 @@ export function ComposerContextLabel({
data-composer-label-motion
className={cn(
"block w-full min-w-0 truncate",
+ displayMode === "panel" && THREAD_DETAILS_PANEL_LABEL_CLASS,
displayMode === "toolbar" &&
"max-w-[240px] transition-opacity duration-180 ease-drawer group-data-[compact]/composer-context:opacity-0 motion-reduce:transition-none",
)}
diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx
index 2b684cd0cd4..2063767f315 100644
--- a/apps/web/src/components/GitActionsControl.tsx
+++ b/apps/web/src/components/GitActionsControl.tsx
@@ -127,6 +127,7 @@ import { type DraftId, useComposerDraftStore } from "~/composerDraftStore";
import {
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
THREAD_DETAILS_PANEL_ICON_CLASS,
+ THREAD_DETAILS_PANEL_LABEL_CLASS,
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
} from "./chat/threadDetailsPanelStyles";
@@ -441,23 +442,25 @@ function GitActionProgressButtonContent({
aria-live="polite"
className={cn(
"grid min-w-0 flex-1 items-center",
- // Pin the title row to the button's minimum content height (min-height
- // minus vertical padding and border) so revealing the output row
- // extends the button downward without re-centering — the title must
- // not shift. No row gap: the collapsed output row must contribute zero
- // height so the single-line running button matches the static button
- // exactly. The panel column gap matches the static row's icon-to-label
- // distance (gap-2.5 plus the label's ml-0.5). In the panel the elapsed
- // counter renders outside the button (in the menu-chevron slot), so
- // there is no trailing column.
+ // Pin the title row to the button's minimum content height so output
+ // expands below it. Panel controls leave 24px after padding and border.
+ // No row gap: collapsed output must not add height. The panel's elapsed
+ // counter uses the menu-chevron slot, so it has no trailing column.
isPanel
- ? "grid-cols-[auto_minmax(0,1fr)] grid-rows-[1.75rem] gap-x-3"
+ ? "grid-cols-[auto_minmax(0,1fr)] grid-rows-[1.5rem] gap-x-3"
: "grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[1.25rem] gap-x-2.5 sm:grid-rows-[1rem]",
)}
role="status"
>
<Spinner aria-hidden="true" className="row-start-1 -mx-0.5 shrink-0" />
- <p className="row-start-1 min-w-0 truncate text-left">{progress.status}</p>
+ <p
+ className={cn(
+ "row-start-1 min-w-0 truncate text-left",
+ isPanel && THREAD_DETAILS_PANEL_LABEL_CLASS,
+ )}
+ >
+ {progress.status}
+ </p>
{!isPanel ? (
<GitActionElapsedTime
startedAtMs={progress.startedAtMs}
@@ -496,11 +499,13 @@ function GitActionSuccessButtonContent({ success }: { success: InlineGitActionSu
return (
<div
aria-live="polite"
- className="grid min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)] grid-rows-[1.75rem] items-center gap-x-3"
+ className="grid min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)] grid-rows-[1.5rem] items-center gap-x-3"
role="status"
>
<CheckIcon aria-hidden="true" className="size-3.5 shrink-0 text-success" />
- <p className="min-w-0 truncate text-left">{success.title}</p>
+ <p className={cn("min-w-0 truncate text-left", THREAD_DETAILS_PANEL_LABEL_CLASS)}>
+ {success.title}
+ </p>
<div
className={cn(
"col-start-2 grid min-w-0 transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none",
@@ -1704,7 +1709,7 @@ export default function GitActionsControl({
<PopoverTrigger
openOnHover
nativeButton={false}
- render={<span className="block w-max cursor-not-allowed" />}
+ render={<span className="block w-full cursor-not-allowed" />}
>
<MenuItem
density={presentation === "menu" ? "touch" : "default"}
@@ -1824,7 +1829,7 @@ export default function GitActionsControl({
onClick={initializeGit}
>
<GitBranchPlusIcon className="size-3.5" aria-hidden />
- <span className="ml-0.5">
+ <span className={cn("ml-0.5", isPanel && THREAD_DETAILS_PANEL_LABEL_CLASS)}>
{initAction.isPending ? "Initializing..." : "Initialize Git"}
</span>
</ThreadDetailsControl>
@@ -1882,7 +1887,7 @@ export default function GitActionsControl({
<span
className={cn(
"sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
- isPanel && "not-sr-only ml-0 truncate",
+ isPanel && cn("not-sr-only ml-0 truncate", THREAD_DETAILS_PANEL_LABEL_CLASS),
)}
>
{quickAction.label}
@@ -1909,7 +1914,7 @@ export default function GitActionsControl({
<span
className={cn(
"sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
- isPanel && "not-sr-only ml-0 truncate",
+ isPanel && cn("not-sr-only ml-0 truncate", THREAD_DETAILS_PANEL_LABEL_CLASS),
)}
>
{quickAction.label}
@@ -1979,7 +1984,7 @@ export default function GitActionsControl({
onClick={onOpenChanges}
>
<FileDiffIcon className={THREAD_DETAILS_PANEL_ICON_CLASS} aria-hidden />
- <span className="flex-1 text-left">Changes</span>
+ <span className={cn("flex-1 text-left", THREAD_DETAILS_PANEL_LABEL_CLASS)}>Changes</span>
<span className="flex items-center gap-1 font-mono text-2xs tabular-nums">
<span className="text-success">+{changesTotals?.insertions ?? 0}</span>
<span className="text-destructive">-{changesTotals?.deletions ?? 0}</span>
diff --git a/apps/web/src/components/ProjectScriptsControl.tsx b/apps/web/src/components/ProjectScriptsControl.tsx
index 5bea0b46cd1..b952cbe0df9 100644
--- a/apps/web/src/components/ProjectScriptsControl.tsx
+++ b/apps/web/src/components/ProjectScriptsControl.tsx
@@ -50,6 +50,7 @@ import { cn } from "~/lib/utils";
import {
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
THREAD_DETAILS_PANEL_ICON_CLASS,
+ THREAD_DETAILS_PANEL_LABEL_CLASS,
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
} from "./chat/threadDetailsPanelStyles";
@@ -322,7 +323,7 @@ export default function ProjectScriptsControl({
<span
className={cn(
"sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
- isPanel && "not-sr-only ml-0 truncate",
+ isPanel && cn("not-sr-only ml-0 truncate", THREAD_DETAILS_PANEL_LABEL_CLASS),
)}
>
{primaryScript.name}
@@ -387,7 +388,9 @@ export default function ProjectScriptsControl({
onClick={() => setActionsMenuOpen({ presentation, scripts: false, imports: true })}
>
<WrenchIcon className={THREAD_DETAILS_PANEL_ICON_CLASS} />
- <span className="min-w-0 truncate">Actions</span>
+ <span className={cn("min-w-0 truncate", THREAD_DETAILS_PANEL_LABEL_CLASS)}>
+ Actions
+ </span>
</ThreadDetailsControl>
<span aria-hidden="true" className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS} />
<Menu
@@ -456,7 +459,7 @@ export default function ProjectScriptsControl({
<span
className={cn(
"sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
- isPanel && "not-sr-only ml-0.5",
+ isPanel && cn("not-sr-only ml-0.5", THREAD_DETAILS_PANEL_LABEL_CLASS),
)}
>
{isPanel ? "Add project script" : "Add action"}
diff --git a/apps/web/src/components/chat/ComposerPrimaryActions.tsx b/apps/web/src/components/chat/ComposerPrimaryActions.tsx
index 85d8504ce25..fc811118aa1 100644
--- a/apps/web/src/components/chat/ComposerPrimaryActions.tsx
+++ b/apps/web/src/components/chat/ComposerPrimaryActions.tsx
@@ -370,7 +370,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
<button
type="button"
className={cn(
- "flex h-7 shrink-0 cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs tabular-nums outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:size-3.5",
+ "flex h-9 shrink-0 cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs tabular-nums outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 sm:h-8 [&_svg]:pointer-events-none [&_svg]:size-3.5",
keepFullHistory
? "border-border text-muted-foreground hover:text-foreground"
: "border-warning/40 text-warning hover:bg-warning/8",
diff --git a/apps/web/src/components/chat/OpenInPicker.tsx b/apps/web/src/components/chat/OpenInPicker.tsx
index 302d09b8244..a6f9bfbf792 100644
--- a/apps/web/src/components/chat/OpenInPicker.tsx
+++ b/apps/web/src/components/chat/OpenInPicker.tsx
@@ -64,6 +64,7 @@ import { useAtomCommand } from "~/state/use-atom-command";
import {
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
THREAD_DETAILS_PANEL_ICON_CLASS,
+ THREAD_DETAILS_PANEL_LABEL_CLASS,
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
} from "./threadDetailsPanelStyles";
@@ -421,7 +422,7 @@ export const OpenInPicker = memo(function OpenInPicker({
compact
? "sr-only"
: "sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
- isPanel && "not-sr-only ml-0 min-w-0 truncate",
+ isPanel && cn("not-sr-only ml-0 min-w-0 truncate", THREAD_DETAILS_PANEL_LABEL_CLASS),
)}
>
{primaryLabel}
diff --git a/apps/web/src/components/chat/ThreadDetailsPrRow.tsx b/apps/web/src/components/chat/ThreadDetailsPrRow.tsx
index c4b149990a2..19a3e91b561 100644
--- a/apps/web/src/components/chat/ThreadDetailsPrRow.tsx
+++ b/apps/web/src/components/chat/ThreadDetailsPrRow.tsx
@@ -75,6 +75,7 @@ import { Button } from "../ui/button";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import {
THREAD_DETAILS_PANEL_ICON_CLASS,
+ THREAD_DETAILS_PANEL_LABEL_CLASS,
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
} from "./threadDetailsPanelStyles";
@@ -398,7 +399,9 @@ export function ThreadDetailsPrRow({
}
>
{icon}
- <span className="min-w-0 flex-1 truncate text-left">{text}</span>
+ <span className={cn("min-w-0 flex-1 truncate text-left", THREAD_DETAILS_PANEL_LABEL_CLASS)}>
+ {text}
+ </span>
</TooltipTrigger>
{rowTooltip}
</Tooltip>
diff --git a/apps/web/src/components/chat/threadDetailsPanelStyles.ts b/apps/web/src/components/chat/threadDetailsPanelStyles.ts
index bd74bd95cd5..d9f88c7adab 100644
--- a/apps/web/src/components/chat/threadDetailsPanelStyles.ts
+++ b/apps/web/src/components/chat/threadDetailsPanelStyles.ts
@@ -14,6 +14,11 @@ const THREAD_DETAILS_PANEL_SPLIT_GROUP_SURFACE_CLASS = `${THREAD_DETAILS_PANEL_H
export const THREAD_DETAILS_PANEL_ROW_CONTENT_CLASS = "gap-2.5 px-2.5 text-left";
+// Center capitals with icons. Only clip horizontally so truncated labels retain
+// accents and descenders outside the trimmed text box.
+export const THREAD_DETAILS_PANEL_LABEL_CLASS =
+ "[text-box:trim-both_cap_alphabetic] overflow-x-clip overflow-y-visible";
+
const THREAD_DETAILS_PANEL_CONTROL_CLASS = `h-8 min-w-0 rounded-lg border-transparent ${THREAD_DETAILS_PANEL_ROW_CONTENT_CLASS} text-[13px] font-medium text-foreground/80`;
export const THREAD_DETAILS_PANEL_ROW_CLASS = `${THREAD_DETAILS_PANEL_CONTROL_CLASS} w-full justify-start ${THREAD_DETAILS_PANEL_ROW_SURFACE_CLASS}`;
diff --git a/apps/web/src/components/ui/middle-truncate.tsx b/apps/web/src/components/ui/middle-truncate.tsx
index fd8a2544773..ae4fbe61b74 100644
--- a/apps/web/src/components/ui/middle-truncate.tsx
+++ b/apps/web/src/components/ui/middle-truncate.tsx
@@ -16,6 +16,7 @@ export function MiddleTruncate({
value,
tail,
showTitle = true,
+ variant = "default",
className,
...props
}: Omit<ComponentProps<"span">, "children"> & {
@@ -24,12 +25,19 @@ export function MiddleTruncate({
tail?: number;
/** The full value on hover. Off where a tooltip already carries it. */
showTitle?: boolean;
+ /** Align capital letters with adjacent icons while preserving accents and descenders. */
+ variant?: "default" | "cap-aligned";
}) {
const split = splitForMiddleTruncate(value, tail);
return (
<span
{...(showTitle ? { title: value } : {})}
- className={cn("inline-flex min-w-0 max-w-full overflow-hidden whitespace-nowrap", className)}
+ className={cn(
+ "inline-flex min-w-0 max-w-full overflow-hidden whitespace-nowrap",
+ variant === "cap-aligned" &&
+ "overflow-x-clip overflow-y-visible [&>span]:[text-box:trim-both_cap_alphabetic] [&>span]:overflow-x-clip [&>span]:overflow-y-visible",
+ className,
+ )}
{...props}
>
{split ? (