Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(canvas): draw the canvas timeline as a rail (#110417)

Shy Alter9ceec7ce9046
diff --git a/products/canvas/frontend/sidePanel/timeline/CanvasTimelineRow.tsx b/products/canvas/frontend/sidePanel/timeline/CanvasTimelineRow.tsx
index 79310e401ab9..3d751b4eb823 100644
--- a/products/canvas/frontend/sidePanel/timeline/CanvasTimelineRow.tsx
+++ b/products/canvas/frontend/sidePanel/timeline/CanvasTimelineRow.tsx
@@ -1,15 +1,18 @@
-import { ReactNode } from 'react'
+import { ReactNode, useEffect, useRef } from 'react'
-import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle, cn } from '@posthog/quill'
+import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle, Text, cn } from '@posthog/quill'
export interface CanvasTimelineRowProps {
title: string
meta: string
icon: ReactNode
+ label?: string
/** Status badges, such as Live or a build that failed. */
badges?: ReactNode
/** Whether this row's version is the one on screen. */
viewing: boolean
+ live?: boolean
+ draft?: boolean
onOpen: () => void
action?: ReactNode
dataAttr: string
@@ -20,42 +23,85 @@ export function CanvasTimelineRow({
title,
meta,
icon,
+ label,
badges,
viewing,
+ live = false,
+ draft = false,
onOpen,
action,
dataAttr,
}: CanvasTimelineRowProps): JSX.Element {
+ const rowRef = useRef<HTMLDivElement>(null)
+
+ useEffect(() => {
+ if (viewing) {
+ rowRef.current?.scrollIntoView({ block: 'nearest' })
+ }
+ }, [viewing])
+
return (
- <Item
- variant="outline"
- size="xs"
- data-selected={viewing || undefined}
- // The open button stretches over the whole row, so the row is one target and the action stays separate.
- // The app compiles fill tokens as plain classes only, so the selected fill is toggled, not a variant.
- className={cn('relative items-start', viewing && 'bg-fill-selected')}
- // Item drops a role prop, so the listitem role for ItemGroup's list rides on the render element.
- render={<div role="listitem" />}
- >
- <ItemMedia variant="icon" aria-hidden>
- {icon}
- </ItemMedia>
- <ItemContent className="min-w-0">
- <ItemTitle className="min-w-0">
- <button
- type="button"
- className="line-clamp-2 cursor-pointer text-left outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-2 focus-visible:after:ring-ring"
- onClick={onOpen}
- aria-current={viewing || undefined}
- data-attr={dataAttr}
+ <div ref={rowRef} role="listitem" className="group/timeline-row flex gap-1">
+ <div aria-hidden className="flex w-7 shrink-0 flex-col items-center">
+ <span className="h-2 w-px bg-border group-first/timeline-row:invisible" />
+ <span
+ className={cn(
+ 'flex size-7 shrink-0 items-center justify-center rounded-full border bg-background text-muted-foreground [&_svg]:size-3.5',
+ draft && 'border-dashed',
+ live && 'border-success-foreground bg-success text-success-foreground',
+ viewing && !live && 'border-foreground text-foreground'
+ )}
+ >
+ {icon}
+ </span>
+ <span className="w-px flex-1 bg-border group-last/timeline-row:invisible" />
+ </div>
+ <Item
+ size="xs"
+ data-selected={viewing || undefined}
+ // The open button stretches over the whole row, so the row is one target and the action stays separate.
+ // The app compiles fill tokens as plain classes only, so the selected fill is toggled, not a variant.
+ className={cn(
+ 'relative mb-1 min-w-0 flex-1 items-start',
+ viewing ? 'bg-fill-selected' : 'hover:bg-fill-hover'
+ )}
+ >
+ <ItemContent className="min-w-0 gap-1">
+ {(label || badges) && (
+ <div className="flex flex-wrap items-center gap-1.5">
+ {label && (
+ <Text size="xs" weight="medium" translate="no">
+ {label}
+ </Text>
+ )}
+ {badges}
+ </div>
+ )}
+ <ItemTitle className="min-w-0">
+ <button
+ type="button"
+ className="line-clamp-2 cursor-pointer text-left font-normal outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-2 focus-visible:after:ring-ring"
+ onClick={onOpen}
+ aria-current={viewing || undefined}
+ data-attr={dataAttr}
+ >
+ {title}
+ </button>
+ </ItemTitle>
+ <ItemDescription className="truncate">{meta}</ItemDescription>
+ </ItemContent>
+ {action && (
+ <ItemActions
+ className={cn(
+ 'relative z-10 transition-opacity motion-reduce:transition-none',
+ !viewing &&
+ 'opacity-0 group-hover/timeline-row:opacity-100 group-focus-within/timeline-row:opacity-100'
+ )}
>
- {title}
- </button>
- </ItemTitle>
- <ItemDescription className="truncate">{meta}</ItemDescription>
- {badges && <div className="flex flex-wrap items-center gap-1">{badges}</div>}
- </ItemContent>
- {action && <ItemActions className="relative z-10">{action}</ItemActions>}
- </Item>
+ {action}
+ </ItemActions>
+ )}
+ </Item>
+ </div>
)
}
diff --git a/products/canvas/frontend/sidePanel/timeline/CanvasTimelineTab.tsx b/products/canvas/frontend/sidePanel/timeline/CanvasTimelineTab.tsx
index 6c7cb6cd4289..5dd2e3e1fc8e 100644
--- a/products/canvas/frontend/sidePanel/timeline/CanvasTimelineTab.tsx
+++ b/products/canvas/frontend/sidePanel/timeline/CanvasTimelineTab.tsx
@@ -10,7 +10,6 @@ import {
EmptyHeader,
EmptyMedia,
EmptyTitle,
- ItemGroup,
Skeleton,
Text,
} from '@posthog/quill'
@@ -83,7 +82,7 @@ export function CanvasTimelineTab(): JSX.Element {
<Text id="canvas-timeline-drafts" size="xs" variant="muted" weight="medium" render={<h3 />}>
Drafts
</Text>
- <ItemGroup combined>
+ <div role="list" className="flex flex-col">
{drafts.map((draft) => (
<CanvasTimelineRow
key={draft.version_id}
@@ -96,6 +95,7 @@ export function CanvasTimelineTab(): JSX.Element {
</Badge>
}
viewing={draft.version_id === browseVersionId}
+ draft
onOpen={() => setBrowseVersion(draft.version_id)}
action={
<Button
@@ -112,14 +112,14 @@ export function CanvasTimelineTab(): JSX.Element {
dataAttr="canvas-timeline-draft"
/>
))}
- </ItemGroup>
+ </div>
</section>
)}
<section aria-labelledby="canvas-timeline-versions" className="flex flex-col gap-2">
<Text id="canvas-timeline-versions" size="xs" variant="muted" weight="medium" render={<h3 />}>
Versions
</Text>
- <ItemGroup combined>
+ <div role="list" className="flex flex-col">
{versions.map((version) => {
const build = latestBuildByVersion.get(version.id)
const live = version.id === headVersionId
@@ -127,8 +127,9 @@ export function CanvasTimelineTab(): JSX.Element {
<CanvasTimelineRow
key={version.id}
icon={version.task_id ? <IconSparkles /> : <IconUser />}
+ label={versionLabels[version.id]}
title={canvasVersionTitle(version)}
- meta={`${versionLabels[version.id]} · ${canvasVersionByline(version)}`}
+ meta={canvasVersionByline(version)}
badges={
live || (build && build.build_status !== 'ready') ? (
<>
@@ -142,6 +143,7 @@ export function CanvasTimelineTab(): JSX.Element {
) : undefined
}
viewing={version.id === displayedVersionId}
+ live={live}
onOpen={() => setBrowseVersion(live ? null : version.id)}
action={
live ? null : (
@@ -161,7 +163,7 @@ export function CanvasTimelineTab(): JSX.Element {
/>
)
})}
- </ItemGroup>
+ </div>
</section>
</div>
)