Skip to content

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

Go

fix(views): bind pills to the xs control height (MUL-8166) (#9433)

Jiayuan Zhangb05646a45270
diff --git a/packages/ui/components/common/actor-avatar.tsx b/packages/ui/components/common/actor-avatar.tsx
index 8a1dfca517..90d76ae502 100644
--- a/packages/ui/components/common/actor-avatar.tsx
+++ b/packages/ui/components/common/actor-avatar.tsx
@@ -33,7 +33,12 @@ function ActorAvatar({
className,
}: ActorAvatarProps) {
const [imgError, setImgError] = useState(false);
- const px = AVATAR_SIZE_PX[size];
+ // A control that fixes its own content size (e.g. a toolbar pill) sets
+ // `--avatar-slot-size`; it wins over `size` so the avatar can't outgrow the
+ // control. A CSS variable rather than React context: it follows the DOM, so
+ // hover cards portaled out of the control keep their own avatar sizes.
+ const diameter = `var(--avatar-slot-size, ${AVATAR_SIZE_PX[size]}px)`;
+ const scaled = (ratio: number) => `calc(${diameter} * ${ratio})`;
const emoji = parseAvatarEmoji(avatarUrl);
useEffect(() => {
@@ -54,14 +59,14 @@ function ActorAvatar({
// the circle — avatar shape is a hard invariant, not a per-site choice.
"rounded-full"
)}
- style={{ width: px, height: px, fontSize: px * 0.45 }}
+ style={{ width: diameter, height: diameter, fontSize: scaled(0.45) }}
>
{emoji ? (
<span
role="img"
aria-label={name}
className="select-none leading-none"
- style={{ fontSize: px * 0.58 }}
+ style={{ fontSize: scaled(0.58) }}
>
{emoji}
</span>
@@ -73,11 +78,11 @@ function ActorAvatar({
onError={() => setImgError(true)}
/>
) : isSystem ? (
- <MulticaIcon noSpin style={{ width: px * 0.55, height: px * 0.55 }} />
+ <MulticaIcon noSpin style={{ width: scaled(0.55), height: scaled(0.55) }} />
) : isAgent ? (
- <Bot style={{ width: px * 0.55, height: px * 0.55 }} />
+ <Bot style={{ width: scaled(0.55), height: scaled(0.55) }} />
) : isSquad ? (
- <Users style={{ width: px * 0.55, height: px * 0.55 }} />
+ <Users style={{ width: scaled(0.55), height: scaled(0.55) }} />
) : (
initials
)}
diff --git a/packages/views/chat/components/chat-input.tsx b/packages/views/chat/components/chat-input.tsx
index fcf3b9806e..25071f351f 100644
--- a/packages/views/chat/components/chat-input.tsx
+++ b/packages/views/chat/components/chat-input.tsx
@@ -695,7 +695,7 @@ export function ChatInput({
title={t(($) => $.input.change_project_context)}
onClear={() => onProjectChange?.(null)}
clearLabel={t(($) => $.input.remove_project_context)}
- className="h-6 border-surface-border bg-surface-raised font-medium text-foreground"
+ className="border-surface-border bg-surface-raised font-medium text-foreground"
/>
}
/>
diff --git a/packages/views/common/pill-button.tsx b/packages/views/common/pill-button.tsx
index e1ab582af3..cac6b41b52 100644
--- a/packages/views/common/pill-button.tsx
+++ b/packages/views/common/pill-button.tsx
@@ -15,8 +15,17 @@ import { cn } from "@multica/ui/lib/utils";
// `overflow-hidden` let the inner `truncate` spans actually shrink (a flex item
// only drops `min-width: auto` once its overflow is hidden); leading icons are
// `shrink-0`, so the text yields first.
+//
+// A pill is an xs control: it takes its height from the shared control ladder
+// (`--button-height-xs`, same caption type as `Button size="xs"`), not from
+// vertical padding — padding lets the tallest child set the height, so a row
+// of pills drifts apart. The pill also sizes what it holds to the 16px caption
+// line, so call sites never pick a tier that outgrows it: avatars through
+// `--avatar-slot-size` (read by the base avatar), label chips by dropping
+// their vertical padding.
const PILL_CHROME =
- "inline-flex items-center rounded-full border text-caption min-w-0 max-w-56 overflow-hidden transition-colors";
+ "inline-flex h-[var(--button-height-xs)] items-center rounded-full border text-caption min-w-0 max-w-56 overflow-hidden transition-colors " +
+ "[--avatar-slot-size:1rem] [&_[data-slot=label-chip]]:py-0";
export function PillButton({
children,
@@ -28,7 +37,7 @@ export function PillButton({
type="button"
className={cn(
PILL_CHROME,
- "gap-1.5 px-2.5 py-1",
+ "gap-1.5 px-2.5",
"hover:bg-accent/60 cursor-pointer",
"data-popup-open:bg-accent data-popup-open:text-accent-foreground",
"disabled:cursor-not-allowed disabled:hover:bg-transparent",
@@ -94,7 +103,7 @@ export function ClearablePillButton({
type="button"
disabled={disabled}
className={cn(
- "flex min-w-0 items-center gap-1.5 overflow-hidden py-1 pl-2.5 cursor-pointer",
+ "flex h-full min-w-0 items-center gap-1.5 overflow-hidden pl-2.5 cursor-pointer",
clearable ? "pr-1" : "pr-2.5",
"disabled:cursor-not-allowed",
)}
@@ -111,7 +120,7 @@ export function ClearablePillButton({
e.stopPropagation();
onClear?.();
}}
- className="flex shrink-0 items-center py-1 pl-0.5 pr-2 text-muted-foreground hover:text-foreground cursor-pointer"
+ className="flex h-full shrink-0 items-center pl-0.5 pr-2 text-muted-foreground hover:text-foreground cursor-pointer"
>
<XIcon className="size-3" />
</button>
diff --git a/packages/views/labels/label-chip.tsx b/packages/views/labels/label-chip.tsx
index 9585548252..4b3dbcd8ad 100644
--- a/packages/views/labels/label-chip.tsx
+++ b/packages/views/labels/label-chip.tsx
@@ -57,6 +57,7 @@ export function LabelChip({ label, onRemove, className, fullName }: LabelChipPro
const nameClass = fullName ? "break-all" : "truncate max-w-[12rem]";
return (
<span
+ data-slot="label-chip"
// `min-w-0` lets the chip shrink when it is a flex item in a width-capped
// container (the create toolbar's label pill). Without it the chip keeps
// its content width and the parent clips it mid-shape; with it the inner