Files
Danny WhiteandJoshen Lim d1e251181f fix(studio): improve pipeline cost estimate loading and recovery (#52056)
## Problem

Pipeline review permits starting before the initial cost estimate
finishes. Estimate failures and background refresh errors also need to
preserve a usable review state.

## Solution

Share cost-query state between the wizard and cost display. Disable
**Start pipeline** only until the first estimate attempt finishes. After
its first failure, show a flush, description-only note and permit
starting while retries continue. Retain cached estimates if a background
refresh fails, and announce unavailable estimates through a persistent
status region.

_All “After” states for Review step:_

| Loading | Loaded | Failed |
| --- | --- | --- |
| <img width="1024" height="686" alt="31887"
src="https://github.com/user-attachments/assets/80b8623e-65ab-4bbb-8fcf-1e5e29a0dcd5"
/> | <img width="1024" height="686" alt="New Pipeline Supabase"
src="https://github.com/user-attachments/assets/ce49550c-d8cf-42b3-98f3-4520ae6b1229"
/> | <img width="1024" height="686" alt="62823"
src="https://github.com/user-attachments/assets/958b2bb3-e7ee-4214-b900-2e634adca05f"
/> |

## To test

1. Enable **Pipeline creation wizard** in Feature Previews and open
`/project/<ref>/database/pipelines/new`. Complete Connection and Data to
reach Review. With network throttling, **Start pipeline** stays disabled
during the initial estimate request; **Back** remains available.
2. Filter Network for `cost-estimate`. Block the GET ending
`/replication/<ref>/sources/<id>/publications/<name>/cost-estimate`,
then reload and complete the wizard again to clear the in-memory
estimate cache. After the first failed request, expect “A cost estimate
is unavailable. You can still start the pipeline.” in a full-width note,
and an enabled **Start pipeline**.
3. Remove the block and obtain an estimate. Block the request again, go
Back and return to Review. A failed background refresh should retain the
cached numbers and allow starting.
4. Check desktop and phone widths. Stop before creating the pipeline and
remove the request block.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-10-22 11:05:44 +11:00

37 lines
1.2 KiB
TypeScript

import type { Control } from 'react-hook-form'
import type { DestinationPanelSchemaType } from '../DestinationPanel/DestinationForm/DestinationForm.schema'
import { PipelineCostEstimate } from './PipelineCostEstimate'
import { usePipelineReviewCosts } from './usePipelineReviewCosts'
import type { ReplicationPublicationData } from '@/data/replication/publication-query'
export const PipelineReviewCosts = ({
control,
publication,
}: {
control: Control<DestinationPanelSchemaType>
publication?: ReplicationPublicationData
}) => {
const costs = usePipelineReviewCosts({ control, publication })
if (costs.status === 'missing-publication')
return (
<div className="p-5 text-sm text-foreground-light">
Select an available publication to estimate costs.
</div>
)
if (costs.status === 'missing-selection')
return (
<div className="p-5 text-sm text-foreground-light">
Complete the initial sync selection to estimate costs.
</div>
)
return (
<PipelineCostEstimate
estimate={costs.estimate}
isLoading={costs.isInitialCostEstimateLoading}
publicationTables={costs.publicationTables}
tableSyncCopy={costs.tableSyncCopy}
/>
)
}