: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(autoresearch): restructure the model page around status and four tabs (#113147)
posthog[bot]26839c7bf07b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 23df5a12b0cc..165c9f367d1e 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6480,6 +6480,30 @@ snapshots:hash: v1.k794b7964.9a713abe443d5a52c29c22dd7555ad8005863f1a7a009702606fa5bd8384a98f.2nVLBkjlKykaLju4RbjgIlLkS-JsIqrCGxIqlHvj2hoproducts-autoresearch-daily-volume-chart--two-weeks--light:hash: v1.k794b7964.657b4864698965984216442d166b797580c2400a075a32a666088955114b6e26.5aBdQrW6RrKJjUXMDizdh6cpFHYQ1hqWTxPzdc2duvk+ products-autoresearch-lifecycle-strip--draft--dark:+ hash: v1.k794b7964.25cf4ab97ab421d5780b370efd62d63d7abb0d95dd8650b510e48282bbcf9c29.M68xJMN3m6w9ZG-jzeoOuW4eYLZlkYdTfScJvRiHt0A+ products-autoresearch-lifecycle-strip--draft--light:+ hash: v1.k794b7964.7c9f6863185efda9dabad5d8dbf1eb603a1fa9b675acbd3749da8dbe6f9f4bd8._Cz8caQ1Qz-Wl_hal4xo2O3DPBYenXBxYpVqzQ3R-0A+ products-autoresearch-lifecycle-strip--first-training-run--dark:+ hash: v1.k794b7964.268bc5414fd83baf11d29941933131523c0427164e01b3fadf5c0a7ac12dedc0.CFJLl_Wd6suPwLWqrawNmbRifK-7N4ou89L5FgBv8Xg+ products-autoresearch-lifecycle-strip--first-training-run--light:+ hash: v1.k794b7964.b928c1cc4d301eb5042057ce75e4c54b474f560248237b661bdc44192f3d35a4.G4e938NNTi2ryA6HJ6QwfFipP5SKF-zFwwAyMHDoh_w+ products-autoresearch-lifecycle-strip--preliminary-champion--dark:+ hash: v1.k794b7964.1eeaff8df503efedfed4608eb801fbdbe6e79d9566566cceb8d4d03aeeea71e3.F4saAb2jIJKOUzYQDPIKdBcfhfQ8UiOGfL_npwPaK1M+ products-autoresearch-lifecycle-strip--preliminary-champion--light:+ hash: v1.k794b7964.a7d1205ba92d7916302c71ac6947eb54d19cd7b315dad2ac740159d5b9523413.cxb9LGruE5_u9KFjovAl_yoKk1W_iA0l2NX7-LOKR34+ products-autoresearch-lifecycle-strip--validated-champion--dark:+ hash: v1.k794b7964.ec5636bb061b046741a42c6ce3faa30704b2b4203947e956c5d7966bada33fd5.pMIwCFfVjMdfrr_RckXkoewH1hbCy3Veditgtv4hx_k+ products-autoresearch-lifecycle-strip--validated-champion--light:+ hash: v1.k794b7964.131ecc736b38defef5b8ba34fa9836f1d2d5132e1d109e4b995b9591a5d9255c.759giT71A_8sdMCqx-FasPgdZzZWHgRvaoUmqVtYYKw+ products-autoresearch-model-detail-scene--narrow--narrow--dark:+ hash: v1.k794b7964.a8261167fe190a6da69fd2bc07cd0b45b9d69ddb6c502e6a76ab6545c9e043d6.3ScvmJEDOvl0AC3sWgI9d6tawFXTfq2B8p-pvUn2htw+ products-autoresearch-model-detail-scene--narrow--narrow--light:+ hash: v1.k794b7964.7e9a7baa51c5bfccfdc2f9d829213fb654249124270ef725da68b668c810e377.tdJkrS3ESfUX55iohONns0waCMExMUde4q0JwmLMqaY+ products-autoresearch-model-detail-scene--wide--wide--dark:+ hash: v1.k794b7964.9c69746cf2c5d848ae83c301d0dd50427d11fb2970ee26be5f07800ac9001405.K6PMRUi2ZPXkyMtB5NzSUiQqrI0QcSq5UC5IRzanmnk+ products-autoresearch-model-detail-scene--wide--wide--light:+ hash: v1.k794b7964.45e55e328260992ff187aa5661b07ac3e8812db2df5c07f20ac9a7ff1dd0141b.ZkwHP20gbuIUXIHfzP_-zevfbJkv3AkQ7-DaMgcf5uwproducts-autoresearch-probability-histogram--bimodal--dark:hash: v1.k794b7964.f95d3982e7c08f2e1b51655520f15e37293aa98e5ca87126a5653d2300bd776b.2G0LsuSx-SLqWn1Oxm_bUHSqfeDPFF6Pof0vDvhZEHMproducts-autoresearch-probability-histogram--bimodal--light:diff --git a/products/autoresearch/frontend/AGENTS.md b/products/autoresearch/frontend/AGENTS.mdindex a84cb0a109ed..e274ceb2576f 100644--- a/products/autoresearch/frontend/AGENTS.md+++ b/products/autoresearch/frontend/AGENTS.md@@ -6,23 +6,24 @@ The product is mostly a backend, and the UI is deliberately thin — it reads st## What lives here-| File | Scene / role |-| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |-| `AutoresearchScene.tsx` | `/autoresearch` — the model list: a container-query grid of model cards and the "New model" entry point. |-| `AutoresearchModelCard.tsx` | One model card: the question as title, a state body (scored, training, draft), and counts. `ModelCardMenu.tsx` holds pause, resume, delete. |-| `pipelineQuestion.ts` | The model's question in plain words ("Who will do X in the next N days?"), shared by the list cards and the detail header. |-| `AutoresearchNewScene.tsx` | `/autoresearch/new` — the create form. Its parts live in `newModel/`. |-| `AutoresearchPipelineScene.tsx` | `/autoresearch/:id` — the detail shell: title bar actions and the tab strip. Each tab lives in `pipeline/`. |-| `autoresearchLogic.ts` | List logic — loads pipelines, lifecycle actions, and setup-status detection for the empty-state gate. |-| `autoresearchNewLogic.ts` | Create form: a `kea-forms` form that validates the definition, then creates the model and optionally starts training. |-| `newModel/` | Create-form parts: template chips, definition sentence, Advanced section, readiness checklist, "What happens next". |-| `autoresearchPipelineLogic.ts` | Detail logic. |-| `PipelineStatusTag.tsx` | Status tag + tooltip shared by the list and detail scenes. |-| `ProbabilityHistogram.tsx` | Decile histogram of the latest scoring run's probabilities. |-| `DailyVolumeChart.tsx` | Bar-per-day chart of scoring volume. |-| `pipeline/` | One file per detail-scene tab (Overview, Training, Predictions, Online performance, Suggestions) and their components. |-| `emptyState/` | `ProductEmptyState` config + example-data preview for the first-run gate. |-| `generated/` | **Generated. Never hand-edit.** Change the serializer in `../backend/presentation/views/serializers.py` and run `hogli build:openapi`. |+| File | Scene / role |+| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |+| `AutoresearchScene.tsx` | `/autoresearch` — the model list: a container-query grid of model cards and the "New model" entry point. |+| `AutoresearchModelCard.tsx` | One model card: the question as title, a state body (scored, training, draft), and counts. `ModelCardMenu.tsx` holds pause, resume, delete. |+| `pipelineQuestion.ts` | The model's question in plain words ("Who will do X in the next N days?"), shared by the list cards and the detail header. |+| `AutoresearchNewScene.tsx` | `/autoresearch/new` — the create form. Its parts live in `newModel/`. |+| `AutoresearchPipelineScene.tsx` | `/autoresearch/:id` — the detail shell: the question header, the lifecycle strip, and four tabs. Each tab lives in `pipeline/`. |+| `autoresearchLogic.ts` | List logic — loads pipelines, lifecycle actions, and setup-status detection for the empty-state gate. |+| `autoresearchNewLogic.ts` | Create form: a `kea-forms` form that validates the definition, then creates the model and optionally starts training. |+| `newModel/` | Create-form parts: template chips, definition sentence, Advanced section, readiness checklist, "What happens next". |+| `autoresearchPipelineLogic.ts` | Detail logic. Also maps the old `?tab=` keys to the four tabs, so saved links still open. |+| `pipelineLifecycle.ts` | The five lifecycle steps (question set to checked against reality) and which one is current. |+| `PipelineStatusTag.tsx` | Status tag + tooltip shared by the list and detail scenes. |+| `ProbabilityHistogram.tsx` | Decile histogram of the latest scoring run's probabilities. |+| `DailyVolumeChart.tsx` | Bar-per-day chart of scoring volume. |+| `pipeline/` | The detail-scene tabs (Predictions, Accuracy, Agent research, Setup) and their components. Agent research combines Training and Suggestions. |+| `emptyState/` | `ProductEmptyState` config + example-data preview for the first-run gate. |+| `generated/` | **Generated. Never hand-edit.** Change the serializer in `../backend/presentation/views/serializers.py` and run `hogli build:openapi`. |Scene registration, routes, and urls live in `../manifest.tsx`.`frontend/src/products.tsx` is generated from the manifests — hand-editing it there gets wiped by `pnpm build:products`. Only the `Scene` enum entries belong in `sceneTypes.ts`.@@ -47,7 +48,7 @@ Follow `frontend/src/AGENTS.md` — it applies to product frontends too.- TypeScript with explicit return types; Tailwind utilities rather than inline styles.- Reuse Lemon / quill components instead of hand-rolling tables, badges, or tags.- Any button that fires a request must guard against double-submission — `loading` / `disabledReason` on `LemonButton`, reset on both success and error paths. The lifecycle actions here (train, score, archive, pause, resume) are all network calls, and several are expensive: firing `train` twice starts two sandbox agent runs and spends the budget twice.-- Usage events are part of the API: renaming one breaks every insight built on it. The list logic captures `autoresearch model list viewed`, `autoresearch model list load failed`, `autoresearch model deleted` / `paused` / `resumed`, `autoresearch model training started` (with `source: 'list'` from a card), `autoresearch model card clicked`, and `autoresearch model action failed` (with `action`). The create logic captures `autoresearch model template selected` (with `template_key`), `autoresearch model custom chosen`, `autoresearch model advanced opened`, `autoresearch model created` (with `action`: `start_training` or `save_draft`), and `autoresearch model training started` / `training start failed`. Buttons carry a `data-attr` for autocapture. Extend the same names when you add a scene.+- Usage events are part of the API: renaming one breaks every insight built on it. The list logic captures `autoresearch model list viewed`, `autoresearch model list load failed`, `autoresearch model deleted` / `paused` / `resumed`, `autoresearch model training started` (with `source: 'list'` from a card), `autoresearch model card clicked`, and `autoresearch model action failed` (with `action`). The create logic captures `autoresearch model template selected` (with `template_key`), `autoresearch model custom chosen`, `autoresearch model advanced opened`, `autoresearch model created` (with `action`: `start_training` or `save_draft`), and `autoresearch model training started` / `training start failed`. The detail logic captures `autoresearch model tab changed` (with `tab`) when a person picks a tab; buttons carry a `data-attr` for autocapture. Extend the same names when you add a scene.## Copydiff --git a/products/autoresearch/frontend/AutoresearchPipelineScene.stories.tsx b/products/autoresearch/frontend/AutoresearchPipelineScene.stories.tsxnew file mode 100644index 000000000000..d214a2de9794--- /dev/null+++ b/products/autoresearch/frontend/AutoresearchPipelineScene.stories.tsx@@ -0,0 +1,156 @@+import { Meta, StoryObj } from '@storybook/react'++import { FEATURE_FLAGS } from 'lib/constants'+import { App } from 'scenes/App'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'+import { toPaginatedResponse } from '~/mocks/handlers'++import type {+ AutoresearchModelApi,+ AutoresearchPipelineApi,+ AutoresearchRunApi,+ AutoresearchTrainingRunApi,+} from './generated/api.schemas'++const PIPELINE_ID = '0190c3f2-0000-7000-8000-000000000001'++const pipeline = {+ id: PIPELINE_ID,+ name: 'File sharers',+ description: '',+ target_event: 'file_shared',+ target_definition: { type: 'event' },+ horizon_days: 7,+ training_lookback_days: 90,+ training_population: {},+ inference_population: {},+ cadence_days: 1,+ iteration_budget: 20,+ iteration_budget_remaining: 6,+ success_auc: null,+ plateau_iterations: 5,+ output_person_property: 'p_file_shared_7d',+ status: 'running',+ created_by: {+ id: 1,+ uuid: '0190c3f2-0000-7000-8000-0000000000aa',+ distinct_id: 'storybook-user',+ first_name: 'Hedge',+ email: '[email protected]',+ },+ created_at: '2026-01-01T09:00:00Z',+ updated_at: '2026-03-01T03:00:00Z',+ last_scored_at: '2026-03-01T03:00:00Z',+ champion_holdout_auc: 0.83,+ champion_realized_auc: 0.81,+ champion_lift_at_10: 3.4,+ champion_is_preliminary: false,+ champion_realized_auc_trend: [],+ people_scored: 48210,+ training_run_count: 2,+ experiment_count: 14,+ live_training_run: null,+} as unknown as AutoresearchPipelineApi++const champion = {+ id: '0190c3f2-0000-7000-8000-0000000000c1',+ pipeline: PIPELINE_ID,+ role: 'champion',+ recipe_hash: 'abc123',+ model_recipe: {},+ model_explanation: {+ method: 'gain on the holdout split',+ top_features: [+ { name: 'files_uploaded_7d', importance: 0.42, direction: 'positive' },+ { name: 'days_since_last_share', importance: 0.31, direction: 'negative' },+ ],+ },+ holdout_score: 0.83,+ realized_score: 0.81,+ calibration_error: 0.04,+ metrics: {},+ source_training_run: null,+ agent_description: 'Gradient boosting on recent sharing and upload activity.',+ is_preliminary: false,+ promoted_at: '2026-01-10T00:00:00Z',+} as unknown as AutoresearchModelApi++const runs = [+ { id: 'score-1', run_type: 'inference', status: 'completed', created_at: '2026-02-10T03:00:00Z', metrics: {} },+ { id: 'score-2', run_type: 'inference', status: 'completed', created_at: '2026-02-11T03:00:00Z', metrics: {} },+ { id: 'score-3', run_type: 'inference', status: 'completed', created_at: '2026-03-01T03:00:00Z', metrics: {} },+ {+ id: 'validate-1',+ run_type: 'validation',+ status: 'completed',+ created_at: '2026-02-18T03:00:00Z',+ metrics: {+ prediction_date: '2026-02-10',+ per_model: {+ [champion.id]: {+ model_role: 'champion',+ emitted_role: 'champion',+ n_scored: 47000,+ realized_auc: 0.81,+ brier_score: 0.06,+ calibration_error: 0.04,+ lift_at_10: 3.4,+ lift_at_20: 2.6,+ },+ },+ },+ },+] as unknown as AutoresearchRunApi[]++const trainingRuns = [+ {+ id: 'training-1',+ pipeline: PIPELINE_ID,+ task_url: null,+ status: 'completed',+ iteration_count: 14,+ best_holdout_score: 0.83,+ summary: null,+ iterations: [],+ error: '',+ started_at: '2026-01-09T09:00:00Z',+ completed_at: '2026-01-10T00:00:00Z',+ created_at: '2026-01-09T09:00:00Z',+ },+] as unknown as AutoresearchTrainingRunApi[]++const meta: Meta = {+ component: App,+ title: 'Products/Autoresearch/Model detail scene',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2026-03-01T12:00:00Z',+ featureFlags: [FEATURE_FLAGS.AUTORESEARCH],+ pageUrl: urls.autoresearchPipeline(PIPELINE_ID),+ },+ decorators: [+ mswDecorator({+ get: {+ [`/api/projects/:team_id/autoresearch/${PIPELINE_ID}/`]: pipeline,+ [`/api/projects/:team_id/autoresearch/${PIPELINE_ID}/models/`]: toPaginatedResponse([champion]),+ [`/api/projects/:team_id/autoresearch/${PIPELINE_ID}/runs/`]: toPaginatedResponse(runs),+ [`/api/projects/:team_id/autoresearch/${PIPELINE_ID}/training_runs/`]:+ toPaginatedResponse(trainingRuns),+ [`/api/projects/:team_id/autoresearch/${PIPELINE_ID}/suggestions/`]: toPaginatedResponse([]),+ },+ }),+ ],+}+export default meta+type Story = StoryObj<typeof meta>++export const Wide: Story = {+ parameters: { testOptions: { viewportWidths: ['wide'] } },+}++export const Narrow: Story = {+ parameters: { testOptions: { viewportWidths: ['narrow'] } },+}diff --git a/products/autoresearch/frontend/AutoresearchPipelineScene.tsx b/products/autoresearch/frontend/AutoresearchPipelineScene.tsxindex 146bd469b17f..782058e76f8a 100644--- a/products/autoresearch/frontend/AutoresearchPipelineScene.tsx+++ b/products/autoresearch/frontend/AutoresearchPipelineScene.tsx@@ -14,13 +14,15 @@ import {AutoresearchPipelineTab,autoresearchPipelineLogic,} from './autoresearchPipelineLogic'+import { AgentResearchTab } from './pipeline/AgentResearchTab'+import { LifecycleStrip } from './pipeline/LifecycleStrip'import { OnlinePerformanceTab } from './pipeline/OnlinePerformanceTab'-import { OverviewTab } from './pipeline/OverviewTab'import { PipelineActions } from './pipeline/PipelineActions'+import { PipelineSummary } from './pipeline/PipelineSummary'import { PredictionsTab } from './pipeline/PredictionsTab'import { ScoreNowButton } from './pipeline/ScoreNowButton'-import { SuggestionsTab } from './pipeline/SuggestionsTab'-import { TrainingTab } from './pipeline/TrainingTab'+import { SetupTab } from './pipeline/SetupTab'+import { pipelineQuestion } from './pipelineQuestion'export const scene: SceneExport = {component: AutoresearchPipelineScene,@@ -29,20 +31,18 @@ export const scene: SceneExport = {}export function AutoresearchPipelineScene(): JSX.Element {- const { pipeline, pipelineLoading, pipelineError, activeTab } = useValues(autoresearchPipelineLogic)+ const { pipeline, pipelineLoading, pipelineError, activeTab, lifecycleSteps } = useValues(autoresearchPipelineLogic)const { setActiveTab, loadDetail } = useActions(autoresearchPipelineLogic)const isEnabled = useFeatureFlag('AUTORESEARCH')const tabs: LemonTab<AutoresearchPipelineTab>[] = [- { key: 'overview', label: 'Overview', content: <OverviewTab /> },- { key: 'training', label: 'Training', content: <TrainingTab /> },{ key: 'predictions', label: 'Predictions', content: <PredictionsTab /> },- { key: 'online_performance', label: 'Online performance', content: <OnlinePerformanceTab /> },- { key: 'suggestions', label: 'Suggestions', content: <SuggestionsTab /> },+ { key: 'accuracy', label: 'Accuracy', content: <OnlinePerformanceTab /> },+ { key: 'agent_research', label: 'Agent research', content: <AgentResearchTab /> },+ { key: 'setup', label: 'Setup', content: <SetupTab /> },]- const heading = pipeline?.name ?? (pipelineLoading ? '' : 'Model')- const subheading = pipeline ? `Predict ${pipeline.target_event} within ${pipeline.horizon_days ?? '?'}d` : undefined+ const heading = pipeline ? pipelineQuestion(pipeline) : pipelineLoading ? '' : 'Model'if (!isEnabled) {return <NotFound object="Autoresearch" caption="This feature is not enabled for your project." />@@ -52,7 +52,7 @@ export function AutoresearchPipelineScene(): JSX.Element {<SceneContent><SceneTitleSectionname={heading}- description={subheading}+ description={pipeline?.name ?? null}resourceType={{ type: 'experiment' }}actions={<>@@ -72,12 +72,16 @@ export function AutoresearchPipelineScene(): JSX.Element {Couldn't load this model. It may have been deleted. Try again, or go back to the model list.</LemonBanner>) : (- <LemonTabs- activeKey={activeTab}- onChange={(key) => setActiveTab(key as AutoresearchPipelineTab)}- tabs={tabs}- sceneInset- />+ <>+ <PipelineSummary />+ {lifecycleSteps && <LifecycleStrip steps={lifecycleSteps} />}+ <LemonTabs+ activeKey={activeTab}+ onChange={(key) => setActiveTab(key as AutoresearchPipelineTab)}+ tabs={tabs}+ sceneInset+ />+ </>)}</SceneContent>)diff --git a/products/autoresearch/frontend/autoresearchPipelineLogic.test.ts b/products/autoresearch/frontend/autoresearchPipelineLogic.test.tsindex 2a6dc02c5b03..6a766e3f4d19 100644--- a/products/autoresearch/frontend/autoresearchPipelineLogic.test.ts+++ b/products/autoresearch/frontend/autoresearchPipelineLogic.test.ts@@ -1,4 +1,6 @@+import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import posthog from 'posthog-js'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'@@ -196,6 +198,83 @@ describe('autoresearchPipelineLogic', () => {logic.unmount()})+ describe('tabs', () => {+ async function mountWithPipeline(+ lastScoredAt: string | null,+ url: string,+ runsFail = false+ ): Promise<ReturnType<typeof autoresearchPipelineLogic.build>> {+ jest.clearAllMocks()+ initKeaTests()+ featureFlagLogic.mount()+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.AUTORESEARCH], {+ [FEATURE_FLAGS.AUTORESEARCH]: true,+ })+ mockRetrieve.mockResolvedValue({ id: 'pipeline-1', name: 'Model', last_scored_at: lastScoredAt })+ mockModelsList.mockResolvedValue({ results: [], next: null })+ if (runsFail) {+ mockRunsList.mockRejectedValue(new Error('runs failed'))+ } else {+ mockRunsList.mockResolvedValue({ results: [], next: null })+ }+ router.actions.push(url)+ const logic = autoresearchPipelineLogic({ id: 'pipeline-1' })+ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadPipelineSuccess'])+ return logic+ }++ it.each([+ ['a scored model', '2026-01-02T00:00:00Z', 'predictions'],+ ['a model that never scored', null, 'agent_research'],+ ])('opens %s on its default tab', async (_name, lastScoredAt, expectedTab) => {+ const logic = await mountWithPipeline(lastScoredAt, '/autoresearch/pipeline-1')+ expect(logic.values.activeTab).toEqual(expectedTab)+ logic.unmount()+ })++ it.each([+ ['training', 'agent_research'],+ ['suggestions', 'agent_research'],+ ['online_performance', 'accuracy'],+ ['predictions', 'predictions'],+ ['overview', undefined],+ ['not_a_tab', undefined],+ ])('rewrites the old ?tab=%s link to the tab it now opens', async (oldTab, expectedUrlTab) => {+ const logic = await mountWithPipeline('2026-01-02T00:00:00Z', `/autoresearch/pipeline-1?tab=${oldTab}`)+ expect(router.values.searchParams.tab).toEqual(expectedUrlTab)+ expect(logic.values.activeTab).toEqual(expectedUrlTab ?? 'predictions')+ logic.unmount()+ })++ it('keeps the lifecycle unknown when the runs fail to load', async () => {+ const logic = await mountWithPipeline('2026-01-02T00:00:00Z', '/autoresearch/pipeline-1', true)+ await expectLogic(logic).toDispatchActions(['loadModelsSuccess', 'loadRunsFailure'])+ expect(logic.values.lifecycleSteps).toBeNull()+ logic.unmount()+ })++ it('records a tab change from the user and keeps it in the URL, but not a change from the URL', async () => {+ const capture = jest.spyOn(posthog, 'capture').mockImplementation(() => undefined)+ const logic = await mountWithPipeline(null, '/autoresearch/pipeline-1')+ capture.mockClear()++ logic.actions.setActiveTab('setup')+ expect(router.values.searchParams.tab).toEqual('setup')+ expect(capture).toHaveBeenCalledWith('autoresearch model tab changed', {+ pipeline_id: 'pipeline-1',+ tab: 'setup',+ })++ capture.mockClear()+ router.actions.push('/autoresearch/pipeline-1?tab=accuracy')+ expect(logic.values.activeTab).toEqual('accuracy')+ expect(capture).not.toHaveBeenCalledWith('autoresearch model tab changed', expect.anything())+ logic.unmount()+ capture.mockRestore()+ })+ })+describe('scoringCoverage', () => {it.each([['a rolling run', [makeScoringRun({})], { scored: 45000, eligible: 250000, rescoreDays: 6 }],diff --git a/products/autoresearch/frontend/autoresearchPipelineLogic.ts b/products/autoresearch/frontend/autoresearchPipelineLogic.tsindex 607d6a17549e..3cf508d7e437 100644--- a/products/autoresearch/frontend/autoresearchPipelineLogic.ts+++ b/products/autoresearch/frontend/autoresearchPipelineLogic.ts@@ -5,6 +5,7 @@ import posthog from 'posthog-js'import api from 'lib/api'import { FEATURE_FLAGS } from 'lib/constants'+import { dayjs } from 'lib/dayjs'import { lemonToast } from 'lib/lemon-ui/LemonToast'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { projectLogic } from 'scenes/projectLogic'@@ -34,8 +35,8 @@ import {autoresearchTrainCreate,} from './generated/api'import {- AutoresearchModelRoleEnumApi,type AutoresearchModelApi,+ AutoresearchModelRoleEnumApi,type AutoresearchPipelineApi,type AutoresearchRunApi,type AutoresearchSuggestionApi,@@ -43,6 +44,7 @@ import {CreateSuggestionPriorityEnumApi,type ModelExplanationFieldApi,} from './generated/api.schemas'+import { LifecycleStep, pipelineLifecycle } from './pipelineLifecycle'import {PREDICTION_SEGMENTS,PREDICTION_SEGMENT_THRESHOLDS,@@ -57,18 +59,27 @@ export interface AutoresearchPipelineLogicProps {id: string}-export type AutoresearchPipelineTab = 'overview' | 'training' | 'predictions' | 'online_performance' | 'suggestions'+export type AutoresearchPipelineTab = 'predictions' | 'accuracy' | 'agent_research' | 'setup'-const AUTORESEARCH_PIPELINE_TABS: AutoresearchPipelineTab[] = [- 'overview',- 'training',- 'predictions',- 'online_performance',- 'suggestions',-]+const AUTORESEARCH_PIPELINE_TABS: AutoresearchPipelineTab[] = ['predictions', 'accuracy', 'agent_research', 'setup']++/** Tab keys from the old five-tab layout, so links saved before the change still open the right tab. */+const LEGACY_PIPELINE_TABS: Record<string, AutoresearchPipelineTab | null> = {+ overview: null,+ training: 'agent_research',+ online_performance: 'accuracy',+ suggestions: 'agent_research',+}-function isPipelineTab(value: string | undefined): value is AutoresearchPipelineTab {- return value !== undefined && (AUTORESEARCH_PIPELINE_TABS as string[]).includes(value)+/** The tab a `?tab=` value opens. Null means the default tab. */+export function pipelineTabFromUrl(value: unknown): AutoresearchPipelineTab | null {+ if (typeof value !== 'string') {+ return null+ }+ if ((AUTORESEARCH_PIPELINE_TABS as string[]).includes(value)) {+ return value as AutoresearchPipelineTab+ }+ return LEGACY_PIPELINE_TABS[value] ?? null}/** How often the Score now button checks a running scoring run. */@@ -277,11 +288,14 @@ export interface autoresearchPipelineLogicValues {dailyVolume: DailyVolumePoint[] | nulldailyVolumeError: booleandailyVolumeLoading: boolean+ defaultTab: AutoresearchPipelineTabdetailRequested: booleanexpandedRunId: string | null+ lifecycleSteps: LifecycleStep[] | nullmodelByTrainingRun: Record<string, AutoresearchModelApi>models: AutoresearchModelApi[]modelsError: boolean+ modelsLoaded: booleanmodelsLoading: booleanonlinePerformanceRows: OnlinePerformanceRow[]pipeline: AutoresearchPipelineApi | null@@ -299,11 +313,13 @@ export interface autoresearchPipelineLogicValues {reportByRunLoading: booleanruns: AutoresearchRunApi[]runsError: boolean+ runsLoaded: booleanrunsLoading: booleansavingCohortSegment: PredictionSegmentKey | nullscoreResult: AutoresearchRunApi | nullscoreResultLoading: booleanscoringCoverage: ScoringCoverage | null+ selectedTab: AutoresearchPipelineTab | nullstartTrainingResult: AutoresearchTrainingRunApi | nullstartTrainingResultLoading: booleansuggestionDraft: string@@ -609,6 +625,9 @@ export interface autoresearchPipelineLogicActions {setSuggestionPriority: (priority: CreateSuggestionPriorityEnumApi) => {priority: CreateSuggestionPriorityEnumApi}+ setTabFromUrl: (tab: AutoresearchPipelineTab | null) => {+ tab: AutoresearchPipelineTab | null+ }startScorePolling: () => {value: true}@@ -695,6 +714,19 @@ export interface autoresearchPipelineLogicMeta {) => ScoringCoverage | nullonlinePerformanceRows: (validationRuns: AutoresearchRunApi[]) => OnlinePerformanceRow[]probabilityHistogram: (probabilityDistribution: ProbabilityBucket[] | null) => ProbabilityBucket[] | null+ defaultTab: (pipeline: AutoresearchPipelineApi | null) => AutoresearchPipelineTab+ activeTab: (+ selectedTab: AutoresearchPipelineTab | null,+ defaultTab: AutoresearchPipelineTab+ ) => AutoresearchPipelineTab+ lifecycleSteps: (+ pipeline: AutoresearchPipelineApi | null,+ champion: AutoresearchModelApi | null,+ runs: AutoresearchRunApi[],+ onlinePerformanceRows: OnlinePerformanceRow[],+ modelsLoaded: boolean,+ runsLoaded: boolean+ ) => LifecycleStep[] | null}}@@ -716,6 +748,7 @@ export const autoresearchPipelineLogic = kea<autoresearchPipelineLogicType>([actions({setActiveTab: (tab: AutoresearchPipelineTab) => ({ tab }),setPredictionsPeopleView: (view: PredictionsPeopleView) => ({ view }),+ setTabFromUrl: (tab: AutoresearchPipelineTab | null) => ({ tab }),loadDetail: true,toggleRunArtifacts: (runId: string) => ({ runId }),reportNotebookOpened: (runId: string) => ({ runId }),@@ -736,10 +769,11 @@ export const autoresearchPipelineLogic = kea<autoresearchPipelineLogicType>([loadDetail: () => true,},],- activeTab: [- 'overview' as AutoresearchPipelineTab,+ selectedTab: [+ null as AutoresearchPipelineTab | null,{setActiveTab: (_, { tab }) => tab,+ setTabFromUrl: (_, { tab }) => tab,},],predictionsPeopleView: [@@ -819,6 +853,18 @@ export const autoresearchPipelineLogic = kea<autoresearchPipelineLogicType>([loadTrainingRunsFailure: () => true,},],+ modelsLoaded: [+ false,+ {+ loadModelsSuccess: () => true,+ },+ ],+ runsLoaded: [+ false,+ {+ loadRunsSuccess: () => true,+ },+ ],runsError: [false,{@@ -1215,6 +1261,39 @@ export const autoresearchPipelineLogic = kea<autoresearchPipelineLogicType>([}))},],+ defaultTab: [+ (s) => [s.pipeline],+ (pipeline: AutoresearchPipelineApi | null): AutoresearchPipelineTab =>+ pipeline?.last_scored_at ? 'predictions' : 'agent_research',+ ],+ activeTab: [+ (s) => [s.selectedTab, s.defaultTab],+ (+ selectedTab: AutoresearchPipelineTab | null,+ defaultTab: AutoresearchPipelineTab+ ): AutoresearchPipelineTab => selectedTab ?? defaultTab,+ ],+ lifecycleSteps: [+ (s) => [s.pipeline, s.champion, s.runs, s.onlinePerformanceRows, s.modelsLoaded, s.runsLoaded],+ (+ pipeline: AutoresearchPipelineApi | null,+ champion: AutoresearchModelApi | null,+ runs: AutoresearchRunApi[],+ onlinePerformanceRows: OnlinePerformanceRow[],+ modelsLoaded: boolean,+ runsLoaded: boolean+ ): LifecycleStep[] | null =>+ // Before models and runs load, an empty list means "not known yet", not "none".+ pipeline && modelsLoaded && runsLoaded+ ? pipelineLifecycle({+ pipeline,+ champion,+ runs,+ validatedDates: onlinePerformanceRows.map((row) => row.prediction_date),+ now: dayjs(),+ })+ : null,+ ],}),listeners(({ actions, values, props, cache }) => ({loadDetail: () => {@@ -1375,6 +1454,10 @@ export const autoresearchPipelineLogic = kea<autoresearchPipelineLogicType>([}}},+ setActiveTab: ({ tab }) => {+ // pinned: analytics event name and properties. Renaming breaks insights built on them.+ posthog.capture('autoresearch model tab changed', { pipeline_id: props.id, tab })+ },reportNotebookOpened: ({ runId }) => {posthog.capture('autoresearch model report notebook opened', { pipeline_id: props.id, run_id: runId })},@@ -1420,26 +1503,30 @@ export const autoresearchPipelineLogic = kea<autoresearchPipelineLogicType>([}},})),- actionToUrl(({ values }) => ({+ actionToUrl(() => ({// Reflect the active tab in the URL (?tab=…) so each tab is deep-linkable.setActiveTab: ({ tab }) => {- const searchParams = { ...router.values.searchParams }- if (tab === 'overview') {- delete searchParams.tab- } else {- searchParams.tab = tab- }- if ((router.values.searchParams.tab ?? 'overview') === (values.activeTab as string)) {+ if (router.values.searchParams.tab === tab) {return // no-op when the URL already matches (avoids a redundant history entry)}- return [router.values.location.pathname, searchParams, router.values.hashParams]+ return [router.values.location.pathname, { ...router.values.searchParams, tab }, router.values.hashParams]},})),urlToAction(({ actions, values }) => ({'/autoresearch/:id': (_, searchParams) => {- const tab = isPipelineTab(searchParams.tab) ? searchParams.tab : 'overview'- if (tab !== values.activeTab) {- actions.setActiveTab(tab)+ const tab = pipelineTabFromUrl(searchParams.tab)+ if (searchParams.tab !== undefined && searchParams.tab !== tab) {+ // A legacy or unknown key: rewrite the URL in place so it shows the tab that opens.+ const { tab: _legacyTab, ...rest } = searchParams+ router.actions.replace(+ router.values.location.pathname,+ tab ? { ...rest, tab } : rest,+ router.values.hashParams+ )+ return+ }+ if (tab !== values.selectedTab) {+ actions.setTabFromUrl(tab)}},})),diff --git a/products/autoresearch/frontend/pipeline/AgentResearchTab.tsx b/products/autoresearch/frontend/pipeline/AgentResearchTab.tsxnew file mode 100644index 000000000000..291ef7dc9e04--- /dev/null+++ b/products/autoresearch/frontend/pipeline/AgentResearchTab.tsx@@ -0,0 +1,18 @@+import { LiveModelCard } from './LiveModelCard'+import { SuggestionsTab } from './SuggestionsTab'+import { TrainingTab } from './TrainingTab'++/** What the agent did (live model, training runs) next to how to steer it (suggestions). */+export function AgentResearchTab(): JSX.Element {+ return (+ <div className="space-y-4">+ <LiveModelCard />+ <div className="@container">+ <div className="grid grid-cols-1 @3xl:grid-cols-[minmax(0,2fr)_minmax(0,1fr)] gap-4 items-start">+ <TrainingTab />+ <SuggestionsTab />+ </div>+ </div>+ </div>+ )+}diff --git a/products/autoresearch/frontend/pipeline/LifecycleStrip.stories.tsx b/products/autoresearch/frontend/pipeline/LifecycleStrip.stories.tsxnew file mode 100644index 000000000000..6d9b3a72b8e2--- /dev/null+++ b/products/autoresearch/frontend/pipeline/LifecycleStrip.stories.tsx@@ -0,0 +1,95 @@+import { Meta, StoryObj } from '@storybook/react'++import { dayjs } from 'lib/dayjs'++import { LifecycleInput, pipelineLifecycle } from '../pipelineLifecycle'+import { LifecycleStrip } from './LifecycleStrip'++const NOW = dayjs('2026-03-01T12:00:00Z')++const NEW_PIPELINE: LifecycleInput['pipeline'] = {+ created_at: '2026-01-01T00:00:00Z',+ horizon_days: 7,+ last_scored_at: null,+ training_run_count: 0,+ experiment_count: 0,+ live_training_run: null,+}++const SCORED_PIPELINE: LifecycleInput['pipeline'] = {+ ...NEW_PIPELINE,+ training_run_count: 2,+ experiment_count: 14,+ last_scored_at: '2026-03-01T03:00:00Z',+}++function scoringRun(day: string): LifecycleInput['runs'][number] {+ return { run_type: 'inference', status: 'completed', created_at: `${day}T03:00:00Z`, rows_scored: 100, metrics: {} }+}++function steps(overrides: Partial<LifecycleInput>): ReturnType<typeof pipelineLifecycle> {+ return pipelineLifecycle({+ pipeline: NEW_PIPELINE,+ champion: null,+ runs: [],+ validatedDates: [],+ now: NOW,+ ...overrides,+ })+}++// Each story builds its steps in render, so relative times read the pinned story clock.+const meta: Meta<typeof LifecycleStrip> = {+ title: 'Products/Autoresearch/Lifecycle strip',+ component: LifecycleStrip,+ parameters: { mockDate: '2026-03-01T12:00:00Z' },+ // The strip is an inline-size container, which contributes no intrinsic width, so an unsized story root collapses to zero.+ decorators: [+ (Story) => (+ <div className="w-[960px]">+ <Story />+ </div>+ ),+ ],+}+export default meta+type Story = StoryObj<typeof LifecycleStrip>++export const Draft: Story = {+ render: () => <LifecycleStrip steps={steps({})} />,+}++export const FirstTrainingRun: Story = {+ render: () => (+ <LifecycleStrip+ steps={steps({+ pipeline: { ...NEW_PIPELINE, training_run_count: 1, experiment_count: 3, live_training_run: {} },+ })}+ />+ ),+}++export const PreliminaryChampion: Story = {+ render: () => (+ <LifecycleStrip+ steps={steps({+ pipeline: SCORED_PIPELINE,+ champion: { is_preliminary: true, promoted_at: '2026-02-27T00:00:00Z' },+ runs: [scoringRun('2026-03-01')],+ })}+ />+ ),+}++export const ValidatedChampion: Story = {+ render: () => (+ <LifecycleStrip+ steps={steps({+ pipeline: SCORED_PIPELINE,+ champion: { is_preliminary: false, promoted_at: '2026-01-10T00:00:00Z' },+ runs: [scoringRun('2026-02-10'), scoringRun('2026-02-11'), scoringRun('2026-03-01')],+ validatedDates: ['2026-02-10', '2026-02-11'],+ })}+ />+ ),+}diff --git a/products/autoresearch/frontend/pipeline/LifecycleStrip.tsx b/products/autoresearch/frontend/pipeline/LifecycleStrip.tsxnew file mode 100644index 000000000000..b0ff0447d779--- /dev/null+++ b/products/autoresearch/frontend/pipeline/LifecycleStrip.tsx@@ -0,0 +1,48 @@+import { IconCheckCircle, IconCircleDashed, IconClock } from '@posthog/icons'++import { cn } from 'lib/utils/css-classes'++import { LifecycleStep, LifecycleStepState } from '../pipelineLifecycle'++const STEP_ICON: Record<LifecycleStepState, JSX.Element> = {+ done: <IconCheckCircle className="text-success shrink-0" />,+ current: <IconClock className="text-accent shrink-0" />,+ upcoming: <IconCircleDashed className="text-muted shrink-0" />,+}++const STEP_STATE_LABEL: Record<LifecycleStepState, string> = {+ done: 'Done',+ current: 'Current step',+ upcoming: 'Not yet',+}++/** Five lifecycle steps in a row. On a narrow scene the row wraps to two lines. */+export function LifecycleStrip({ steps }: { steps: LifecycleStep[] }): JSX.Element {+ return (+ <div className="@container">+ <ol className="grid grid-cols-2 @lg:grid-cols-3 @4xl:grid-cols-5 gap-2 list-none p-0 m-0">+ {steps.map((step) => (+ <li+ key={step.key}+ aria-label={`${step.label}: ${STEP_STATE_LABEL[step.state]}`}+ className={cn(+ 'flex items-start gap-2 rounded border p-2 min-w-0',+ step.state === 'current' && 'border-accent bg-surface-secondary'+ )}+ data-attr={`autoresearch-lifecycle-${step.key}`}+ >+ <span className="text-base leading-5">{STEP_ICON[step.state]}</span>+ <div className="flex flex-col min-w-0">+ <span+ className={cn('text-sm font-semibold', step.state === 'upcoming' && 'text-secondary')}+ >+ {step.label}+ </span>+ <span className="text-xs text-secondary">{step.detail}</span>+ </div>+ </li>+ ))}+ </ol>+ </div>+ )+}diff --git a/products/autoresearch/frontend/pipeline/LiveModelCard.tsx b/products/autoresearch/frontend/pipeline/LiveModelCard.tsxnew file mode 100644index 000000000000..23a96d2b87a8--- /dev/null+++ b/products/autoresearch/frontend/pipeline/LiveModelCard.tsx@@ -0,0 +1,48 @@+import { useValues } from 'kea'++import { LemonTag, Tooltip } from '@posthog/lemon-ui'++import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'+import { FeatureImportanceChart } from './FeatureImportanceChart'+import { MetricCard } from './MetricCard'++/** The champion model: its metrics, feature drivers, and the agent's description. Renders nothing before a champion exists. */+export function LiveModelCard(): JSX.Element | null {+ const { champion } = useValues(autoresearchPipelineLogic)+ if (!champion) {+ return null+ }+ return (+ <div className="border rounded p-4 space-y-4">+ <div className="flex items-center gap-2">+ <span className="text-sm font-semibold text-muted">Live model</span>+ {champion.is_preliminary && (+ <Tooltip title="Promoted on holdout AUC alone. Realized metrics confirm it once prediction horizons elapse.">+ <LemonTag type="warning">Preliminary</LemonTag>+ </Tooltip>+ )}+ </div>+ <div className="grid grid-cols-2 gap-4 md:grid-cols-3">+ <MetricCard+ label="Holdout AUC"+ value={champion.holdout_score?.toFixed(3) ?? '—'}+ tooltip="Offline AUC of the champion model, measured on held-out training data. Higher is better."+ />+ <MetricCard+ label="Realized AUC"+ value={champion.realized_score?.toFixed(3) ?? '—'}+ tooltip="AUC of the champion model measured against actual outcomes once predictions matured. Higher is better."+ />+ <MetricCard+ label="Calibration error"+ value={champion.calibration_error?.toFixed(3) ?? '—'}+ tooltip="Expected calibration error (ECE): how far predicted probabilities drift from observed rates. Lower is better."+ />+ </div>+ <FeatureImportanceChart explanation={champion.model_explanation} />+ {champion.agent_description && (+ <div className="text-sm text-muted italic">"{champion.agent_description}"</div>+ )}+ </div>+ )+}diff --git a/products/autoresearch/frontend/pipeline/MetricCard.tsx b/products/autoresearch/frontend/pipeline/MetricCard.tsxnew file mode 100644index 000000000000..cf2be19d3b66--- /dev/null+++ b/products/autoresearch/frontend/pipeline/MetricCard.tsx@@ -0,0 +1,15 @@+import { Tooltip } from '@posthog/lemon-ui'++export function MetricCard({ label, value, tooltip }: { label: string; value: string; tooltip?: string }): JSX.Element {+ const labelElement = (+ <div className={`text-xs font-semibold text-muted uppercase tracking-wide${tooltip ? ' cursor-help' : ''}`}>+ {label}+ </div>+ )+ return (+ <div className="border rounded p-3 space-y-1">+ {tooltip ? <Tooltip title={tooltip}>{labelElement}</Tooltip> : labelElement}+ <div className="text-lg font-bold truncate">{value}</div>+ </div>+ )+}diff --git a/products/autoresearch/frontend/pipeline/OverviewTab.tsx b/products/autoresearch/frontend/pipeline/OverviewTab.tsxdeleted file mode 100644index be42e76c9fe2..000000000000--- a/products/autoresearch/frontend/pipeline/OverviewTab.tsx+++ /dev/null@@ -1,120 +0,0 @@-import { useValues } from 'kea'--import { LemonSkeleton, LemonTag, Tooltip } from '@posthog/lemon-ui'--import { dayjs } from 'lib/dayjs'--import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'-import { AutoresearchModelRoleEnumApi, AutoresearchPipelineApi } from '../generated/api.schemas'-import { PipelineStatusTag } from '../PipelineStatusTag'-import { FeatureImportanceChart } from './FeatureImportanceChart'--export function OverviewTab(): JSX.Element {- const { pipeline, models } = useValues(autoresearchPipelineLogic)- if (!pipeline) {- return <LemonSkeleton className="h-40" />- }- const champion = models.find((m) => m.role === AutoresearchModelRoleEnumApi.Champion)- return (- <div className="space-y-4">- <div className="flex items-center gap-2">- <span className="text-sm font-semibold text-muted">Status</span>- <PipelineStatusTag status={pipeline.status} />- </div>- <div className="grid grid-cols-2 gap-4 md:grid-cols-4">- <MetricCard label="Target event" value={pipeline.target_event} />- <MetricCard label="Prediction horizon" value={`${pipeline.horizon_days ?? '—'}d`} />- <MetricCard label="Training lookback" value={`${pipeline.training_lookback_days ?? '—'}d`} />- <MetricCard- label="Budget remaining"- value={`${pipeline.iteration_budget_remaining} / ${pipeline.iteration_budget ?? '—'}`}- />- </div>- {champion && (- <div className="border rounded p-4 space-y-4">- <div className="flex items-center gap-2">- <span className="text-sm font-semibold text-muted">Champion model</span>- {champion.is_preliminary && (- <Tooltip title="Promoted on holdout AUC alone. Realized metrics confirm it once prediction horizons elapse.">- <LemonTag type="warning">Preliminary</LemonTag>- </Tooltip>- )}- </div>- <div className="grid grid-cols-2 gap-4 md:grid-cols-3">- <MetricCard- label="Holdout AUC"- value={champion.holdout_score?.toFixed(3) ?? '—'}- tooltip="Offline AUC of the champion model, measured on held-out training data. Higher is better."- />- <MetricCard- label="Realized AUC"- value={champion.realized_score?.toFixed(3) ?? '—'}- tooltip="AUC of the champion model measured against actual outcomes once predictions matured. Higher is better."- />- <MetricCard- label="Calibration error"- value={champion.calibration_error?.toFixed(3) ?? '—'}- tooltip="Expected calibration error (ECE): how far predicted probabilities drift from observed rates. Lower is better."- />- </div>- <FeatureImportanceChart explanation={champion.model_explanation} />- {champion.agent_description && (- <div className="text-sm text-muted italic">"{champion.agent_description}"</div>- )}- </div>- )}- <div className="border rounded p-4">- <DetailRow label="Output person property">- <code>{pipeline.output_person_property ?? '—'}</code>- </DetailRow>- <DetailRow label="Training population">- <span className="font-mono text-xs">{populationSummary(pipeline.training_population)}</span>- </DetailRow>- <DetailRow label="Inference population">- <span className="font-mono text-xs">{populationSummary(pipeline.inference_population)}</span>- </DetailRow>- <DetailRow label="Last scored">- {pipeline.last_scored_at ? dayjs(pipeline.last_scored_at).fromNow() : 'Never'}- </DetailRow>- <DetailRow label="Created">- {dayjs(pipeline.created_at).format('MMM D, YYYY')}- {pipeline.created_by?.first_name ? ` by ${pipeline.created_by.first_name}` : ''}- </DetailRow>- </div>- <p className="text-sm text-muted">- Editing the target, populations, and budget in the UI is coming soon. For now, use the{' '}- <code>autoresearch</code> API or MCP tools, or recreate the model.- </p>- </div>- )-}--function DetailRow({ label, children }: { label: string; children: React.ReactNode }): JSX.Element {- return (- <div className="flex justify-between items-start gap-4 py-2 border-b last:border-0">- <div className="text-sm font-semibold text-muted">{label}</div>- <div className="text-sm text-right">{children}</div>- </div>- )-}--function populationSummary(population: AutoresearchPipelineApi['training_population']): string {- if (!population || typeof population !== 'object' || Object.keys(population).length === 0) {- return 'All users'- }- return JSON.stringify(population)-}--function MetricCard({ label, value, tooltip }: { label: string; value: string; tooltip?: string }): JSX.Element {- const labelElement = (- <div className={`text-xs font-semibold text-muted uppercase tracking-wide${tooltip ? ' cursor-help' : ''}`}>- {label}- </div>- )- return (- <div className="border rounded p-3 space-y-1">- {tooltip ? <Tooltip title={tooltip}>{labelElement}</Tooltip> : labelElement}- <div className="text-lg font-bold truncate">{value}</div>- </div>- )-}diff --git a/products/autoresearch/frontend/pipeline/PipelineSummary.tsx b/products/autoresearch/frontend/pipeline/PipelineSummary.tsxnew file mode 100644index 000000000000..c8e95560baab--- /dev/null+++ b/products/autoresearch/frontend/pipeline/PipelineSummary.tsx@@ -0,0 +1,45 @@+import { useValues } from 'kea'++import { dayjs } from 'lib/dayjs'+import { humanFriendlyNumber } from 'lib/utils/numbers'++import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'+import { modelQuality } from '../modelQuality'+import { ModelQualityTag } from '../ModelQualityTag'+import { PipelineStatusTag } from '../PipelineStatusTag'++/** The line under the model's question: status, quality verdict, and how many people the model scored. */+export function PipelineSummary(): JSX.Element | null {+ const { pipeline } = useValues(autoresearchPipelineLogic)+ if (!pipeline) {+ return null+ }+ const quality = modelQuality({+ holdoutAuc: pipeline.champion_holdout_auc,+ realizedAuc: pipeline.champion_realized_auc,+ liftAt10: pipeline.champion_lift_at_10,+ isPreliminary: pipeline.champion_is_preliminary,+ target: pipeline.target_event,+ })+ return (+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-sm">+ <PipelineStatusTag status={pipeline.status} />+ {quality && (+ <span className="flex items-center gap-1 min-w-0">+ <ModelQualityTag+ quality={quality}+ holdoutAuc={pipeline.champion_holdout_auc}+ realizedAuc={pipeline.champion_realized_auc}+ />+ <span className="text-secondary">{quality.sentence}</span>+ </span>+ )}+ <span className="text-secondary">+ {pipeline.people_scored != null+ ? `${humanFriendlyNumber(pipeline.people_scored)} people scored`+ : 'Not scored yet'}+ {pipeline.last_scored_at && ` · last scored ${dayjs(pipeline.last_scored_at).fromNow()}`}+ </span>+ </div>+ )+}diff --git a/products/autoresearch/frontend/pipeline/SetupTab.tsx b/products/autoresearch/frontend/pipeline/SetupTab.tsxnew file mode 100644index 000000000000..77de34916876--- /dev/null+++ b/products/autoresearch/frontend/pipeline/SetupTab.tsx@@ -0,0 +1,64 @@+import { useValues } from 'kea'++import { LemonSkeleton } from '@posthog/lemon-ui'++import { dayjs } from 'lib/dayjs'++import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'+import { AutoresearchPipelineApi } from '../generated/api.schemas'+import { MetricCard } from './MetricCard'++export function SetupTab(): JSX.Element {+ const { pipeline } = useValues(autoresearchPipelineLogic)+ if (!pipeline) {+ return <LemonSkeleton className="h-40" />+ }+ return (+ <div className="space-y-4">+ <div className="grid grid-cols-2 gap-4 md:grid-cols-4">+ <MetricCard label="Target event" value={pipeline.target_event} />+ <MetricCard label="Prediction horizon" value={`${pipeline.horizon_days ?? '—'}d`} />+ <MetricCard label="Training lookback" value={`${pipeline.training_lookback_days ?? '—'}d`} />+ <MetricCard+ label="Budget remaining"+ value={`${pipeline.iteration_budget_remaining} / ${pipeline.iteration_budget ?? '—'}`}+ />+ </div>+ <div className="border rounded p-4">+ <DetailRow label="Output person property">+ <code>{pipeline.output_person_property ?? '—'}</code>+ </DetailRow>+ <DetailRow label="Training population">+ <span className="font-mono text-xs">{populationSummary(pipeline.training_population)}</span>+ </DetailRow>+ <DetailRow label="Inference population">+ <span className="font-mono text-xs">{populationSummary(pipeline.inference_population)}</span>+ </DetailRow>+ <DetailRow label="Created">+ {dayjs(pipeline.created_at).format('MMM D, YYYY')}+ {pipeline.created_by?.first_name ? ` by ${pipeline.created_by.first_name}` : ''}+ </DetailRow>+ </div>+ <p className="text-sm text-muted">+ Editing the target, populations, and budget in the UI is coming soon. For now, use the{' '}+ <code>autoresearch</code> API or MCP tools, or recreate the model.+ </p>+ </div>+ )+}++function DetailRow({ label, children }: { label: string; children: React.ReactNode }): JSX.Element {+ return (+ <div className="flex justify-between items-start gap-4 py-2 border-b last:border-0">+ <div className="text-sm font-semibold text-muted">{label}</div>+ <div className="text-sm text-right">{children}</div>+ </div>+ )+}++function populationSummary(population: AutoresearchPipelineApi['training_population']): string {+ if (!population || typeof population !== 'object' || Object.keys(population).length === 0) {+ return 'All users'+ }+ return JSON.stringify(population)+}diff --git a/products/autoresearch/frontend/pipeline/SuggestionForm.tsx b/products/autoresearch/frontend/pipeline/SuggestionForm.tsxindex 33fc90105dc0..00ead7a3c763 100644--- a/products/autoresearch/frontend/pipeline/SuggestionForm.tsx+++ b/products/autoresearch/frontend/pipeline/SuggestionForm.tsx@@ -20,7 +20,7 @@ export function SuggestionForm(): JSX.Element {maxRows={6}data-attr="autoresearch-suggestion-input"/>- <div className="flex items-center gap-2">+ <div className="flex flex-wrap items-center gap-2"><LemonSelectsize="small"value={suggestionPriority}diff --git a/products/autoresearch/frontend/pipelineLifecycle.test.ts b/products/autoresearch/frontend/pipelineLifecycle.test.tsnew file mode 100644index 000000000000..064600d0d5d3--- /dev/null+++ b/products/autoresearch/frontend/pipelineLifecycle.test.ts@@ -0,0 +1,103 @@+import { dayjs } from 'lib/dayjs'++import { LifecycleInput, LifecycleStepState, pipelineLifecycle } from './pipelineLifecycle'++const NOW = dayjs('2026-03-01T12:00:00Z')++const NEW_PIPELINE: LifecycleInput['pipeline'] = {+ created_at: '2026-01-01T00:00:00Z',+ horizon_days: 7,+ last_scored_at: null,+ training_run_count: 0,+ experiment_count: 0,+ live_training_run: null,+}++function scoringRun(day: string): LifecycleInput['runs'][number] {+ return { run_type: 'inference', status: 'completed', created_at: `${day}T03:00:00Z`, rows_scored: 100, metrics: {} }+}++function input(overrides: Partial<LifecycleInput>): LifecycleInput {+ return { pipeline: NEW_PIPELINE, champion: null, runs: [], validatedDates: [], now: NOW, ...overrides }+}++describe('pipelineLifecycle', () => {+ it.each<[string, LifecycleInput, LifecycleStepState[]]>([+ ['a draft model', input({}), ['done', 'current', 'upcoming', 'upcoming', 'upcoming']],+ [+ 'a model whose only attempt failed before any experiment',+ input({ pipeline: { ...NEW_PIPELINE, training_run_count: 1 } }),+ ['done', 'current', 'upcoming', 'upcoming', 'upcoming'],+ ],+ [+ 'a model in its first training run',+ input({+ pipeline: { ...NEW_PIPELINE, training_run_count: 1, experiment_count: 3, live_training_run: {} },+ }),+ ['done', 'current', 'upcoming', 'upcoming', 'upcoming'],+ ],+ [+ 'a preliminary champion that scored before any date matured',+ input({+ pipeline: {+ ...NEW_PIPELINE,+ training_run_count: 1,+ experiment_count: 5,+ last_scored_at: '2026-02-28T03:00:00Z',+ },+ champion: { is_preliminary: true, promoted_at: '2026-02-27T00:00:00Z' },+ runs: [scoringRun('2026-02-28')],+ }),+ ['done', 'done', 'done', 'done', 'current'],+ ],+ [+ 'a validated champion',+ input({+ pipeline: {+ ...NEW_PIPELINE,+ training_run_count: 2,+ experiment_count: 9,+ last_scored_at: '2026-02-28T03:00:00Z',+ },+ champion: { is_preliminary: false, promoted_at: '2026-01-10T00:00:00Z' },+ runs: [scoringRun('2026-02-10'), scoringRun('2026-02-11'), scoringRun('2026-02-28')],+ validatedDates: ['2026-02-10', '2026-02-10'],+ }),+ ['done', 'done', 'done', 'done', 'done'],+ ],+ ])('marks each step for %s', (_name, lifecycleInput, expectedStates) => {+ expect(pipelineLifecycle(lifecycleInput).map((step) => step.state)).toEqual(expectedStates)+ })++ it.each([+ [+ 'counts distinct validated dates out of matured scored dates',+ [scoringRun('2026-02-10'), scoringRun('2026-02-11'), scoringRun('2026-02-28')],+ ['2026-02-10', '2026-02-10'],+ '1 of 2 matured dates checked',+ ],+ [+ 'skips a scoring run that scored nobody',+ [scoringRun('2026-02-10'), { ...scoringRun('2026-02-11'), rows_scored: 0 }],+ ['2026-02-10'],+ '1 of 1 matured date checked',+ ],+ [+ 'counts the prediction date, not the day the run started',+ [{ ...scoringRun('2026-02-23'), metrics: { prediction_date: '2026-02-22' } }],+ [],+ '0 of 1 matured date checked',+ ],+ [+ 'says when the first check comes before any date matured',+ [scoringRun('2026-02-28')],+ [],+ 'First check 7 days after scoring',+ ],+ ])('%s', (_name, runs, validatedDates, expectedDetail) => {+ const steps = pipelineLifecycle(+ input({ pipeline: { ...NEW_PIPELINE, last_scored_at: '2026-02-28T03:00:00Z' }, runs, validatedDates })+ )+ expect(steps.find((step) => step.key === 'checked')?.detail.replace(/\s/g, ' ')).toEqual(expectedDetail)+ })+})diff --git a/products/autoresearch/frontend/pipelineLifecycle.ts b/products/autoresearch/frontend/pipelineLifecycle.tsnew file mode 100644index 000000000000..d5901ae0debe--- /dev/null+++ b/products/autoresearch/frontend/pipelineLifecycle.ts@@ -0,0 +1,120 @@+import { dayjs } from 'lib/dayjs'+import { pluralize } from 'lib/utils/strings'++import { AutoresearchModelApi, AutoresearchPipelineApi, AutoresearchRunApi } from './generated/api.schemas'++export type LifecycleStepKey = 'question_set' | 'agent_searched' | 'model_live' | 'scoring' | 'checked'++export type LifecycleStepState = 'done' | 'current' | 'upcoming'++export interface LifecycleStep {+ key: LifecycleStepKey+ label: string+ detail: string+ state: LifecycleStepState+}++export interface LifecycleInput {+ pipeline: Pick<+ AutoresearchPipelineApi,+ 'created_at' | 'horizon_days' | 'last_scored_at' | 'training_run_count' | 'experiment_count'+ > & { live_training_run: unknown }+ champion: Pick<AutoresearchModelApi, 'is_preliminary' | 'promoted_at'> | null+ runs: Pick<AutoresearchRunApi, 'run_type' | 'status' | 'created_at' | 'rows_scored' | 'metrics'>[]+ /** Prediction dates (YYYY-MM-DD) that a validation run checked against real outcomes. */+ validatedDates: string[]+ now: dayjs.Dayjs+}++/** The date a scoring run predicts for. Validation groups runs by this date, so it is the date to count. */+function predictionDate(run: LifecycleInput['runs'][number]): string {+ const recorded = run.metrics?.prediction_date+ return typeof recorded === 'string' ? recorded : dayjs(run.created_at).utc().format('YYYY-MM-DD')+}++/** Scored dates whose prediction horizon has passed, so their real outcomes are known. */+function maturedScoredDates(+ runs: LifecycleInput['runs'],+ horizonDays: number | undefined,+ now: dayjs.Dayjs+): Set<string> {+ const cutoff = now.subtract(horizonDays ?? 0, 'day')+ const dates = new Set<string>()+ for (const run of runs) {+ // A run that scored nobody emits no predictions, so validation has nothing to check for its date.+ if (run.run_type !== 'inference' || run.status !== 'completed' || !run.rows_scored) {+ continue+ }+ const date = predictionDate(run)+ if (!dayjs.utc(date).isAfter(cutoff)) {+ dates.add(date)+ }+ }+ return dates+}++function checkedDetail(input: LifecycleInput): string {+ const validated = new Set(input.validatedDates).size+ const matured = Math.max(maturedScoredDates(input.runs, input.pipeline.horizon_days, input.now).size, validated)+ if (matured === 0) {+ return input.pipeline.last_scored_at+ ? `First check ${pluralize(input.pipeline.horizon_days ?? 0, 'day')} after scoring`+ : 'Not yet'+ }+ return `${validated} of ${pluralize(matured, 'matured date')} checked`+}++/** Where a model is in its lifecycle. The first step that is not done is the current step. */+export function pipelineLifecycle(input: LifecycleInput): LifecycleStep[] {+ const { pipeline, champion } = input+ const searching = pipeline.live_training_run != null+ const steps: Omit<LifecycleStep, 'state'>[] = [+ {+ key: 'question_set',+ label: 'Question set',+ detail: dayjs(pipeline.created_at).format('MMM D, YYYY'),+ },+ {+ key: 'agent_searched',+ label: 'Agent searched',+ detail:+ pipeline.training_run_count > 0+ ? `${pluralize(pipeline.training_run_count, 'run')} · ${pluralize(pipeline.experiment_count, 'experiment')}`+ : 'Not started',+ },+ {+ key: 'model_live',+ label: 'Best model live',+ detail: !champion+ ? 'Not yet'+ : champion.is_preliminary+ ? 'Preliminary'+ : champion.promoted_at+ ? dayjs(champion.promoted_at).format('MMM D, YYYY')+ : 'Live',+ },+ {+ key: 'scoring',+ label: 'Scoring on schedule',+ detail: pipeline.last_scored_at ? `Last run ${dayjs(pipeline.last_scored_at).fromNow()}` : 'Not yet',+ },+ {+ key: 'checked',+ label: 'Checked against reality',+ detail: checkedDetail(input),+ },+ ]+ const done: Record<LifecycleStepKey, boolean> = {+ question_set: true,+ // A failed attempt counts as a run but records no experiments, so it is not a search.+ agent_searched: champion != null || (pipeline.experiment_count > 0 && !searching),+ model_live: champion != null,+ scoring: pipeline.last_scored_at != null,+ checked: input.validatedDates.length > 0,+ }+ const currentIndex = steps.findIndex((step) => !done[step.key])+ return steps.map((step, index) => ({+ ...step,+ state: done[step.key] ? 'done' : index === currentIndex ? 'current' : 'upcoming',+ }))+}