: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
import { useActions, useValues } from 'kea'
import { LemonBanner, LemonTab, LemonTabs, Spinner } from '@posthog/lemon-ui'
import { NotFound } from 'lib/components/NotFound'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { SceneExport } from 'scenes/sceneTypes'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import {
AutoresearchPipelineLogicProps,
AutoresearchPipelineTab,
autoresearchPipelineLogic,
} from './autoresearchPipelineLogic'
import { AgentResearchTab } from './pipeline/AgentResearchTab'
import { LifecycleStrip } from './pipeline/LifecycleStrip'
import { OnlinePerformanceTab } from './pipeline/OnlinePerformanceTab'
import { PipelineActions } from './pipeline/PipelineActions'
import { PipelineSummary } from './pipeline/PipelineSummary'
import { PredictionsTab } from './pipeline/PredictionsTab'
import { QuillPipelineActions } from './pipeline/QuillPipelineActions'
import { QuillScoreNowButton } from './pipeline/QuillScoreNowButton'
import { ScoreNowButton } from './pipeline/ScoreNowButton'
import { SetupTab } from './pipeline/SetupTab'
import { pipelineQuestion, pipelineSubtitle } from './pipelineQuestion'
import { notLiveExplanation } from './trainingScheduleLogic'
export const scene: SceneExport = {
component: AutoresearchPipelineScene,
logic: autoresearchPipelineLogic,
paramsToProps: ({ params: { id } }): AutoresearchPipelineLogicProps => ({ id }),
}
export function AutoresearchPipelineScene(): JSX.Element {
const { pipeline, pipelineLoading, pipelineError, activeTab, lifecycleSteps } = useValues(autoresearchPipelineLogic)
const { setActiveTab, loadDetail } = useActions(autoresearchPipelineLogic)
const isEnabled = useFeatureFlag('AUTORESEARCH')
const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')
const tabs: LemonTab<AutoresearchPipelineTab>[] = [
{ key: 'predictions', label: 'Predictions', content: <PredictionsTab /> },
{ key: 'accuracy', label: 'Accuracy', content: <OnlinePerformanceTab /> },
{ key: 'agent_research', label: 'Agent research', content: <AgentResearchTab /> },
{ key: 'setup', label: 'Setup', content: <SetupTab /> },
]
const heading = pipeline ? pipelineQuestion(pipeline) : pipelineLoading ? '' : 'Model'
const notLive = pipeline ? notLiveExplanation(pipeline) : null
if (!isEnabled) {
return <NotFound object="Autoresearch" caption="This feature is not enabled for your project." />
}
return (
<SceneContent>
<SceneTitleSection
name={heading}
description={pipeline ? pipelineSubtitle(pipeline) : null}
resourceType={{ type: 'experiment' }}
actions={
todayRailNav ? (
<>
<QuillScoreNowButton />
<QuillPipelineActions />
</>
) : (
<>
<ScoreNowButton />
<PipelineActions />
</>
)
}
/>
{pipelineLoading && !pipeline ? (
<Spinner />
) : pipelineError && !pipeline ? (
<LemonBanner
type="error"
action={{ children: 'Retry', onClick: () => loadDetail(), 'data-attr': 'autoresearch-model-retry' }}
>
Couldn't load this model. It may have been deleted. Try again, or go back to the model list.
</LemonBanner>
) : (
<>
<PipelineSummary />
{lifecycleSteps && <LifecycleStrip steps={lifecycleSteps} />}
{notLive && (
<LemonBanner type="warning">
<div>{notLive}</div>
<div className="text-xs font-mono mt-1 break-words">
Reason: {pipeline?.not_promoted_reason}
</div>
</LemonBanner>
)}
<LemonTabs
activeKey={activeTab}
onChange={(key) => setActiveTab(key as AutoresearchPipelineTab)}
tabs={tabs}
sceneInset
/>
</>
)}
</SceneContent>
)
}