Skip to content

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

Go

feat(ui): Motion Wave 2 — drag settle, sidebar/peek collapse, Desktop tab close & ⌘K drill-down (MUL-9952) (#11299)

Jiayuan Zhang7af9e79cec53
diff --git a/apps/desktop/src/renderer/src/components/desktop-layout.tsx b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
index 13f1926974..eadaa1067d 100644
--- a/apps/desktop/src/renderer/src/components/desktop-layout.tsx
+++ b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
@@ -1,5 +1,8 @@
import { useEffect, useRef, useSyncExternalStore } from "react";
+import { AnimatePresence, motion, useIsPresent } from "motion/react";
import { useQuery } from "@tanstack/react-query";
+import { useReducedMotion } from "@multica/core/appearance";
+import { UI_EASE_OUT } from "@multica/ui/lib/motion";
import { cn } from "@multica/ui/lib/utils";
import { MulticaIcon } from "@multica/ui/components/common/multica-icon";
import {
@@ -105,6 +108,44 @@ function MainTopBar({ railMounted }: { railMounted: boolean }) {
);
}
+const CURTAIN_ENTER_DURATION = 0.16;
+const CURTAIN_EXIT_DURATION = 0.14;
+
+function WorkspaceLoadingCurtain({
+ label,
+ reduceMotion,
+}: {
+ label: string;
+ reduceMotion: boolean;
+}) {
+ const isPresent = useIsPresent();
+ return (
+ <motion.div
+ aria-label={label}
+ aria-live="polite"
+ role="status"
+ initial={reduceMotion ? false : { opacity: 0 }}
+ animate={{
+ opacity: 1,
+ transition: { duration: reduceMotion ? 0 : CURTAIN_ENTER_DURATION, ease: UI_EASE_OUT },
+ }}
+ exit={{
+ opacity: 0,
+ transition: { duration: reduceMotion ? 0 : CURTAIN_EXIT_DURATION, ease: UI_EASE_OUT },
+ }}
+ className={cn(
+ "absolute inset-0 z-20 flex items-center justify-center bg-page-canvas",
+ !isPresent && "pointer-events-none",
+ )}
+ >
+ <div className="flex flex-col items-center gap-4">
+ <MulticaIcon mode="think" size={40} />
+ <p className="text-body text-muted-foreground">{label}</p>
+ </div>
+ </motion.div>
+ );
+}
+
// The content card: the space panel and the tab content share one surface,
// split by a single hairline. It hugs the rail; without one (compact, or no
// workspace yet) it mirrors the fixed mr-2 so it sits centred in the frame.
@@ -119,6 +160,7 @@ function MainCanvas({
}) {
const { isCompact } = useSidebar();
const { t } = useT("layout");
+ const reduceMotion = useReducedMotion();
const loadingLabel = t(($) => $.workspace_loader.loading_workspace);
return (
@@ -137,18 +179,20 @@ function MainCanvas({
<div className="relative flex min-w-0 flex-1 flex-col overflow-hidden">
{children}
</div>
- {showWorkspaceLoading && (
- <div
- aria-label={loadingLabel}
- aria-live="polite"
- className="absolute inset-0 z-20 flex items-center justify-center bg-page-canvas"
- role="status"
- >
- <div className="flex flex-col items-center gap-4">
- <MulticaIcon mode="think" size={40} />
- <p className="text-body text-muted-foreground">{loadingLabel}</p>
- </div>
- </div>
+ {reduceMotion ? (
+ showWorkspaceLoading && (
+ <WorkspaceLoadingCurtain label={loadingLabel} reduceMotion />
+ )
+ ) : (
+ <AnimatePresence initial={false}>
+ {showWorkspaceLoading && (
+ <WorkspaceLoadingCurtain
+ key="workspace-loading-curtain"
+ label={loadingLabel}
+ reduceMotion={false}
+ />
+ )}
+ </AnimatePresence>
)}
</div>
);
diff --git a/apps/desktop/src/renderer/src/components/tab-bar.test.tsx b/apps/desktop/src/renderer/src/components/tab-bar.test.tsx
index 8d193190a3..e01ec48f8d 100644
--- a/apps/desktop/src/renderer/src/components/tab-bar.test.tsx
+++ b/apps/desktop/src/renderer/src/components/tab-bar.test.tsx
@@ -242,7 +242,7 @@ describe("TabBar hover action buttons", () => {
...getAllByLabelText("Pin tab"),
...getAllByLabelText("Close tab"),
]) {
- expect(button).toHaveClass("hidden", "group-hover:flex", "group-active:flex");
+ expect(button).toHaveClass("opacity-0", "group-hover:opacity-100", "group-active:opacity-100");
}
});
diff --git a/apps/desktop/src/renderer/src/components/tab-bar.tsx b/apps/desktop/src/renderer/src/components/tab-bar.tsx
index ad32e414ec..985b9d16f8 100644
--- a/apps/desktop/src/renderer/src/components/tab-bar.tsx
+++ b/apps/desktop/src/renderer/src/components/tab-bar.tsx
@@ -1,13 +1,13 @@
import {
- Fragment,
useEffect,
useLayoutEffect,
useRef,
useState,
type RefObject,
} from "react";
-import { motion } from "motion/react";
+import { AnimatePresence, motion, useIsPresent } from "motion/react";
import { useReducedMotion } from "@multica/core/appearance";
+import { UI_EASE_OUT } from "@multica/ui/lib/motion";
import { toast } from "sonner";
import { X, Plus, Pin, PinOff, ListX, ListEnd, AppWindow, Link2 } from "@multica/ui/icons";
import { copyText } from "@multica/ui/lib/clipboard";
@@ -51,6 +51,8 @@ import { parseIssueWindowPath } from "../../../shared/issue-window";
const TAB_SCROLL_FADE_SIZE = 24;
const TAB_ENTRY_EASE = [0.22, 1, 0.36, 1] as const;
+const TAB_CLOSE_DURATION = 0.14;
+const TAB_GAP_PX = 6;
type TabSnapshot = {
workspaceSlug: string | null;
@@ -202,6 +204,7 @@ function SortableTabItem({
if (tab.title !== title) updateTab(tab.id, { title });
}, [titleResolved, title, tab.id, tab.title, updateTab]);
+ const isPresent = useIsPresent();
const {
attributes,
listeners,
@@ -209,7 +212,7 @@ function SortableTabItem({
transform,
transition,
isDragging,
- } = useSortable({ id: tab.id });
+ } = useSortable({ id: tab.id, disabled: !isPresent });
// Pin is a secondary interaction state, not an identity: a pinned tab keeps
// its resource visual (a project's icon, an issue's status, an actor's
@@ -311,143 +314,168 @@ function SortableTabItem({
pointerdown (electron/electron#55100); that drops :hover, hides the
button before mouseup, and the click lands on the tab instead. */}
<span
- onClick={handleTogglePin}
- onPointerDown={stopDragOnAction}
- role="button"
- aria-label={pinLabel}
- title={pinLabel}
- className="hidden size-3.5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors group-hover:flex group-active:flex hover:bg-muted-foreground/20 hover:text-foreground"
+ className={cn(
+ "pointer-events-none absolute inset-y-1.5 right-1.5 flex items-center gap-0.5 rounded-r-lg pl-3 opacity-0 transition-opacity duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none group-hover:opacity-100 group-active:opacity-100",
+ isActive
+ ? "bg-gradient-to-l from-page-canvas via-page-canvas/95 to-transparent"
+ : "bg-gradient-to-l from-page-canvas/90 via-page-canvas/80 to-transparent",
+ )}
>
- {tab.pinned ? <PinOff className="size-2.5" /> : <Pin className="size-2.5" />}
- </span>
- {showCloseButton && (
<span
- onClick={handleClose}
+ onClick={handleTogglePin}
onPointerDown={stopDragOnAction}
role="button"
- aria-label={closeLabel}
- className="hidden size-3.5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors group-hover:flex group-active:flex hover:bg-muted-foreground/20 hover:text-foreground"
+ aria-label={pinLabel}
+ title={pinLabel}
+ className="pointer-events-none flex size-3.5 shrink-0 items-center justify-center rounded-sm text-muted-foreground opacity-0 transition-[opacity,color,background-color] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none group-hover:pointer-events-auto group-hover:opacity-100 group-active:pointer-events-auto group-active:opacity-100 hover:bg-muted-foreground/20 hover:text-foreground"
>
- <X className="size-2.5" />
+ {tab.pinned ? <PinOff className="size-2.5" /> : <Pin className="size-2.5" />}
</span>
- )}
+ {showCloseButton && (
+ <span
+ onClick={handleClose}
+ onPointerDown={stopDragOnAction}
+ role="button"
+ aria-label={closeLabel}
+ className="pointer-events-none flex size-3.5 shrink-0 items-center justify-center rounded-sm text-muted-foreground opacity-0 transition-[opacity,color,background-color] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none group-hover:pointer-events-auto group-hover:opacity-100 group-active:pointer-events-auto group-active:opacity-100 hover:bg-muted-foreground/20 hover:text-foreground"
+ >
+ <X className="size-2.5" />
+ </span>
+ )}
+ </span>
</button>
);
return (
- <div
- ref={setNodeRef}
- style={style}
+ <motion.div
+ initial={false}
+ exit={
+ shouldReduceMotion
+ ? { opacity: 0, transition: { duration: 0 } }
+ : {
+ width: 0,
+ minWidth: 0,
+ opacity: 0,
+ marginRight: -TAB_GAP_PX,
+ transition: { duration: TAB_CLOSE_DURATION, ease: UI_EASE_OUT },
+ }
+ }
data-tab-frame
data-tab-id={tab.id}
data-mc="tab"
data-active={isActive ? "true" : "false"}
data-pinned={tab.pinned ? "true" : "false"}
- className={cn("h-full w-56 min-w-32", isActive && "z-10")}
+ className={cn(
+ "h-full w-56 min-w-32",
+ isActive && "z-10",
+ !isPresent && "pointer-events-none overflow-hidden",
+ )}
>
- <motion.div
- className="group/tab relative size-full"
- initial={isEntering ? { opacity: 0, x: 8 } : false}
- animate={{ opacity: 1, x: 0 }}
- transition={{ duration: isEntering ? 0.18 : 0, ease: TAB_ENTRY_EASE }}
- onAnimationComplete={() => setIsEntering(false)}
- >
- {/* Every tab is a pill on the title bar; the active one is made of
- the content card's own material so it reads as the card's tab
- without having to join it. */}
- <span
- aria-hidden
- className={cn(
- "pointer-events-none absolute inset-x-0 inset-y-1.5 rounded-lg transition-colors",
- isActive
- ? "bg-page-canvas shadow-[var(--surface-shadow)] ring-1 ring-surface-border"
- : "bg-page-canvas/50 group-hover/tab:bg-page-canvas/80",
- isDragging && "opacity-60",
- )}
- />
- <ContextMenu>
- <TooltipHint label={tab.pinned ? tabName : undefined} side="bottom">
- <ContextMenuTrigger render={tabButton} />
- </TooltipHint>
- <ContextMenuContent>
- {issueWindowPath && (
- <>
- <ContextMenuItem onClick={handleOpenAsWindow}>
- <AppWindow />
- {openWindowLabel}
- </ContextMenuItem>
- <ContextMenuSeparator />
- </>
+ <div ref={setNodeRef} style={style} className="size-full">
+ <motion.div
+ className="group/tab relative size-full"
+ initial={isEntering ? { opacity: 0, x: 8 } : false}
+ animate={{ opacity: 1, x: 0 }}
+ transition={{ duration: isEntering ? 0.18 : 0, ease: TAB_ENTRY_EASE }}
+ onAnimationComplete={() => setIsEntering(false)}
+ >
+ {/* Every tab is a pill on the title bar; the active one is made of
+ the content card's own material so it reads as the card's tab
+ without having to join it. */}
+ <span
+ aria-hidden
+ className={cn(
+ "pointer-events-none absolute inset-x-0 inset-y-1.5 rounded-lg transition-[background-color,box-shadow,opacity] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none",
+ isActive
+ ? "bg-page-canvas shadow-[var(--surface-shadow)] ring-1 ring-surface-border"
+ : "bg-page-canvas/50 group-hover/tab:bg-page-canvas/80",
+ isDragging && "opacity-60",
)}
- <ContextMenuItem onClick={() => togglePin(tab.id)}>
- {tab.pinned ? (
- <>
- <PinOff />
- {pinLabel}
- </>
- ) : (
+ />
+ <ContextMenu>
+ <TooltipHint label={tab.pinned ? tabName : undefined} side="bottom">
+ <ContextMenuTrigger render={tabButton} />
+ </TooltipHint>
+ <ContextMenuContent>
+ {issueWindowPath && (
<>
- <Pin />
- {pinLabel}
+ <ContextMenuItem onClick={handleOpenAsWindow}>
+ <AppWindow />
+ {openWindowLabel}
+ </ContextMenuItem>
+ <ContextMenuSeparator />
</>
)}
- </ContextMenuItem>
- <ContextMenuItem onClick={handleCopyLink}>
- <Link2 />
- {t(($) => $.desktop.tab_bar.copy_link)}
- </ContextMenuItem>
- <ContextMenuSeparator />
- <ContextMenuItem
- variant="destructive"
- disabled={tab.pinned || isOnly}
- onClick={() => closeTab(tab.id)}
- >
- <X />
- {closeLabel}
- </ContextMenuItem>
- <ContextMenuItem
- variant="destructive"
- disabled={!canCloseOthers}
- onClick={() => closeOtherTabs(tab.id)}
- >
- <ListX />
- {closeOthersLabel}
- </ContextMenuItem>
- <ContextMenuItem
- variant="destructive"
- disabled={!canCloseRight}
- onClick={() => closeTabsToRight(tab.id)}
- >
- <ListEnd />
- {t(($) => $.desktop.tab_bar.close_right)}
- </ContextMenuItem>
- </ContextMenuContent>
- </ContextMenu>
- {showAddedHighlight && (
- <motion.span
- aria-hidden
- className="pointer-events-none absolute inset-x-0 inset-y-1.5 rounded-lg bg-primary/10 ring-1 ring-inset ring-primary/20"
- initial={{ opacity: shouldReduceMotion ? 0.25 : 0.65 }}
- animate={{ opacity: 0 }}
- transition={{ duration: shouldReduceMotion ? 0.16 : 0.42 }}
- onAnimationComplete={() => setShowAddedHighlight(false)}
- />
- )}
- {attentionSequence > 0 && (
- // Keyed so each background open of this tab replays the flash.
- <motion.span
- key={attentionSequence}
- aria-hidden
- data-tab-attention
- className="pointer-events-none absolute inset-x-0 inset-y-1.5 rounded-lg bg-brand/20 ring-2 ring-inset ring-brand/70"
- initial={{ opacity: 0 }}
- animate={{ opacity: shouldReduceMotion ? [0.5, 0] : [0, 1, 0, 1, 0] }}
- transition={{ duration: shouldReduceMotion ? 0.2 : 0.9, ease: "easeOut" }}
- onAnimationComplete={() => clearTabAttention(attentionSequence)}
- />
- )}
- </motion.div>
- </div>
+ <ContextMenuItem onClick={() => togglePin(tab.id)}>
+ {tab.pinned ? (
+ <>
+ <PinOff />
+ {pinLabel}
+ </>
+ ) : (
+ <>
+ <Pin />
+ {pinLabel}
+ </>
+ )}
+ </ContextMenuItem>
+ <ContextMenuItem onClick={handleCopyLink}>
+ <Link2 />
+ {t(($) => $.desktop.tab_bar.copy_link)}
+ </ContextMenuItem>
+ <ContextMenuSeparator />
+ <ContextMenuItem
+ variant="destructive"
+ disabled={tab.pinned || isOnly}
+ onClick={() => closeTab(tab.id)}
+ >
+ <X />
+ {closeLabel}
+ </ContextMenuItem>
+ <ContextMenuItem
+ variant="destructive"
+ disabled={!canCloseOthers}
+ onClick={() => closeOtherTabs(tab.id)}
+ >
+ <ListX />
+ {closeOthersLabel}
+ </ContextMenuItem>
+ <ContextMenuItem
+ variant="destructive"
+ disabled={!canCloseRight}
+ onClick={() => closeTabsToRight(tab.id)}
+ >
+ <ListEnd />
+ {t(($) => $.desktop.tab_bar.close_right)}
+ </ContextMenuItem>
+ </ContextMenuContent>
+ </ContextMenu>
+ {showAddedHighlight && (
+ <motion.span
+ aria-hidden
+ className="pointer-events-none absolute inset-x-0 inset-y-1.5 rounded-lg bg-primary/10 ring-1 ring-inset ring-primary/20"
+ initial={{ opacity: shouldReduceMotion ? 0.25 : 0.65 }}
+ animate={{ opacity: 0 }}
+ transition={{ duration: shouldReduceMotion ? 0.16 : 0.42 }}
+ onAnimationComplete={() => setShowAddedHighlight(false)}
+ />
+ )}
+ {attentionSequence > 0 && (
+ // Keyed so each background open of this tab replays the flash.
+ <motion.span
+ key={attentionSequence}
+ aria-hidden
+ data-tab-attention
+ className="pointer-events-none absolute inset-x-0 inset-y-1.5 rounded-lg bg-brand/20 ring-2 ring-inset ring-brand/70"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: shouldReduceMotion ? [0.5, 0] : [0, 1, 0, 1, 0] }}
+ transition={{ duration: shouldReduceMotion ? 0.2 : 0.9, ease: "easeOut" }}
+ onAnimationComplete={() => clearTabAttention(attentionSequence)}
+ />
+ )}
+ </motion.div>
+ </div>
+ </motion.div>
);
}
@@ -671,31 +699,36 @@ export function TabBar() {
style={tabFadeStyle}
>
<SortableContext items={tabIds} strategy={horizontalListSortingStrategy}>
- {tabs.map((tab, index) => (
- <Fragment key={tab.id}>
- <SortableTabItem
- tab={tab}
- isActive={tab.id === activeTabId}
- isOnly={tabs.length === 1}
- canCloseOthers={tabs.some(
- (candidate) => candidate.id !== tab.id && !candidate.pinned,
- )}
- canCloseRight={tabs.some(
- (candidate, i) => i > index && !candidate.pinned,
- )}
- isNew={addedTabIdSet.has(tab.id)}
- shouldReduceMotion={shouldReduceMotion}
- />
- {tab.pinned &&
- index === pinnedCount - 1 &&
- unpinnedCount > 0 && (
+ <AnimatePresence key={activeWorkspaceSlug ?? "none"}>
+ {tabs.flatMap((tab, index) => {
+ const nodes = [
+ <SortableTabItem
+ key={tab.id}
+ tab={tab}
+ isActive={tab.id === activeTabId}
+ isOnly={tabs.length === 1}
+ canCloseOthers={tabs.some(
+ (candidate) => candidate.id !== tab.id && !candidate.pinned,
+ )}
+ canCloseRight={tabs.some(
+ (candidate, i) => i > index && !candidate.pinned,
+ )}
+ isNew={addedTabIdSet.has(tab.id)}
+ shouldReduceMotion={shouldReduceMotion}
+ />,
+ ];
+ if (tab.pinned && index === pinnedCount - 1 && unpinnedCount > 0) {
+ nodes.push(
<div
+ key="__pinned-divider__"
aria-hidden
className="h-4 w-px shrink-0 bg-surface-border"
- />
- )}
- </Fragment>
- ))}
+ />,
+ );
+ }
+ return nodes;
+ })}
+ </AnimatePresence>
</SortableContext>
</div>
</DndContext>
diff --git a/apps/desktop/src/renderer/src/components/window-overlay.tsx b/apps/desktop/src/renderer/src/components/window-overlay.tsx
index 3e20276312..d16f417757 100644
--- a/apps/desktop/src/renderer/src/components/window-overlay.tsx
+++ b/apps/desktop/src/renderer/src/components/window-overlay.tsx
@@ -1,12 +1,19 @@
+import { AnimatePresence, motion, useIsPresent } from "motion/react";
import { useQuery } from "@tanstack/react-query";
+import { useReducedMotion } from "@multica/core/appearance";
+import { UI_EASE_IN, UI_EASE_OUT } from "@multica/ui/lib/motion";
+import { cn } from "@multica/ui/lib/utils";
import { InvitationsPage } from "@multica/views/invitations";
import { OnboardingFlow } from "@multica/views/onboarding";
import { useNavigation } from "@multica/views/navigation";
import { paths } from "@multica/core/paths";
import { workspaceListOptions } from "@multica/core/workspace/queries";
-import { useWindowOverlayStore } from "@/stores/window-overlay-store";
+import { useWindowOverlayStore, type WindowOverlay as WindowOverlayData } from "@/stores/window-overlay-store";
import { useLocalRuntimesPending } from "../platform/use-local-runtimes-pending";
+const OVERLAY_ENTER_DURATION = 0.18;
+const OVERLAY_EXIT_DURATION = 0.16;
+
/**
* Window-level transition overlay: renders above the tab system when the
* user is in a pre-workspace flow (onboarding, create workspace, accept
@@ -27,12 +34,33 @@ import { useLocalRuntimesPending } from "../platform/use-local-runtimes-pending"
*/
export function WindowOverlay() {
const overlay = useWindowOverlayStore((s) => s.overlay);
- if (!overlay) return null;
- return <WindowOverlayInner />;
+ const reduceMotion = useReducedMotion();
+
+ if (reduceMotion) {
+ return overlay ? <WindowOverlayInner overlay={overlay} reduceMotion /> : null;
+ }
+
+ return (
+ <AnimatePresence>
+ {overlay && (
+ <WindowOverlayInner
+ key={overlay.type}
+ overlay={overlay}
+ reduceMotion={false}
+ />
+ )}
+ </AnimatePresence>
+ );
}
-function WindowOverlayInner() {
- const overlay = useWindowOverlayStore((s) => s.overlay);
+function WindowOverlayInner({
+ overlay,
+ reduceMotion,
+}: {
+ overlay: NonNullable<WindowOverlayData>;
+ reduceMotion: boolean;
+}) {
+ const isPresent = useIsPresent();
const close = useWindowOverlayStore((s) => s.close);
const { push } = useNavigation();
const { data: wsList = [] } = useQuery(workspaceListOptions());
@@ -40,8 +68,6 @@ function WindowOverlayInner() {
// flash "no runtime found" while the daemon is still probing CLI versions.
const runtimesPending = useLocalRuntimesPending();
- if (!overlay) return null;
-
// Back is only meaningful when there's somewhere to go — i.e. the user
// has at least one workspace. Zero-workspace users can only Log out or
// complete the flow.
@@ -56,7 +82,21 @@ function WindowOverlayInner() {
};
return (
- <div className="fixed inset-0 z-50 flex flex-col overflow-auto bg-background">
+ <motion.div
+ initial={reduceMotion ? false : { opacity: 0 }}
+ animate={{
+ opacity: 1,
+ transition: { duration: reduceMotion ? 0 : OVERLAY_ENTER_DURATION, ease: UI_EASE_OUT },
+ }}
+ exit={{
+ opacity: 0,
+ transition: { duration: reduceMotion ? 0 : OVERLAY_EXIT_DURATION, ease: UI_EASE_IN },
+ }}
+ className={cn(
+ "fixed inset-0 z-50 flex flex-col overflow-auto bg-background",
+ !isPresent && "pointer-events-none",
+ )}
+ >
{/* Creating a workspace is the onboarding flow entered at the
workspace step: a second workspace still needs its own runtime and
its own Mika, so running one flow keeps the two from drifting. */}
@@ -107,6 +147,6 @@ function WindowOverlayInner() {
runtimesPending={runtimesPending}
/>
)}
- </div>
+ </motion.div>
);
}
diff --git a/packages/views/issues/components/board-card.tsx b/packages/views/issues/components/board-card.tsx
index e0bc63bf4a..b9b8a6276d 100644
--- a/packages/views/issues/components/board-card.tsx
+++ b/packages/views/issues/components/board-card.tsx
@@ -404,7 +404,7 @@ export const DraggableBoardCard = memo(function DraggableBoardCard({
data-peeked={peeked ? "" : undefined}
{...attributes}
{...listeners}
- className={`group/card ${isDragging ? "opacity-30" : ""}`}
+ className={`group/card transition-opacity duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none ${isDragging ? "opacity-30" : ""}`}
onKeyDown={
peek
? (e) => {
diff --git a/packages/views/issues/components/board-column.tsx b/packages/views/issues/components/board-column.tsx
index 31c778fadf..5653c0c373 100644
--- a/packages/views/issues/components/board-column.tsx
+++ b/packages/views/issues/components/board-column.tsx
@@ -1,6 +1,7 @@
"use client";
import { memo, useCallback, useMemo, useState, type ReactNode } from "react";
+import { AnimatePresence, motion } from "motion/react";
import { Virtuoso } from "react-virtuoso";
import { Ban, EyeOff, FolderMinus, MoreHorizontal, Plus, UserMinus } from "@multica/ui/icons";
import { useDroppable } from "@dnd-kit/core";
@@ -19,6 +20,7 @@ import {
DropdownMenuItem,
} from "@multica/ui/components/ui/dropdown-menu";
import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";
+import { UI_EASE_IN, UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import { useWorkspaceId } from "@multica/core/hooks";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
import { useViewStoreApi } from "@multica/core/issues/stores/view-store-context";
@@ -36,7 +38,7 @@ import { VirtuosoSeed } from "../../common/virtuoso-seed";
import { useBoardWorkflow } from "./board-workflow-context";
import { ColumnHandoff } from "../../workflows/column-handoff";
import type { IssueCreateDefaults } from "../surface/types";
-import { paletteColor } from "@multica/core/appearance";
+import { paletteColor, useReducedMotion } from "@multica/core/appearance";
// Insertion-position prediction intentionally omitted. The server's
// ORDER BY uses PostgreSQL's en_US.utf8 collation (glibc), which
@@ -141,6 +143,7 @@ export const BoardColumn = memo(function BoardColumn({
const statusFixedByView = !!status && viewBaseline?.status.has(status) === true;
const { t } = useT("issues");
const { t: tCommon } = useT("common");
+ const reduceMotion = useReducedMotion();
// Resolve IDs to Issue objects, preserving parent-provided order
const resolvedIssues = useMemo(
@@ -207,23 +210,41 @@ export const BoardColumn = memo(function BoardColumn({
<div
data-mc="board-column"
style={{ width: BOARD_COL_WIDTH }}
- className={`group/column relative flex shrink-0 flex-col rounded-board-column bg-board-column p-2 ${
+ className={`group/column relative flex shrink-0 flex-col rounded-board-column bg-board-column p-2 transition-shadow duration-150 motion-reduce:transition-none ${
hint ? "ring-2 ring-brand/30" : ""
}`}
>
{/* A dragged card whose workflow lacks this status cannot land here: the
column is hatched over and says why. (MUL-7420) */}
- {blockedReason && (
- <div
- aria-hidden
- className="pointer-events-none absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/60 bg-[repeating-linear-gradient(135deg,transparent_0_8px,var(--color-border)_8px_9px)]"
- >
- <span className="flex items-center gap-1.5 rounded-md border border-surface-border bg-card px-2.5 py-1 text-caption text-muted-foreground shadow-sm">
- <Ban className="size-3" />
- {blockedReason}
- </span>
- </div>
- )}
+ <AnimatePresence initial={false}>
+ {blockedReason && (
+ <motion.div
+ key="blocked-overlay"
+ aria-hidden
+ initial={reduceMotion ? false : { opacity: 0 }}
+ animate={{
+ opacity: 1,
+ transition: {
+ duration: reduceMotion ? 0 : UI_MOTION_DURATION.fast,
+ ease: UI_EASE_OUT,
+ },
+ }}
+ exit={{
+ opacity: 0,
+ transition: {
+ duration: reduceMotion ? 0 : UI_MOTION_DURATION.micro,
+ ease: UI_EASE_IN,
+ },
+ }}
+ className="pointer-events-none absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/60 bg-[repeating-linear-gradient(135deg,transparent_0_8px,var(--color-border)_8px_9px)]"
+ >
+ <span className="flex items-center gap-1.5 rounded-md border border-surface-border bg-card px-2.5 py-1 text-caption text-muted-foreground shadow-sm">
+ <Ban className="size-3" />
+ {blockedReason}
+ </span>
+ </motion.div>
+ )}
+ </AnimatePresence>
<div className="mb-2 flex items-center justify-between gap-2 px-1.5">
<BoardGroupHeading group={group} count={totalCount ?? issueIds.length} />
@@ -307,23 +328,65 @@ export const BoardColumn = memo(function BoardColumn({
</div>
</div>
<div className="relative min-h-[200px] flex-1 rounded-lg">
- {hint && (
- <div className="pointer-events-none absolute inset-x-1 bottom-1 z-10 flex items-center justify-center gap-1.5 rounded-lg border border-dashed border-brand/50 bg-card px-3 py-3 text-caption text-muted-foreground shadow-sm">
- {hint.actor && <ActorAvatar actorType={hint.actor.type} actorId={hint.actor.id} size="xs" profileLink={false} />}
- <span className="truncate">
- {hint.run
- ? t(($) => $.workflows.board.drop_hint_run, { name: hint.name })
- : t(($) => $.workflows.board.drop_hint, { name: hint.name })}
- </span>
- </div>
- )}
- {isOver && sortLabel && (
- <div className="pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-background/40">
- <span className="rounded-md bg-popover px-2.5 py-1 text-caption font-medium text-popover-foreground shadow-sm border border-border">
- {sortLabel}
- </span>
- </div>
- )}
+ <AnimatePresence initial={false}>
+ {hint && (
+ <motion.div
+ key="drop-hint-overlay"
+ initial={reduceMotion ? false : { opacity: 0, y: 4 }}
+ animate={{
+ opacity: 1,
+ y: 0,
+ transition: {
+ duration: reduceMotion ? 0 : UI_MOTION_DURATION.fast,
+ ease: UI_EASE_OUT,
+ },
+ }}
+ exit={{
+ opacity: 0,
+ y: reduceMotion ? 0 : 4,
+ transition: {
+ duration: reduceMotion ? 0 : UI_MOTION_DURATION.micro,
+ ease: UI_EASE_IN,
+ },
+ }}
+ className="pointer-events-none absolute inset-x-1 bottom-1 z-10 flex items-center justify-center gap-1.5 rounded-lg border border-dashed border-brand/50 bg-card px-3 py-3 text-caption text-muted-foreground shadow-sm"
+ >
+ {hint.actor && <ActorAvatar actorType={hint.actor.type} actorId={hint.actor.id} size="xs" profileLink={false} />}
+ <span className="truncate">
+ {hint.run
+ ? t(($) => $.workflows.board.drop_hint_run, { name: hint.name })
+ : t(($) => $.workflows.board.drop_hint, { name: hint.name })}
+ </span>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ <AnimatePresence initial={false}>
+ {isOver && sortLabel && (
+ <motion.div
+ key="sort-locked-overlay"
+ initial={reduceMotion ? false : { opacity: 0 }}
+ animate={{
+ opacity: 1,
+ transition: {
+ duration: reduceMotion ? 0 : UI_MOTION_DURATION.fast,
+ ease: UI_EASE_OUT,
+ },
+ }}
+ exit={{
+ opacity: 0,
+ transition: {
+ duration: reduceMotion ? 0 : UI_MOTION_DURATION.micro,
+ ease: UI_EASE_IN,
+ },
+ }}
+ className="pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-background/40"
+ >
+ <span className="rounded-md bg-popover px-2.5 py-1 text-caption font-medium text-popover-foreground shadow-sm border border-border">
+ {sortLabel}
+ </span>
+ </motion.div>
+ )}
+ </AnimatePresence>
<div
ref={mergedRef}
// Per-column scroll registration for the tab session memento
diff --git a/packages/views/issues/components/board-view.tsx b/packages/views/issues/components/board-view.tsx
index 1b8d56cab3..461827aca1 100644
--- a/packages/views/issues/components/board-view.tsx
+++ b/packages/views/issues/components/board-view.tsx
@@ -57,6 +57,7 @@ import type {
IssueGroupPageState,
} from "../surface/use-issue-group-branches";
import { useDragSettle } from "./use-drag-settle";
+import { createIssueDropAnimation, ISSUE_DRAG_OVERLAY_CLASS } from "./drag-drop-animation";
import { useIssuePeekActions } from "../surface/peek-context";
import { useBoardDragPan } from "./use-board-drag-pan";
import { useRestoredScrollRef } from "../../platform";
@@ -484,6 +485,8 @@ function BoardViewImpl({
// --- Drag state ---
const [activeIssue, setActiveIssue] = useState<Issue | null>(null);
+ const skipDropAnimationRef = useRef(false);
+ const dropAnimation = useMemo(() => createIssueDropAnimation(skipDropAnimationRef), []);
const [pendingHandoff, setPendingHandoff] = useState<{
issue: Issue;
status: IssueStatus;
@@ -602,6 +605,7 @@ function BoardViewImpl({
const handleDragStart = useCallback(
(event: DragStartEvent) => {
+ skipDropAnimationRef.current = false;
isDraggingRef.current = true;
const issue = issueMapRef.current.get(event.active.id as string) ?? null;
setActiveIssue(issue);
@@ -652,8 +656,10 @@ function BoardViewImpl({
isDraggingRef.current = false;
setActiveIssue(null);
- const resetColumns = () =>
+ const resetColumns = () => {
+ skipDropAnimationRef.current = true;
setColumns(buildColumns(groupedIssues, groups, grouping, groupingOptionIds));
+ };
if (!over) {
resetColumns();
@@ -831,6 +837,7 @@ function BoardViewImpl({
// column mirror resyncing with the cache afterwards — see the same handler in
// list-view for the touch path that makes this routine (MUL-6240).
const handleDragCancel = useCallback(() => {
+ skipDropAnimationRef.current = true;
isDraggingRef.current = false;
setActiveIssue(null);
setColumns(buildColumns(groupedIssues, groups, grouping, groupingOptionIds));
@@ -932,9 +939,9 @@ function BoardViewImpl({
)}
</div>
- <DragOverlay dropAnimation={null}>
+ <DragOverlay dropAnimation={dropAnimation}>
{activeIssue ? (
- <div style={{ width: BOARD_CARD_WIDTH }} className="rotate-1 cursor-grabbing opacity-90 shadow-lg shadow-black/10">
+ <div style={{ width: BOARD_CARD_WIDTH }} className={ISSUE_DRAG_OVERLAY_CLASS}>
<BoardCardContent
issue={activeIssue}
childProgress={childProgressMap.get(activeIssue.id)}
diff --git a/packages/views/issues/components/drag-drop-animation.test.ts b/packages/views/issues/components/drag-drop-animation.test.ts
new file mode 100644
index 0000000000..3d5a411a18
--- /dev/null
+++ b/packages/views/issues/components/drag-drop-animation.test.ts
@@ -0,0 +1,138 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { DEFAULT_APPEARANCE, useAppearanceStore } from "@multica/core/appearance";
+import { UI_EASE_OUT_CSS } from "@multica/ui/lib/motion";
+import {
+ createIssueDropAnimation,
+ ISSUE_DROP_DURATION_MS,
+} from "./drag-drop-animation";
+
+type FakeAnimation = {
+ onfinish: (() => void) | null;
+ oncancel: (() => void) | null;
+ cancel: ReturnType<typeof vi.fn>;
+};
+
+function makeFakeAnim(): FakeAnimation {
+ return {
+ onfinish: null,
+ oncancel: null,
+ cancel: vi.fn(),
+ };
+}
+
+function makeDropArgs() {
+ const activeNode = document.createElement("div");
+ activeNode.style.opacity = "0.85";
+
+ const overlayNode = document.createElement("div");
+ const innerCard = document.createElement("div");
+ overlayNode.appendChild(innerCard);
+
+ const outerAnim = makeFakeAnim();
+ const innerAnim = makeFakeAnim();
+ const outerAnimate = vi.fn(() => outerAnim as unknown as Animation);
+ const innerAnimate = vi.fn(() => innerAnim as unknown as Animation);
+ overlayNode.animate = outerAnimate;
+ innerCard.animate = innerAnimate;
+
+ return {
+ activeNode,
+ overlayNode,
+ outerAnim,
+ innerAnim,
+ outerAnimate,
+ innerAnimate,
+ args: {
+ active: {
+ id: "issue-1",
+ data: { current: {} },
+ node: activeNode,
+ rect: { top: 200, left: 300, bottom: 300, right: 560, width: 260, height: 100 },
+ },
+ dragOverlay: {
+ node: overlayNode,
+ rect: { top: 140, left: 180, bottom: 240, right: 440, width: 260, height: 100 },
+ },
+ transform: { x: 10, y: 20, scaleX: 1, scaleY: 1 },
+ draggableNodes: new Map(),
+ droppableContainers: new Map(),
+ measuringConfiguration: {} as never,
+ } as unknown as Parameters<ReturnType<typeof createIssueDropAnimation>>[0],
+ };
+}
+
+beforeEach(() => {
+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE });
+});
+
+describe("createIssueDropAnimation", () => {
+ it("glides the overlay into the target slot and straightens the lifted card over 170ms UI_EASE_OUT_CSS", async () => {
+ const skipRef = { current: false };
+ const drop = createIssueDropAnimation(skipRef);
+ const { activeNode, outerAnim, innerAnim, outerAnimate, innerAnimate, args } = makeDropArgs();
+
+ const promise = drop(args);
+
+ expect(activeNode.style.visibility).toBe("hidden");
+ expect(activeNode.style.opacity).toBe("0.85");
+ expect(outerAnimate).toHaveBeenCalledWith(
+ [
+ { transform: "translate3d(10px, 20px, 0) scaleX(1) scaleY(1)" },
+ { transform: "translate3d(130px, 80px, 0) scaleX(1) scaleY(1)" },
+ ],
+ {
+ duration: ISSUE_DROP_DURATION_MS,
+ easing: UI_EASE_OUT_CSS,
+ fill: "forwards",
+ },
+ );
+ expect(innerAnimate).toHaveBeenCalledWith(
+ expect.arrayContaining([
+ expect.objectContaining({
+ transform: "rotate(0deg) scale(1)",
+ opacity: "1",
+ boxShadow: "none",
+ }),
+ ]),
+ {
+ duration: ISSUE_DROP_DURATION_MS,
+ easing: UI_EASE_OUT_CSS,
+ fill: "forwards",
+ },
+ );
+
+ outerAnim.onfinish?.();
+ await promise;
+
+ expect(activeNode.style.visibility).toBe("");
+ expect(activeNode.style.opacity).toBe("0.85");
+ expect(innerAnim.cancel).toHaveBeenCalledOnce();
+ });
+
+ it("skips animation immediately when the drag was cancelled or blocked", () => {
+ const skipRef = { current: true };
+ const drop = createIssueDropAnimation(skipRef);
+ const { activeNode, outerAnimate, innerAnimate, args } = makeDropArgs();
+
+ const result = drop(args);
+
+ expect(result).toBeUndefined();
+ expect(outerAnimate).not.toHaveBeenCalled();
+ expect(innerAnimate).not.toHaveBeenCalled();
+ expect(activeNode.style.visibility).toBe("");
+ });
+
+ it("skips animation immediately when reduced motion is enabled", () => {
+ useAppearanceStore.getState().set({ reduceMotion: true });
+ const skipRef = { current: false };
+ const drop = createIssueDropAnimation(skipRef);
+ const { activeNode, outerAnimate, innerAnimate, args } = makeDropArgs();
+
+ const result = drop(args);
+
+ expect(result).toBeUndefined();
+ expect(outerAnimate).not.toHaveBeenCalled();
+ expect(innerAnimate).not.toHaveBeenCalled();
+ expect(activeNode.style.visibility).toBe("");
+ });
+});
diff --git a/packages/views/issues/components/drag-drop-animation.ts b/packages/views/issues/components/drag-drop-animation.ts
new file mode 100644
index 0000000000..4dbbe2c996
--- /dev/null
+++ b/packages/views/issues/components/drag-drop-animation.ts
@@ -0,0 +1,112 @@
+import type { RefObject } from "react";
+import type { DropAnimationFunction } from "@dnd-kit/core";
+import { CSS } from "@dnd-kit/utilities";
+import { prefersReducedMotion } from "@multica/core/appearance";
+import { UI_EASE_OUT_CSS } from "@multica/ui/lib/motion";
+
+export const ISSUE_DROP_DURATION_MS = 170;
+
+/** Shared lifted overlay presentation across Board, List, and Swimlane drags. */
+export const ISSUE_DRAG_OVERLAY_CLASS =
+ "rotate-1 scale-[1.01] cursor-grabbing opacity-95 shadow-lg shadow-black/10 motion-reduce:rotate-0 motion-reduce:scale-100";
+
+/**
+ * Drop animation for issue drags across Board, List, and Swimlane views.
+ *
+ * Glides the floating overlay into the settled target slot while straightening
+ * its lifted tilt/scale/shadow back to rest over 170ms (`UI_EASE_OUT_CSS`),
+ * keeping the underlying slot hidden until landing so the two never flash
+ * side-by-side. Skips immediately when the drag was cancelled, intercepted
+ * (workflow block/handoff, archived status, sort-locked no-op), or when
+ * reduced motion is enabled.
+ */
+export function createIssueDropAnimation(
+ shouldSkipRef: RefObject<boolean>,
+): DropAnimationFunction {
+ return ({ active, dragOverlay, transform }) => {
+ if (shouldSkipRef.current || prefersReducedMotion()) {
+ return;
+ }
+
+ const overlayNode = dragOverlay.node;
+ if (typeof overlayNode.animate !== "function") {
+ return;
+ }
+
+ const delta = {
+ x: dragOverlay.rect.left - active.rect.left,
+ y: dragOverlay.rect.top - active.rect.top,
+ };
+ const scale = {
+ scaleX:
+ transform.scaleX !== 1
+ ? (active.rect.width * transform.scaleX) / dragOverlay.rect.width
+ : 1,
+ scaleY:
+ transform.scaleY !== 1
+ ? (active.rect.height * transform.scaleY) / dragOverlay.rect.height
+ : 1,
+ };
+ const finalTransform = {
+ x: transform.x - delta.x,
+ y: transform.y - delta.y,
+ ...scale,
+ };
+
+ // `visibility`, not `opacity`: the slot's own opacity transition would
+ // fade it out on drop and back in after landing.
+ const previousActiveVisibility = active.node.style.visibility;
+ active.node.style.visibility = "hidden";
+
+ const innerCard = overlayNode.firstElementChild as HTMLElement | null;
+ const timing: KeyframeAnimationOptions = {
+ duration: ISSUE_DROP_DURATION_MS,
+ easing: UI_EASE_OUT_CSS,
+ fill: "forwards",
+ };
+
+ const outerAnim = overlayNode.animate(
+ [
+ { transform: CSS.Transform.toString(transform) ?? "none" },
+ { transform: CSS.Transform.toString(finalTransform) ?? "none" },
+ ],
+ timing,
+ );
+
+ const innerAnim =
+ innerCard && typeof innerCard.animate === "function"
+ ? innerCard.animate(
+ [
+ {
+ transform: getComputedStyle(innerCard).transform,
+ opacity: getComputedStyle(innerCard).opacity,
+ boxShadow: getComputedStyle(innerCard).boxShadow,
+ },
+ {
+ transform: "rotate(0deg) scale(1)",
+ opacity: "1",
+ boxShadow: "none",
+ },
+ ],
+ timing,
+ )
+ : null;
+
+ let cleaned = false;
+ const cleanup = () => {
+ if (cleaned) return;
+ cleaned = true;
+ active.node.style.visibility = previousActiveVisibility;
+ innerAnim?.cancel();
+ };
+
+ return new Promise<void>((resolve) => {
+ const done = () => {
+ cleanup();
+ resolve();
+ };
+ outerAnim.onfinish = done;
+ outerAnim.oncancel = done;
+ });
+ };
+}
diff --git a/packages/views/issues/components/list-row.tsx b/packages/views/issues/components/list-row.tsx
index 6f2e835f2b..6f82783546 100644
--- a/packages/views/issues/components/list-row.tsx
+++ b/packages/views/issues/components/list-row.tsx
@@ -112,7 +112,7 @@ function ListRowContent({
data-peeked={peeked ? "" : undefined}
style={containerStyle}
{...containerProps}
- className={`group/row flex h-[var(--issue-row-height)] items-center gap-2 px-[var(--issue-row-padding-x,1rem)] text-body transition-colors ${
+ className={`group/row flex h-[var(--issue-row-height)] items-center gap-2 px-[var(--issue-row-padding-x,1rem)] text-body transition-[background-color,color,opacity] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none ${
selected
? "bg-issue-row-selected hover:not-data-[popup-open]:bg-issue-row-selected data-[popup-open]:bg-issue-row-selected"
: "hover:not-data-[popup-open]:bg-issue-row-hover data-[popup-open]:bg-issue-row-hover"
diff --git a/packages/views/issues/components/list-view.tsx b/packages/views/issues/components/list-view.tsx
index c0fbcbd8b8..d187013d4b 100644
--- a/packages/views/issues/components/list-view.tsx
+++ b/packages/views/issues/components/list-view.tsx
@@ -25,6 +25,7 @@ import { useViewStore } from "@multica/core/issues/stores/view-store-context";
import { StatusHeading } from "./status-heading";
import { ListRow, DraggableListRow, rowParity, type ChildProgress } from "./list-row";
import { useDragSettle } from "./use-drag-settle";
+import { createIssueDropAnimation, ISSUE_DRAG_OVERLAY_CLASS } from "./drag-drop-animation";
import { ListLoadMoreFooter } from "./list-load-more-footer";
import { useT } from "../../i18n";
import {
@@ -135,6 +136,8 @@ function ListViewImpl({
// --- Drag state ---
const [activeIssue, setActiveIssue] = useState<Issue | null>(null);
+ const skipDropAnimationRef = useRef(false);
+ const dropAnimation = useMemo(() => createIssueDropAnimation(skipDropAnimationRef), []);
// Shared drag/settle primitive (see use-drag-settle) — same machine as
// board-view, so the two surfaces can't drift apart.
const {
@@ -185,6 +188,7 @@ function ListViewImpl({
const handleDragStart = useCallback(
(event: DragStartEvent) => {
+ skipDropAnimationRef.current = false;
isDraggingRef.current = true;
const issue = issueMapRef.current.get(event.active.id as string) ?? null;
setActiveIssue(issue);
@@ -227,8 +231,10 @@ function ListViewImpl({
isDraggingRef.current = false;
setActiveIssue(null);
- const resetColumns = () =>
+ const resetColumns = () => {
+ skipDropAnimationRef.current = true;
setColumns(buildColumns(issues, groups, "status"));
+ };
if (!over || !onMoveIssue) {
resetColumns();
@@ -352,6 +358,7 @@ function ListViewImpl({
// onValueChange is guarded by the same ref — made tapping a status header a
// no-op, so groups could no longer be collapsed at all (MUL-6240).
const handleDragCancel = useCallback(() => {
+ skipDropAnimationRef.current = true;
isDraggingRef.current = false;
setActiveIssue(null);
setColumns(buildColumns(issues, groups, "status"));
@@ -445,9 +452,9 @@ function ListViewImpl({
{content}
</div>
- <DragOverlay dropAnimation={null}>
+ <DragOverlay dropAnimation={dropAnimation}>
{activeIssue ? (
- <div className="max-w-2xl rotate-1 cursor-grabbing opacity-90 shadow-lg shadow-black/10 rounded-md border border-border bg-card px-4 py-2">
+ <div className={`max-w-2xl rounded-md border border-border bg-card px-4 py-2 ${ISSUE_DRAG_OVERLAY_CLASS}`}>
<span className="text-caption text-muted-foreground mr-2">{activeIssue.identifier}</span>
<span className="text-body">{activeIssue.title}</span>
</div>
diff --git a/packages/views/issues/components/swimlane-view.tsx b/packages/views/issues/components/swimlane-view.tsx
index 51acd35473..35e233e538 100644
--- a/packages/views/issues/components/swimlane-view.tsx
+++ b/packages/views/issues/components/swimlane-view.tsx
@@ -54,6 +54,7 @@ import {
import { sortIssues } from "../utils/sort";
import { BUILT_IN_STATUS_ORDER, STATUS_CONFIG } from "@multica/core/issues/config";
import { DraggableBoardCard, BoardCardContent } from "./board-card";
+import { createIssueDropAnimation, ISSUE_DRAG_OVERLAY_CLASS } from "./drag-drop-animation";
import { StatusIcon } from "./status-icon";
import { Button } from "@multica/ui/components/ui/button";
import { StatusHeading } from "./status-heading";
@@ -990,6 +991,8 @@ function SwimLaneViewImpl({
);
const [activeIssue, setActiveIssue] = useState<Issue | null>(null);
+ const skipDropAnimationRef = useRef(false);
+ const dropAnimation = useMemo(() => createIssueDropAnimation(skipDropAnimationRef), []);
// The outer scroll box is the customScrollParent for the lane Virtuoso.
const [scrollEl, setScrollEl] = useState<HTMLDivElement | null>(null);
const laneListRef = useRef<HTMLDivElement>(null);
@@ -1081,11 +1084,13 @@ function SwimLaneViewImpl({
);
const handleDragStart = useCallback((event: DragStartEvent) => {
+ skipDropAnimationRef.current = false;
isDraggingRef.current = true;
const activeId = event.active.id as string;
// Lane drags don't carry an Issue payload — clear the card overlay so
// we don't show a stale card during a lane reorder.
if (parseLaneId(activeId) !== null) {
+ skipDropAnimationRef.current = true;
setActiveIssue(null);
return;
}
@@ -1189,7 +1194,10 @@ function SwimLaneViewImpl({
isDraggingRef.current = false;
setActiveIssue(null);
- const reset = () => setLocalCells(cells);
+ const reset = () => {
+ skipDropAnimationRef.current = true;
+ setLocalCells(cells);
+ };
if (!over) {
reset();
@@ -1410,6 +1418,7 @@ function SwimLaneViewImpl({
// localCells resyncing with the cache afterwards — see the same handler in
// list-view for the touch path that makes this routine (MUL-6240).
const handleDragCancel = useCallback(() => {
+ skipDropAnimationRef.current = true;
isDraggingRef.current = false;
setActiveIssue(null);
setLocalCells(cells);
@@ -1577,9 +1586,9 @@ function SwimLaneViewImpl({
</div>
</div>
- <DragOverlay dropAnimation={null}>
+ <DragOverlay dropAnimation={dropAnimation}>
{activeIssue ? (
- <div className="w-[280px] rotate-2 scale-105 cursor-grabbing opacity-90 shadow-lg shadow-black/10">
+ <div className={`w-[280px] ${ISSUE_DRAG_OVERLAY_CLASS}`}>
<BoardCardContent
issue={activeIssue}
childProgress={childProgressMap.get(activeIssue.id)}
@@ -1665,7 +1674,7 @@ function DraggableSwimLane({
}, 0);
return (
- <div ref={setNodeRef} style={style} className={`flex flex-col ${isDragging ? "opacity-50" : ""}`}>
+ <div ref={setNodeRef} style={style} className={`flex flex-col transition-opacity duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none ${isDragging ? "opacity-50" : ""}`}>
{/* Non-interactive container — the inner collapse button and any
ancillary links (e.g. open-parent) are independent controls so we
don't nest an <a> inside a <button>. The drag listeners attach
diff --git a/packages/views/layout/app-rail.test.tsx b/packages/views/layout/app-rail.test.tsx
index 1449d5476b..2aff370528 100644
--- a/packages/views/layout/app-rail.test.tsx
+++ b/packages/views/layout/app-rail.test.tsx
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
import { act, fireEvent, screen, waitFor, within } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { DEFAULT_APPEARANCE, useAppearanceStore } from "@multica/core/appearance";
import { configStore } from "@multica/core/config";
import { DOCS_V1_FLAG } from "@multica/core/feature-flags";
import { useRailOrderStore } from "@multica/core/navigation";
@@ -156,6 +157,7 @@ beforeEach(() => {
useRailOrderStore.setState({ order: null });
configStore.getState().setFeatureFlags({ [DOCS_V1_FLAG]: true });
useSidebarTreeStore.setState({ inboxSettings: DEFAULT_SIDEBAR_INBOX_SETTINGS });
+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE });
});
const railOrder = () =>
@@ -329,12 +331,15 @@ describe("AppRail inbox return", () => {
});
describe("AppRail badges", () => {
- it("counts inbox unread on Work with a static counter", () => {
+ it("counts inbox unread on Work with an animated counter that respects reduced motion", () => {
state.inboxUnread = 4;
renderRail();
- const badge = countBadge("/acme/issues") as (HTMLElement & { animated?: boolean }) | null;
- expect(badge).toHaveAttribute("aria-label", "4");
- expect(badge?.animated).toBe(false);
+ const badge = () => countBadge("/acme/issues") as (HTMLElement & { animated?: boolean }) | null;
+ expect(badge()).toHaveAttribute("aria-label", "4");
+ expect(badge()?.animated).toBe(true);
+
+ act(() => useAppearanceStore.getState().set({ reduceMotion: true }));
+ expect(badge()?.animated).toBe(false);
});
it("leaves Work unbadged when the Inbox settings turn the badge off", () => {
diff --git a/packages/views/layout/app-rail.tsx b/packages/views/layout/app-rail.tsx
index 08fbc5aa7d..e213454fa7 100644
--- a/packages/views/layout/app-rail.tsx
+++ b/packages/views/layout/app-rail.tsx
@@ -1,7 +1,10 @@
"use client";
import { useCallback, useMemo } from "react";
+import { AnimatePresence, motion } from "motion/react";
import { useQuery } from "@tanstack/react-query";
+import { useReducedMotion } from "@multica/core/appearance";
+import { UI_EASE_IN, UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import {
DndContext,
PointerSensor,
@@ -115,30 +118,61 @@ function useRailBadges(guest: boolean): Partial<Record<RailSpaceId, RailBadge>>
return badges;
}
-function RailBadgeMark({ badge }: { badge: RailBadge }) {
+function RailBadgeMark({ badge }: { badge?: RailBadge }) {
+ const reduceMotion = useReducedMotion();
// The ring cuts the badge out of whatever the item is painted with.
const ring = "ring-2 ring-app-shell group-aria-[current=page]:ring-sidebar-accent";
- if (badge.kind === "dot") {
- return (
- <span
- aria-hidden
- className={cn(
- "absolute top-1 right-3 size-2 rounded-full bg-warning",
- ring,
- )}
- />
- );
- }
return (
- <CappedNumberFlow
- value={badge.value}
- animated={false}
- className={cn(
- "absolute top-0 right-1 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] leading-none font-medium tabular-nums",
- ring,
- badge.tone === "brand" ? "bg-brand text-brand-foreground" : "bg-foreground text-background",
+ <AnimatePresence initial={false}>
+ {badge?.kind === "dot" && (
+ <motion.span
+ key="dot"
+ aria-hidden
+ initial={reduceMotion ? false : { opacity: 0, scale: 0.5 }}
+ animate={{
+ opacity: 1,
+ scale: 1,
+ transition: { duration: reduceMotion ? 0 : UI_MOTION_DURATION.fast, ease: UI_EASE_OUT },
+ }}
+ exit={{
+ opacity: 0,
+ scale: reduceMotion ? 1 : 0.5,
+ transition: { duration: reduceMotion ? 0 : UI_MOTION_DURATION.micro, ease: UI_EASE_IN },
+ }}
+ className={cn(
+ "absolute top-1 right-3 size-2 rounded-full bg-warning",
+ ring,
+ )}
+ />
+ )}
+ {badge?.kind === "count" && (
+ <motion.span
+ key="count"
+ initial={reduceMotion ? false : { opacity: 0, scale: 0.6 }}
+ animate={{
+ opacity: 1,
+ scale: 1,
+ transition: { duration: reduceMotion ? 0 : UI_MOTION_DURATION.fast, ease: UI_EASE_OUT },
+ }}
+ exit={{
+ opacity: 0,
+ scale: reduceMotion ? 1 : 0.6,
+ transition: { duration: reduceMotion ? 0 : UI_MOTION_DURATION.micro, ease: UI_EASE_IN },
+ }}
+ className="pointer-events-none absolute top-0 right-1 flex"
+ >
+ <CappedNumberFlow
+ value={badge.value}
+ animated={!reduceMotion}
+ className={cn(
+ "flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] leading-none font-medium tabular-nums",
+ ring,
+ badge.tone === "brand" ? "bg-brand text-brand-foreground" : "bg-foreground text-background",
+ )}
+ />
+ </motion.span>
)}
- />
+ </AnimatePresence>
);
}
@@ -216,7 +250,7 @@ function RailSpaceLink({
>
<Icon className="size-5" />
<span className="max-w-full truncate px-0.5 text-micro leading-[14px]">{label}</span>
- {badge && <RailBadgeMark badge={badge} />}
+ <RailBadgeMark badge={badge} />
</AppLink>
);
// The menu portals out of the sortable item, but its React events still
diff --git a/packages/views/layout/bottom-bar.tsx b/packages/views/layout/bottom-bar.tsx
index 06199882e3..0655972ed6 100644
--- a/packages/views/layout/bottom-bar.tsx
+++ b/packages/views/layout/bottom-bar.tsx
@@ -1,6 +1,9 @@
"use client";
+import { AnimatePresence, motion } from "motion/react";
import { TriangleAlert } from "@multica/ui/icons";
+import { useReducedMotion } from "@multica/core/appearance";
+import { UI_EASE_IN, UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import { useChatStore } from "@multica/core/chat";
import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";
import { useIsGuest } from "@multica/core/permissions";
@@ -20,6 +23,7 @@ import { useTeamAgentStatus } from "./panels/team-status";
*/
function TeamStatus({ wsId }: { wsId: string }) {
const { t } = useT("layout");
+ const reduceMotion = useReducedMotion();
const p = useWorkspacePaths();
const shell = useAppShell();
const { stuck, byAgent } = useTeamAgentStatus(wsId);
@@ -31,15 +35,35 @@ function TeamStatus({ wsId }: { wsId: string }) {
return (
<div className="flex min-w-0 items-center gap-1">
- {waitingTasks > 0 && (
- <AppLink
- href={teamHref}
- className="inline-flex h-[22px] min-w-0 items-center gap-1.5 rounded-md bg-page-canvas pr-2 pl-1.5 text-caption font-medium text-foreground ring-1 ring-surface-border outline-none transition-colors hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-ring"
- >
- <TriangleAlert aria-hidden className="size-3.5 shrink-0 text-warning" />
- <span className="truncate">{t(($) => $.panels.team.stuck, { count: waitingTasks })}</span>
- </AppLink>
- )}
+ <AnimatePresence initial={false}>
+ {waitingTasks > 0 && (
+ <motion.div
+ key="stuck-tasks-pill"
+ initial={reduceMotion ? false : { opacity: 0, y: 4, scale: 0.96 }}
+ animate={{
+ opacity: 1,
+ y: 0,
+ scale: 1,
+ transition: { duration: reduceMotion ? 0 : UI_MOTION_DURATION.fast, ease: UI_EASE_OUT },
+ }}
+ exit={{
+ opacity: 0,
+ y: reduceMotion ? 0 : 4,
+ scale: reduceMotion ? 1 : 0.96,
+ transition: { duration: reduceMotion ? 0 : UI_MOTION_DURATION.micro, ease: UI_EASE_IN },
+ }}
+ className="flex min-w-0"
+ >
+ <AppLink
+ href={teamHref}
+ className="inline-flex h-[22px] min-w-0 items-center gap-1.5 rounded-md bg-page-canvas pr-2 pl-1.5 text-caption font-medium text-foreground ring-1 ring-surface-border outline-none transition-colors hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-ring"
+ >
+ <TriangleAlert aria-hidden className="size-3.5 shrink-0 text-warning" />
+ <span className="truncate">{t(($) => $.panels.team.stuck, { count: waitingTasks })}</span>
+ </AppLink>
+ </motion.div>
+ )}
+ </AnimatePresence>
</div>
);
}
diff --git a/packages/views/layout/collection-page.tsx b/packages/views/layout/collection-page.tsx
index 81095bdc36..36ef8357df 100644
--- a/packages/views/layout/collection-page.tsx
+++ b/packages/views/layout/collection-page.tsx
@@ -1,6 +1,9 @@
"use client";
import { useEffect, useRef, useState, type ComponentProps, type ReactNode } from "react";
+import { motion } from "motion/react";
+import { useReducedMotion } from "@multica/core/appearance";
+import { UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import {
ChevronDown,
Filter,
@@ -247,11 +250,18 @@ export function CollectionSearch({
label,
}: CollectionSearchProps) {
const { t } = useT("layout");
+ const reduceMotion = useReducedMotion();
const [open, setOpen] = useState(false);
const rootRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null);
const focusTriggerOnCloseRef = useRef(false);
const expanded = open || value !== "";
+ const mountedExpandedRef = useRef(expanded);
+ const animateExpand = !reduceMotion && !mountedExpandedRef.current;
+
+ useEffect(() => {
+ mountedExpandedRef.current = false;
+ }, []);
// Only opening focuses the field: a query restored on return must not take
// focus from the list, whose j/k keys need it on the page.
@@ -306,54 +316,61 @@ export function CollectionSearch({
)}
>
{expanded ? (
- <InputGroup
- className="h-7 w-full"
- onFocus={() => setOpen(true)}
- onBlur={(event) => {
- if (event.currentTarget.contains(event.relatedTarget as Node | null)) return;
- // Switching windows blurs too but keeps the element active; the
- // field should still be open on return.
- if (document.activeElement === event.target) return;
- setOpen(false);
- }}
+ <motion.div
+ className="w-full min-w-0"
+ initial={animateExpand ? { opacity: 0.4, width: 28 } : false}
+ animate={{ opacity: 1, width: "100%" }}
+ transition={{ duration: animateExpand ? UI_MOTION_DURATION.fast : 0, ease: UI_EASE_OUT }}
>
- <InputGroupAddon>
- <Search aria-hidden="true" className="size-3.5" />
- </InputGroupAddon>
- <InputGroupInput
- ref={inputRef}
- value={value}
- onChange={(event) => onChange(event.target.value)}
- onKeyDown={(event) => {
- if (event.key !== "Escape" || isImeComposing(event)) return;
- event.preventDefault();
- close();
- event.currentTarget.blur();
+ <InputGroup
+ className="h-7 w-full"
+ onFocus={() => setOpen(true)}
+ onBlur={(event) => {
+ if (event.currentTarget.contains(event.relatedTarget as Node | null)) return;
+ // Switching windows blurs too but keeps the element active; the
+ // field should still be open on return.
+ if (document.activeElement === event.target) return;
+ setOpen(false);
}}
- aria-label={label}
- aria-keyshortcuts="/"
- placeholder={label}
- autoComplete="off"
- spellCheck={false}
- className="h-full"
- />
- {value ? (
- <InputGroupAddon align="inline-end">
- <IconButton
- size="icon-xs"
- tooltipSide="bottom"
- label={t(($) => $.collection.clear_search)}
- className="text-muted-foreground"
- onClick={() => {
- focusTriggerOnCloseRef.current = true;
- close();
- }}
- >
- <X />
- </IconButton>
+ >
+ <InputGroupAddon>
+ <Search aria-hidden="true" className="size-3.5" />
</InputGroupAddon>
- ) : null}
- </InputGroup>
+ <InputGroupInput
+ ref={inputRef}
+ value={value}
+ onChange={(event) => onChange(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key !== "Escape" || isImeComposing(event)) return;
+ event.preventDefault();
+ close();
+ event.currentTarget.blur();
+ }}
+ aria-label={label}
+ aria-keyshortcuts="/"
+ placeholder={label}
+ autoComplete="off"
+ spellCheck={false}
+ className="h-full"
+ />
+ {value ? (
+ <InputGroupAddon align="inline-end">
+ <IconButton
+ size="icon-xs"
+ tooltipSide="bottom"
+ label={t(($) => $.collection.clear_search)}
+ className="text-muted-foreground"
+ onClick={() => {
+ focusTriggerOnCloseRef.current = true;
+ close();
+ }}
+ >
+ <X />
+ </IconButton>
+ </InputGroupAddon>
+ ) : null}
+ </InputGroup>
+ </motion.div>
) : (
<IconButton
label={label}
diff --git a/packages/views/layout/list-column.test.tsx b/packages/views/layout/list-column.test.tsx
index 5a17daf013..9024b5e740 100644
--- a/packages/views/layout/list-column.test.tsx
+++ b/packages/views/layout/list-column.test.tsx
@@ -1,5 +1,6 @@
-import { act, fireEvent } from "@testing-library/react";
+import { act, fireEvent, waitFor } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
+import { DEFAULT_APPEARANCE, useAppearanceStore } from "@multica/core/appearance";
import { SidebarProvider } from "@multica/ui/components/ui/sidebar";
import { renderWithI18n } from "../test/i18n";
import { AppShellProvider, useAppShell } from "./app-shell-context";
@@ -119,4 +120,65 @@ describe("ListColumn", () => {
vi.useRealTimers();
}
});
+
+ it("keeps the list visible while it collapses, so the edge clips it instead of a fade", async () => {
+ const { container, rerender } = renderWithI18n(<ListColumn>list</ListColumn>);
+ rerender(<ListColumn collapsed>list</ListColumn>);
+ const column = container.querySelector<HTMLElement>("[data-slot='list-column']")!;
+ const inner = column.firstElementChild as HTMLElement;
+ expect(column).toHaveClass("w-0", "overflow-hidden");
+ // Motion applies instant transitions on its next frame.
+ await act(() => new Promise((resolve) => setTimeout(resolve, 50)));
+ expect(inner.style.opacity).toBe("1");
+ expect(inner).not.toHaveClass("pointer-events-none");
+ });
+
+ it("keeps floating through the peek exit, then tucks back once it has slid out", async () => {
+ // Real timers: Motion's frame loop has to run for the exit to finish.
+ const { container } = renderWithI18n(
+ <SidebarProvider>
+ <AppShellProvider>
+ <Reader />
+ <ListColumn collapsed>list</ListColumn>
+ </AppShellProvider>
+ </SidebarProvider>,
+ );
+ const column = container.querySelector<HTMLElement>("[data-slot='list-column']")!;
+ const inner = column.firstElementChild as HTMLElement;
+ act(() => shell!.requestPeek("chat"));
+ await waitFor(() => expect(column).not.toHaveClass("overflow-hidden"));
+
+ act(() => shell!.closePeek());
+ // The same commit that ends the peek still floats the column.
+ expect(column).not.toHaveClass("overflow-hidden");
+ expect(inner).toHaveClass("pointer-events-none");
+
+ await waitFor(() => expect(column).toHaveClass("overflow-hidden"));
+ expect(inner).not.toHaveClass("pointer-events-none");
+ await waitFor(() => expect(inner.style.opacity).toBe("1"));
+ });
+
+ it("tucks back at once under reduced motion", () => {
+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE, reduceMotion: true });
+ vi.useFakeTimers();
+ try {
+ const { container } = renderWithI18n(
+ <SidebarProvider>
+ <AppShellProvider>
+ <Reader />
+ <ListColumn collapsed>list</ListColumn>
+ </AppShellProvider>
+ </SidebarProvider>,
+ );
+ const column = container.querySelector<HTMLElement>("[data-slot='list-column']")!;
+ act(() => shell!.requestPeek("chat"));
+ act(() => vi.advanceTimersByTime(200));
+ act(() => shell!.closePeek());
+ expect(column).toHaveClass("overflow-hidden");
+ expect(column.firstElementChild).not.toHaveClass("pointer-events-none");
+ } finally {
+ vi.useRealTimers();
+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE });
+ }
+ });
});
diff --git a/packages/views/layout/list-column.tsx b/packages/views/layout/list-column.tsx
index a6254b3334..15c1b5fc3d 100644
--- a/packages/views/layout/list-column.tsx
+++ b/packages/views/layout/list-column.tsx
@@ -1,12 +1,17 @@
"use client";
-import { useRef } from "react";
+import { useRef, useState } from "react";
+import { motion } from "motion/react";
+import { useReducedMotion } from "@multica/core/appearance";
import { useSidebarSafe } from "@multica/ui/components/ui/sidebar";
+import { UI_EASE_IN, UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import { cn } from "@multica/ui/lib/utils";
import { useAppShell } from "./app-shell-context";
import { PanelResizeHandle, type PanelWidth } from "./panel-resize-handle";
import { LIST_COLUMN_WIDTH_CLASS, NAV_COLUMN_MOTION_CLASS, NAV_PEEK_CLASS } from "./rail-styles";
+const PEEK_EXIT_DURATION = 0.11;
+
const WIDTH_CLASS: Record<PanelWidth, string> = {
nav: "w-(--sidebar-width)",
list: LIST_COLUMN_WIDTH_CLASS,
@@ -36,11 +41,38 @@ export function ListColumn({
const ref = useRef<HTMLElement>(null);
const sidebar = useSidebarSafe();
const shell = useAppShell();
+ const reduceMotion = useReducedMotion();
const onToggle = shell?.toggleNav ?? sidebar?.toggleSidebar;
// Hovering this space's rail item while collapsed floats the column itself
// over the page. Only the inner box moves, so the column keeps its width
// (no collapse motion) and the list keeps its state.
const peeking = collapsed && !!shell?.peekSpace && shell.peekSpace === shell.space;
+ // Derived during render so the column keeps floating on the very frame the
+ // peek ends; a post-commit effect would drop it for one frame and skip the
+ // exit animation.
+ const [prevPeeking, setPrevPeeking] = useState(peeking);
+ const [peekExiting, setPeekExiting] = useState(false);
+ if (peeking !== prevPeeking) {
+ setPrevPeeking(peeking);
+ setPeekExiting(!peeking && collapsed && !reduceMotion);
+ } else if (peekExiting && (!collapsed || reduceMotion)) {
+ setPeekExiting(false);
+ }
+
+ const floating = peeking || peekExiting;
+ // Outside a peek the inner box rests visible: a collapsing column is
+ // clipped by its own shrinking width, not faded.
+ const animateStyle =
+ peeking && !reduceMotion
+ ? { opacity: [0, 1], x: [-8, 0] }
+ : peekExiting
+ ? { opacity: 0, x: -8 }
+ : { opacity: 1, x: 0 };
+ const transition = peeking && !reduceMotion
+ ? { duration: UI_MOTION_DURATION.fast, ease: UI_EASE_OUT }
+ : peekExiting
+ ? { duration: PEEK_EXIT_DURATION, ease: UI_EASE_IN }
+ : { duration: 0 };
return (
<>
@@ -53,22 +85,29 @@ export function ListColumn({
"relative flex h-full shrink-0 justify-end",
NAV_COLUMN_MOTION_CLASS,
collapsed ? "w-0" : WIDTH_CLASS[width],
- !peeking && "overflow-hidden",
+ !floating && "overflow-hidden",
className,
)}
>
- <div
+ <motion.div
data-slot={peeking ? "list-column-peek" : undefined}
onPointerEnter={peeking ? shell.holdPeek : undefined}
onPointerLeave={peeking ? shell.releasePeek : undefined}
+ initial={false}
+ animate={animateStyle}
+ transition={transition}
+ onAnimationComplete={() => {
+ if (peekExiting) setPeekExiting(false);
+ }}
className={cn(
"flex h-full shrink-0 flex-col overflow-hidden",
- peeking ? NAV_PEEK_CLASS : cn("border-r", innerClassName),
+ floating ? NAV_PEEK_CLASS : cn("border-r", innerClassName),
+ peekExiting && "pointer-events-none",
WIDTH_CLASS[width],
)}
>
{children}
- </div>
+ </motion.div>
</aside>
{!collapsed && sidebar && !sidebar.isCompact && onToggle && (
<div className="relative w-0 shrink-0">
diff --git a/packages/views/layout/object-page.tsx b/packages/views/layout/object-page.tsx
index b71f768782..a15669d978 100644
--- a/packages/views/layout/object-page.tsx
+++ b/packages/views/layout/object-page.tsx
@@ -32,6 +32,7 @@ import {
useRightSidebarShortcut,
} from "./animated-right-sidebar";
import { BreadcrumbHeader, type BreadcrumbSegment } from "./breadcrumb-header";
+import { PanelDisclosure } from "./panel-nav";
/** The reading column of an object page; the header above it stays full width. */
export const OBJECT_PAGE_BODY =
@@ -282,7 +283,7 @@ export function ObjectSection({
const [stateOpen, setOpen] = useState(defaultOpen);
const open = !collapsible || stateOpen;
return (
- <section className={cn("space-y-2", className)}>
+ <section className={cn(!collapsible && "space-y-2", className)}>
<div className="flex h-7 items-center gap-2">
<h2 className="text-body font-medium">
{collapsible ? (
@@ -299,7 +300,7 @@ export function ObjectSection({
<ChevronRight
aria-hidden="true"
className={cn(
- "!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform motion-reduce:transition-none",
+ "!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none",
open && "rotate-90",
)}
/>
@@ -314,7 +315,23 @@ export function ObjectSection({
{open && action ? <div className="ml-auto flex items-center gap-1">{action}</div> : null}
</div>
{/* Folded content stays mounted, so an editor's unsaved draft survives. */}
- {collapsible ? <div hidden={!open}>{children}</div> : children}
+ {collapsible ? (
+ <div
+ aria-hidden={!open}
+ inert={!open}
+ style={{ visibility: open ? "visible" : "hidden" }}
+ className={cn(
+ "grid transition-[grid-template-rows,opacity,visibility] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none",
+ open ? "visible grid-rows-[1fr] opacity-100" : "invisible grid-rows-[0fr] opacity-0",
+ )}
+ >
+ <div className="overflow-hidden">
+ <div className="pt-2">{children}</div>
+ </div>
+ </div>
+ ) : (
+ children
+ )}
</section>
);
}
@@ -414,14 +431,16 @@ export function ObjectPanelSection({
{title}
<ChevronRight
className={cn(
- "!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform",
+ "!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none",
open && "rotate-90",
)}
/>
</button>
{open && action ? <div className="flex shrink-0 items-center">{action}</div> : null}
</div>
- {open ? <div className="space-y-0.5 pl-2">{children}</div> : null}
+ <PanelDisclosure open={open}>
+ <div className="space-y-0.5 pl-2">{children}</div>
+ </PanelDisclosure>
</div>
);
}
diff --git a/packages/views/layout/panel-nav.test.tsx b/packages/views/layout/panel-nav.test.tsx
index c138e7d052..0c7a601f44 100644
--- a/packages/views/layout/panel-nav.test.tsx
+++ b/packages/views/layout/panel-nav.test.tsx
@@ -1,6 +1,7 @@
-import { describe, expect, it, vi } from "vitest";
-import { render, screen } from "@testing-library/react";
-import { PanelBody, PanelScrollFadeContext } from "./panel-nav";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { render, screen, waitFor } from "@testing-library/react";
+import { DEFAULT_APPEARANCE, useAppearanceStore } from "@multica/core/appearance";
+import { PanelBody, PanelDisclosure, PanelScrollFadeContext } from "./panel-nav";
// jsdom drops `mask-image`, so the fade stands in as a style it keeps.
vi.mock("@multica/ui/hooks/use-scroll-fade", () => ({
@@ -32,3 +33,68 @@ describe("PanelBody scroll fade", () => {
expect(scroller()).not.toHaveAttribute("style");
});
});
+
+describe("PanelDisclosure", () => {
+ afterEach(() => {
+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE });
+ });
+
+ it("collapses and unmounts content after exit animation", async () => {
+ const { rerender } = render(
+ <PanelDisclosure open id="sec-1">
+ <span>section body</span>
+ </PanelDisclosure>,
+ );
+ expect(screen.getByText("section body")).toBeInTheDocument();
+
+ rerender(
+ <PanelDisclosure open={false} id="sec-1">
+ <span>section body</span>
+ </PanelDisclosure>,
+ );
+ await waitFor(() => expect(screen.queryByText("section body")).toBeNull());
+ });
+
+ it("clips only while animating, so a resting section keeps its rows' focus outlines", async () => {
+ const { rerender } = render(
+ <PanelDisclosure open id="sec-3">
+ <span>clip body</span>
+ </PanelDisclosure>,
+ );
+ const body = () => document.getElementById("sec-3")!;
+ expect(body().style.overflow).toBe("visible");
+
+ rerender(
+ <PanelDisclosure open={false} id="sec-3">
+ <span>clip body</span>
+ </PanelDisclosure>,
+ );
+ await waitFor(() => expect(document.getElementById("sec-3")).toBeNull());
+
+ rerender(
+ <PanelDisclosure open id="sec-3">
+ <span>clip body</span>
+ </PanelDisclosure>,
+ );
+ // jsdom never applies Motion's discrete `transitionEnd`, so the return
+ // to `visible` after the enter animation is only observable in a browser.
+ expect(body().style.overflow).toBe("hidden");
+ });
+
+ it("unmounts immediately in the same frame when reduced motion is enabled", () => {
+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE, reduceMotion: true });
+ const { rerender } = render(
+ <PanelDisclosure open id="sec-2">
+ <span>reduced body</span>
+ </PanelDisclosure>,
+ );
+ expect(screen.getByText("reduced body")).toBeInTheDocument();
+
+ rerender(
+ <PanelDisclosure open={false} id="sec-2">
+ <span>reduced body</span>
+ </PanelDisclosure>,
+ );
+ expect(screen.queryByText("reduced body")).toBeNull();
+ });
+});
diff --git a/packages/views/layout/panel-nav.tsx b/packages/views/layout/panel-nav.tsx
index 427f0ba5ab..e50e3da98e 100644
--- a/packages/views/layout/panel-nav.tsx
+++ b/packages/views/layout/panel-nav.tsx
@@ -1,7 +1,10 @@
"use client";
import { createContext, useContext, useId, useRef, type RefObject } from "react";
+import { AnimatePresence, motion, useIsPresent } from "motion/react";
+import { useReducedMotion } from "@multica/core/appearance";
import { ChevronDown } from "@multica/ui/icons";
+import { UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import { cn } from "@multica/ui/lib/utils";
import { useScrollFade } from "@multica/ui/hooks/use-scroll-fade";
import { AppLink } from "../navigation";
@@ -102,6 +105,77 @@ export function PanelBody({
);
}
+function PanelDisclosureInner({
+ id,
+ className,
+ children,
+}: {
+ id?: string;
+ className?: string;
+ children: React.ReactNode;
+}) {
+ const isPresent = useIsPresent();
+ return (
+ <motion.div
+ id={id}
+ inert={!isPresent}
+ // Clip only while the height moves, so rows' focus outlines aren't cut
+ // off once the section rests open.
+ initial={{ height: 0, opacity: 0, overflow: "hidden" }}
+ animate={{
+ height: "auto",
+ opacity: 1,
+ transition: { duration: UI_MOTION_DURATION.fast, ease: UI_EASE_OUT },
+ transitionEnd: { overflow: "visible" },
+ }}
+ exit={{
+ height: 0,
+ opacity: 0,
+ overflow: "hidden",
+ transition: { duration: UI_MOTION_DURATION.fast, ease: UI_EASE_OUT },
+ }}
+ className={cn(!isPresent && "pointer-events-none", className)}
+ >
+ {children}
+ </motion.div>
+ );
+}
+
+/**
+ * Smooth 150ms height + opacity disclosure matched to sidebar and section
+ * chevron rotation. Unmounts children after exit (and immediately under
+ * reduced motion) so collapsed lists release their subscriptions.
+ */
+export function PanelDisclosure({
+ open,
+ id,
+ className,
+ children,
+}: {
+ open: boolean;
+ id?: string;
+ className?: string;
+ children: React.ReactNode;
+}) {
+ const reduceMotion = useReducedMotion();
+ if (reduceMotion) {
+ return open ? (
+ <div id={id} className={className}>
+ {children}
+ </div>
+ ) : null;
+ }
+ return (
+ <AnimatePresence initial={false}>
+ {open && (
+ <PanelDisclosureInner key="disclosure" id={id} className={className}>
+ {children}
+ </PanelDisclosureInner>
+ )}
+ </AnimatePresence>
+ );
+}
+
export function PanelSection({
label,
heading,
@@ -133,7 +207,7 @@ export function PanelSection({
<ChevronDown
aria-hidden
className={cn(
- "size-3.5 shrink-0 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none",
+ "size-3.5 shrink-0 transition-[transform,opacity] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none",
collapsed
? "-rotate-90"
: "opacity-0 group-hover/section:opacity-100 group-focus-within/section:opacity-100",
@@ -189,7 +263,9 @@ export function PanelSection({
)}
{action}
</div>
- {!collapsed && <div id={contentId}>{children}</div>}
+ <PanelDisclosure open={!collapsed} id={contentId}>
+ {children}
+ </PanelDisclosure>
</section>
);
}
diff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsx
index adad0802dd..8fb6c59ee9 100644
--- a/packages/views/layout/panels/inbox-section.test.tsx
+++ b/packages/views/layout/panels/inbox-section.test.tsx
@@ -468,11 +468,11 @@ describe("InboxSection", () => {
expect(header()).not.toHaveTextContent("3");
});
- it("collapses from the section label", () => {
+ it("collapses from the section label", async () => {
renderSection([item({ id: "n1", issue_id: "issue-a" })]);
fireEvent.click(screen.getByRole("button", { name: "Inbox" }));
expect(useSidebarTreeStore.getState().inboxCollapsed).toBe(true);
- expect(rows()).toHaveLength(0);
+ await waitFor(() => expect(rows()).toHaveLength(0));
});
it("collapses from its open tab, and a closed tab opens the section on that list", () => {
diff --git a/packages/views/layout/panels/pinned-section.test.tsx b/packages/views/layout/panels/pinned-section.test.tsx
index 0c9160a1bb..d666c6b083 100644
--- a/packages/views/layout/panels/pinned-section.test.tsx
+++ b/packages/views/layout/panels/pinned-section.test.tsx
@@ -167,9 +167,9 @@ describe("PinnedSection", () => {
fireEvent.click(screen.getByRole("button", { name: "Pinned" }));
expect(useSidebarTreeStore.getState().pinnedCollapsed).toBe(true);
- expect(screen.queryByText("Keep this pin")).toBeNull();
expect(screen.getByRole("button", { name: "Pinned" })).toHaveAttribute("aria-expanded", "false");
expect(activePinnedRoute).toBe(false);
+ await waitFor(() => expect(screen.queryByText("Keep this pin")).toBeNull());
});
it("shows a pinned project's chosen icon, keeping the folder when it has none", async () => {
diff --git a/packages/views/layout/panels/pinned-section.tsx b/packages/views/layout/panels/pinned-section.tsx
index 6fc9190a85..4bdfd2c8ca 100644
--- a/packages/views/layout/panels/pinned-section.tsx
+++ b/packages/views/layout/panels/pinned-section.tsx
@@ -263,7 +263,7 @@ function SortablePinItem({
{/* Holds the same right-edge slot as a tree row's avatars, and yields
it to the unpin button on hover. */}
{trailing && (
- <span className="flex shrink-0 items-center group-hover/pin:invisible group-focus-within/pin:invisible">
+ <span className="flex shrink-0 items-center transition-opacity duration-150 motion-reduce:transition-none group-hover/pin:opacity-0 group-focus-within/pin:opacity-0">
{trailing}
</span>
)}
@@ -275,7 +275,7 @@ function SortablePinItem({
<li
ref={setNodeRef}
style={{ transform: CSS.Translate.toString(transform), transition }}
- className={cn("group/pin relative", isDragging && "opacity-30")}
+ className={cn("group/pin relative transition-opacity duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none", isDragging && "opacity-30")}
{...attributes}
{...listeners}
>
@@ -284,7 +284,7 @@ function SortablePinItem({
<button
type="button"
aria-label={t(($) => $.sidebar.unpin_tooltip)}
- className="absolute top-1/2 right-1.5 hidden size-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground group-hover/pin:flex group-focus-within/pin:flex hover:bg-surface-selected hover:text-foreground"
+ className="pointer-events-none absolute top-1/2 right-1.5 flex size-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-[opacity,background-color,color] duration-150 motion-reduce:transition-none group-hover/pin:pointer-events-auto group-hover/pin:opacity-100 group-focus-within/pin:pointer-events-auto group-focus-within/pin:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100 hover:bg-surface-selected hover:text-foreground"
onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
event.preventDefault();
diff --git a/packages/views/layout/panels/team-panel.test.tsx b/packages/views/layout/panels/team-panel.test.tsx
index ea03159946..6a202529cd 100644
--- a/packages/views/layout/panels/team-panel.test.tsx
+++ b/packages/views/layout/panels/team-panel.test.tsx
@@ -178,7 +178,7 @@ describe("TeamPanel agent previews", () => {
expect(working.getAllByRole("link")).toHaveLength(5);
});
- it("previews and collapses each status independently, retaining collapse state on remount", () => {
+ it("previews and collapses each status independently, retaining collapse state on remount", async () => {
seedAgents(7);
seedAgents(8, "queued");
const runtimes = [runtime(), runtime({ id: "rt-offline", status: "offline" })];
@@ -193,7 +193,7 @@ describe("TeamPanel agent previews", () => {
expect(working.getAllByRole("link")).toHaveLength(5);
fireEvent.click(working.getByRole("button", { name: "Working now" }));
- expect(working.queryAllByRole("link")).toHaveLength(0);
+ await waitFor(() => expect(working.queryAllByRole("link")).toHaveLength(0));
expect(working.getByText("7")).toBeInTheDocument();
expect(attention.getAllByRole("link")).toHaveLength(8);
fireEvent.click(attention.getByRole("button", { name: "Needs attention" }));
diff --git a/packages/views/layout/panels/views-section.test.tsx b/packages/views/layout/panels/views-section.test.tsx
index 9edba4072a..471f36428d 100644
--- a/packages/views/layout/panels/views-section.test.tsx
+++ b/packages/views/layout/panels/views-section.test.tsx
@@ -1,5 +1,5 @@
import type { ReactNode } from "react";
-import { fireEvent, screen } from "@testing-library/react";
+import { fireEvent, screen, waitFor } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";
import { useActiveIssueViewStore } from "@multica/core/issue-views/active-view-store";
@@ -89,14 +89,14 @@ beforeEach(() => {
});
describe("ViewsSection", () => {
- it("collapses from the section label", () => {
+ it("collapses from the section label", async () => {
renderSection();
expect(screen.getByText("All views")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Views" }));
expect(useSidebarTreeStore.getState().viewsCollapsed).toBe(true);
- expect(screen.queryByText("All views")).toBeNull();
expect(screen.getByRole("button", { name: "Views" })).toHaveAttribute("aria-expanded", "false");
+ await waitFor(() => expect(screen.queryByText("All views")).toBeNull());
});
it("opens again to show a new view, named in the page header", () => {
diff --git a/packages/views/layout/panels/views-section.tsx b/packages/views/layout/panels/views-section.tsx
index 0cecad65c2..5cf5b0cc82 100644
--- a/packages/views/layout/panels/views-section.tsx
+++ b/packages/views/layout/panels/views-section.tsx
@@ -57,7 +57,7 @@ import { ViewNameInput } from "../../issue-views/view-name-input";
import { BUILTIN_VIEW_ICON, useBuiltinViewLabel, useBuiltinViewNavigation } from "../../issue-views/builtin-views";
import { shouldOpenRowMenu, useRowMenu } from "../../common/point-menu";
import { useT } from "../../i18n";
-import { PANEL_ROW_CLASS, PanelCount, PanelLink, PanelList, PanelSection, isPathWithin, panelRowAnchor, panelRowStateClass } from "../panel-nav";
+import { PANEL_ROW_CLASS, PanelCount, PanelDisclosure, PanelLink, PanelList, PanelSection, isPathWithin, panelRowAnchor, panelRowStateClass } from "../panel-nav";
import { useDragClickGuard } from "../use-drag-click-guard";
import { SECTION_SETTINGS_REVEAL_CLASS, ViewsSectionSettings } from "./sidebar-settings";
import { SidebarIssueList, TREE_ROW_BUTTON_CLASS, TreeRow } from "./sidebar-tree";
@@ -406,7 +406,7 @@ function BuiltinViewRow({
</span>
}
/>
- {expanded && (
+ <PanelDisclosure open={expanded}>
<SidebarIssueList
id={listId}
wsId={wsId}
@@ -420,7 +420,7 @@ function BuiltinViewRow({
linkRef.current?.focus();
}}
/>
- )}
+ </PanelDisclosure>
</>
);
}
@@ -557,7 +557,7 @@ function SavedViewRow({
</span>
}
/>
- {expanded && (
+ <PanelDisclosure open={expanded}>
<SidebarIssueList
id={listId}
wsId={wsId}
@@ -571,7 +571,7 @@ function SavedViewRow({
linkRef.current?.focus();
}}
/>
- )}
+ </PanelDisclosure>
</>
);
}
diff --git a/packages/views/layout/panels/work-tree.tsx b/packages/views/layout/panels/work-tree.tsx
index 6b21670b5c..0ec7c071fa 100644
--- a/packages/views/layout/panels/work-tree.tsx
+++ b/packages/views/layout/panels/work-tree.tsx
@@ -57,6 +57,7 @@ import { useT } from "../../i18n";
import {
PANEL_ROW_CLASS,
PanelCount,
+ PanelDisclosure,
PanelLink,
PanelList,
PanelSection,
@@ -546,10 +547,10 @@ function ProjectFolderTreeItem({
<FolderMenu folder={folder} />
</CollectionRowContext.Provider>
)}
- {expanded && (
- // Same connector as an expanded project's issues, so the projects'
- // icons sit on the folder's label column: 1px border + 5px + the
- // row's 12px reaches the folder row's 12px + 16px icon + 10px gap.
+ <PanelDisclosure open={expanded}>
+ {/* Same connector as an expanded project's issues, so the projects'
+ icons sit on the folder's label column: 1px border + 5px + the
+ row's 12px reaches the folder row's 12px + 16px icon + 10px gap. */}
<SortableContext items={projectIds} strategy={verticalListSortingStrategy}>
<ul id={listId} className="ml-5 space-y-px border-l border-surface-border pl-[5px]">
{projects.length === 0 ? (
@@ -561,7 +562,7 @@ function ProjectFolderTreeItem({
)}
</ul>
</SortableContext>
- )}
+ </PanelDisclosure>
</li>
);
}
@@ -649,7 +650,7 @@ function NoProjectTreeItem({
</span>
}
/>
- {expanded && (
+ <PanelDisclosure open={expanded}>
<SidebarIssueList
id={listId}
wsId={wsId}
@@ -665,7 +666,7 @@ function NoProjectTreeItem({
rowRef.current?.focus();
}}
/>
- )}
+ </PanelDisclosure>
</li>
);
}
@@ -780,7 +781,7 @@ function ProjectTreeItem({
/>
</CollectionRowContext.Provider>
)}
- {expanded && (
+ <PanelDisclosure open={expanded}>
<SidebarIssueList
id={listId}
wsId={wsId}
@@ -796,7 +797,7 @@ function ProjectTreeItem({
linkRef.current?.focus();
}}
/>
- )}
+ </PanelDisclosure>
</li>
);
}
diff --git a/packages/views/layout/rail-workspaces.tsx b/packages/views/layout/rail-workspaces.tsx
index 0ff2b81e2c..fe630aec15 100644
--- a/packages/views/layout/rail-workspaces.tsx
+++ b/packages/views/layout/rail-workspaces.tsx
@@ -77,7 +77,7 @@ function NewWindowButton({ onOpen }: { onOpen: () => void }) {
type="button"
tabIndex={-1}
aria-label={label}
- className="-my-1 -mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground opacity-0 group-hover/workspace:opacity-100 group-data-highlighted/workspace:opacity-100 hover:bg-surface-selected hover:text-foreground"
+ className="-my-1 -mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-[opacity,background-color,color] duration-150 motion-reduce:transition-none group-hover/workspace:opacity-100 group-data-highlighted/workspace:opacity-100 hover:bg-surface-selected hover:text-foreground"
onClick={(event) => {
event.preventDefault();
onOpen();
@@ -99,7 +99,7 @@ function PinButton({ pinned, unread, onToggle }: { pinned: boolean; unread: bool
return (
<TooltipHint label={label} side="right">
<button type="button" aria-label={label} tabIndex={0}
- className={cn("absolute inset-0 flex items-center justify-center rounded-md opacity-0 group-hover/workspace:opacity-100 group-data-highlighted/workspace:opacity-100 focus-visible:opacity-100 hover:bg-surface-selected", unread ? "text-brand" : "text-muted-foreground")}
+ className={cn("absolute inset-0 flex items-center justify-center rounded-md opacity-0 transition-[opacity,background-color,color] duration-150 motion-reduce:transition-none group-hover/workspace:opacity-100 group-data-highlighted/workspace:opacity-100 focus-visible:opacity-100 hover:bg-surface-selected", unread ? "text-brand" : "text-muted-foreground")}
onClick={(event) => { event.preventDefault(); event.stopPropagation(); onToggle(); }}
onKeyDown={(event) => { if (event.key === "Enter" || event.key === " ") event.stopPropagation(); }}
>
@@ -218,7 +218,7 @@ export function RailWorkspaces() {
<span className="min-w-0 flex-1 truncate">{ws.name}</span>
{isCurrent && <Check />}
<span className="relative flex size-5 shrink-0 items-center justify-center">
- <span className="flex group-hover/workspace:opacity-0 group-data-highlighted/workspace:opacity-0">
+ <span className="flex transition-opacity duration-150 motion-reduce:transition-none group-hover/workspace:opacity-0 group-data-highlighted/workspace:opacity-0">
{ws.pinned_at ? (
<Pin className={cn("size-4 fill-current", !isCurrent && unreadIds.has(ws.id) ? "text-brand" : "text-muted-foreground")} />
) : !isCurrent && unreadIds.has(ws.id) ? <UnreadDot /> : null}
diff --git a/packages/views/layout/space-panel.tsx b/packages/views/layout/space-panel.tsx
index 0f3fec57e3..5e71c5b076 100644
--- a/packages/views/layout/space-panel.tsx
+++ b/packages/views/layout/space-panel.tsx
@@ -2,8 +2,11 @@
import { DocTree } from "../docs/components/doc-tree";
import { useEffect, useRef } from "react";
+import { AnimatePresence, motion, useIsPresent } from "motion/react";
+import { useReducedMotion } from "@multica/core/appearance";
import { useCurrentWorkspace, type AppSpaceId } from "@multica/core/paths";
import { useIsGuest } from "@multica/core/permissions";
+import { UI_EASE_IN, UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import { cn } from "@multica/ui/lib/utils";
import { useSidebar } from "@multica/ui/components/ui/sidebar";
import { useAppShell } from "./app-shell-context";
@@ -44,6 +47,50 @@ export function SpacePanelContent({ space }: { space: AppSpaceId | null }) {
return Panel ? <Panel /> : null;
}
+const PEEK_EXIT_DURATION = 0.11;
+
+function SpacePanelPeek({
+ isListPeek,
+ reduceMotion,
+ onPointerEnter,
+ onPointerLeave,
+ children,
+}: {
+ isListPeek: boolean;
+ reduceMotion: boolean;
+ onPointerEnter: () => void;
+ onPointerLeave: () => void;
+ children: React.ReactNode;
+}) {
+ const isPresent = useIsPresent();
+ return (
+ <motion.aside
+ data-slot="space-panel-peek"
+ onPointerEnter={onPointerEnter}
+ onPointerLeave={onPointerLeave}
+ initial={reduceMotion ? false : { opacity: 0, x: -8 }}
+ animate={{
+ opacity: 1,
+ x: 0,
+ transition: { duration: reduceMotion ? 0 : UI_MOTION_DURATION.fast, ease: UI_EASE_OUT },
+ }}
+ exit={{
+ opacity: 0,
+ x: reduceMotion ? 0 : -8,
+ transition: { duration: reduceMotion ? 0 : PEEK_EXIT_DURATION, ease: UI_EASE_IN },
+ }}
+ className={cn(
+ NAV_PEEK_CLASS,
+ "max-md:hidden",
+ !isPresent && "pointer-events-none",
+ isListPeek && LIST_COLUMN_WIDTH_CLASS,
+ )}
+ >
+ {children}
+ </motion.aside>
+ );
+}
+
/**
* 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
@@ -54,6 +101,7 @@ export function SpacePanelContent({ space }: { space: AppSpaceId | null }) {
export function SpacePanel() {
const shell = useAppShell();
const { open, isCompact } = useSidebar();
+ const reduceMotion = useReducedMotion();
const panelRef = useRef<HTMLElement>(null);
useEffect(() => {
// Public state hook for themes (docs/theming.md).
@@ -97,19 +145,20 @@ export function SpacePanel() {
<PanelResizeHandle panelRef={panelRef} onToggle={shell.toggleNav} />
</div>
)}
- {Peek && (
- <aside
- data-slot="space-panel-peek"
- onPointerEnter={shell.holdPeek}
- onPointerLeave={shell.releasePeek}
- className={cn(
- NAV_PEEK_CLASS,
- "max-md:hidden",
- peekSpace && LIST_PEEKS[peekSpace] && LIST_COLUMN_WIDTH_CLASS,
+ {navCollapsed && (
+ <AnimatePresence>
+ {Peek && (
+ <SpacePanelPeek
+ key="space-panel-peek"
+ isListPeek={Boolean(peekSpace && LIST_PEEKS[peekSpace])}
+ reduceMotion={reduceMotion}
+ onPointerEnter={shell.holdPeek}
+ onPointerLeave={shell.releasePeek}
+ >
+ <Peek />
+ </SpacePanelPeek>
)}
- >
- <Peek />
- </aside>
+ </AnimatePresence>
)}
</>
);
diff --git a/packages/views/search/rows.tsx b/packages/views/search/rows.tsx
index d909abf27e..e005796157 100644
--- a/packages/views/search/rows.tsx
+++ b/packages/views/search/rows.tsx
@@ -18,7 +18,7 @@ export const GROUP_CLASS =
"px-2 py-1 [&_[cmdk-group-heading]]:flex [&_[cmdk-group-heading]]:min-w-0 [&_[cmdk-group-heading]]:items-center [&_[cmdk-group-heading]]:gap-1.5 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pt-1.5 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:text-caption [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground";
export const ROW_CLASS =
- "group/row flex min-h-[var(--issue-row-height)] cursor-default select-none items-center gap-2.5 rounded-md px-2 py-1 text-body outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-accent";
+ "group/row flex min-h-[var(--issue-row-height)] cursor-default select-none items-center gap-2.5 rounded-md px-2 py-1 text-body outline-none transition-[background-color,opacity] duration-100 motion-reduce:transition-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-accent";
export const ROW_ICON_CLASS = "size-4 shrink-0 text-muted-foreground";
diff --git a/packages/views/search/search-command.tsx b/packages/views/search/search-command.tsx
index 67cc15f448..476a7cec83 100644
--- a/packages/views/search/search-command.tsx
+++ b/packages/views/search/search-command.tsx
@@ -1,7 +1,11 @@
"use client";
-import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
+import { motion } from "motion/react";
+import { useReducedMotion } from "@multica/core/appearance";
import { ChevronRight, SearchIcon } from "@multica/ui/icons";
+import { UI_EASE_OUT } from "@multica/ui/lib/motion";
+import { cn } from "@multica/ui/lib/utils";
import { Command as CommandPrimitive } from "cmdk";
import {
selectCommandBarContexts,
@@ -141,6 +145,7 @@ function PaletteBody({
return (
<PaletteContext.Provider value={api}>
<PaletteFrame
+ active={active}
stack={stack}
setStack={setStack}
pageQuery={pageQuery}
@@ -151,14 +156,18 @@ function PaletteBody({
);
}
+const PALETTE_NAV_DURATION = 0.14;
+
/** Everything that reads the palette API lives under its provider. */
function PaletteFrame({
+ active,
stack,
setStack,
pageQuery,
setPageQuery,
recordIntent,
}: {
+ active: boolean;
stack: PaletteStackEntry[];
setStack: React.Dispatch<React.SetStateAction<PaletteStackEntry[]>>;
pageQuery: string;
@@ -166,12 +175,86 @@ function PaletteFrame({
recordIntent: (e: Pick<MouseEvent, "button" | "metaKey" | "ctrlKey" | "shiftKey">) => void;
}) {
const { t } = useT("search");
+ const reduceMotion = useReducedMotion();
const entries = useCommandBarContextStore(selectCommandBarContexts);
const contexts = useMemo(() => entries.map((entry) => entry.context), [entries]);
const [rawQuery, setRawQuery] = useState("");
const current = stack[stack.length - 1] ?? null;
const inputValue = current ? pageQuery : rawQuery;
+ const inputRef = useRef<HTMLInputElement>(null);
+ const listRef = useRef<HTMLDivElement>(null);
+ const contentRef = useRef<HTMLDivElement>(null);
+ const prevDepthRef = useRef(stack.length);
+ const navDirectionRef = useRef<-1 | 0 | 1>(0);
+ if (stack.length !== prevDepthRef.current) {
+ navDirectionRef.current = stack.length > prevDepthRef.current ? 1 : -1;
+ prevDepthRef.current = stack.length;
+ }
+ const navDirection = navDirectionRef.current;
+ const pageKey = current ? `${stack.length}:${current.page.type}` : "root";
+
+ const [listHeight, setListHeight] = useState<number | undefined>(undefined);
+ const [animateHeight, setAnimateHeight] = useState(false);
+ const activeRef = useRef(active);
+ activeRef.current = active;
+
+ // Keep list height smooth as filtering or subpage navigation changes the
+ // rendered rows, without animating from 0 on initial open or collapsing
+ // while the dialog exits.
+ useLayoutEffect(() => {
+ if (reduceMotion) {
+ setListHeight(undefined);
+ setAnimateHeight(false);
+ return;
+ }
+ const content = contentRef.current;
+ const list = listRef.current;
+ if (!content || !list || typeof ResizeObserver === "undefined") return;
+
+ let initialized = false;
+ let rafId = 0;
+ const syncHeight = () => {
+ if (!activeRef.current) return;
+ // offsetHeight ignores the dialog's zoom-in transform; a scaled
+ // getBoundingClientRect() read would pin the list at ~95% height.
+ const contentHeight = content.offsetHeight;
+ if (contentHeight <= 0) return;
+ const styles = getComputedStyle(list);
+ const padY =
+ (Number.parseFloat(styles.paddingTop) || 0) +
+ (Number.parseFloat(styles.paddingBottom) || 0);
+ const maxH = Number.parseFloat(styles.maxHeight);
+ const rawNext = contentHeight + padY;
+ const clamped = Number.isFinite(maxH) && maxH > 0 ? Math.min(rawNext, maxH) : rawNext;
+ setListHeight(clamped);
+ if (!initialized) {
+ initialized = true;
+ rafId = requestAnimationFrame(() => setAnimateHeight(true));
+ }
+ };
+
+ syncHeight();
+ const observer = new ResizeObserver(syncHeight);
+ observer.observe(content);
+ return () => {
+ cancelAnimationFrame(rafId);
+ observer.disconnect();
+ };
+ }, [reduceMotion]);
+
+ // Reset scroll to the top and keep the caret at the end of any carried query
+ // when drilling into or returning from a subpage.
+ useLayoutEffect(() => {
+ if (listRef.current) listRef.current.scrollTop = 0;
+ if (navDirection === 0) return;
+ const el = inputRef.current;
+ if (!el) return;
+ el.focus();
+ const end = el.value.length;
+ el.setSelectionRange(end, end);
+ }, [pageKey, navDirection]);
+
// Base UI's DialogPortal only mounts PaletteBody while open or exiting, so
// keeping `active: true` does not fetch while closed and prevents recent
// items and search results from clearing on frame 1 of the exit animation.
@@ -194,7 +277,6 @@ function PaletteFrame({
<>
<CommandPrimitive
data-mc="command-palette"
- key={stack.length}
label={t(($) => $.title)}
shouldFilter={false}
onPointerDownCapture={recordIntent}
@@ -209,7 +291,17 @@ function PaletteFrame({
<div className="flex items-center gap-2 border-b px-4 py-3">
<SearchIcon className="size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
{current && (
- <nav aria-label={t(($) => $.breadcrumb_aria)} className="flex min-w-0 shrink items-center gap-1">
+ <motion.nav
+ key={pageKey}
+ aria-label={t(($) => $.breadcrumb_aria)}
+ initial={reduceMotion ? false : { opacity: 0, x: -6 }}
+ animate={{
+ opacity: 1,
+ x: 0,
+ transition: { duration: reduceMotion ? 0 : PALETTE_NAV_DURATION, ease: UI_EASE_OUT },
+ }}
+ className="flex min-w-0 shrink items-center gap-1"
+ >
{current.crumbs.map((crumb, index) => (
<Fragment key={`${index}:${crumb}`}>
{index > 0 && <ChevronRight className="size-3 shrink-0 text-muted-foreground" />}
@@ -218,16 +310,15 @@ function PaletteFrame({
</span>
</Fragment>
))}
- </nav>
+ </motion.nav>
)}
<CommandPrimitive.Input
+ ref={inputRef}
autoFocus
placeholder={current ? t(($) => $.page_placeholder) : t(($) => $.placeholder)}
value={inputValue}
onValueChange={(value) => (current ? setPageQuery(value) : setRawQuery(value))}
onKeyDown={handleKeyDown}
- // The input remounts when a page opens or closes; keep the caret
- // after text carried across.
onFocus={(e) => {
const end = e.currentTarget.value.length;
e.currentTarget.setSelectionRange(end, end);
@@ -237,12 +328,31 @@ function PaletteFrame({
<ShortcutKeycaps shortcut={ESCAPE} className="hidden shrink-0 sm:inline-flex" />
</div>
- <CommandPrimitive.List className="max-h-[min(440px,55vh)] overflow-y-auto overflow-x-hidden py-1">
- {current ? (
- <PageView page={current.page} query={pageQuery} />
- ) : (
- <RootView model={model} rawQuery={rawQuery} />
+ <CommandPrimitive.List
+ ref={listRef}
+ style={listHeight !== undefined ? { height: listHeight } : undefined}
+ className={cn(
+ "max-h-[min(440px,55vh)] overflow-y-auto overflow-x-hidden py-1",
+ animateHeight && "transition-[height] duration-[140ms] ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none",
)}
+ >
+ <div ref={contentRef}>
+ <motion.div
+ key={pageKey}
+ initial={reduceMotion || navDirection === 0 ? false : { opacity: 0, x: navDirection * 10 }}
+ animate={{ opacity: 1, x: 0 }}
+ transition={{
+ duration: reduceMotion || navDirection === 0 ? 0 : PALETTE_NAV_DURATION,
+ ease: UI_EASE_OUT,
+ }}
+ >
+ {current ? (
+ <PageView page={current.page} query={pageQuery} />
+ ) : (
+ <RootView model={model} rawQuery={rawQuery} />
+ )}
+ </motion.div>
+ </div>
</CommandPrimitive.List>
<PaletteFooter mode={current ? "page" : "root"} />