Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): design-system Timeline with dotted faded connectors (#18464)

Trang Nguyeneaeb5076c2c3
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a9ac819aa2..4cce8f91d5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -560,6 +560,7 @@ The background color of the following component will be `hsl(var(--primary))` an
| --find-match-background | Background color for search matches | CodeMirrorEditor |
| --surface-sunken | Off-white panel behind detail content (99%, lighter than zinc-50) | Trace detail panel, nav sidebar |
| --surface-output | Background of output blocks in the trace preview (zinc-100) | IOPreview, MarkdownViewer |
+| --line-dotted | Dotted connector lines; dimmed in dark | dotted-line-y, prompt timeline |
| --surface | Sticky table chrome fill; follows --surface-context | Table headers, footers |
| --observation-<type>-line | Observation type colour for stroked icons and borders | ItemTypeIcon, graph nodes |
| --observation-<type>-fill | Observation type colour for fills under white icons | ItemTypeTile, timeline bars |
diff --git a/web/src/components/design-system/Timeline/Timeline.stories.tsx b/web/src/components/design-system/Timeline/Timeline.stories.tsx
new file mode 100644
index 0000000000..7ea76a50a5
--- /dev/null
+++ b/web/src/components/design-system/Timeline/Timeline.stories.tsx
@@ -0,0 +1,58 @@
+import { fn } from "storybook/test";
+
+import preview from "../../../../.storybook/preview";
+import { Timeline } from "./Timeline";
+
+const meta = preview.meta({
+ component: Timeline,
+});
+
+const versions = [
+ { version: 3, message: "Tighten system prompt", author: "jane" },
+ { version: 2, message: "Add tool instructions", author: "sam" },
+ { version: 1, message: "Initial version", author: "jane" },
+];
+
+function renderItems(items: typeof versions, activeVersion?: number) {
+ return items.map((item) => (
+ <Timeline.Item
+ key={item.version}
+ isActive={item.version === activeVersion}
+ onClick={fn()}
+ >
+ <span className="text-xs"># {item.version}</span>
+ <span
+ className="text-muted-foreground truncate text-xs"
+ title={item.message}
+ >
+ {item.message}
+ </span>
+ <span className="text-muted-foreground text-xs">by {item.author}</span>
+ </Timeline.Item>
+ ));
+}
+
+export const Default = meta.story({
+ args: {
+ children: renderItems(versions),
+ },
+});
+
+export const WithSelection = meta.story({
+ args: {
+ children: renderItems(versions, 2),
+ },
+});
+
+export const LongList = meta.story({
+ args: {
+ children: renderItems(
+ Array.from({ length: 12 }, (_, i) => ({
+ version: 12 - i,
+ message: `Revision ${12 - i}`,
+ author: i % 2 === 0 ? "jane" : "sam",
+ })),
+ 12,
+ ),
+ },
+});
diff --git a/web/src/components/design-system/Timeline/Timeline.tsx b/web/src/components/design-system/Timeline/Timeline.tsx
new file mode 100644
index 0000000000..1529e28728
--- /dev/null
+++ b/web/src/components/design-system/Timeline/Timeline.tsx
@@ -0,0 +1,75 @@
+import { cva } from "class-variance-authority";
+import type * as React from "react";
+
+type TimelineProps = {
+ children: React.ReactNode;
+};
+
+function TimelineRoot({ children }: TimelineProps) {
+ return (
+ <div className="relative w-full">
+ {/* The last item draws no connector, so the line ends at its dot. */}
+ <div className="flex flex-col gap-2 pl-5 [&>:last-child_[data-timeline-connector]]:hidden">
+ {children}
+ </div>
+ </div>
+ );
+}
+
+const timelineItemVariants = cva(
+ "group group/timeline-item relative flex w-full cursor-pointer flex-col gap-1 rounded-sm p-2",
+ {
+ variants: {
+ isActive: {
+ true: "bg-muted text-foreground",
+ false: "hover:bg-muted/50",
+ },
+ },
+ defaultVariants: {
+ isActive: false,
+ },
+ },
+);
+
+type TimelineItemProps = {
+ children: React.ReactNode;
+ ref?: React.RefObject<HTMLDivElement | null>;
+ isActive?: boolean;
+ onClick?: React.MouseEventHandler<HTMLDivElement>;
+ onMouseEnter?: () => void;
+ onMouseLeave?: () => void;
+};
+
+function TimelineItem({
+ children,
+ ref,
+ isActive = false,
+ onClick,
+ onMouseEnter,
+ onMouseLeave,
+}: TimelineItemProps) {
+ return (
+ <div
+ ref={ref}
+ className={timelineItemVariants({ isActive })}
+ onClick={onClick}
+ onMouseEnter={onMouseEnter}
+ onMouseLeave={onMouseLeave}
+ >
+ <div className="bg-foreground-tertiary absolute top-3.25 -left-3.5 size-1.5 rounded-full" />
+ {/* Connector to the next item's dot, inset 4px from both dots. */}
+ <div
+ data-timeline-connector
+ className="dotted-line-y absolute top-5.75 -bottom-4.25 -left-3.5 w-1.5 bg-top"
+ />
+
+ {children}
+ </div>
+ );
+}
+
+const Timeline = Object.assign(TimelineRoot, {
+ Item: TimelineItem,
+});
+
+export { Timeline };
diff --git a/web/src/features/prompts/components/prompt-history.tsx b/web/src/features/prompts/components/prompt-history.tsx
index 4e6eee8d78..97925358c3 100644
--- a/web/src/features/prompts/components/prompt-history.tsx
+++ b/web/src/features/prompts/components/prompt-history.tsx
@@ -1,10 +1,7 @@
import { type RouterOutputs } from "@/src/utils/api";
import { useState, useRef, useEffect } from "react";
import { PromptVersionDiffDialogContent } from "./PromptVersionDiffDialog";
-import {
- Timeline,
- TimelineItem,
-} from "@/src/features/prompts/components/timeline";
+import { Timeline } from "@/src/components/design-system/Timeline/Timeline";
import { Badge } from "@/src/components/ui/badge";
import { CommandItem } from "@/src/components/ui/command";
import { Button } from "@/src/components/ui/button";
@@ -60,7 +57,7 @@ const PromptHistoryTraceNode = (props: {
cursor: "pointer",
}}
>
- <TimelineItem
+ <Timeline.Item
key={prompt.id}
isActive={props.currentPromptVersion === prompt.version}
onMouseEnter={() => setIsHovered(true)}
@@ -177,7 +174,7 @@ const PromptHistoryTraceNode = (props: {
</div>
</div>
</div>
- </TimelineItem>
+ </Timeline.Item>
</CommandItem>
);
};
diff --git a/web/src/features/prompts/components/timeline.tsx b/web/src/features/prompts/components/timeline.tsx
deleted file mode 100644
index da7dd0182b..0000000000
--- a/web/src/features/prompts/components/timeline.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-/* eslint-disable @repo/no-style-props */
-import { cn } from "@/src/utils/tailwind";
-
-interface TimelineProps {
- children: React.ReactNode;
- className?: string;
-}
-
-export function Timeline({ children, className }: TimelineProps) {
- return (
- <div className={cn("relative w-full", className)}>
- {/* Timeline line */}
- <div className="bg-border-contrast absolute left-2 mt-4 h-[calc(100%-16px)] w-px" />
-
- {/* Timeline items container */}
- <div className="pl-4">{children}</div>
- </div>
- );
-}
-
-interface TimelineItemProps {
- children: React.ReactNode;
- ref?: React.RefObject<HTMLDivElement | null>;
- className?: string;
- isActive?: boolean;
- onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
- onMouseEnter?: () => void;
- onMouseLeave?: () => void;
-}
-
-export function TimelineItem({
- children,
- ref,
- isActive,
- onClick,
- onMouseEnter,
- onMouseLeave,
- className,
-}: TimelineItemProps) {
- return (
- <div
- ref={ref}
- className={cn(
- "group relative mb-2 flex w-full cursor-pointer flex-col gap-1 rounded-sm p-2",
- isActive ? "bg-muted" : "hover:bg-muted/50",
- className,
- )}
- onClick={onClick}
- onMouseEnter={onMouseEnter}
- onMouseLeave={onMouseLeave}
- >
- {/* Timeline dot */}
- <div
- className={cn(
- "bg-border-contrast absolute top-3 left-[-11.5px] h-2 w-2 rounded-full",
- isActive ? "border-primary" : "border-muted-foreground",
- )}
- />
-
- {children}
- </div>
- );
-}
diff --git a/web/src/features/skills/components/SkillVersionHistory.tsx b/web/src/features/skills/components/SkillVersionHistory.tsx
index 91349737e0..2127a7436f 100644
--- a/web/src/features/skills/components/SkillVersionHistory.tsx
+++ b/web/src/features/skills/components/SkillVersionHistory.tsx
@@ -3,10 +3,7 @@ import { FileDiffIcon, PanelLeftClose, PanelLeftOpen } from "lucide-react";
import { IconButton } from "@/src/components/design-system/IconButton/IconButton";
import { Badge } from "@/src/components/ui/badge";
import { Button } from "@/src/components/ui/button";
-import {
- Timeline,
- TimelineItem,
-} from "@/src/features/prompts/components/timeline";
+import { Timeline } from "@/src/components/design-system/Timeline/Timeline";
import { cn } from "@/src/utils/tailwind";
import { type SkillEditorStore } from "./skillEditorStore";
import { SkillLabelsSelect } from "./SkillMetadataSelect";
@@ -97,7 +94,7 @@ export function SkillVersionHistory(
<div className="overflow-y-auto p-2">
<Timeline>
{showDraft ? (
- <TimelineItem isActive={props.kind === "new" || props.isDraft}>
+ <Timeline.Item isActive={props.kind === "new" || props.isDraft}>
<div className="flex items-start gap-1">
<button
type="button"
@@ -139,7 +136,7 @@ export function SkillVersionHistory(
</SkillVersionComparisonController>
) : null}
</div>
- </TimelineItem>
+ </Timeline.Item>
) : null}
{props.kind === "versions"
? sortedVersions.map(
@@ -151,9 +148,8 @@ export function SkillVersionHistory(
createdBy,
creator,
}) => (
- <TimelineItem
+ <Timeline.Item
key={version}
- className="group/skill-version"
isActive={
!props.isDraft && version === props.selectedVersion
}
@@ -227,7 +223,7 @@ export function SkillVersionHistory(
openComparison(version, props.isDraft);
};
return (
- <div className="shrink-0 group-focus-within/skill-version:opacity-100 group-hover/skill-version:opacity-100 [@media(hover:hover)]:opacity-0">
+ <div className="shrink-0 group-focus-within/timeline-item:opacity-100 group-hover/timeline-item:opacity-100 [@media(hover:hover)]:opacity-0">
<IconButton
icon={FileDiffIcon}
label={
@@ -250,7 +246,7 @@ export function SkillVersionHistory(
</SkillVersionComparisonController>
) : null}
</div>
- </TimelineItem>
+ </Timeline.Item>
),
)
: null}
diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css
index e228b3ffea..5da64ac6b6 100644
--- a/web/src/styles/globals.css
+++ b/web/src/styles/globals.css
@@ -151,6 +151,7 @@
--color-border: hsl(var(--border));
--color-border-contrast: hsl(var(--border-contrast));
+ --color-line-dotted: hsl(var(--line-dotted));
--color-input: hsl(var(--input));
--color-ring: hsl(var(--ring));
--color-background: hsl(var(--background));
@@ -357,6 +358,7 @@
/* Structural/viz lines (tree connectors, timeline grid + bar outlines):
one clear step stronger than the hairline --border. */
--border-contrast: 240 4.9% 83.9%; /* zinc-300 */
+ --line-dotted: 240 5.2% 33.9%; /* zinc-600 */
--input: 240 5.9% 90%; /* zinc-200 */
--primary: 240 5.9% 10%; /* zinc-900 */
@@ -582,6 +584,7 @@
/* Hairline must read on EVERY surface tier, including popover (12%). */
--border: 0 0% 20%;
--border-contrast: 0 0% 26%;
+ --line-dotted: 0 0% 42%;
--input: 0 0% 18%;
--primary: 0 0% 90%;
@@ -933,6 +936,24 @@
}
}
+/* Vertical twin of underline-dotted, e.g. timeline connectors. */
+@utility dotted-line-y {
+ background-image: linear-gradient(
+ to bottom,
+ hsl(var(--line-dotted)) 1px,
+ transparent 1px
+ );
+ background-repeat: repeat-y;
+ background-size: 1px 4px;
+ mask-image: linear-gradient(
+ to bottom,
+ transparent,
+ black calc(var(--spacing) * 3),
+ black calc(100% - var(--spacing) * 3),
+ transparent
+ );
+}
+
@utility scrollbar-visible {
&::-webkit-scrollbar {
width: 8px;