feat(research): add workspace and evidence-linked finding UI
This commit is contained in:
parent
ee45257507
commit
e3bd708838
21 changed files with 4566 additions and 1379 deletions
|
|
@ -2,6 +2,7 @@ import { ArrowLeftIcon, PlusIcon } from '@heroicons/react/24/outline';
|
|||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||
import { isCanonicalRunResult } from '@stock-bot/stock-config/canonical-research';
|
||||
import { SaveFindingDialog } from '@/features/research/components/SaveFindingDialog';
|
||||
import {
|
||||
catalogExecutionReason,
|
||||
supportedLegacyStrategy,
|
||||
|
|
@ -34,6 +35,7 @@ export function BacktestDetailPageV2() {
|
|||
const navigate = useNavigate();
|
||||
const [activeTab, setActiveTab] = useState('details');
|
||||
const [showNewRun, setShowNewRun] = useState(false);
|
||||
const [showFinding, setShowFinding] = useState(false);
|
||||
const [showArchiveDialog, setShowArchiveDialog] = useState(false);
|
||||
const [showCanonicalSetup, setShowCanonicalSetup] = useState(false);
|
||||
const navigationGeneration = useRef(0);
|
||||
|
|
@ -62,6 +64,17 @@ export function BacktestDetailPageV2() {
|
|||
refreshRun,
|
||||
} = useBacktestV2();
|
||||
const archived = Boolean(backtest?.archivedAt);
|
||||
const findingResult =
|
||||
!isLoading &&
|
||||
currentRun?.status === 'completed' &&
|
||||
currentRun.id === runId &&
|
||||
currentRun.backtestId === id &&
|
||||
runResults?.status === 'completed' &&
|
||||
runResults.runId === runId &&
|
||||
runResults.backtestId === id &&
|
||||
backtest?.id === id
|
||||
? runResults
|
||||
: null;
|
||||
const catalog = Boolean(backtest?.strategyVersionId) || backtest?.strategy === 'catalog';
|
||||
const unsupportedLegacy = Boolean(
|
||||
backtest && !catalog && !supportedLegacyStrategy(backtest.strategy)
|
||||
|
|
@ -87,6 +100,7 @@ export function BacktestDetailPageV2() {
|
|||
setShowNewRun(false);
|
||||
setShowArchiveDialog(false);
|
||||
setShowCanonicalSetup(false);
|
||||
setShowFinding(false);
|
||||
return () => {
|
||||
navigationGeneration.current++;
|
||||
};
|
||||
|
|
@ -469,6 +483,21 @@ export function BacktestDetailPageV2() {
|
|||
</div>
|
||||
|
||||
{/* Run Controls */}
|
||||
{currentRun && (
|
||||
<button
|
||||
type="button"
|
||||
disabled={!findingResult}
|
||||
title={
|
||||
findingResult
|
||||
? 'Cite saved run measurements'
|
||||
: 'A completed run with available saved results is required'
|
||||
}
|
||||
onClick={() => setShowFinding(true)}
|
||||
className="px-3 py-2 text-sm text-primary-500 border border-border rounded-md disabled:opacity-50"
|
||||
>
|
||||
Save finding
|
||||
</button>
|
||||
)}
|
||||
{backtest && (
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -577,6 +606,13 @@ export function BacktestDetailPageV2() {
|
|||
{currentRun && <RunDataset dataset={currentRun.dataset} />}
|
||||
<div className="min-h-0 flex-1 overflow-y-auto">{renderTabContent()}</div>
|
||||
</div>
|
||||
{showFinding && findingResult && (
|
||||
<SaveFindingDialog
|
||||
key={findingResult.runId}
|
||||
result={findingResult}
|
||||
onClose={() => setShowFinding(false)}
|
||||
/>
|
||||
)}
|
||||
{showArchiveDialog && backtest && (
|
||||
<ArchiveBacktestDialog
|
||||
key={backtest.id}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue