Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): ux nits: make the sidebar dot hittable, unify hovercard and center it vertically. (#97236)

posthog[bot]73442612b3be
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx
index 8bee5dd20fe1..76c6c8fdc908 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx
@@ -83,6 +83,7 @@ const ChannelItemPreviewHandleContext =
* Sharing the handle is also what makes sliding down the list feel like one
* card moving: Base UI skips the open delay when the pointer crosses to another
* trigger of an already-open popup.
+
*/
export function ChannelItemPreviewCardProvider({
children,
@@ -141,9 +142,13 @@ export function ChannelItemPreviewCardProvider({
{({ payload }) =>
payload ? (
<PreviewCard.Portal>
+ {/* Centred on the row rather than hung from its top edge. A card
+ four hundred pixels tall aligned to a twenty-eight pixel row
+ sits almost entirely below it, so the run to it is a run
+ downwards whichever row you are on */}
<PreviewCard.Positioner
side="right"
- align="start"
+ align="center"
sideOffset={10}
className="z-50"
>
@@ -216,40 +221,33 @@ function useKeyboardPreview(
}
/**
- * A row that shows the shared preview card while it is pointed at. Shared by
- * the channel sidebar's rows and the space tree's session rows so the two can't
- * drift into showing different facts or actions for one task.
- *
- * `children` is the row itself, handed to the trigger.
+ * A row that shows the shared card while it is pointed at, whatever the row is
+ * about: what a space and a session differ in is the payload they carry, and
+ * they are one popup being moved between them, so they are one trigger too.
+
*/
-export function ChannelItemHoverCard({
- item,
- menu,
- highlighted = false,
+function PreviewTrigger({
+ payload,
+ highlighted,
children,
}: {
- item: ChannelItemModel;
- menu: TaskRowMenuProps;
+ payload: ChannelPreviewPayload;
/** The keyboard is on this row, which opens the card as hovering does. */
- highlighted?: boolean;
+ highlighted: boolean;
children: ReactNode;
}) {
const card = useContext(ChannelItemPreviewHandleContext);
- // The card reads the row it is over off the active trigger, so what the row
- // has to say travels as the trigger's payload. Kept stable, because a new
- // identity writes it to the card's store again.
- const payload = useMemo(
- () => ({ kind: "item" as const, item, menu }),
- [item, menu],
- );
// Ours rather than Base UI's own, because opening from the keyboard means
// naming the trigger to open.
const triggerId = useId();
useKeyboardPreview(card, triggerId, highlighted);
const row = (
- // Pointing at any row hands the card to the pointer, so the row the
- // keyboard opened it on stops trying to close it.
- <div className="flex min-w-0" onPointerEnter={card?.releaseKeyboard}>
+ <div
+ className="flex min-w-0"
+ // Pointing at any row hands the card to the pointer, so the row the
+ // keyboard opened it on stops trying to close it.
+ onPointerEnter={card?.releaseKeyboard}
+ >
{children}
</div>
);
@@ -271,14 +269,41 @@ export function ChannelItemHoverCard({
}
/**
- * A space row that shows the shared preview card while it is pointed at, with
- * the space's own card in it rather than a session's.
- *
- * The same handle as the session rows on purpose: a space and the sessions
- * under it are one list to the pointer, so crossing between them swaps the
- * card's contents instead of closing one popup and opening another. It opens on
- * the keyboard's highlight the way they do, too — walking the tree shows the
- * same card whichever kind of row the highlight lands on.
+ * A session row's card. Shared by the channel sidebar's rows and the space
+ * tree's session rows so the two can't drift into showing different facts or
+ * actions for one task.
+ */
+export function ChannelItemHoverCard({
+ item,
+ menu,
+ highlighted = false,
+ children,
+}: {
+ item: ChannelItemModel;
+ menu: TaskRowMenuProps;
+ /** The keyboard is on this row, which opens the card as hovering does. */
+ highlighted?: boolean;
+ children: ReactNode;
+}) {
+ // The card reads the row it is over off the active trigger, so what the row
+ // has to say travels as the trigger's payload. Kept stable, because a new
+ // identity writes it to the card's store again.
+ const payload = useMemo(
+ () => ({ kind: "item" as const, item, menu }),
+ [item, menu],
+ );
+ return (
+ <PreviewTrigger payload={payload} highlighted={highlighted}>
+ {children}
+ </PreviewTrigger>
+ );
+}
+
+/**
+ * A space row's card, on the same handle as the session rows on purpose: a
+ * space and the sessions under it are one list to the pointer, so crossing
+ * between them swaps the card's contents instead of closing one popup and
+ * opening another.
*/
export function SpaceHoverCard({
space,
@@ -290,31 +315,15 @@ export function SpaceHoverCard({
highlighted?: boolean;
children: ReactNode;
}) {
- const card = useContext(ChannelItemPreviewHandleContext);
// Stable for the reason a session row's is: a new identity writes the payload
// to the card's store again. The caller memoizes what it passes.
const payload = useMemo(
() => ({ kind: "space" as const, ...space }),
[space],
);
- const triggerId = useId();
- useKeyboardPreview(card, triggerId, highlighted);
- const row = (
- <div className="flex min-w-0" onPointerEnter={card?.releaseKeyboard}>
- {children}
- </div>
- );
-
- if (!card) return row;
-
return (
- <PreviewCard.Trigger
- handle={card.handle}
- payload={payload}
- id={triggerId}
- delay={OPEN_DELAY_MS}
- closeDelay={CLOSE_DELAY_MS}
- render={row}
- />
+ <PreviewTrigger payload={payload} highlighted={highlighted}>
+ {children}
+ </PreviewTrigger>
);
}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemPreview.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemPreview.tsx
index 967c2d90eba7..9182c3d68b66 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemPreview.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemPreview.tsx
@@ -334,7 +334,13 @@ export function ChannelItemPreview({
<ItemGroup className="gap-0!">
<Item size="xs" className="flex-nowrap p-2">
<ItemContent className="min-w-0 gap-2">
- <ItemTitle className="wrap-break-word flex items-start gap-2">
+ {/* `wrap-anywhere` rather than `wrap-break-word`: quill sizes a
+ title to `width: fit-content`, so the box is as wide as the
+ longest thing that cannot be broken, and only
+ `overflow-wrap: anywhere` takes a long token out of that
+ measurement. A title that is one pasted url otherwise makes the
+ box wider than the card and runs off its right edge. */}
+ <ItemTitle className="wrap-anywhere flex items-start gap-2">
<span className="flex h-[1lh] w-4 shrink-0 items-center justify-center">
{previewGlyph(item, dot)}
</span>
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx
index 717145cd03a3..eb5278b53d86 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx
@@ -249,7 +249,10 @@ function ChannelItemDot({
const pendingDelete = useIsCanvasPendingDelete(item.id);
const deleting = item.kind === "canvas" && pendingDelete;
return (
- <TaskStatusDot dot={deleting ? DELETING_DOT : taskDot(status ?? {})} />
+ <TaskStatusDot
+ dot={deleting ? DELETING_DOT : taskDot(status ?? {})}
+ hitArea="row"
+ />
);
}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
index 21e68ef57bcc..54b6c0b59ca9 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
@@ -528,7 +528,7 @@ const SpaceTaskRow = memo(function SpaceTaskRow({
<span className="sr-only">Archiving</span>
</>
) : (
- <TaskStatusDot dot={taskDot(status ?? {})} />
+ <TaskStatusDot dot={taskDot(status ?? {})} hitArea="row" />
)}
<span
className={cn(
@@ -1302,39 +1302,44 @@ const ChannelSection = memo(
<ChannelActionItems actions={actions} kind="context" />
</ContextMenuContent>
</ContextMenu>
- </SpaceHoverCard>
- {/* Hover actions stay visible while the menu is open. */}
- <div className="absolute top-1 right-1">
- <ButtonGroup>
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- variant="outline"
- size="icon-xs"
- aria-label={`New task in ${channel.name}`}
- className={cn(
- "gap-1 transition-opacity group-hover:border-border",
- menuOpen
- ? "opacity-100"
- : "opacity-0 group-hover/chan:opacity-100",
- )}
- onClick={newTask}
- >
- <PlusIcon size={12} weight="bold" />
- </Button>
- }
+ {/* Inside the card's trigger rather than beside it. These overlay
+ the row's own right edge, so reaching for one is not leaving
+ the row — and the card, which the trigger's bounds decide,
+ should read it that way too. Still positioned against
+ `group/chan`, which is the nearest positioned ancestor either
+ way. */}
+ <div className="absolute top-1 right-1">
+ <ButtonGroup>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="outline"
+ size="icon-xs"
+ aria-label={`New task in ${channel.name}`}
+ className={cn(
+ "gap-1 transition-opacity group-hover:border-border",
+ menuOpen
+ ? "opacity-100"
+ : "opacity-0 group-hover/chan:opacity-100",
+ )}
+ onClick={newTask}
+ >
+ <PlusIcon size={12} weight="bold" />
+ </Button>
+ }
+ />
+ <TooltipContent side="top">New task</TooltipContent>
+ </Tooltip>
+ <ChannelMenu
+ channelName={channel.name}
+ actions={actions}
+ open={menuOpen}
+ onOpenChange={setMenuOpen}
/>
- <TooltipContent side="top">New task</TooltipContent>
- </Tooltip>
- <ChannelMenu
- channelName={channel.name}
- actions={actions}
- open={menuOpen}
- onOpenChange={setMenuOpen}
- />
- </ButtonGroup>
- </div>
+ </ButtonGroup>
+ </div>
+ </SpaceHoverCard>
{/* One modal for both the dropdown and context-menu "Rename" actions. */}
{renameMounted && (
<RenameChannelModal
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx
index abed537a6b91..039ea98750cb 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx
@@ -158,7 +158,9 @@ export function SpacePreviewContent({
{/* The row's own mark rides with the name rather than in a gutter of
its own: a quiet space has no mark, and a column that is empty on
most cards is an indent nothing pays for. */}
- <ItemTitle className="flex items-center gap-2 break-words">
+ {/* `wrap-anywhere` for the reason a session's card takes it, which
+ `ChannelItemPreview` spells out. */}
+ <ItemTitle className="wrap-anywhere flex items-center gap-2">
{hasAttention && (
<span
aria-hidden
@@ -169,7 +171,7 @@ export function SpacePreviewContent({
}}
/>
)}
- {channel.name}
+ <span className="min-w-0 font-bold">{channel.name}</span>
</ItemTitle>
<ItemDescription>
{/* No count until the page lands: "0 sessions" on a space that has
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.test.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.test.tsx
index bd291e5a7267..4f051598dd28 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.test.tsx
+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.test.tsx
@@ -18,6 +18,13 @@ const idle: TaskDot = {
label: "All caught up",
};
+const blocked: TaskDot = {
+ tone: "blue",
+ style: "solid",
+ pulse: false,
+ label: "Needs your input",
+};
+
describe("TaskStatusDot", () => {
it("uses the braille spinner without changing the status column width", () => {
render(
@@ -35,4 +42,22 @@ describe("TaskStatusDot", () => {
expect(mark.querySelector(".ph-dots-frame")).toHaveTextContent("⠋");
expect(mark.querySelector("svg")).not.toBeInTheDocument();
});
+
+ it("grows a row's trigger past the dot without moving the mark", () => {
+ // Separate containers, so each dot's siblings are only its own.
+ render(<TaskStatusDot dot={idle} />);
+ render(<TaskStatusDot dot={blocked} hitArea="row" />);
+
+ const bare = screen.getByRole("img", { name: "All caught up" });
+ const mark = screen.getByRole("img", { name: "Needs your input" });
+
+ // The dot keeps the box it had, so the row's leading column doesn't shift.
+ expect(mark.style.width).toBe(bare.style.width);
+ // What grew is the trigger around it, and only for a row.
+ expect(mark.parentElement).toHaveClass("relative");
+ expect(mark.parentElement?.querySelector(".absolute")).toHaveClass(
+ "-inset-2",
+ );
+ expect(bare.parentElement?.querySelector(".absolute")).toBeNull();
+ });
});
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx
index e163eb128712..bfe3288cb395 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx
+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx
@@ -111,11 +111,39 @@ function dotMark(dot: TaskDot, decorative = false): ReactElement {
* A task's state as a single dot: blue wants a decision, the brand yellow is
* working or unread, grey is quiet. The trigger renders as a span because rows are
* `<button>`s — a nested button would be invalid HTML.
+ *
+ * `hitArea="row"` is for the list rows, where the dot is the only thing to aim
+ * at and eight pixels of it is a target people miss — enough that the tooltip
+ * reads as absent rather than small, so the colours end up meaning nothing. The
+ * dot keeps its own box in the row's layout, so nothing moves; the trigger
+ * grows around it into the square below.
*/
-export function TaskStatusDot({ dot }: { dot: TaskDot }) {
+export function TaskStatusDot({
+ dot,
+ hitArea = "dot",
+}: {
+ dot: TaskDot;
+ /** `row`: the row's whole leading square, not just the mark drawn in it. */
+ hitArea?: "dot" | "row";
+}) {
return (
<RowTooltip label={dot.label} side="right">
- {dotMark(dot)}
+ {hitArea === "row" ? (
+ <span className="relative flex shrink-0 items-center justify-center">
+ {dotMark(dot)}
+ {/* `-inset-2` around an 8px dot is a 24px square. On a 28px row whose
+ dot sits in its 8px of leading padding, that square starts at the
+ row's own left edge and stops just short of its top and bottom —
+ the target you were already aiming at. It overflows the dot's box
+ instead of widening it, so the mark stays where it was drawn, and
+ `mouseenter` counts an overflowing child as part of the trigger. */}
+ {/* `aria-hidden` because the mark inside carries the label; a second
+ named element here would announce the state twice. */}
+ <span aria-hidden className="-inset-2 absolute" />
+ </span>
+ ) : (
+ dotMark(dot)
+ )}
</RowTooltip>
);
}