: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(web-analytics): replace proposal cards with a drafts queue (#109630)
Jordan Mryyanbb129fb2e7ef
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 16c08f03147c..627ba6e59955 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7250,14 +7250,6 @@ snapshots:hash: v1.k794b7964.75044871dcc2faa507f449a17e07deb6e0cf20cc73cdc5fc3e656dbcf4baf31b.ANyIBMkLPcA_SBd96Nd2GVIfhyf97CbOy3za6mYR0z4products-web-analytics-content-autopilot-brief--missing-brief--light:hash: v1.k794b7964.d5e3b3a7b64a0ecf4023a55b0cf1a3c32c97fa70d31dd1da48d0d3da1c87a740.LImf4sGZGBFGBCuuNLggitGjsee4HyVuZ4UhkS1KOSI- products-web-analytics-content-autopilot-proposal-card--blocking-validation--dark:- hash: v1.k794b7964.8209374f939a22b6b211c2a21698ca15c4d6e18eda905eafc2c826539fa6a6f3.iZuZv-_mdz_BoFNzarvgUmumBKyNRvbdYMCWKcRQ5Bs- products-web-analytics-content-autopilot-proposal-card--blocking-validation--light:- hash: v1.k794b7964.5f57f98214e924ea35b8b0ee1246f9fb01bc73b6611fbb47d24673a32585a39f.aCi-hrNzgZ5o9NZWhs5Etj5X4ICf2vJyL3Zle7J3XnM- products-web-analytics-content-autopilot-proposal-card--ready-for-review--dark:- hash: v1.k794b7964.bf31cb5454ab3b5b5410666a11ba19a0c149cccd7ae57b56efb32035f98239c8.I25YeYWQe17NAqrEq81n-U3tR8dMX8usKI0RRXhc7vI- products-web-analytics-content-autopilot-proposal-card--ready-for-review--light:- hash: v1.k794b7964.2d32fe2131b0ecca9c82ad58d395e73e204ab96db50f814fea3797f241829965.ndis7gl5c6uNZ_5DhF8CiTwDrvHWrUHsSyp3db3PUL0products-web-analytics-content-autopilot-sources--with-research-notes--dark:hash: v1.k794b7964.2be0596eea5d943ea5154d78d076fb1ae33583f6d1a82bd61b23e91807004a6c.c2JSeWbl54pOJlq8Zu3slJG20JJVq25E1D9JX4yn8rwproducts-web-analytics-content-autopilot-sources--with-research-notes--light:@@ -7278,6 +7270,14 @@ snapshots:hash: v1.k794b7964.e78c4329f8ed2b268ae0f9e12750faf36b52a13f93afa4cdef6c6d3f967b85d4.seSi9FnXUv4lFgG8LnjWfQSx48DPmw0NvAouHKLV-hEproducts-web-analytics-content-autopilot-workspace--active-run--light:hash: v1.k794b7964.01d2d2224dc6d1eec26cb051db45e73b3f09578cace3d92a865717270f36e9a0.fyfh1pZRPid9MiuWc2YolgmQRCYae61gLJ9TTZiQ_AU+ products-web-analytics-content-autopilot-workspace--drafts-tab--dark:+ hash: v1.k794b7964.8b76f06f9f7932c7011f0edbd86449b904ef1eb4fc0820685fb89b936e3f443e.pRJHP3NREhhrmFXFZqRwtZtFLEBWvBGp8DRglBSyd44+ products-web-analytics-content-autopilot-workspace--drafts-tab--light:+ hash: v1.k794b7964.027ecb35adf95e2611cea3d1d390aec6c5a876d9f3bd920204216ab6803ca44a.H2CQyp9rv7yF8ghTpjUl_bYF4MsrKXwnk36ijRuY7sY+ products-web-analytics-content-autopilot-workspace--failed-run--dark:+ hash: v1.k794b7964.3d8a16bf937d62edab696e840497fad20cb5065d7d706833bec861357516a490.brmGznNIzalassalSt8p3-pUe09akPMMOqgToVi7GV4+ products-web-analytics-content-autopilot-workspace--failed-run--light:+ hash: v1.k794b7964.5b838524626886f5d22ea592a8be8815bd4ba492b281f07679072a21099c9e87.COVxz4-01XJAxdibxcT5UdSyWYVL-g-8c0TPe0DSMKMproducts-web-analytics-content-autopilot-workspace--multiple-sites--dark:hash: v1.k794b7964.b59bcd4873161e4d1a649a7acf03a84e86f1e4bd063a0418833288e4b4995422.1P0EVXKwtUq4LrVS9jlKO_tbPn6kLp8nmpiAyVZ8GG0products-web-analytics-content-autopilot-workspace--multiple-sites--light:diff --git a/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.stories.tsx b/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.stories.tsxindex b5920ed3f750..5bd74673dd29 100644--- a/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.stories.tsx+++ b/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.stories.tsx@@ -133,6 +133,29 @@ ActiveRun.decorators = [}),]+export const FailedRun: StoryFn<typeof ContentAutopilot> = () => (+ <div className="p-6">+ <ContentAutopilot />+ </div>+)+FailedRun.decorators = [+ workspaceHandlers({+ profiles: [EXAMPLE_PROFILE],+ runs: [+ {+ ...EXAMPLE_RUN,+ run_status: 'failed',+ errors: [+ {+ error_code: 'timed_out',+ message: 'Drafting took too long. Try fewer opportunities at once.',+ },+ ],+ },+ ],+ }),+]+const ProposalStory = ({ tab }: { tab?: ContentAutopilotProposalTab }): JSX.Element => {const { profileDataLoaded } = useValues(contentAutopilotLogic)const { selectProposal, setProposalTab } = useActions(contentAutopilotLogic)@@ -161,5 +184,38 @@ ProposalReview.decorators = [}),]+export const DraftsTab: StoryFn<typeof ContentAutopilot> = () => {+ const { profileDataLoaded } = useValues(contentAutopilotLogic)+ const { setWorkspaceTab } = useActions(contentAutopilotLogic)+ useEffect(() => {+ if (profileDataLoaded) {+ setWorkspaceTab('drafts')+ }+ }, [profileDataLoaded, setWorkspaceTab])+ return (+ <div className="p-6">+ <ContentAutopilot />+ </div>+ )+}+DraftsTab.decorators = [+ workspaceHandlers({+ profiles: [EXAMPLE_PROFILE],+ runs: [EXAMPLE_RUN],+ proposals: [+ { ...EXAMPLE_PROPOSAL_LIST, id: '00000000-0000-4000-8000-000000000211', lifecycle_status: 'failed' },+ EXAMPLE_PROPOSAL_LIST,+ {+ ...EXAMPLE_PROPOSAL_LIST,+ id: '00000000-0000-4000-8000-000000000212',+ proposal_type: 'new_content',+ lifecycle_status: 'exported',+ title: 'Does web analytics work without cookies?',+ },+ ],+ opportunities: EXAMPLE_OPPORTUNITIES,+ }),+]+export const ProposalPreview: StoryFn<typeof ContentAutopilot> = () => <ProposalStory />ProposalPreview.decorators = ProposalReview.decoratorsdiff --git a/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.tsx b/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.tsxindex 1aa020f6c531..ef20a0e12c27 100644--- a/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.tsx+++ b/products/web_analytics/frontend/contentAutopilot/ContentAutopilot.tsx@@ -13,10 +13,12 @@ import {Spinner,} from '@posthog/lemon-ui'+import { pluralize } from 'lib/utils/strings'++import { ContentAutopilotDrafts } from './ContentAutopilotDrafts'import { contentAutopilotLogic } from './contentAutopilotLogic'import { ContentAutopilotOpportunities } from './ContentAutopilotOpportunities'import { ContentAutopilotProposalDetail } from './ContentAutopilotProposalDetail'-import { ContentAutopilotProposalSection } from './ContentAutopilotProposalSection'import { ContentAutopilotSetup } from './ContentAutopilotSetup'export const ContentAutopilot = (): JSX.Element => {@@ -24,9 +26,9 @@ export const ContentAutopilot = (): JSX.Element => {profile,activeRun,siteRuns,- siteProposals,- newContentProposals,- pageImprovementProposals,+ reviewQueue,+ readyDraftCount,+ failedDraftCount,workspaceTab,onboardingOpen,siteProfiles,@@ -40,10 +42,11 @@ export const ContentAutopilot = (): JSX.Element => {profileDataLoaded,visibleOpportunities,} = useValues(contentAutopilotLogic)- const { beginOnboarding, cancelRun, selectProfile, selectProposal, loadWorkspace, setWorkspaceTab } =+ const { beginOnboarding, cancelRun, selectProfile, loadWorkspace, setWorkspaceTab } =useActions(contentAutopilotLogic)const loading = siteProfilesLoading || runsLoading || proposalsLoadingconst lastRun = siteRuns[0]+ const lastRunErrors = lastRun?.run_status === 'failed' ? lastRun.errors.map(({ message }) => message).join(' ') : ''const confirmCancelRun = (): void => {if (!activeRun) {return@@ -132,11 +135,27 @@ export const ContentAutopilot = (): JSX.Element => {Stop drafting</LemonButton></LemonCard>+ ) : failedDraftCount > 0 ? (+ <LemonBanner+ type="error"+ action={+ workspaceTab === 'drafts'+ ? undefined+ : {+ children: 'View drafts',+ onClick: () => setWorkspaceTab('drafts'),+ 'data-attr': 'content-autopilot-view-failed-drafts',+ }+ }+ >+ {pluralize(failedDraftCount, 'draft')} from the latest run didn't pass. Open a draft+ to see what to fix, or regenerate it.+ {lastRunErrors ? ` ${lastRunErrors}` : null}+ </LemonBanner>) : lastRun?.run_status === 'failed' ? (<LemonBanner type="error">The latest run failed.{' '}- {lastRun.errors.map(({ message }) => message).join(' ') ||- 'Select opportunities and draft them again.'}+ {lastRunErrors || 'Select opportunities and draft them again.'}</LemonBanner>) : null}@@ -152,40 +171,10 @@ export const ContentAutopilot = (): JSX.Element => {},{key: 'drafts',- label: `Drafts (${siteProposals.length})`,- content:- siteProposals.length === 0 ? (- <LemonCard hoverEffect={false} className="p-8 text-center">- <h3 className="m-0">No drafts yet</h3>- <p className="m-0 mt-2 text-muted max-w-xl mx-auto">- Pick questions on the Opportunities tab and draft them. Drafts- show up here for review.- </p>- <LemonButton- type="secondary"- className="mt-4 mx-auto"- onClick={() => setWorkspaceTab('opportunities')}- data-attr="content-autopilot-drafts-empty-opportunities"- >- Go to opportunities- </LemonButton>- </LemonCard>- ) : (- <>- <ContentAutopilotProposalSection- title="New content"- description="Original articles for topics people search for that do not have a dedicated page."- proposals={newContentProposals}- onReview={selectProposal}- />- <ContentAutopilotProposalSection- title="Page improvements"- description="Focused metadata, linking, and content changes."- proposals={pageImprovementProposals}- onReview={selectProposal}- />- </>- ),+ label: readyDraftCount+ ? `Drafts (${readyDraftCount} ready to review)`+ : `Drafts (${reviewQueue.length})`,+ content: <ContentAutopilotDrafts />,},]}/>diff --git a/products/web_analytics/frontend/contentAutopilot/ContentAutopilotDrafts.tsx b/products/web_analytics/frontend/contentAutopilot/ContentAutopilotDrafts.tsxnew file mode 100644index 000000000000..435eec85a062--- /dev/null+++ b/products/web_analytics/frontend/contentAutopilot/ContentAutopilotDrafts.tsx@@ -0,0 +1,120 @@+import { useActions, useValues } from 'kea'++import { LemonButton, LemonCard, LemonTable, LemonTag } from '@posthog/lemon-ui'++import { TZLabel } from 'lib/components/TZLabel'++import type { ContentAutopilotProposalListApi } from 'products/web_analytics/frontend/generated/api.schemas'++import { contentAutopilotLogic } from './contentAutopilotLogic'++const statusTag = (proposal: ContentAutopilotProposalListApi): JSX.Element => {+ switch (proposal.lifecycle_status) {+ case 'ready_for_review':+ return <LemonTag type="success">Ready to review</LemonTag>+ case 'generating':+ return <LemonTag type="completion">Drafting</LemonTag>+ case 'exported':+ return <LemonTag type="primary">Downloaded</LemonTag>+ case 'rejected':+ return <LemonTag type="muted">Rejected</LemonTag>+ case 'failed':+ return proposal.validation_report.checks.some(+ ({ check_key, passed }) => check_key === 'generation' && !passed+ ) ? (+ <LemonTag type="danger">Couldn't draft</LemonTag>+ ) : (+ <LemonTag type="warning">Needs fixes</LemonTag>+ )+ }+}++const pagePath = (proposal: ContentAutopilotProposalListApi): string =>+ proposal.file_path ? `/${proposal.file_path.replace(/\.mdx?$/, '')}` : ''++export const ContentAutopilotDrafts = (): JSX.Element | null => {+ const { reviewQueue, workspaceErrors } = useValues(contentAutopilotLogic)+ const { selectProposal, setWorkspaceTab } = useActions(contentAutopilotLogic)++ if (reviewQueue.length === 0 && workspaceErrors.proposals) {+ return null+ }++ if (reviewQueue.length === 0) {+ return (+ <LemonCard hoverEffect={false} className="p-8 text-center">+ <h3 className="m-0">No drafts yet</h3>+ <p className="m-0 mt-2 text-muted max-w-xl mx-auto">+ Pick questions on the Opportunities tab and draft them. Drafts show up here for review.+ </p>+ <LemonButton+ type="secondary"+ className="mt-4 mx-auto"+ onClick={() => setWorkspaceTab('opportunities')}+ data-attr="content-autopilot-drafts-empty-opportunities"+ >+ Go to opportunities+ </LemonButton>+ </LemonCard>+ )+ }++ return (+ <LemonTable+ dataSource={reviewQueue}+ rowKey="id"+ columns={[+ {+ title: 'Draft',+ key: 'title',+ render: (_, proposal) => (+ <div className="py-2 min-w-60">+ <div className="font-semibold">{proposal.title}</div>+ <div className="text-xs text-muted mt-1">{proposal.target_query}</div>+ </div>+ ),+ },+ {+ title: 'Change',+ key: 'change',+ render: (_, proposal) => (+ <div className="text-sm">+ <div>{proposal.proposal_type === 'new_content' ? 'New page' : 'Updates a page'}</div>+ <div className="text-xs text-muted truncate max-w-80">{pagePath(proposal)}</div>+ </div>+ ),+ },+ {+ title: 'Status',+ key: 'status',+ render: (_, proposal) => statusTag(proposal),+ },+ {+ title: 'Updated',+ key: 'updated',+ render: (_, proposal) => <TZLabel time={proposal.updated_at} />,+ },+ {+ key: 'actions',+ render: (_, proposal) => (+ <div className="flex justify-end">+ <LemonButton+ size="small"+ type={proposal.lifecycle_status === 'ready_for_review' ? 'primary' : 'secondary'}+ onClick={() => selectProposal(proposal.id)}+ disabledReason={+ proposal.lifecycle_status === 'generating'+ ? 'This draft is still being written'+ : undefined+ }+ data-attr="content-autopilot-review-draft"+ >+ Review+ </LemonButton>+ </div>+ ),+ },+ ]}+ />+ )+}diff --git a/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalCard.stories.tsx b/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalCard.stories.tsxdeleted file mode 100644index 5c553ce8ec29..000000000000--- a/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalCard.stories.tsx+++ /dev/null@@ -1,47 +0,0 @@-import type { Meta, StoryFn } from '@storybook/react'--import { FEATURE_FLAGS } from 'lib/constants'--import { ContentAutopilotProposalCard } from './ContentAutopilotProposalCard'-import { EXAMPLE_PROPOSAL_LIST } from './contentAutopilotStoryFixtures'--const meta: Meta<typeof ContentAutopilotProposalCard> = {- title: 'Products/Web Analytics/Content autopilot/Proposal card',- component: ContentAutopilotProposalCard,- parameters: {- layout: 'centered',- featureFlags: [FEATURE_FLAGS.WEB_ANALYTICS_PAGE_PERFORMANCE, FEATURE_FLAGS.WEB_ANALYTICS_CONTENT_AUTOPILOT],- },-}--export default meta--export const ReadyForReview: StoryFn<typeof ContentAutopilotProposalCard> = () => (- <div className="w-[640px]">- <ContentAutopilotProposalCard proposal={EXAMPLE_PROPOSAL_LIST} onReview={() => undefined} />- </div>-)--export const BlockingValidation: StoryFn<typeof ContentAutopilotProposalCard> = () => (- <div className="w-[640px]">- <ContentAutopilotProposalCard- proposal={{- ...EXAMPLE_PROPOSAL_LIST,- lifecycle_status: 'failed',- validation_report: {- passed: false,- checks: [- {- check_key: 'factual_sources',- label: 'Factual sourcing',- passed: false,- message: 'One factual claim has no public source.',- blocking: true,- },- ],- },- }}- onReview={() => undefined}- />- </div>-)diff --git a/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalCard.tsx b/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalCard.tsxdeleted file mode 100644index 2860aedc4b07..000000000000--- a/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalCard.tsx+++ /dev/null@@ -1,49 +0,0 @@-import { LemonButton, LemonCard, LemonTag } from '@posthog/lemon-ui'--import type { ContentAutopilotProposalListApi } from 'products/web_analytics/frontend/generated/api.schemas'--export interface ContentAutopilotProposalCardProps {- proposal: ContentAutopilotProposalListApi- onReview: (proposalId: string) => void-}--const statusLabel: Record<ContentAutopilotProposalListApi['lifecycle_status'], string> = {- generating: 'Generating',- ready_for_review: 'Ready for review',- rejected: 'Rejected',- exported: 'Exported',- failed: 'Failed',-}--export const ContentAutopilotProposalCard = ({- proposal,- onReview,-}: ContentAutopilotProposalCardProps): JSX.Element => {- const primaryEvidence = proposal.evidence[0]-- return (- <LemonCard hoverEffect={false} className="p-4 flex flex-col gap-3">- <div className="flex flex-wrap items-center justify-between gap-2">- <LemonTag type={proposal.validation_report.passed ? 'success' : 'danger'}>- {statusLabel[proposal.lifecycle_status]}- </LemonTag>- <span className="text-xs text-muted">{proposal.file_path}</span>- </div>- <div>- <h3 className="m-0">{proposal.title}</h3>- <p className="m-0 mt-1 text-muted">{proposal.target_query}</p>- </div>- {primaryEvidence ? (- <div className="rounded border p-3 bg-surface-secondary">- <div className="font-semibold">Why PostHog selected this</div>- <div className="text-sm mt-1">{primaryEvidence.explanation}</div>- </div>- ) : null}- <div className="flex justify-end mt-auto">- <LemonButton type="secondary" onClick={() => onReview(proposal.id)}>- Review proposal- </LemonButton>- </div>- </LemonCard>- )-}diff --git a/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalSection.tsx b/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalSection.tsxdeleted file mode 100644index 74e95e8589f1..000000000000--- a/products/web_analytics/frontend/contentAutopilot/ContentAutopilotProposalSection.tsx+++ /dev/null@@ -1,35 +0,0 @@-import type { ContentAutopilotProposalListApi } from 'products/web_analytics/frontend/generated/api.schemas'--import { ContentAutopilotProposalCard } from './ContentAutopilotProposalCard'--export interface ContentAutopilotProposalSectionProps {- title: string- description: string- proposals: ContentAutopilotProposalListApi[]- onReview: (proposalId: string) => void-}--export const ContentAutopilotProposalSection = ({- title,- description,- proposals,- onReview,-}: ContentAutopilotProposalSectionProps): JSX.Element | null => {- if (proposals.length === 0) {- return null- }-- return (- <section>- <div className="mb-3">- <h2 className="m-0">{title}</h2>- <p className="m-0 mt-1 text-muted">{description}</p>- </div>- <div className="grid grid-cols-1 xl:grid-cols-2 gap-3">- {proposals.map((proposal) => (- <ContentAutopilotProposalCard key={proposal.id} proposal={proposal} onReview={onReview} />- ))}- </div>- </section>- )-}diff --git a/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.test.ts b/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.test.tsindex 83c496cbe98d..2c9867bb2862 100644--- a/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.test.ts+++ b/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.test.ts@@ -362,19 +362,39 @@ describe('contentAutopilotLogic', () => {expect(mountedLogic.values.workspaceTab).toBe('opportunities')})- it('groups the proposals returned for the selected site', async () => {- const newContent: ContentAutopilotProposalListApi = {+ it('puts drafts ready for review first in the review queue', async () => {+ const rejected: ContentAutopilotProposalListApi = {...EXAMPLE_PROPOSAL_LIST,id: '00000000-0000-4000-8000-000000000202',- proposal_type: 'new_content',+ lifecycle_status: 'rejected',}- mockProposalsList.mockResolvedValue(paginated([EXAMPLE_PROPOSAL_LIST, newContent]))+ const failed: ContentAutopilotProposalListApi = {+ ...EXAMPLE_PROPOSAL_LIST,+ id: '00000000-0000-4000-8000-000000000203',+ lifecycle_status: 'failed',+ }+ const ready: ContentAutopilotProposalListApi = {+ ...EXAMPLE_PROPOSAL_LIST,+ lifecycle_status: 'ready_for_review',+ }+ const failedInAnOlderRun: ContentAutopilotProposalListApi = {+ ...EXAMPLE_PROPOSAL_LIST,+ id: '00000000-0000-4000-8000-000000000204',+ run_id: '00000000-0000-4000-8000-000000000199',+ lifecycle_status: 'failed',+ }+ mockProposalsList.mockResolvedValue(paginated([rejected, failed, failedInAnOlderRun, ready]))const mountedLogic = await mountWorkspace()- expect(mountedLogic.values.siteProposals.map(({ id }) => id)).toEqual([EXAMPLE_PROPOSAL_LIST.id, newContent.id])- expect(mountedLogic.values.newContentProposals.map(({ id }) => id)).toEqual([newContent.id])- expect(mountedLogic.values.pageImprovementProposals.map(({ id }) => id)).toEqual([EXAMPLE_PROPOSAL_LIST.id])+ expect(mountedLogic.values.reviewQueue.map(({ id }) => id)).toEqual([+ ready.id,+ failed.id,+ failedInAnOlderRun.id,+ rejected.id,+ ])+ expect(mountedLogic.values.readyDraftCount).toBe(1)+ expect(mountedLogic.values.failedDraftCount).toBe(1)})it('polls while work is active and stops refreshing after it settles', async () => {diff --git a/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.ts b/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.tsindex 424f58f4fa41..e77dd9ca668e 100644--- a/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.ts+++ b/products/web_analytics/frontend/contentAutopilot/contentAutopilotLogic.ts@@ -18,6 +18,7 @@ import type {import { webAnalyticsContentAutopilotOpportunitiesDraftBodyOpportunityIdsMax } from 'products/web_analytics/frontend/generated/api.zod'export type ContentAutopilotOnboardingStep = 'site' | 'sources'+export type ContentAutopilotProposalTab = 'preview' | 'draft' | 'changes' | 'brief' | 'sources'export type ContentAutopilotWorkspaceTab = 'opportunities' | 'drafts'export type ContentAutopilotWorkspaceResource = 'profiles' | 'runs' | 'proposals'@@ -26,6 +27,14 @@ export type ContentAutopilotWorkspaceErrors = Partial<Record<ContentAutopilotWorexport type ContentAutopilotWorkspaceSettled = Record<ContentAutopilotWorkspaceResource, boolean>export type ContentAutopilotProfileDataSettled = Record<ContentAutopilotProfileResource, boolean>+const REVIEW_ORDER: Record<ContentAutopilotProposalListApi['lifecycle_status'], number> = {+ ready_for_review: 0,+ failed: 1,+ generating: 2,+ exported: 3,+ rejected: 4,+}+export interface ContentAutopilotProposalActionReasons {reject?: stringregenerate?: string@@ -143,14 +152,13 @@ export interface contentAutopilotLogicValues {draftDisabledReason: string | undefinedexportedProposal: ContentAutopilotExportResponseApi | nullexportedProposalLoading: boolean- newContentProposals: ContentAutopilotProposalListApi[]+ failedDraftCount: numberonboardingOpen: booleanonboardingStep: ContentAutopilotOnboardingStepopportunities: ContentAutopilotOpportunityApi[] | nullopportunitiesError: string | nullopportunitiesLoading: booleanopportunitySearch: string- pageImprovementProposals: ContentAutopilotProposalListApi[]profile: ContentAutopilotSiteProfileApi | nullprofileDataLoaded: booleanprofileDataSettled: ContentAutopilotProfileDataSettled@@ -165,6 +173,8 @@ export interface contentAutopilotLogicValues {proposals: ContentAutopilotProposalListApi[]proposalsLoading: booleanproposedMarkdown: string+ readyDraftCount: number+ reviewQueue: ContentAutopilotProposalListApi[]runMutation: ContentAutopilotRunApi | nullrunMutationLoading: booleanruns: ContentAutopilotRunApi[]@@ -540,10 +550,12 @@ export interface contentAutopilotLogicMeta {selectedProposal: ContentAutopilotProposalApi | null,proposedMarkdown: string) => boolean- newContentProposals: (siteProposals: ContentAutopilotProposalListApi[]) => ContentAutopilotProposalListApi[]- pageImprovementProposals: (+ reviewQueue: (siteProposals: ContentAutopilotProposalListApi[]) => ContentAutopilotProposalListApi[]+ readyDraftCount: (siteProposals: ContentAutopilotProposalListApi[]) => number+ failedDraftCount: (+ siteRuns: ContentAutopilotRunApi[],siteProposals: ContentAutopilotProposalListApi[]- ) => ContentAutopilotProposalListApi[]+ ) => numberworkspaceInitialized: (workspaceSettled: ContentAutopilotWorkspaceSettled) => booleanprofileDataLoaded: (profileDataSettled: ContentAutopilotProfileDataSettled) => booleanproposalActionReasons: (@@ -1031,15 +1043,22 @@ export const contentAutopilotLogic = kea<contentAutopilotLogicType>([(selectedProposal: ContentAutopilotProposalApi | null, proposedMarkdown: string): boolean =>selectedProposal !== null && proposedMarkdown !== selectedProposal.proposed_markdown,],- newContentProposals: [+ reviewQueue: [(selectors) => [selectors.siteProposals],(proposals: ContentAutopilotProposalListApi[]): ContentAutopilotProposalListApi[] =>- proposals.filter(({ proposal_type }) => proposal_type === 'new_content'),+ [...proposals].sort((a, b) => REVIEW_ORDER[a.lifecycle_status] - REVIEW_ORDER[b.lifecycle_status]),],- pageImprovementProposals: [+ readyDraftCount: [(selectors) => [selectors.siteProposals],- (proposals: ContentAutopilotProposalListApi[]): ContentAutopilotProposalListApi[] =>- proposals.filter(({ proposal_type }) => proposal_type === 'page_improvement'),+ (proposals: ContentAutopilotProposalListApi[]): number =>+ proposals.filter(({ lifecycle_status }) => lifecycle_status === 'ready_for_review').length,+ ],+ failedDraftCount: [+ (selectors) => [selectors.siteRuns, selectors.siteProposals],+ (runs: ContentAutopilotRunApi[], proposals: ContentAutopilotProposalListApi[]): number =>+ proposals.filter(+ ({ lifecycle_status, run_id }) => lifecycle_status === 'failed' && run_id === runs[0]?.id+ ).length,],workspaceInitialized: [(selectors) => [selectors.workspaceSettled],diff --git a/products/web_analytics/frontend/contentAutopilot/contentAutopilotStoryFixtures.ts b/products/web_analytics/frontend/contentAutopilot/contentAutopilotStoryFixtures.tsindex 8f55790d3f91..c3862cdeb09d 100644--- a/products/web_analytics/frontend/contentAutopilot/contentAutopilotStoryFixtures.ts+++ b/products/web_analytics/frontend/contentAutopilot/contentAutopilotStoryFixtures.ts@@ -71,7 +71,7 @@ export const EXAMPLE_PROPOSAL: ContentAutopilotProposalApi = {],},content_package: {- file_path: 'contents/docs/web-analytics.mdx',+ file_path: 'docs/web-analytics.md',title: 'Web analytics',description: 'Understand web traffic, behavior, and conversion with privacy-friendly analytics.',slug: 'web-analytics',