Fix quick command executions not appearing in execution tab
Changes: - Create execution record in database when quick command is sent - Store initial log entry with command details - Broadcast execution_started event to update UI - Display quick commands as "[Quick Command]" in execution list - Fix worker communication to properly track all executions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -810,18 +810,18 @@
|
|||||||
executions.slice(0, 5).map(e => `
|
executions.slice(0, 5).map(e => `
|
||||||
<div class="execution-item" onclick="viewExecution('${e.id}')">
|
<div class="execution-item" onclick="viewExecution('${e.id}')">
|
||||||
<span class="status ${e.status}">${e.status}</span>
|
<span class="status ${e.status}">${e.status}</span>
|
||||||
<strong>${e.workflow_name || 'Unknown Workflow'}</strong>
|
<strong>${e.workflow_name || '[Quick Command]'}</strong>
|
||||||
<div class="timestamp">by ${e.started_by} at ${new Date(e.started_at).toLocaleString()}</div>
|
<div class="timestamp">by ${e.started_by} at ${new Date(e.started_at).toLocaleString()}</div>
|
||||||
</div>
|
</div>
|
||||||
`).join('');
|
`).join('');
|
||||||
document.getElementById('dashExecutions').innerHTML = dashHtml;
|
document.getElementById('dashExecutions').innerHTML = dashHtml;
|
||||||
|
|
||||||
const fullHtml = executions.length === 0 ?
|
const fullHtml = executions.length === 0 ?
|
||||||
'<div class="empty">No executions yet</div>' :
|
'<div class="empty">No executions yet</div>' :
|
||||||
executions.map(e => `
|
executions.map(e => `
|
||||||
<div class="execution-item" onclick="viewExecution('${e.id}')">
|
<div class="execution-item" onclick="viewExecution('${e.id}')">
|
||||||
<span class="status ${e.status}">${e.status}</span>
|
<span class="status ${e.status}">${e.status}</span>
|
||||||
<strong>${e.workflow_name || 'Unknown Workflow'}</strong>
|
<strong>${e.workflow_name || '[Quick Command]'}</strong>
|
||||||
<div class="timestamp">
|
<div class="timestamp">
|
||||||
Started by ${e.started_by} at ${new Date(e.started_at).toLocaleString()}
|
Started by ${e.started_by} at ${new Date(e.started_at).toLocaleString()}
|
||||||
${e.completed_at ? ` • Completed at ${new Date(e.completed_at).toLocaleString()}` : ''}
|
${e.completed_at ? ` • Completed at ${new Date(e.completed_at).toLocaleString()}` : ''}
|
||||||
|
|||||||
18
server.js
18
server.js
@@ -765,13 +765,26 @@ app.post('/api/workers/:id/command', authenticateSSO, async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const { command } = req.body;
|
const { command } = req.body;
|
||||||
const executionId = generateUUID();
|
const executionId = generateUUID();
|
||||||
|
const workerId = req.params.id;
|
||||||
|
|
||||||
|
// Create execution record in database
|
||||||
|
await pool.query(
|
||||||
|
'INSERT INTO executions (id, workflow_id, status, started_by, started_at, logs) VALUES (?, ?, ?, ?, NOW(), ?)',
|
||||||
|
[executionId, null, 'running', req.user.username, JSON.stringify([{
|
||||||
|
step: 'quick_command',
|
||||||
|
action: 'command_sent',
|
||||||
|
worker_id: workerId,
|
||||||
|
command: command,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
}])]
|
||||||
|
);
|
||||||
|
|
||||||
// Send command via WebSocket
|
// Send command via WebSocket
|
||||||
const commandMessage = {
|
const commandMessage = {
|
||||||
type: 'execute_command',
|
type: 'execute_command',
|
||||||
execution_id: executionId,
|
execution_id: executionId,
|
||||||
command: command,
|
command: command,
|
||||||
worker_id: req.params.id,
|
worker_id: workerId,
|
||||||
timeout: 60000
|
timeout: 60000
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -781,6 +794,7 @@ app.post('/api/workers/:id/command', authenticateSSO, async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
broadcast({ type: 'execution_started', execution_id: executionId, workflow_id: null });
|
||||||
res.json({ success: true, execution_id: executionId });
|
res.json({ success: true, execution_id: executionId });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
|
|||||||
Reference in New Issue
Block a user