From 080df9a3679cc6efdcce4ae56bab38a309577300 Mon Sep 17 00:00:00 2001 From: Saleh Mir Date: Mon, 8 Jun 2026 19:07:11 +0200 Subject: [PATCH] Fix MCP optimization sessions failing to load in the dashboard create_optimization_draft_service persisted an incomplete session results state ({alert} only). The dashboard's loadSession patches that state in and then reads results.progressbar.current / results.exception.error directly, so MCP-created sessions crashed with 'Failed to load session' (dashboard-run ones work because the store is pre-filled). Persist the COMPLETE results shape, matching dashboard-v1 optimizationStore.ts. Pairs with the dashboard-v1 guard PR (which also recovers already-saved broken sessions). The dashboard must be rebuilt into jesse/static at release. Co-Authored-By: Claude Opus 4.8 --- jesse/mcp/tools/services/optimization.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jesse/mcp/tools/services/optimization.py b/jesse/mcp/tools/services/optimization.py index 2e57cd22e..5131fafdd 100644 --- a/jesse/mcp/tools/services/optimization.py +++ b/jesse/mcp/tools/services/optimization.py @@ -259,9 +259,27 @@ def create_optimization_draft_service( 'warm_up_candles': int(warm_up_candles), } + # Persist the FULL results shape the dashboard's optimization store expects (see + # dashboard-v1 stores/optimizationStore.ts state()). The frontend's loadSession patches + # this state in and then reads nested objects directly (results.progressbar.current, + # results.exception.error); a partial shape here left those undefined and crashed + # "Failed to load session". Keep this in sync with the store's default results. state_dict = { 'form': form_data, 'results': { + 'showResults': False, + 'executing': False, + 'logsModal': False, + 'status': '', + 'progressbar': {'current': 0, 'estimated_remaining_seconds': 0}, + 'routes_info': [], + 'best_candidates': [], + 'metrics': [], + 'generalInfo': [], + 'selectedObjectiveMetric': '', + 'infoLogs': '', + 'info': [], + 'exception': {'error': '', 'traceback': ''}, 'alert': {'message': '', 'type': ''}, }, }