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.

1.3 KB
Raw Blame
import { useActions, useValues } from 'kea'
import { useEffect } from 'react'

import type { WizardRunApi } from '../../generated/api.schemas'
import { wizardRunDetailsLogic } from '../../logics/wizardRunDetailsLogic'
import { wizardRunSyncLogic } from '../../logics/wizardRunSyncLogic'
import { WizardRunDetailsDialog } from './WizardRunDetailsDialog'

export function WizardRunSceneSyncDetailsDialog({
    projectId,
    onRunAgain,
}: {
    projectId: string
    onRunAgain: (run: WizardRunApi) => void
}): JSX.Element {
    const { tasksByRunId } = useValues(wizardRunSyncLogic({ projectId }))
    const { loadRunData, watchRuns } = useActions(wizardRunSyncLogic({ projectId }))
    const { selectedRun } = useValues(wizardRunDetailsLogic)
    const selectedRunId = selectedRun?.id
    useEffect(() => {
        watchRuns('run-details', selectedRunId ? [selectedRunId] : [])
        return () => watchRuns('run-details', [])
    }, [selectedRunId, watchRuns])
    useEffect(() => {
        if (selectedRun) {
            loadRunData(selectedRun, { tasksOnly: true })
        }
    }, [selectedRun, loadRunData])

    return (
        <WizardRunDetailsDialog
            tasks={selectedRun ? (tasksByRunId[selectedRun.id] ?? []) : []}
            onRunAgain={onRunAgain}
        />
    )
}