Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(motion): straighten Tailwind v4 drag drop, harden CollapsibleSlot & static reduced-motion tab cues (MUL-9948) (#11325)
Jiayuan Zhang972329339b6d
diff --git a/apps/desktop/src/renderer/src/components/tab-bar.test.tsx b/apps/desktop/src/renderer/src/components/tab-bar.test.tsxindex e01ec48f8d..52845f7bf1 100644--- a/apps/desktop/src/renderer/src/components/tab-bar.test.tsx+++ b/apps/desktop/src/renderer/src/components/tab-bar.test.tsx@@ -8,6 +8,7 @@ import {within,type RenderResult,} from "@testing-library/react";+import { DEFAULT_APPEARANCE, useAppearanceStore } from "@multica/core/appearance";import { I18nProvider } from "@multica/core/i18n/react";import type { SupportedLocale } from "@multica/core/i18n";import { RESOURCES } from "@multica/views/locales";@@ -356,6 +357,25 @@ describe("TabBar background open of an open tab", () => {timeout: 3000,});});++ it("shows a static highlight without fading under reduced motion and clears after a short hold", async () => {+ useAppearanceStore.getState().set({ reduceMotion: true });+ try {+ state.tabAttention = { tabId: "tB", sequence: 4 };+ const { container } = render(<TabBar />);++ const attention = container.querySelector<HTMLElement>("[data-tab-attention]");+ expect(attention).not.toBeNull();+ // Static span: no inline animated opacity style.+ expect(attention?.style.opacity).toBe("");++ await waitFor(() => expect(state.clearTabAttention).toHaveBeenCalledWith(4), {+ timeout: 1500,+ });+ } finally {+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE });+ }+ });});describe("TabBar pill chrome", () => {diff --git a/apps/desktop/src/renderer/src/components/tab-bar.tsx b/apps/desktop/src/renderer/src/components/tab-bar.tsxindex 985b9d16f8..7f7e5a2d3a 100644--- a/apps/desktop/src/renderer/src/components/tab-bar.tsx+++ b/apps/desktop/src/renderer/src/components/tab-bar.tsx@@ -53,6 +53,9 @@ 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;+const REDUCED_ADDED_HIGHLIGHT_MS = 180;+const REDUCED_ATTENTION_HOLD_MS = 250;+const REDUCED_EDGE_FEEDBACK_MS = 250;type TabSnapshot = {workspaceSlug: string | null;@@ -273,6 +276,24 @@ function SortableTabItem({setShowAddedHighlight(false);}, [isDragging]);+ useEffect(() => {+ if (!showAddedHighlight || !shouldReduceMotion) return;+ const timer = window.setTimeout(+ () => setShowAddedHighlight(false),+ REDUCED_ADDED_HIGHLIGHT_MS,+ );+ return () => window.clearTimeout(timer);+ }, [showAddedHighlight, shouldReduceMotion]);++ useEffect(() => {+ if (attentionSequence <= 0 || !shouldReduceMotion) return;+ const timer = window.setTimeout(+ () => clearTabAttention(attentionSequence),+ REDUCED_ATTENTION_HOLD_MS,+ );+ return () => window.clearTimeout(timer);+ }, [attentionSequence, shouldReduceMotion, clearTabAttention]);+const tabButton = (<buttontype="button"@@ -348,6 +369,7 @@ function SortableTabItem({return (<motion.div+ inert={!isPresent}initial={false}exit={shouldReduceMotion@@ -450,29 +472,43 @@ function SortableTabItem({</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 && (+ {showAddedHighlight &&+ (shouldReduceMotion ? (+ <span+ aria-hidden+ className="pointer-events-none absolute inset-x-0 inset-y-1.5 rounded-lg bg-primary/10 opacity-40 ring-1 ring-inset ring-primary/20"+ />+ ) : (+ <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: 0.65 }}+ animate={{ opacity: 0 }}+ transition={{ duration: 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)}- />- )}+ (shouldReduceMotion ? (+ <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 opacity-60 ring-2 ring-inset ring-brand/70"+ />+ ) : (+ <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: [0, 1, 0, 1, 0] }}+ transition={{ duration: 0.9, ease: "easeOut" }}+ onAnimationComplete={() => clearTabAttention(attentionSequence)}+ />+ ))}</motion.div></div></motion.div>@@ -506,30 +542,44 @@ function NewTabEdgeFeedback({setSignal({ tabId: newTabId, sequence: sequenceRef.current });}, [newTabId, scrollerRef]);+ useEffect(() => {+ if (!signal || !shouldReduceMotion) return;+ const { sequence } = signal;+ const timer = window.setTimeout(() => {+ setSignal((current) => (current?.sequence === sequence ? null : current));+ }, REDUCED_EDGE_FEEDBACK_MS);+ return () => window.clearTimeout(timer);+ }, [signal, shouldReduceMotion]);+if (!signal) return null;+ if (shouldReduceMotion) {+ return (+ <div+ key={`${signal.tabId}-${signal.sequence}`}+ aria-hidden+ data-new-tab-edge-feedback="true"+ className="pointer-events-none absolute inset-y-1.5 right-0 z-20 w-8 rounded-r-lg bg-gradient-to-l from-primary/35 via-primary/10 to-transparent opacity-50"+ />+ );+ }+return (<motion.divkey={`${signal.tabId}-${signal.sequence}`}aria-hiddendata-new-tab-edge-feedback="true"className="pointer-events-none absolute inset-y-1.5 right-0 z-20 w-8 rounded-r-lg bg-gradient-to-l from-primary/35 via-primary/10 to-transparent"- initial={{- opacity: shouldReduceMotion ? 0.45 : 0,- x: shouldReduceMotion ? 0 : 4,- }}- animate={{- opacity: shouldReduceMotion ? [0.45, 0] : [0, 0.8, 0],- x: 0,- }}+ initial={{ opacity: 0, x: 4 }}+ animate={{ opacity: [0, 0.8, 0], x: 0 }}transition={{opacity: {- duration: shouldReduceMotion ? 0.2 : 0.45,- times: shouldReduceMotion ? [0, 1] : [0, 0.18, 1],+ duration: 0.45,+ times: [0, 0.18, 1],ease: "easeOut",},x: {- duration: shouldReduceMotion ? 0 : 0.18,+ duration: 0.18,ease: TAB_ENTRY_EASE,},}}diff --git a/packages/views/chat/components/collapsible-slot.test.tsx b/packages/views/chat/components/collapsible-slot.test.tsxnew file mode 100644index 0000000000..105a774892--- /dev/null+++ b/packages/views/chat/components/collapsible-slot.test.tsx@@ -0,0 +1,68 @@+import { afterEach, describe, expect, it } from "vitest";+import { cleanup, render, screen, waitFor } from "@testing-library/react";+import { DEFAULT_APPEARANCE, useAppearanceStore } from "@multica/core/appearance";+import { CollapsibleSlot } from "./collapsible-slot";++afterEach(() => {+ cleanup();+ useAppearanceStore.setState({ ...DEFAULT_APPEARANCE });+});++describe("CollapsibleSlot", () => {+ it("marks the exiting slot inert and pointer-events-none until it unmounts", async () => {+ const { container, rerender } = render(+ <CollapsibleSlot slotKey="chat-status-banner" visible>+ <button type="button">Retry</button>+ </CollapsibleSlot>,+ );++ const slot = container.querySelector('[data-slot="chat-status-banner"]')!;+ expect(slot).not.toHaveAttribute("inert");+ expect(slot.className).not.toContain("pointer-events-none");+ expect(screen.getByRole("button", { name: "Retry" })).toBeInTheDocument();++ rerender(+ <CollapsibleSlot slotKey="chat-status-banner" visible={false}>+ <button type="button">Retry</button>+ </CollapsibleSlot>,+ );++ const exiting = container.querySelector('[data-slot="chat-status-banner"]');+ if (exiting) {+ expect(exiting).toHaveAttribute("inert");+ expect(exiting.className).toContain("pointer-events-none");+ }++ await waitFor(() => {+ expect(container.querySelector('[data-slot="chat-status-banner"]')).toBeNull();+ });+ });++ it("mounts and unmounts in the same commit under reduced motion", () => {+ useAppearanceStore.getState().set({ reduceMotion: true });++ const { container, rerender } = render(+ <CollapsibleSlot slotKey="chat-status-banner" visible={false}>+ <span>Banner</span>+ </CollapsibleSlot>,+ );+ expect(container.querySelector('[data-slot="chat-status-banner"]')).toBeNull();++ rerender(+ <CollapsibleSlot slotKey="chat-status-banner" visible>+ <span>Banner</span>+ </CollapsibleSlot>,+ );+ const slot = container.querySelector<HTMLElement>('[data-slot="chat-status-banner"]')!;+ expect(slot).toBeInTheDocument();+ expect(slot.style.height).toBe("");+ expect(slot.style.opacity).toBe("");++ rerender(+ <CollapsibleSlot slotKey="chat-status-banner" visible={false}>+ <span>Banner</span>+ </CollapsibleSlot>,+ );+ expect(container.querySelector('[data-slot="chat-status-banner"]')).toBeNull();+ });+});diff --git a/packages/views/chat/components/collapsible-slot.tsx b/packages/views/chat/components/collapsible-slot.tsxindex 7b318047e2..bfcf0bd84d 100644--- a/packages/views/chat/components/collapsible-slot.tsx+++ b/packages/views/chat/components/collapsible-slot.tsx@@ -1,9 +1,37 @@"use client";import type { ReactNode } from "react";-import { AnimatePresence, motion } from "motion/react";+import { AnimatePresence, motion, useIsPresent } from "motion/react";import { useReducedMotion } from "@multica/core/appearance";import { UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";+import { cn } from "@multica/ui/lib/utils";++function CollapsibleSlotInner({+ slotKey,+ children,+}: {+ slotKey: string;+ children: ReactNode;+}) {+ const isPresent = useIsPresent();+ return (+ <motion.div+ data-slot={slotKey}+ inert={!isPresent}+ initial={{ opacity: 0, height: 0, overflow: "hidden" }}+ animate={{+ opacity: 1,+ height: "auto",+ transitionEnd: { overflow: "visible" },+ }}+ exit={{ opacity: 0, height: 0, overflow: "hidden" }}+ transition={{ duration: UI_MOTION_DURATION.fast, ease: UI_EASE_OUT }}+ className={cn("shrink-0", !isPresent && "pointer-events-none")}+ >+ {children}+ </motion.div>+ );+}export function CollapsibleSlot({slotKey,@@ -15,26 +43,21 @@ export function CollapsibleSlot({children: ReactNode;}) {const reduceMotion = useReducedMotion();- const duration = reduceMotion ? 0 : UI_MOTION_DURATION.fast;++ if (reduceMotion) {+ return visible ? (+ <div data-slot={slotKey} className="shrink-0">+ {children}+ </div>+ ) : null;+ }return (<AnimatePresence initial={false}>{visible && (- <motion.div- key={slotKey}- data-slot={slotKey}- initial={{ opacity: 0, height: 0, overflow: "hidden" }}- animate={{- opacity: 1,- height: "auto",- transitionEnd: { overflow: "visible" },- }}- exit={{ opacity: 0, height: 0, overflow: "hidden" }}- transition={{ duration, ease: UI_EASE_OUT }}- className="shrink-0"- >+ <CollapsibleSlotInner key={slotKey} slotKey={slotKey}>{children}- </motion.div>+ </CollapsibleSlotInner>)}</AnimatePresence>);diff --git a/packages/views/issues/components/drag-drop-animation.test.ts b/packages/views/issues/components/drag-drop-animation.test.tsindex 3d5a411a18..727c3ceaa6 100644--- a/packages/views/issues/components/drag-drop-animation.test.ts+++ b/packages/views/issues/components/drag-drop-animation.test.ts@@ -26,6 +26,8 @@ function makeDropArgs() {const overlayNode = document.createElement("div");const innerCard = document.createElement("div");+ innerCard.style.rotate = "1deg";+ innerCard.style.scale = "1.01";overlayNode.appendChild(innerCard);const outerAnim = makeFakeAnim();@@ -87,13 +89,18 @@ describe("createIssueDropAnimation", () => {},);expect(innerAnimate).toHaveBeenCalledWith(- expect.arrayContaining([+ [expect.objectContaining({- transform: "rotate(0deg) scale(1)",+ rotate: "1deg",+ scale: "1.01",+ }),+ {+ rotate: "0deg",+ scale: "1",opacity: "1",boxShadow: "none",- }),- ]),+ },+ ],{duration: ISSUE_DROP_DURATION_MS,easing: UI_EASE_OUT_CSS,diff --git a/packages/views/issues/components/drag-drop-animation.ts b/packages/views/issues/components/drag-drop-animation.tsindex 4dbbe2c996..b85e7d6f89 100644--- a/packages/views/issues/components/drag-drop-animation.ts+++ b/packages/views/issues/components/drag-drop-animation.ts@@ -73,17 +73,29 @@ export function createIssueDropAnimation(timing,);+ const innerStyle = innerCard ? getComputedStyle(innerCard) : null;+ const fromRotate =+ innerStyle?.rotate && innerStyle.rotate !== "none"+ ? innerStyle.rotate+ : "0deg";+ const fromScale =+ innerStyle?.scale && innerStyle.scale !== "none" ? innerStyle.scale : "1";+const innerAnim =- innerCard && typeof innerCard.animate === "function"+ innerCard && innerStyle && typeof innerCard.animate === "function"? innerCard.animate([{- transform: getComputedStyle(innerCard).transform,- opacity: getComputedStyle(innerCard).opacity,- boxShadow: getComputedStyle(innerCard).boxShadow,+ // Tailwind v4 `rotate-*` and `scale-*` write the standalone+ // `rotate` and `scale` properties, not `transform`.+ rotate: fromRotate,+ scale: fromScale,+ opacity: innerStyle.opacity,+ boxShadow: innerStyle.boxShadow,},{- transform: "rotate(0deg) scale(1)",+ rotate: "0deg",+ scale: "1",opacity: "1",boxShadow: "none",},