fix(research): keep experiment choices after linked template failure (RP10)

This commit is contained in:
Boki 2026-10-27 13:37:48 -04:00
parent 49da701aa7
commit f0e7d07476
5 changed files with 230 additions and 8 deletions

View file

@ -30,13 +30,23 @@ export function useExperimentTemplates(initialBacktestId: string) {
if (!Array.isArray(rows)) {
throw new Error('The saved backtest list could not be read');
}
const selected =
initialBacktestId && !rows.some(item => item?.id === initialBacktestId)
? await backtestApiV2.getBacktest(initialBacktestId)
: null;
if (current) {
setMoreTemplates(rows.length === limit);
setBacktests((selected ? [...rows, selected] : rows).filter(canonical));
if (!current) {
return;
}
setMoreTemplates(rows.length === limit);
setBacktests(rows.filter(canonical));
if (initialBacktestId && !rows.some(item => item?.id === initialBacktestId)) {
// A missing linked template must not hide the successfully loaded catalog.
try {
const selected = await backtestApiV2.getBacktest(initialBacktestId);
if (current) {
setBacktests([...rows, selected].filter(canonical));
}
} catch (cause) {
if (current) {
setTemplateError(`Could not load the selected backtest: ${message(cause)}`);
}
}
}
})()
.catch(cause => {