From a99545be2a7e53a63fc00f0e7238efab3cb88f7e Mon Sep 17 00:00:00 2001 From: tenyoru Date: Mon, 9 Nov 2026 14:26:33 +0100 Subject: [PATCH 1/2] feat(web): hide the empty Settled shelf until a thread is dragged --- .../SidebarListMarkers.browser.test.tsx | 103 ++++++++++++++++++ .../components/sidebar/SidebarListMarkers.tsx | 26 +++-- 2 files changed, 118 insertions(+), 11 deletions(-) create mode 100644 apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx diff --git a/apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx b/apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx new file mode 100644 index 0000000000000..4b068570bfbd4 --- /dev/null +++ b/apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx @@ -0,0 +1,103 @@ +import { DndContext, useDndContext, useDraggable } from "@dnd-kit/core"; +import { useState } from "react"; +import { expect, it, vi } from "vite-plus/test"; +import { userEvent } from "vite-plus/test/browser"; + +import { act, render } from "../../../test/render"; +import { sidebarMarkerId } from "../Sidebar.logic"; +import { SidebarSectionHeader } from "./SidebarListMarkers"; + +vi.mock("./SidebarThreadRow", () => ({ + SIDEBAR_SORTABLE_DRAG_DISABLED: { draggable: true }, +})); + +function Shelf({ count }: { count: number }) { + const { active } = useDndContext(); + const { setNodeRef, attributes, listeners } = useDraggable({ id: "thread" }); + return ( + <> + + + + ); +} + +function Harness() { + const [count, setCount] = useState(0); + return ( +
+ { + if (over?.id === sidebarMarkerId("settled-header")) setCount(1); + }} + > + + + +
+ ); +} + +it("reveals an empty Settled drop target only for a drag and keeps it after a drop", async () => { + await using screen = await render(, { + router: false /* shelf drag/drop does not navigate */, + }); + const settled = screen.getByRole("button", { name: /^Settled\s*0$/ }); + await expect.element(settled).not.toBeInTheDocument(); + + const startDrag = async () => { + const thread = screen.getByRole("button", { name: "Thread" }).element(); + const { x, y, width, height } = thread.getBoundingClientRect(); + await act(() => { + thread.dispatchEvent( + new PointerEvent("pointerdown", { + bubbles: true, + isPrimary: true, + pointerId: 1, + button: 0, + buttons: 1, + clientX: x + width / 2, + clientY: y + height / 2, + }), + ); + }); + await expect.element(settled).toBeVisible(); + }; + + await startDrag(); + await act(() => + document.dispatchEvent( + new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: true }), + ), + ); + await expect.element(settled).not.toBeInTheDocument(); + + await startDrag(); + const target = settled.element().getBoundingClientRect(); + await act(() => { + document.dispatchEvent( + new PointerEvent("pointermove", { + bubbles: true, + pointerId: 1, + buttons: 1, + clientX: target.x + target.width / 2, + clientY: target.y + target.height / 2, + }), + ); + }); + await act(() => document.dispatchEvent(new PointerEvent("pointerup", { pointerId: 1 }))); + await expect.element(screen.getByRole("button", { name: /^Settled\s*1$/ })).toBeVisible(); + + await userEvent.click(screen.getByRole("button", { name: "Unsettle" })); + await expect.element(settled).not.toBeInTheDocument(); +}); diff --git a/apps/web/src/components/sidebar/SidebarListMarkers.tsx b/apps/web/src/components/sidebar/SidebarListMarkers.tsx index da9444a5c1b24..e9d008ea6a569 100644 --- a/apps/web/src/components/sidebar/SidebarListMarkers.tsx +++ b/apps/web/src/components/sidebar/SidebarListMarkers.tsx @@ -126,22 +126,26 @@ export function SidebarSectionHeader(props: { : props.marker === "snoozed-header" ? "snoozed" : "settled"; + // Keep the zero-height marker mounted so an empty shelf remains a valid drop target. + const visible = props.count > 0 || props.dragging === true; return ( - {props.count}} - > - {props.label} - + {visible ? ( + {props.count}} + > + {props.label} + + ) : null} ); } From dbc4f9a1f1ac15f7fce8a2f9f45e5c0cefd7bf2e Mon Sep 17 00:00:00 2001 From: tenyoru Date: Mon, 9 Nov 2026 14:35:51 +0100 Subject: [PATCH 2/2] feat(web): hide the Settled header's count and chevron while dragging --- .../sidebar/SidebarListMarkers.browser.test.tsx | 2 +- apps/web/src/components/sidebar/SidebarListMarkers.tsx | 7 ++++++- apps/web/src/components/ui/collapsible-section-header.tsx | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx b/apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx index 4b068570bfbd4..f73b7ea54de91 100644 --- a/apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx +++ b/apps/web/src/components/sidebar/SidebarListMarkers.browser.test.tsx @@ -52,7 +52,7 @@ it("reveals an empty Settled drop target only for a drag and keeps it after a dr await using screen = await render(, { router: false /* shelf drag/drop does not navigate */, }); - const settled = screen.getByRole("button", { name: /^Settled\s*0$/ }); + const settled = screen.getByTestId("sidebar-settled-shelf-toggle"); await expect.element(settled).not.toBeInTheDocument(); const startDrag = async () => { diff --git a/apps/web/src/components/sidebar/SidebarListMarkers.tsx b/apps/web/src/components/sidebar/SidebarListMarkers.tsx index e9d008ea6a569..cf82c8da4c4ee 100644 --- a/apps/web/src/components/sidebar/SidebarListMarkers.tsx +++ b/apps/web/src/components/sidebar/SidebarListMarkers.tsx @@ -141,7 +141,12 @@ export function SidebarSectionHeader(props: { expanded={props.toggle.expanded} tone={props.isDropTarget ? "accent" : props.dragging ? "emphasized" : "muted"} data-testid={`sidebar-${shelf}-shelf-toggle`} - accessory={{props.count}} + accessory={ + + {props.count} + + } + showChevron={!props.dragging} > {props.label} diff --git a/apps/web/src/components/ui/collapsible-section-header.tsx b/apps/web/src/components/ui/collapsible-section-header.tsx index 94323b0ad9443..674d83bfaba2d 100644 --- a/apps/web/src/components/ui/collapsible-section-header.tsx +++ b/apps/web/src/components/ui/collapsible-section-header.tsx @@ -14,12 +14,14 @@ export function CollapsibleSectionHeader({ tone = "muted", variant = "default", accessory, + showChevron = true, ...buttonProps }: Omit, "className" | "style" | "aria-expanded"> & { expanded: boolean; tone?: keyof typeof tones; variant?: "default" | "panel"; accessory?: ReactNode; + showChevron?: boolean; }) { return ( );