Fix set_flag blocks being dropped after trade_action
Bug: trade_order_generators.js set skipAdditionalParsing=true which caused json_base_generator.js to return early before processing <next> sibling blocks. This meant set_flag and other blocks connected after trade_action were silently dropped from the JSON. Fix: Removed the unnecessary skipAdditionalParsing flag. The code path it was meant to protect was already in an else branch, so the flag served no purpose and broke <next> block handling. Also includes minor fixes to Strategies.js and backtesting.js from earlier session work. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3976fc8366
commit
91f51cd71f
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue