Skip to content

Commit 94e5450

Browse files
committed
feat(web): animate task completion segments
1 parent eee0557 commit 94e5450

3 files changed

Lines changed: 71 additions & 7 deletions

File tree

‎apps/web/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"jszip": "3.10.1",
4141
"lexical": "^0.41.0",
4242
"lucide-react": "^0.564.0",
43+
"motion": "13.2.0",
4344
"react": "19.2.6",
4445
"react-dom": "19.2.6",
4546
"react-markdown": "^10.1.0",

‎apps/web/src/components/chat/ComposerTasksBadge.tsx‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { ListTodoIcon } from "lucide-react";
2+
// Motion state updates animate only the decorative completion fill:
3+
// https://motion.dev/docs/react-animation
4+
// https://motion.dev/docs/react-use-reduced-motion
5+
import { motion, useReducedMotion } from "motion/react";
26
import { memo, type ComponentProps } from "react";
37

48
import { formatDuration } from "../../session-logic";
@@ -35,6 +39,7 @@ function TaskSegments({
3539
readonly className?: string;
3640
readonly steps: readonly ComposerTaskStep[];
3741
}) {
42+
const reduceMotion = useReducedMotion();
3843
if (steps.length <= 1 || steps.length > MAX_TASK_SEGMENTS) return null;
3944

4045
return (
@@ -43,14 +48,18 @@ function TaskSegments({
4348
<span
4449
key={key}
4550
className={cn(
46-
"h-[3px] min-w-0 flex-1 rounded-full",
47-
step.status === "completed"
48-
? "bg-success"
49-
: step.status === "inProgress"
50-
? "bg-primary"
51-
: "bg-muted-foreground/25",
51+
"relative h-[3px] min-w-0 flex-1 overflow-hidden rounded-full",
52+
step.status === "inProgress" ? "bg-primary" : "bg-muted-foreground/25",
5253
)}
53-
/>
54+
>
55+
<motion.span
56+
className="absolute inset-0 origin-left bg-success"
57+
// History opens at its real state; only subsequent progress changes animate.
58+
initial={false}
59+
animate={{ scaleX: step.status === "completed" ? 1 : 0 }}
60+
transition={{ type: "tween", duration: reduceMotion ? 0 : 0.18, ease: "easeOut" }}
61+
/>
62+
</span>
5463
))}
5564
</span>
5665
);

‎pnpm-lock.yaml‎

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)