mirror of
https://github.com/actions/runner.git
synced 2026-01-23 04:51:23 +08:00
loa steps
This commit is contained in:
@@ -14,6 +14,9 @@ let replHistoryIndex = -1;
|
||||
let currentLayout = 'bottom'; // 'bottom' | 'sidebar'
|
||||
let currentStepElement = null; // Track current step for breakpoint indicator
|
||||
let stepsList = []; // Cached steps from DAP
|
||||
let cachedExportYaml = null; // Cached YAML for export after disconnect
|
||||
let cachedExportStats = null; // Cached stats for export modal
|
||||
let stepsWereLoaded = false; // Track if we ever successfully loaded steps
|
||||
let activeContextMenu = null; // Track open context menu
|
||||
let activeModal = null; // Track open modal
|
||||
|
||||
@@ -527,15 +530,20 @@ async function loadSteps() {
|
||||
try {
|
||||
const result = JSON.parse(response.result);
|
||||
if (result.Success && result.Result) {
|
||||
renderStepList(result.Result);
|
||||
// Result contains { steps, totalCount, completedCount, pendingCount }
|
||||
renderStepList(result.Result.steps);
|
||||
enableStepControls(true);
|
||||
stepsWereLoaded = true;
|
||||
|
||||
// Auto-cache export YAML for later use (after disconnect)
|
||||
await cacheExportYaml();
|
||||
return;
|
||||
}
|
||||
} catch (parseErr) {
|
||||
// Response might not be JSON, that's ok
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fallback: show empty state
|
||||
renderStepList([]);
|
||||
} catch (error) {
|
||||
@@ -547,6 +555,23 @@ async function loadSteps() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache export YAML for use after DAP disconnect
|
||||
*/
|
||||
async function cacheExportYaml() {
|
||||
try {
|
||||
const result = await sendStepCommand('step.export', { changesOnly: false, withComments: true });
|
||||
if (result.Success) {
|
||||
cachedExportYaml = result.Message || result.Result?.yaml || '';
|
||||
cachedExportStats = result.Result || {};
|
||||
console.log('[Content] Cached export YAML');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('[Content] Failed to cache export YAML:', error);
|
||||
// Silent failure - user can still try Export button manually
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable step manipulation controls
|
||||
*/
|
||||
@@ -556,8 +581,13 @@ function enableStepControls(enabled) {
|
||||
const addBtn = debuggerPane.querySelector('.dap-add-step-btn');
|
||||
const exportBtn = debuggerPane.querySelector('.dap-export-btn');
|
||||
|
||||
// Add button requires active connection
|
||||
if (addBtn) addBtn.disabled = !enabled;
|
||||
if (exportBtn) exportBtn.disabled = !enabled;
|
||||
|
||||
// Export button stays enabled if we have cached YAML (for use after disconnect)
|
||||
if (exportBtn) {
|
||||
exportBtn.disabled = !enabled && !cachedExportYaml;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1138,16 +1168,32 @@ async function handleEditStep(modal, stepIndex, isRun) {
|
||||
* Show Export modal
|
||||
*/
|
||||
async function showExportModal() {
|
||||
const result = await sendStepCommand('step.export', { changesOnly: false, withComments: true });
|
||||
let yaml, stats;
|
||||
|
||||
if (!result.Success) {
|
||||
appendOutput(`Failed to export: ${result.Message || result.Error}`, 'error');
|
||||
if (isConnected) {
|
||||
// Connected: fetch fresh export
|
||||
const result = await sendStepCommand('step.export', { changesOnly: false, withComments: true });
|
||||
|
||||
if (!result.Success) {
|
||||
appendOutput(`Failed to export: ${result.Message || result.Error}`, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
yaml = result.Message || result.Result?.yaml || '';
|
||||
stats = result.Result || {};
|
||||
|
||||
// Update cache with fresh data
|
||||
cachedExportYaml = yaml;
|
||||
cachedExportStats = stats;
|
||||
} else if (cachedExportYaml) {
|
||||
// Disconnected: use cached data
|
||||
yaml = cachedExportYaml;
|
||||
stats = cachedExportStats || {};
|
||||
} else {
|
||||
appendOutput('No export data available', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const yaml = result.Message || result.Result?.yaml || '';
|
||||
const stats = result.Result || {};
|
||||
|
||||
const content = `
|
||||
<div class="dap-export-stats mb-2 color-fg-muted">
|
||||
Total steps: ${stats.totalSteps || 0} |
|
||||
|
||||
Reference in New Issue
Block a user