Add abort execution feature for stuck/running processes

This commit is contained in:
2026-01-08 22:11:59 -05:00
parent 500163d3f8
commit 9fb9424cea
2 changed files with 73 additions and 0 deletions

View File

@@ -1780,6 +1780,11 @@
// Add action buttons
html += '<div style="margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--terminal-green); display: flex; gap: 10px;">';
// Abort button (only for running executions)
if (execution.status === 'running') {
html += `<button onclick="abortExecution('${executionId}')" style="background-color: var(--terminal-red); border-color: var(--terminal-red);">[ ⛔ Abort Execution ]</button>`;
}
// Re-run button (only for quick commands with command in logs)
const commandLog = execution.logs?.find(l => l.action === 'command_sent');
if (commandLog && commandLog.command) {
@@ -1899,6 +1904,18 @@
`;
}
if (log.action === 'execution_aborted') {
return `
<div class="log-entry" style="border-left-color: var(--terminal-red);">
<div class="log-timestamp">[${timestamp}]</div>
<div class="log-title" style="color: var(--terminal-red);">⛔ Execution Aborted</div>
<div class="log-details">
<div class="log-field"><span class="log-label">Aborted by:</span> ${escapeHtml(log.aborted_by)}</div>
</div>
</div>
`;
}
// Fallback for unknown log types
return `<div class="log-entry"><pre>${JSON.stringify(log, null, 2)}</pre></div>`;
}
@@ -1952,6 +1969,28 @@
document.getElementById('quickCommand').scrollIntoView({ behavior: 'smooth' });
}
async function abortExecution(executionId) {
if (!confirm('Are you sure you want to abort this execution? This will mark it as failed.')) return;
try {
const response = await fetch(`/api/executions/${executionId}/abort`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
if (response.ok) {
showTerminalNotification('Execution aborted', 'success');
closeModal('viewExecutionModal');
refreshData();
} else {
alert('Failed to abort execution');
}
} catch (error) {
console.error('Error aborting execution:', error);
alert('Error aborting execution');
}
}
async function downloadExecutionLogs(executionId) {
try {
const response = await fetch(`/api/executions/${executionId}`);