@@ -21,15 +21,14 @@ import type {
2121 TaskRun ,
2222 TaskThreadMessage ,
2323} from "@posthog/shared/domain-types" ;
24- import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient" ;
2524import { iconForTemplate } from "@posthog/ui/features/canvas/components/canvasTemplateIcon" ;
2625import { useTaskRuns } from "@posthog/ui/features/canvas/hooks/useTaskRuns" ;
2726import { useReviewNavigationStore } from "@posthog/ui/features/code-review/reviewNavigationStore" ;
2827import { usePrArtifact } from "@posthog/ui/features/git-interaction/usePrArtifact" ;
28+ import { usePanelLayoutStore } from "@posthog/ui/features/panels/panelLayoutStore" ;
2929import { usePrComments } from "@posthog/ui/features/pr-review/usePrComments" ;
3030import { usePrReviewThreads } from "@posthog/ui/features/pr-review/usePrReviewThreads" ;
3131import { FileIcon } from "@posthog/ui/primitives/FileIcon" ;
32- import { toast } from "@posthog/ui/primitives/toast" ;
3332import { openExternalUrl } from "@posthog/ui/shell/openExternal" ;
3433import { formatFileSize } from "@posthog/ui/utils/formatFileSize" ;
3534import { parseHttpsUrl , parseShareLink } from "@posthog/ui/utils/posthogLinks" ;
@@ -43,8 +42,8 @@ type ArtifactRow =
4342 | {
4443 kind : "file" ;
4544 key : string ;
45+ artifactId : string | null ;
4646 name : string ;
47- storagePath : string | null ;
4847 runId : string | null ;
4948 size : number | undefined ;
5049 }
@@ -110,8 +109,8 @@ function buildRows(
110109 rows . push ( {
111110 kind : "file" ,
112111 key : `file:${ file . id ?? file . storage_path ?? name } ` ,
112+ artifactId : file . id ?? null ,
113113 name,
114- storagePath : file . storage_path ?? null ,
115114 runId,
116115 size : file . size ,
117116 } ) ;
@@ -238,41 +237,32 @@ function CanvasRow({ name, url }: { name: string; url: string | null }) {
238237function FileRow ( {
239238 taskId,
240239 runId,
240+ artifactId,
241241 name,
242- storagePath,
243242 size,
244243} : {
245244 taskId : string ;
246245 runId : string | null ;
246+ artifactId : string | null ;
247247 name : string ;
248- storagePath : string | null ;
249248 size : number | undefined ;
250249} ) {
251- const client = useOptionalAuthenticatedClient ( ) ;
252- const canOpen = ! ! client && ! ! runId && ! ! storagePath ;
250+ const openArtifactTab = usePanelLayoutStore ( ( state ) => state . openArtifactTab ) ;
251+ const canOpen = ! ! runId && ! ! artifactId ;
253252 const onOpen = canOpen
254253 ? ( ) => {
255- client
256- . presignTaskRunArtifact (
257- taskId ,
258- runId as string ,
259- storagePath as string ,
260- )
261- . then ( ( url ) => openExternalUrl ( url ) )
262- . catch ( ( error : unknown ) => {
263- toast . error ( "Couldn't open file" , {
264- description :
265- error instanceof Error ? error . message : String ( error ) ,
266- } ) ;
267- } ) ;
254+ openArtifactTab ( taskId , {
255+ runId : runId as string ,
256+ artifactId : artifactId as string ,
257+ name,
258+ } ) ;
268259 }
269260 : undefined ;
270261 return (
271262 < ArtifactListRow
272263 icon = { < FileIcon filename = { name } size = { 14 } /> }
273264 title = { name }
274265 detail = { [ "File" , formatFileSize ( size ) ] . filter ( Boolean ) . join ( " · " ) }
275- external = { canOpen }
276266 onOpen = { onOpen }
277267 />
278268 ) ;
@@ -320,8 +310,8 @@ export function TaskArtifactsList({
320310 key = { row . key }
321311 taskId = { task . id }
322312 runId = { row . runId }
313+ artifactId = { row . artifactId }
323314 name = { row . name }
324- storagePath = { row . storagePath }
325315 size = { row . size }
326316 />
327317 ) : (
0 commit comments