Skip to content

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

Go

MUL-8556: feat(inbox): give Inbox and Chat lists their own width and compact inbox rows (#9882)

Jiayuan Zhang70a76256808c
diff --git a/packages/ui/components/ui/sidebar.tsx b/packages/ui/components/ui/sidebar.tsx
index 1dac84bbbc..720268a799 100644
--- a/packages/ui/components/ui/sidebar.tsx
+++ b/packages/ui/components/ui/sidebar.tsx
@@ -30,6 +30,13 @@ const SIDEBAR_WIDTH_DEFAULT = 240
const SIDEBAR_WIDTH_MIN = 200
const SIDEBAR_WIDTH_MAX = 320
const SIDEBAR_WIDTH_STORAGE_KEY = "sidebar_width"
+// List columns (Inbox, Chat) hold two-line rows with an avatar, so they get
+// their own width instead of the nav's: one shared value is either too narrow
+// for the rows or too wide for the nav's short labels.
+const LIST_COLUMN_WIDTH_DEFAULT = 320
+const LIST_COLUMN_WIDTH_MIN = 280
+const LIST_COLUMN_WIDTH_MAX = 480
+const LIST_COLUMN_WIDTH_STORAGE_KEY = "list_column_width"
const SIDEBAR_WIDTH_MOBILE = "18rem"
const SIDEBAR_WIDTH_ICON = "3rem"
const SIDEBAR_DRAG_THRESHOLD = 2
@@ -58,6 +65,36 @@ function clampSidebarWidth(width: number) {
return Math.max(SIDEBAR_WIDTH_MIN, Math.min(SIDEBAR_WIDTH_MAX, width))
}
+function clampListColumnWidth(width: number) {
+ return Math.max(LIST_COLUMN_WIDTH_MIN, Math.min(LIST_COLUMN_WIDTH_MAX, width))
+}
+
+function useStoredWidth(
+ storageKey: string,
+ defaultWidth: number,
+ clamp: (width: number) => number
+) {
+ const [width, setWidth] = React.useState(defaultWidth)
+ React.useEffect(() => {
+ const stored = localStorage.getItem(storageKey)
+ if (stored) {
+ const storedWidth = Number(stored)
+ if (Number.isFinite(storedWidth)) {
+ setWidth(clamp(storedWidth))
+ }
+ }
+ }, [storageKey, clamp])
+ const commit = React.useCallback(
+ (w: number) => {
+ const clamped = clamp(w)
+ setWidth(clamped)
+ localStorage.setItem(storageKey, String(clamped))
+ },
+ [storageKey, clamp]
+ )
+ return [width, commit] as const
+}
+
type SidebarContextProps = {
state: "expanded" | "collapsed"
open: boolean
@@ -85,6 +122,7 @@ type SidebarContextProps = {
type SidebarResizeContextProps = {
commitWidth: (width: number) => void
+ commitListWidth: (width: number) => void
}
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
@@ -141,21 +179,16 @@ function SidebarProvider({
const isCompact = useIsCompact()
const [openMobile, setOpenMobile] = React.useState(false)
- const [width, _setWidth] = React.useState(SIDEBAR_WIDTH_DEFAULT)
- React.useEffect(() => {
- const stored = localStorage.getItem(SIDEBAR_WIDTH_STORAGE_KEY)
- if (stored) {
- const storedWidth = Number(stored)
- if (Number.isFinite(storedWidth)) {
- _setWidth(clampSidebarWidth(storedWidth))
- }
- }
- }, [])
- const commitWidth = React.useCallback((w: number) => {
- const clamped = clampSidebarWidth(w)
- _setWidth(clamped)
- localStorage.setItem(SIDEBAR_WIDTH_STORAGE_KEY, String(clamped))
- }, [])
+ const [width, commitWidth] = useStoredWidth(
+ SIDEBAR_WIDTH_STORAGE_KEY,
+ SIDEBAR_WIDTH_DEFAULT,
+ clampSidebarWidth
+ )
+ const [listWidth, commitListWidth] = useStoredWidth(
+ LIST_COLUMN_WIDTH_STORAGE_KEY,
+ LIST_COLUMN_WIDTH_DEFAULT,
+ clampListColumnWidth
+ )
// This is the internal state of the sidebar.
// We use openProp and setOpenProp for control from outside the component.
@@ -248,8 +281,9 @@ function SidebarProvider({
const resizeContextValue = React.useMemo<SidebarResizeContextProps>(
() => ({
commitWidth,
+ commitListWidth,
}),
- [commitWidth]
+ [commitWidth, commitListWidth]
)
return (
@@ -260,6 +294,7 @@ function SidebarProvider({
style={
{
"--sidebar-width": `${width}px`,
+ "--list-column-width": `${listWidth}px`,
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
...style,
} as React.CSSProperties
@@ -1007,6 +1042,7 @@ export {
SidebarRail,
SidebarSeparator,
SidebarTrigger,
+ clampListColumnWidth,
clampSidebarWidth,
useSidebar,
useSidebarResize,
diff --git a/packages/views/chat/chat-page.tsx b/packages/views/chat/chat-page.tsx
index b66f991c71..2425d2df1b 100644
--- a/packages/views/chat/chat-page.tsx
+++ b/packages/views/chat/chat-page.tsx
@@ -458,7 +458,7 @@ export function ChatPage() {
const hasTarget = !!c.activeSessionId || composingNew;
return (
<div className="flex min-h-0 flex-1">
- <ListColumn collapsed={listCollapsed}>
+ <ListColumn collapsed={listCollapsed} width="list">
{listHeader}
<div className="flex-1 min-h-0 overflow-y-auto">{listBody}</div>
</ListColumn>
diff --git a/packages/views/inbox/components/inbox-list-item.tsx b/packages/views/inbox/components/inbox-list-item.tsx
index 07344c6fe6..7b2e4d7a96 100644
--- a/packages/views/inbox/components/inbox-list-item.tsx
+++ b/packages/views/inbox/components/inbox-list-item.tsx
@@ -126,7 +126,7 @@ export function InboxListItem({
onContextMenu={
openContextMenu ? (e) => openContextMenu(item, e) : undefined
}
- className={`group flex w-full cursor-default select-none items-center gap-3 rounded-md px-2 py-2.5 text-left outline-none transition-colors focus-visible:ring-1 focus-visible:ring-ring ${
+ className={`group flex w-full cursor-default select-none items-center gap-2.5 rounded-md px-2 py-2.5 text-left outline-none transition-colors focus-visible:ring-1 focus-visible:ring-ring ${
isSelected
? "bg-accent"
: "hover:bg-accent/50 data-[popup-open]:bg-accent/50"
@@ -172,23 +172,6 @@ export function InboxListItem({
}
/>
<InboxRowMenu item={item} view={view} />
- {item.issue_status && (
- // Icon-only, like every other issue row — but a colour is not a
- // name, and this row has no space for the CustomStatusChip the
- // board card and list row carry. `title` is that name.
- <span
- title={statusLabelOf(item.issue_status)}
- className="flex shrink-0 items-center"
- >
- <StatusIcon
- status={item.issue_status}
- category={statusCategoryOf(item.issue_status)}
- color={statusColor}
- icon={item.issue_status ? statusIconOf(item.issue_status) : null}
- className="h-3.5 w-3.5 shrink-0"
- />
- </span>
- )}
</div>
</div>
<div className="mt-0.5 flex items-center justify-between gap-2">
@@ -207,6 +190,25 @@ export function InboxListItem({
hoverCard={false}
/>
)}
+ {/* On the detail line rather than the title's, so the title keeps
+ the whole first line to itself. */}
+ {item.issue_status && (
+ // Icon-only, like every other issue row — but a colour is not a
+ // name, and this row has no space for the CustomStatusChip the
+ // board card and list row carry. `title` is that name.
+ <span
+ title={statusLabelOf(item.issue_status)}
+ className="flex shrink-0 items-center"
+ >
+ <StatusIcon
+ status={item.issue_status}
+ category={statusCategoryOf(item.issue_status)}
+ color={statusColor}
+ icon={item.issue_status ? statusIconOf(item.issue_status) : null}
+ className="h-3.5 w-3.5 shrink-0"
+ />
+ </span>
+ )}
<span className={`text-caption ${showUnread ? "text-muted-foreground" : "text-muted-foreground"}`}>
{timeAgo(item.created_at)}
</span>
diff --git a/packages/views/inbox/components/inbox-page.test.tsx b/packages/views/inbox/components/inbox-page.test.tsx
index 514c60055f..df17732dc1 100644
--- a/packages/views/inbox/components/inbox-page.test.tsx
+++ b/packages/views/inbox/components/inbox-page.test.tsx
@@ -322,16 +322,16 @@ describe("InboxPage", () => {
expect(screen.queryByTestId("row")).toBeNull();
});
- // The list takes the space panel's width, so its divider lines up with the
- // panel's when switching spaces.
- it("sizes the desktop list with the shared panel width", () => {
+ // Inbox rows need more room than the nav's labels, so the list is sized by
+ // the list width rather than the space panel's.
+ it("sizes the desktop list with the list column width", () => {
reset();
layout.width = DESKTOP;
const { container } = render(<InboxPage />);
expect(container.querySelector("[data-slot='list-column']")).toHaveClass(
- "w-(--sidebar-width)",
+ "w-[min(var(--list-column-width),40vw)]",
);
});
diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsx
index 0f3745bb48..85b0baca6f 100644
--- a/packages/views/inbox/components/inbox-page.tsx
+++ b/packages/views/inbox/components/inbox-page.tsx
@@ -1032,7 +1032,7 @@ export function InboxPage() {
if (viewLoading) {
return (
<div className="flex min-h-0 flex-1">
- <ListColumn collapsed={listCollapsed}>
+ <ListColumn collapsed={listCollapsed} width="list">
<div className="flex h-12 shrink-0 items-center pl-5 pr-2">
<Skeleton className="h-5 w-16" />
</div>
@@ -1058,7 +1058,7 @@ export function InboxPage() {
return (
<div className="flex min-h-0 flex-1">
- <ListColumn collapsed={listCollapsed}>{listPanel}</ListColumn>
+ <ListColumn collapsed={listCollapsed} width="list">{listPanel}</ListColumn>
<div className="flex h-full min-h-0 min-w-0 flex-1 flex-col">
{detailContent ?? (
<>
diff --git a/packages/views/layout/list-column.test.tsx b/packages/views/layout/list-column.test.tsx
index 90bc40dc75..7bde55749a 100644
--- a/packages/views/layout/list-column.test.tsx
+++ b/packages/views/layout/list-column.test.tsx
@@ -33,6 +33,49 @@ describe("ListColumn", () => {
expect(shell?.listCollapsed).toBe(true);
});
+ it("sizes a list column by its own width and commits drags there", () => {
+ localStorage.clear();
+ const { container } = renderWithI18n(
+ <SidebarProvider>
+ <AppShellProvider>
+ <ListColumn width="list">list</ListColumn>
+ </AppShellProvider>
+ </SidebarProvider>,
+ );
+ const wrapper = container.querySelector<HTMLElement>("[data-slot='sidebar-wrapper']")!;
+ const column = container.querySelector<HTMLElement>("[data-slot='list-column']")!;
+ expect(column).toHaveClass("w-[min(var(--list-column-width),40vw)]");
+ expect(wrapper.style.getPropertyValue("--list-column-width")).toBe("320px");
+
+ const handle = container.querySelector<HTMLElement>("[data-slot='space-panel-resize']")!;
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({ width: 320 } as DOMRect);
+ fireEvent.pointerDown(handle, { button: 0, isPrimary: true, pointerId: 1, clientX: 320 });
+ act(() => {
+ document.dispatchEvent(new PointerEvent("pointermove", { pointerId: 1, clientX: 700 }));
+ });
+ expect(column.style.getPropertyValue("--list-column-width")).toBe("480px");
+ act(() => {
+ document.dispatchEvent(new PointerEvent("pointerup", { pointerId: 1, clientX: 700 }));
+ });
+
+ expect(localStorage.getItem("list_column_width")).toBe("480");
+ expect(localStorage.getItem("sidebar_width")).toBeNull();
+ expect(wrapper.style.getPropertyValue("--list-column-width")).toBe("480px");
+ expect(wrapper.style.getPropertyValue("--sidebar-width")).toBe("240px");
+ });
+
+ it("restores a stored list width within its bounds", () => {
+ localStorage.setItem("list_column_width", "900");
+ const { container } = renderWithI18n(
+ <SidebarProvider>
+ <ListColumn width="list">list</ListColumn>
+ </SidebarProvider>,
+ );
+ const wrapper = container.querySelector<HTMLElement>("[data-slot='sidebar-wrapper']")!;
+ expect(wrapper.style.getPropertyValue("--list-column-width")).toBe("480px");
+ localStorage.clear();
+ });
+
it("renders without a resize edge outside the shell", () => {
const { container } = renderWithI18n(<ListColumn>list</ListColumn>);
expect(container.querySelector("[data-slot='space-panel-resize']")).toBeNull();
diff --git a/packages/views/layout/list-column.tsx b/packages/views/layout/list-column.tsx
index 9149c6d300..4a61fa4f12 100644
--- a/packages/views/layout/list-column.tsx
+++ b/packages/views/layout/list-column.tsx
@@ -4,22 +4,31 @@ import { useRef } from "react";
import { useSidebarSafe } from "@multica/ui/components/ui/sidebar";
import { cn } from "@multica/ui/lib/utils";
import { useAppShell } from "./app-shell-context";
-import { PanelResizeHandle } from "./panel-resize-handle";
-import { NAV_COLUMN_MOTION_CLASS, NAV_PEEK_CLASS } from "./rail-styles";
+import { PanelResizeHandle, type PanelWidth } from "./panel-resize-handle";
+import { LIST_COLUMN_WIDTH_CLASS, NAV_COLUMN_MOTION_CLASS, NAV_PEEK_CLASS } from "./rail-styles";
+
+const WIDTH_CLASS: Record<PanelWidth, string> = {
+ nav: "w-(--sidebar-width)",
+ list: LIST_COLUMN_WIDTH_CLASS,
+};
/**
* The list column of a list-and-detail page (Inbox, Chat, Settings). It takes
- * the space panel's width, resize edge and collapse motion, so the column's
- * divider stays put when switching between spaces and one drag resizes them
- * all. It stays mounted while collapsed, keeping the list's scroll position.
+ * the space panel's resize edge and collapse motion. A `nav` column (Settings)
+ * also takes the panel's width, so its divider stays put when switching
+ * spaces; a `list` column (Inbox, Chat) shares the wider list width instead,
+ * because its rows carry far more than the nav's labels. It stays mounted
+ * while collapsed, keeping the list's scroll position.
*/
export function ListColumn({
collapsed = false,
+ width = "nav",
className,
innerClassName,
children,
}: {
collapsed?: boolean;
+ width?: PanelWidth;
className?: string;
innerClassName?: string;
children: React.ReactNode;
@@ -43,7 +52,7 @@ export function ListColumn({
className={cn(
"relative flex h-full shrink-0 justify-end",
NAV_COLUMN_MOTION_CLASS,
- collapsed ? "w-0" : "w-(--sidebar-width)",
+ collapsed ? "w-0" : WIDTH_CLASS[width],
!peeking && "overflow-hidden",
className,
)}
@@ -53,8 +62,9 @@ export function ListColumn({
onPointerEnter={peeking ? shell.holdPeek : undefined}
onPointerLeave={peeking ? shell.releasePeek : undefined}
className={cn(
- "flex h-full w-(--sidebar-width) shrink-0 flex-col overflow-hidden",
+ "flex h-full shrink-0 flex-col overflow-hidden",
peeking ? NAV_PEEK_CLASS : cn("border-r", innerClassName),
+ WIDTH_CLASS[width],
)}
>
{children}
@@ -62,7 +72,7 @@ export function ListColumn({
</aside>
{!collapsed && sidebar && !sidebar.isCompact && onToggle && (
<div className="relative w-0 shrink-0">
- <PanelResizeHandle panelRef={ref} onToggle={onToggle} />
+ <PanelResizeHandle panelRef={ref} onToggle={onToggle} width={width} />
</div>
)}
</>
diff --git a/packages/views/layout/panel-resize-handle.tsx b/packages/views/layout/panel-resize-handle.tsx
index e91bd0c85e..8b11bafb1e 100644
--- a/packages/views/layout/panel-resize-handle.tsx
+++ b/packages/views/layout/panel-resize-handle.tsx
@@ -2,6 +2,7 @@
import { useCallback, useEffect, useRef } from "react";
import {
+ clampListColumnWidth,
clampSidebarWidth,
useSidebarResize,
} from "@multica/ui/components/ui/sidebar";
@@ -9,21 +10,35 @@ import { useT } from "../i18n";
const RESIZE_DRAG_THRESHOLD = 2;
+/**
+ * Which committed width a column is sized by: `nav` is `--sidebar-width`, the
+ * space panel's; `list` is `--list-column-width`, shared by the list columns
+ * whose rows need more room than the nav's labels (Inbox, Chat).
+ */
+export type PanelWidth = "nav" | "list";
+
+const WIDTH_VARIABLE: Record<PanelWidth, string> = {
+ nav: "--sidebar-width",
+ list: "--list-column-width",
+};
+
/**
* A column's trailing edge: drag to resize, click to collapse. Every column
- * sized by `--sidebar-width` shares the one committed width. The preview
+ * sized by the same width variable shares the one committed width. The preview
* writes the width straight onto the panel element and commits once on
* release, so a drag re-renders nothing until the pointer comes up.
*/
export function PanelResizeHandle({
panelRef,
onToggle,
+ width = "nav",
}: {
panelRef: React.RefObject<HTMLElement | null>;
onToggle: () => void;
+ width?: PanelWidth;
}) {
const { t } = useT("ui");
- const { commitWidth } = useSidebarResize();
+ const { commitWidth, commitListWidth } = useSidebarResize();
const cancelRef = useRef<(() => void) | null>(null);
const draggedRef = useRef(false);
@@ -36,10 +51,13 @@ export function PanelResizeHandle({
e.preventDefault();
cancelRef.current?.();
draggedRef.current = false;
+ const clamp = width === "list" ? clampListColumnWidth : clampSidebarWidth;
+ const commit = width === "list" ? commitListWidth : commitWidth;
+ const variable = WIDTH_VARIABLE[width];
const handle = e.currentTarget;
const pointerId = e.pointerId;
const startX = e.clientX;
- const startWidth = clampSidebarWidth(panel.getBoundingClientRect().width);
+ const startWidth = clamp(panel.getBoundingClientRect().width);
let latestWidth = startWidth;
document.documentElement.setAttribute("data-sidebar-resizing", "true");
@@ -49,8 +67,8 @@ export function PanelResizeHandle({
document.removeEventListener("pointercancel", onCancel);
window.removeEventListener("blur", onBlur);
document.documentElement.removeAttribute("data-sidebar-resizing");
- if (mode === "commit" && draggedRef.current) commitWidth(latestWidth);
- panel.style.removeProperty("--sidebar-width");
+ if (mode === "commit" && draggedRef.current) commit(latestWidth);
+ panel.style.removeProperty(variable);
cancelRef.current = null;
if (handle.hasPointerCapture?.(pointerId)) handle.releasePointerCapture?.(pointerId);
};
@@ -59,10 +77,10 @@ export function PanelResizeHandle({
const delta = event.clientX - startX;
if (!draggedRef.current && Math.abs(delta) < RESIZE_DRAG_THRESHOLD) return;
draggedRef.current = true;
- const next = clampSidebarWidth(startWidth + delta);
+ const next = clamp(startWidth + delta);
if (next === latestWidth) return;
latestWidth = next;
- panel.style.setProperty("--sidebar-width", `${next}px`);
+ panel.style.setProperty(variable, `${next}px`);
};
const onUp = (event: PointerEvent) => {
if (event.pointerId === pointerId) finish("commit");
@@ -79,7 +97,7 @@ export function PanelResizeHandle({
cancelRef.current = () => finish("cancel");
handle.setPointerCapture?.(pointerId);
},
- [commitWidth, panelRef],
+ [commitListWidth, commitWidth, panelRef, width],
);
return (
diff --git a/packages/views/layout/rail-styles.ts b/packages/views/layout/rail-styles.ts
index 67e346bdd5..b6cec484a3 100644
--- a/packages/views/layout/rail-styles.ts
+++ b/packages/views/layout/rail-styles.ts
@@ -10,6 +10,13 @@
export const NAV_COLUMN_MOTION_CLASS =
"transition-[width] duration-(--nav-panel-duration) ease-(--nav-panel-easing) motion-reduce:transition-none";
+/**
+ * The Inbox and Chat list width. Capped against the viewport so a column
+ * dragged wide on a large display leaves the detail pane usable on a smaller
+ * one.
+ */
+export const LIST_COLUMN_WIDTH_CLASS = "w-[min(var(--list-column-width),40vw)]";
+
/** A collapsed panel or list column previewed over the card's leading edge. */
export const NAV_PEEK_CLASS =
"absolute inset-y-0 left-0 z-30 flex w-(--sidebar-width) flex-col overflow-hidden rounded-xl bg-page-canvas shadow-[var(--floating-shadow)] ring-1 ring-surface-border";
diff --git a/packages/views/layout/space-panel.tsx b/packages/views/layout/space-panel.tsx
index 23befaf79b..a529ae94ee 100644
--- a/packages/views/layout/space-panel.tsx
+++ b/packages/views/layout/space-panel.tsx
@@ -8,7 +8,7 @@ import { useAppShell } from "./app-shell-context";
import { PanelResizeHandle } from "./panel-resize-handle";
import { AutopilotsPanel } from "./panels/autopilots-panel";
import { ChatPeek, InboxPeek } from "./panels/list-space-peeks";
-import { NAV_COLUMN_MOTION_CLASS, NAV_PEEK_CLASS } from "./rail-styles";
+import { LIST_COLUMN_WIDTH_CLASS, NAV_COLUMN_MOTION_CLASS, NAV_PEEK_CLASS } from "./rail-styles";
import { TeamPanel } from "./panels/team-panel";
import { KeptRowsRelease, WorkPanel } from "./panels/work-panel";
@@ -19,12 +19,15 @@ const PANELS: Partial<Record<AppSpaceId, () => React.ReactNode>> = {
};
// Inbox and Chat keep their lists in their pages, so from another space they
-// preview through a standalone copy of the list.
-const PEEKS: Partial<Record<AppSpaceId, () => React.ReactNode>> = {
- ...PANELS,
+// preview through a standalone copy of the list, at the list width.
+const LIST_PEEKS: Partial<Record<AppSpaceId, () => React.ReactNode>> = {
inbox: InboxPeek,
chat: ChatPeek,
};
+const PEEKS: Partial<Record<AppSpaceId, () => React.ReactNode>> = {
+ ...PANELS,
+ ...LIST_PEEKS,
+};
/** The current space's panel content, or null for spaces without one. */
export function SpacePanelContent({ space }: { space: AppSpaceId | null }) {
@@ -35,8 +38,8 @@ export function SpacePanelContent({ space }: { space: AppSpaceId | null }) {
/**
* The space panel inside the content card: a column on the card's leading
* edge, separated from the page by one hairline. Spaces without a shell
- * panel (Inbox, Chat, Settings) render their own `ListColumn` at the same
- * width instead, so nothing mounts for them. While collapsed, hovering a rail space previews
+ * panel (Inbox, Chat, Settings) render their own `ListColumn` instead, so
+ * nothing mounts for them. While collapsed, hovering a rail space previews
* its panel over the page.
*/
export function SpacePanel() {
@@ -83,7 +86,11 @@ export function SpacePanel() {
data-slot="space-panel-peek"
onPointerEnter={shell.holdPeek}
onPointerLeave={shell.releasePeek}
- className={cn(NAV_PEEK_CLASS, "max-md:hidden")}
+ className={cn(
+ NAV_PEEK_CLASS,
+ "max-md:hidden",
+ peekSpace && LIST_PEEKS[peekSpace] && LIST_COLUMN_WIDTH_CLASS,
+ )}
>
<Peek />
</aside>