diff --git a/public/assets/pages/executions.css b/public/assets/pages/executions.css index 3164a9e..59bcd0f 100644 --- a/public/assets/pages/executions.css +++ b/public/assets/pages/executions.css @@ -250,3 +250,15 @@ html[data-theme="light"] .ex-cmp-head { background: var(--bg-secondary); } html[data-theme="light"] .ex-log-title { color: var(--text-primary); } html[data-theme="light"] .ex-diff-same { color: var(--text-muted); } html[data-theme="light"] .ex-row.is-selected td { background: rgba(255, 179, 0, 0.18); } + +/* Command executions in the list: `command @ worker` (#15). */ +.ex-row-cmd { + display: inline-block; + max-width: min(24rem, 100%); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + vertical-align: bottom; + color: var(--text-primary, inherit); +} +.ex-row-worker { color: var(--text-muted, inherit); white-space: nowrap; } diff --git a/public/assets/pages/executions.js b/public/assets/pages/executions.js index 87892a2..3ad229e 100644 --- a/public/assets/pages/executions.js +++ b/public/assets/pages/executions.js @@ -128,6 +128,13 @@ return '(' + st.total + ')'; } + // Workflows by name; commands as `command @ worker` instead of "[Quick Command]" (#15). + function nameCell(e) { + if (e.workflow_name || !e.command) return '' + esc(execName(e)) + ''; + return '' + esc(e.command) + '' + + (e.worker_name ? ' @ ' + esc(e.worker_name) + '' : ''); + } + // 'waiting' when a running execution is blocked on a prompt (#3). function displayStatus(e) { return e.status === 'running' && e.waiting_for_input ? 'waiting' : e.status; @@ -157,7 +164,7 @@ ' data-execution-id="' + esc(e.id) + '" tabindex="0">' + check + '' + esc(displayStatus(e)) + '' + - '' + esc(execName(e)) + '' + + '' + nameCell(e) + '' + '' + esc(e.started_by || '') + '' + '' + esc(Pulse.fmt.dateTime(e.started_at)) + '' + '' + completed + '' + diff --git a/server.js b/server.js index 5e86faa..eb7f889 100644 --- a/server.js +++ b/server.js @@ -1695,9 +1695,13 @@ app.get('/api/executions', authenticateSSO, async (req, res) => { const [rows] = await pool.query( `SELECT e.id, e.workflow_id, e.status, e.started_by, e.started_at, e.completed_at, - w.name as workflow_name + w.name as workflow_name, + -- What a command execution ran, and where (#15): its first log entry. + IF(e.workflow_id IS NULL, LEFT(JSON_UNQUOTE(JSON_EXTRACT(e.logs, '$[0].command')), 500), NULL) AS command, + IF(e.workflow_id IS NULL, wk.name, NULL) AS worker_name FROM executions e LEFT JOIN workflows w ON e.workflow_id = w.id + LEFT JOIN workers wk ON e.workflow_id IS NULL AND wk.id = JSON_UNQUOTE(JSON_EXTRACT(e.logs, '$[0].worker_id')) ${whereClause} ORDER BY e.started_at DESC LIMIT ? OFFSET ?`, [...queryParams, limit, offset] diff --git a/tests/integration/gandalf.int.js b/tests/integration/gandalf.int.js index f835fa9..5f115ef 100644 --- a/tests/integration/gandalf.int.js +++ b/tests/integration/gandalf.int.js @@ -76,3 +76,11 @@ test('execution search finds runs by the command they ran (#16)', async () => { expect(byId.executions.map(e => e.id)).toContain(submit.json.execution_id); expect((await sso('GET', '/api/executions?search=no-such-command-anywhere')).json.executions).toEqual([]); }); + +test('the execution list says what a command ran and where (#15)', async () => { + const marker = `sum-${Date.now().toString(36)}`; + const submit = await gandalf('POST', '/api/internal/command', { worker_id: workerId, command: `echo ${marker}` }); + await waitForExecution(submit.json.execution_id); + const row = (await sso('GET', `/api/executions?search=${marker}`)).json.executions[0]; + expect(row).toMatchObject({ command: `echo ${marker}`, worker_name: 'node-01' }); +}); diff --git a/tests/ui/quick-command.ui.js b/tests/ui/quick-command.ui.js index 30fd48a..1cd6e7e 100644 --- a/tests/ui/quick-command.ui.js +++ b/tests/ui/quick-command.ui.js @@ -21,6 +21,10 @@ test('a quick command runs on a worker and its output shows in Executions', asyn const detail = page.locator('#ex-detail-body'); await expect(detail).toContainText(marker); await expect(detail).toContainText(/completed/i); + + // The list row says what ran and where, not just "[Quick Command]" (#15). + await page.keyboard.press('Escape'); + await expect(page.locator('#ex-list-manual .ex-row').filter({ hasText: `echo ${marker}` }).first()).toContainText('@ node-02'); }); test('a failing command is reported as failed with its stderr', async ({ page }) => {