diff --git a/apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx b/apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx index 5f8ba785..56ef87b1 100644 --- a/apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx +++ b/apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx @@ -36,6 +36,8 @@ export function BacktestDetailPageV2() { const [showFinding, setShowFinding] = useState(false); const [showArchiveDialog, setShowArchiveDialog] = useState(false); const [showCanonicalSetup, setShowCanonicalSetup] = useState(false); + // A visited editor owns drafts and captured dataset retries until this backtest changes. + const [settingsOwner, setSettingsOwner] = useState(null); const navigationGeneration = useRef(0); const { @@ -95,13 +97,18 @@ export function BacktestDetailPageV2() { navigationGeneration.current++; setShowNewRun(false); setShowArchiveDialog(false); - setShowCanonicalSetup(false); setShowFinding(false); return () => { navigationGeneration.current++; }; }, [id, runId]); + useEffect(() => { + setSettingsOwner(null); + setShowCanonicalSetup(false); + setActiveTab('runs'); + }, [id]); + useEffect(() => { if (id) { void loadBacktest(id); @@ -217,6 +224,44 @@ export function BacktestDetailPageV2() { [backtest] ); + const renderSettings = () => ( +
+ {catalog && backtest && (showCanonicalSetup || backtest.config.canonical) ? ( + updateBacktest(backtest.id, request)} + onClose={!backtest.config.canonical ? () => setShowCanonicalSetup(false) : undefined} + /> + ) : ( + <> + {catalog && ( +
+

+ This draft is not configured for canonical execution. Select an eligible retained + dataset and inspect the simulation policy before running. +

+ +
+ )} + + + )} +
+ ); + const renderTabContent = () => { if (['details', 'trades'].includes(activeTab)) { if (isLoading) { @@ -329,46 +374,6 @@ export function BacktestDetailPageV2() { /> ); - case 'settings': - return ( -
- {catalog && backtest && (showCanonicalSetup || backtest.config.canonical) ? ( - updateBacktest(backtest.id, request)} - onClose={ - !backtest.config.canonical ? () => setShowCanonicalSetup(false) : undefined - } - /> - ) : ( - <> - {catalog && ( -
-

- This draft is not configured for canonical execution. Select an eligible - retained dataset and inspect the simulation policy before running. -

- -
- )} - - - )} -
- ); case 'details': // Only render if we have matching results or no results yet if (runResults && currentRun && runResults.runId !== currentRun.id) { @@ -462,7 +467,12 @@ export function BacktestDetailPageV2() { {(currentRun ? runTabs : []).concat(baseTabs).map(tab => (