fix(ui): always show Full Report link when runId exists in session history#150
fix(ui): always show Full Report link when runId exists in session history#150toanalien wants to merge 3 commits into
Conversation
…story Previously, when loading a session from history (e.g. in a new browser), the run_complete card was silently dropped if api.getRun() failed or returned non-report-worthy data. This caused the "Full Report" link to disappear for remote/cross-browser users while remaining visible in the original browser's in-memory cache. Now the card always renders when runId is present in message metadata, with metrics and equity curve as optional enrichments. Also improves the RunDetail error page with diagnostic hints and a back button.
|
Thanks for the fix — the root cause is real and the The regressionEvery assistant turn carries a # session/service.py
if attempt.run_dir:
reply_metadata["run_id"] = Path(attempt.run_dir).nameThere is no separate lightweight chat path — a plain conversational answer also gets a On The case worth preservingThe genuine bug is narrower: a run that is report-worthy but has no metrics in metadata (e.g. a Pine-only or equity-curve-only run). Metrics-bearing backtests already render from metadata alone (first branch, no Suggested fixOnly fall back to a bare card when let fetchedMetrics, fetchedCurve, runUnavailable = false;
try {
const runData = await api.getRun(runId);
if (isReportWorthyRun(runData)) {
fetchedMetrics = runData.metrics;
fetchedCurve = runData.equity_curve?.map(e => ({ time: e.time, equity: Number(e.equity) }));
} else {
// succeeded but not report-worthy (plain chat) -> no card
continue; // or skip the addMessage in the SSE path
}
} catch {
runUnavailable = true; // can't tell -> still show the link
}
// push run_complete card only when we have data OR the run couldn't be fetchedThis keeps the cross-browser fix (auth failure → |
…logic Address PR review: not every run_id is a backtest — plain chat turns also get a run_id. Now only show the Full Report card when getRun() confirms report-worthiness OR when the fetch fails (auth/network). Plain chat turns where getRun() succeeds but isReportWorthyRun is false correctly skip the card, avoiding spurious links.
Summary
loadSessionMessagesand SSE handler now always render therun_completecard whenrunIdexists in message metadata, even ifapi.getRun()fails (auth error, 404, network issue)Root Cause
When reloading a session from history, if
metricswas missing from message metadata, the code calledapi.getRun(runId)to fetch run data. If that call failed (common for remote/cross-browser access due to auth), the error was silently caught and the card was never added — so the "Full Report" link disappeared entirely. The original browser still showed it because the card was cached in Zustand's in-memory store from the live SSE session.Test plan
cd frontend && npx vite buildpasses