diff --git a/src/static/Strategies.js b/src/static/Strategies.js index 758271f..83ee5d4 100644 --- a/src/static/Strategies.js +++ b/src/static/Strategies.js @@ -1137,12 +1137,24 @@ class StratWorkspaceManager { this.workspace.clear(); Blockly.Xml.domToWorkspace(workspaceXml, this.workspace); } catch (error) { + // Save the failed XML for debugging + const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); + const debugKey = `failed_strategy_xml_${timestamp}`; + try { + localStorage.setItem(debugKey, workspaceXmlText); + console.error(`Failed XML saved to localStorage as "${debugKey}"`); + console.error('To retrieve: localStorage.getItem("' + debugKey + '")'); + } catch (e) { + // If localStorage fails, log to console + console.error('Failed workspace XML (copy for debugging):', workspaceXmlText); + } + if (error instanceof SyntaxError) { console.error('Syntax error in workspace XML:', error.message); - alert('There was a syntax error in the workspace data. Please check the data and try again.'); + alert('There was a syntax error in the workspace data. Please check the data and try again.\n\nDebug XML saved to localStorage as: ' + debugKey); } else { console.error('Unexpected error restoring workspace:', error); - alert('An unexpected error occurred while restoring the workspace.'); + alert('An unexpected error occurred while restoring the workspace.\n\nDebug XML saved to localStorage as: ' + debugKey); } } } diff --git a/src/static/backtesting.js b/src/static/backtesting.js index 4aff9a1..81a5028 100644 --- a/src/static/backtesting.js +++ b/src/static/backtesting.js @@ -514,6 +514,12 @@ class Backtesting { this.setText(this.backtestDraggableHeader, "Create New Backtest"); this.clearForm(); + // Auto-select first strategy AFTER clearForm() to avoid being reset + const strategies = this.getAvailableStrategies(); + if (strategies && strategies.length > 0) { + this.strategyDropdown.value = strategies[0].tbl_key; + } + // Set default start_date to 1 hour ago const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000); // Current time minus 1 hour const formattedDate = this.formatDateToLocalInput(oneHourAgo); diff --git a/src/static/blocks/generators/trade_order_generators.js b/src/static/blocks/generators/trade_order_generators.js index 110d846..a37af62 100644 --- a/src/static/blocks/generators/trade_order_generators.js +++ b/src/static/blocks/generators/trade_order_generators.js @@ -78,9 +78,6 @@ export function defineTradeOrderGenerators() { } } - // **Set the skipAdditionalParsing flag** - json.skipAdditionalParsing = true; - console.log(`Generated JSON for 'trade_action' block:`, json); return json; };