: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tasks): copy a link to an artifact and play video artifacts (#110024)
Shy Alter19b74bacec54
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsxindex 890d6cf016b3..37fec4a16755 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx@@ -192,6 +192,22 @@ const REPORT_OLDER_VERSIONS: TaskRunArtifactResponseApi[] = [const REPORT_FILE_NAME = 'trial-drop-report.md'+// A two-second clip drawn on a canvas for this story: a square that moves across a light frame.+const WALKTHROUGH_WEBM_BASE64 =+ 'GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQRChYECGFOAZwEAAAAAABx8EU2bdLlNu4tTq4QVSalmU6yBbk27i1OrhBZUrmtTrIGTTbuLU6uEH0O2dVOsgcJNu4xTq4QcU7trU6yCHGrsrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBEiYRE8iKYTYCGQ2hyb21lV0GGQ2hyb21lFlSua6quqNeBAXPFh9bR4jEMD0qDgQFV7oEBhoVWX1ZQOOCLsIIBQLqBtFPAgQEfQ7Z1AQAAAAAAG5zngQCgQpqhQgWBAAAAUBgAnQEqQAG0AAqHCIWFiJmEiDgCIkZK4eNlfd5ckOv7FpXrImOH18f4QWr4kzvRX/EeYeExzVnFUYmwUvZibAn2wqi7h6iBEsDw87U1Amf3ThM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qEDwAGAAYWC/0AAiABDNfrXJPlYAA+4IHC6BB0qFBqYEHkQDxCwAqEHAAGsgH8AVxk/komgH9Af4D/AUOcBnQW7RgAI/2nUw/kug/2nUjonzPMBwxo2SriB+pEr8g/3q2DsPyXRVEwwahFvFzaRnPvAU2YNYkylze2E61IhUrIqLIqLIoIP74AqqN9suY/FQqZ6xqpmWdzMgNcY5d4Mmy1L5r86wLllYab+eeqtYpbJGgnK8zvAINakxvnqRhSERgQAelvV2L9RzXWw8Gt02zIP55p+EDVooJ3rpa07HhbZ8C+DTplxQIh2U0m9BYWik0VqQE7vJVSmy57fsBNiwnHHwhidUSfDKq01mKcYYlKJ/Tzf6PjqePd/+o0+J+ep3/qNP+o0Gqqxqr78T//M7/wrLh4/SH/8JrY6jubw8X/+IVF2jf/4hUXgT6zGnx/UO+HH+v/9GBfNDpxp3LcBOXIG3oFnXtmT/2Vw8zGDV4VZaR+y+Ztf/+Hn/6Fq/r5DSjh3In//Vztijd+pH/79oB8/SnY0ZWQVVfbxB/mv+9r7/8/9cl5Dj4ffAX+TP8YFv+DKyFW+eXfuc4o7iig3UM1InZk4VI9fAAdaGfpp3ugQGlmJECACoRwBRgAGFgv9AAIgAQzX61yT5WAPuCB04cU7trjbuLs4EAt4b3gQHxgcI='++const VIDEO_ARTIFACT: TaskRunArtifactResponseApi = {+ id: 'artifact-walkthrough',+ name: 'plan-picker-walkthrough.webm',+ type: 'output',+ source: 'agent_output',+ size: 7340,+ content_type: 'video/webm',+ storage_path: 'tasks/artifacts/artifact-walkthrough',+ uploaded_at: '2026-09-28T18:19:00Z',+ uploaded_by: 'agent',+}+const CONTENT_BY_PATH: Record<string, string> = {'tasks/artifacts/artifact-report': REPORT_MARKDOWN,'tasks/artifacts/artifact-report-v2': REPORT_SECOND_DRAFT_MARKDOWN,@@ -329,6 +345,10 @@ function taskMocks(request: Request}) => {const { storage_path } = (await request.json()) as { storage_path: string }+ if (storage_path === VIDEO_ARTIFACT.storage_path) {+ const bytes = Uint8Array.from(atob(WALKTHROUGH_WEBM_BASE64), (char) => char.charCodeAt(0))+ return new HttpResponse(bytes, { headers: { 'Content-Type': 'video/webm' } })+ }return new HttpResponse(CONTENT_BY_PATH[storage_path] ?? '', {headers: { 'Content-Type': 'text/plain' },})@@ -410,6 +430,11 @@ export const Image: Story = { render: () => <StoryPage fileName="trial-starts-byexport const Csv: Story = { render: () => <StoryPage fileName="trial-starts-by-week.csv" /> }+export const Video: Story = {+ parameters: { msw: { mocks: taskMocks([VIDEO_ARTIFACT, ...ARTIFACTS]) } },+ render: () => <StoryPage fileName={VIDEO_ARTIFACT.name} />,+}+export const Versions: Story = {parameters: { msw: { mocks: taskMocks([...ARTIFACTS, ...REPORT_OLDER_VERSIONS]) } },render: () => <StoryPage fileName={REPORT_FILE_NAME} />,diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsxindex b68f80cc8281..f05cab3af0dd 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx@@ -14,6 +14,8 @@ import {IconExpand45,IconImage,IconLock,+ IconShare,+ IconVideoCamera,} from '@posthog/icons'import {Badge,@@ -82,7 +84,15 @@ type PreviewMode = 'rendered' | 'source'function KindIcon({ kind, className }: { kind: ArtifactPreviewKind; className?: string }): JSX.Element {const Icon =- kind === 'html' ? IconCode : kind === 'image' ? IconImage : kind === 'csv' ? IconDatabase : IconDocument+ kind === 'html'+ ? IconCode+ : kind === 'image'+ ? IconImage+ : kind === 'video'+ ? IconVideoCamera+ : kind === 'csv'+ ? IconDatabase+ : IconDocumentreturn <Icon className={className} />}@@ -197,6 +207,50 @@ function TextLoading(): JSX.Element {)}+function VideoPreview({ taskId, name }: { taskId: string; name: string }): JSX.Element {+ const { selectedArtifact, selectedMedia, artifactMediaLoading } = useValues(taskRunArtifactsLogic({ taskId }))+ const { loadArtifactMedia } = useActions(taskRunArtifactsLogic({ taskId }))+ if (!selectedMedia) {+ return (+ <div className="flex h-full items-center justify-center">+ <Spinner />+ </div>+ )+ }+ if (!selectedMedia.url) {+ return (+ <Empty className="h-full">+ <EmptyHeader>+ <EmptyTitle>This video can't play here</EmptyTitle>+ <EmptyDescription>{selectedMedia.error}</EmptyDescription>+ </EmptyHeader>+ <EmptyContent>+ <Button+ variant="outline"+ loading={artifactMediaLoading}+ onClick={() => selectedArtifact && loadArtifactMedia(selectedArtifact)}+ data-attr="task-artifact-retry"+ >+ Try again+ </Button>+ </EmptyContent>+ </Empty>+ )+ }+ return (+ <div className="flex h-full items-center justify-center p-6">+ <video+ key={selectedMedia.artifactId}+ src={selectedMedia.url}+ controls+ preload="metadata"+ aria-label={name}+ className="max-h-full max-w-full rounded-sm border border-border bg-black"+ />+ </div>+ )+}+function ArtifactPreview({ taskId, mode }: { taskId: string; mode: PreviewMode }): JSX.Element | null {const { selectedArtifact, selectedKind, selectedText, selectedRun, currentProjectId, artifactTextLoading } =useValues(taskRunArtifactsLogic({ taskId }))@@ -211,6 +265,9 @@ function ArtifactPreview({ taskId, mode }: { taskId: string; mode: PreviewMode }const src = artifactDownloadUrl(currentProjectId, taskId, selectedArtifact)return src ? <ArtifactImageViewer key={selectedArtifact.id} src={src} alt={selectedArtifact.name} /> : null}+ if (selectedKind === 'video') {+ return <VideoPreview taskId={taskId} name={selectedArtifact.name} />+ }if (selectedKind === 'none') {return (<Empty className="h-full">@@ -424,6 +481,36 @@ function CopySourceAction({ text }: { text: string | null }): JSX.Element {)}+function CopyLinkAction({ taskId }: { taskId: string }): JSX.Element {+ const { shareUrl } = useValues(taskRunArtifactsLogic({ taskId }))+ const { reportLinkCopied } = useActions(taskRunArtifactsLogic({ taskId }))+ const [copied, setCopied] = useState(false)+ useEffect(() => {+ if (!copied) {+ return+ }+ const timeout = window.setTimeout(() => setCopied(false), 2000)+ return () => window.clearTimeout(timeout)+ }, [copied])+ return (+ <IconAction+ label={copied ? 'Link copied' : 'Copy link to this file'}+ disabledReason={shareUrl ? undefined : 'The file is not ready yet'}+ onClick={() => {+ if (shareUrl) {+ void navigator.clipboard.writeText(shareUrl).then(() => {+ setCopied(true)+ reportLinkCopied()+ })+ }+ }}+ dataAttr="task-artifact-copy-link"+ >+ {copied ? <IconCheck className="size-4" /> : <IconShare className="size-4" />}+ </IconAction>+ )+}+function ArtifactToolbar({taskId,artifact,@@ -524,6 +611,7 @@ function ArtifactToolbar({<IconChevronRight className="size-4" /></IconAction></div>+ <CopyLinkAction taskId={taskId} /><IconActionlabel={versioned ? 'Download this version' : 'Download'}href={downloadUrl ?? undefined}@@ -547,7 +635,8 @@ function ArtifactToolbar({function PreviewSurface({ taskId, mode }: { taskId: string; mode: PreviewMode }): JSX.Element {const { selectedKind } = useValues(taskRunArtifactsLogic({ taskId }))- const fills = mode === 'rendered' && (selectedKind === 'html' || selectedKind === 'image')+ const fills =+ mode === 'rendered' && (selectedKind === 'html' || selectedKind === 'image' || selectedKind === 'video')return (<div className={cn('min-h-0 flex-1 bg-surface-tertiary', fills ? 'flex flex-col' : 'overflow-y-auto')}><ArtifactPreview taskId={taskId} mode={mode} />diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.tsindex abe4a84d0fd5..659b18072a88 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.ts@@ -53,6 +53,7 @@ describe('taskRunArtifacts', () => {'image',],['the extension with no type', { name: 'weeks.csv' }, 'csv'],+ ['a video by extension', { name: 'walkthrough.webm' }, 'video'],['an unknown binary', { name: 'bundle.zip', content_type: 'application/zip' }, 'none'],])('artifactPreviewKind reads %s', (_, overrides, expected) => {expect(artifactPreviewKind(artifact(overrides))).toBe(expected)diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.tsindex 1c7bd5d4b2fd..d1cfdaf3efab 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.ts@@ -2,12 +2,13 @@ import type { TaskRunArtifactResponseApi } from 'products/tasks/frontend/generatexport type TaskRunTab = 'conversation' | 'artifacts'-export type ArtifactPreviewKind = 'markdown' | 'html' | 'image' | 'csv' | 'text' | 'none'+export type ArtifactPreviewKind = 'markdown' | 'html' | 'image' | 'video' | 'csv' | 'text' | 'none'export const ARTIFACT_KIND_LABEL: Record<ArtifactPreviewKind, string> = {markdown: 'Markdown',html: 'HTML',image: 'Image',+ video: 'Video',csv: 'CSV',text: 'Text',none: 'File',@@ -29,6 +30,9 @@ export function artifactPreviewKind(artifact: TaskRunArtifactResponseApi): Artifif (contentType.startsWith('image/') || ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'].includes(ext)) {return 'image'}+ if (contentType.startsWith('video/') || ['mp4', 'm4v', 'mov', 'webm', 'ogv'].includes(ext)) {+ return 'video'+ }if (contentType === 'text/csv' || ext === 'csv') {return 'csv'}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.tsindex 4c4322f52e08..f36fa9896319 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.ts@@ -36,6 +36,11 @@ describe('taskRunArtifactsLogic', () => {selectedVersionId: 'v1',})+ // The copied link must reopen the same file and version.+ expect(logic.values.shareUrl).toBe(+ `http://localhost/project/${logic.values.currentProjectId}/ai?task=${TASK_ID}&artifact=report.md&artifact_version=v1`+ )+logic.actions.selectArtifact('chart.svg')expect(router.values.searchParams).toEqual({ artifact: 'chart.svg' })diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.tsindex 2704e714a02a..2b1fa85bf18e 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts@@ -1,10 +1,24 @@-import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'+import {+ MakeLogicType,+ actions,+ afterMount,+ beforeUnmount,+ connect,+ kea,+ key,+ listeners,+ path,+ props,+ reducers,+ selectors,+} from 'kea'import { loaders } from 'kea-loaders'-import { actionToUrl, router, urlToAction } from 'kea-router'+import { actionToUrl, combineUrl, router, urlToAction } from 'kea-router'import posthog from 'posthog-js'import api from 'lib/api'import { projectLogic } from 'scenes/projectLogic'+import { urls } from 'scenes/urls'import {getTasksRunsArtifactsDownloadCreateUrl,@@ -36,27 +50,39 @@ export interface ArtifactText {error: string | null}+export interface ArtifactMedia {+ artifactId: string+ /** A `blob:` URL. The app's media-src allows it, and not the object storage origin. */+ url: string | null+ error: string | null+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface taskRunArtifactsLogicValues {currentProjectId: number | null // projectLogicruns: TaskRun[] // taskDetailSceneLogicselectedRun: TaskRunDetailDTOApi | null // taskDetailSceneLogicactiveTab: TaskRunTab+ artifactMedia: ArtifactMedia | null+ artifactMediaLoading: booleanartifactText: ArtifactText | nullartifactTextLoading: booleanartifacts: RunArtifact[]chainRuns: TaskRunDetailDTOApi[]chainRunsLoading: booleanfiles: ArtifactFile[]+ mediaById: Record<string, ArtifactMedia>selectedArtifact: RunArtifact | nullselectedFile: ArtifactFile | nullselectedFileName: string | nullselectedIndex: numberselectedKind: ArtifactPreviewKind | null+ selectedMedia: ArtifactMedia | nullselectedText: ArtifactText | nullselectedVersion: RunArtifact | nullselectedVersionId: string | nullselectedVersionIndex: number+ shareUrl: string | nulltextsById: Record<string, ArtifactText>}@@ -75,6 +101,21 @@ export interface taskRunArtifactsLogicActions {ensureSelectedText: () => {value: true}+ loadArtifactMedia: (artifact: RunArtifact) => RunArtifact+ loadArtifactMediaFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadArtifactMediaSuccess: (+ artifactMedia: ArtifactMedia | null,+ payload?: RunArtifact+ ) => {+ artifactMedia: ArtifactMedia | null+ payload?: RunArtifact+ }loadArtifactText: (artifact: RunArtifact) => RunArtifactloadArtifactTextFailure: (error: string,@@ -112,6 +153,9 @@ export interface taskRunArtifactsLogicActions {fileName: stringversionId: string | null}+ reportLinkCopied: () => {+ value: true+ }selectArtifact: (fileName: string) => {fileName: string}@@ -138,6 +182,17 @@ export interface taskRunArtifactsLogicMeta {selectedVersion: (selectedFile: ArtifactFile | null, selectedVersionIndex: number) => RunArtifact | nullselectedArtifact: (selectedVersion: RunArtifact | null) => RunArtifact | nullselectedKind: (selectedArtifact: RunArtifact | null) => ArtifactPreviewKind | null+ selectedMedia: (+ selectedArtifact: RunArtifact | null,+ mediaById: Record<string, ArtifactMedia>+ ) => ArtifactMedia | null+ shareUrl: (+ currentProjectId: number | null,+ selectedFileName: string | null,+ selectedFile: ArtifactFile | null,+ selectedVersionId: string | null,+ arg: any+ ) => string | nullselectedText: (selectedArtifact: RunArtifact | null,textsById: Record<string, ArtifactText>@@ -154,6 +209,8 @@ export type taskRunArtifactsLogicType = MakeLogicType<// A long-lived task can have many runs. Older runs past this cap keep their files out of the list.const MAX_CHAIN_RUNS = 20+// A video plays from a blob in memory, so a very large file goes to a download instead.+const MAX_MEDIA_PREVIEW_BYTES = 200 * 1024 * 1024/** The download-by-id URL redirects to a fresh presigned link, so an `img` or an `a` can use it directly. */export function artifactDownloadUrl(projectId: number | null, taskId: string, artifact: RunArtifact): string | null {@@ -194,6 +251,7 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([downloadArtifact: (artifact: RunArtifact) => ({ artifact }),ensureSelectedText: true,openFromUrl: (fileName: string, versionId: string | null) => ({ fileName, versionId }),+ reportLinkCopied: true,}),loaders(({ props, values }) => ({chainRuns: [@@ -214,6 +272,41 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([},},],+ artifactMedia: [+ null as ArtifactMedia | null,+ {+ loadArtifactMedia: async (artifact: RunArtifact): Promise<ArtifactMedia | null> => {+ if (values.currentProjectId === null || !artifact.id || !artifact.storage_path) {+ return null+ }+ if ((artifact.size ?? 0) > MAX_MEDIA_PREVIEW_BYTES) {+ return {+ artifactId: artifact.id,+ url: null,+ error: 'This video is too large to play here. Download it to watch it.',+ }+ }+ try {+ // nosemgrep: prefer-codegen-api -- A file download: the generated function parses the body as JSON.+ const response = await api.createResponse(+ getTasksRunsArtifactsDownloadCreateUrl(+ String(values.currentProjectId),+ props.taskId,+ artifact.runId+ ),+ { storage_path: artifact.storage_path }+ )+ return { artifactId: artifact.id, url: URL.createObjectURL(await response.blob()), error: null }+ } catch {+ return {+ artifactId: artifact.id,+ url: null,+ error: 'This video did not load. Try again later.',+ }+ }+ },+ },+ ],artifactText: [null as ArtifactText | null,{@@ -262,6 +355,13 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([openFromUrl: (_, { versionId }) => versionId,},],+ mediaById: [+ {} as Record<string, ArtifactMedia>,+ {+ loadArtifactMediaSuccess: (state, { artifactMedia }) =>+ artifactMedia ? { ...state, [artifactMedia.artifactId]: artifactMedia } : state,+ },+ ],textsById: [{} as Record<string, ArtifactText>,{@@ -310,6 +410,39 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([(selectedArtifact: RunArtifact | null): ArtifactPreviewKind | null =>selectedArtifact ? artifactPreviewKind(selectedArtifact) : null,],+ selectedMedia: [+ (s) => [s.selectedArtifact, s.mediaById],+ (selectedArtifact: RunArtifact | null, mediaById: Record<string, ArtifactMedia>): ArtifactMedia | null =>+ (selectedArtifact?.id && mediaById[selectedArtifact.id]) || null,+ ],+ /** The link that opens this tab on the open file and version, for someone else. */+ shareUrl: [+ (s) => [+ s.currentProjectId,+ s.selectedFileName,+ s.selectedFile,+ s.selectedVersionId,+ (_, props) => props.taskId,+ ],+ (+ currentProjectId: number | null,+ selectedFileName: string | null,+ selectedFile: ArtifactFile | null,+ selectedVersionId: string | null,+ taskId: string+ ): string | null => {+ // The same file the url sync writes, so the copied link matches the address bar.+ const fileName = selectedFileName ?? selectedFile?.name+ if (currentProjectId === null || !fileName) {+ return null+ }+ const params: Record<string, string> = { task: taskId, [ARTIFACT_PARAM]: fileName }+ if (selectedVersionId) {+ params[VERSION_PARAM] = selectedVersionId+ }+ return urls.absolute(urls.project(currentProjectId, combineUrl('/ai', params).url))+ },+ ],selectedText: [(s) => [s.selectedArtifact, s.textsById],(selectedArtifact: RunArtifact | null, textsById: Record<string, ArtifactText>): ArtifactText | null =>@@ -320,8 +453,13 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([const loadSelectedText = (): void => {const artifact = values.selectedArtifactconst kind = values.selectedKind- if (values.activeTab === 'artifacts' && artifact && kind && isTextPreview(kind) && !values.selectedText) {+ if (values.activeTab !== 'artifacts' || !artifact || !kind) {+ return+ }+ if (isTextPreview(kind) && !values.selectedText) {actions.loadArtifactText(artifact)+ } else if (kind === 'video' && !values.selectedMedia) {+ actions.loadArtifactMedia(artifact)}}const previewSelected = (): void => {@@ -367,6 +505,13 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([downloadArtifact: ({ artifact }) => {posthog.capture('task artifact downloaded', { kind: artifactPreviewKind(artifact) })},+ reportLinkCopied: () => {+ // pinned: analytics event name and properties. Renaming them breaks insights.+ posthog.capture('task artifact link copied', {+ kind: values.selectedKind,+ is_latest_version: values.selectedVersionIndex === 0,+ })+ },openFromUrl: ({ versionId }) => {// pinned: analytics event name and properties. Renaming them breaks insights.posthog.capture('task artifact link opened', { has_version: !!versionId })@@ -415,4 +560,11 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([actions.loadChainRuns(values.runs.map((run) => run.id))}}),+ beforeUnmount(({ values }) => {+ for (const media of Object.values(values.mediaById)) {+ if (media.url) {+ URL.revokeObjectURL(media.url)+ }+ }+ }),])