Quick Command shows the output right under the form (#5)
CI / Lint (eslint) (pull_request) Successful in 19s
CI / Test (jest) (pull_request) Successful in 30s
CI / Security (npm audit) (pull_request) Successful in 14s
CI / Integration (api) (pull_request) Successful in 2m35s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m52s
CI / UI (playwright) (pull_request) Successful in 2m31s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m35s

After Execute, each worker gets a card that says Running until its result
arrives, then shows the status (Completed, Failed (exit N), Timed out,
Killed), the duration, stdout, stderr in red, and a link to the full
record in Executions. Multi-worker runs get one card per worker.

- The result comes from the live command_result event; one that arrives
  before the POST returns is buffered. If the event is missed (e.g. the
  live connection dropped), the card polls the execution every 5 s.
- Each stream shows up to 100,000 characters, with a note pointing to
  Executions for the rest.
- The server's command_result broadcast now includes duration.
- [hidden] now always wins over component display rules: both worker
  pickers used to show in either mode because .lt-form-group sets
  display: flex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 15:27:28 -05:00
1 parent 156c311217
commit c01e3ead32
6 files changed
+195 -64

No files matched your search

+35
View File
@@ -83,3 +83,38 @@
color: var(--text-muted);
font-size: 0.85em;
}
/* Results under the form, one card per worker (#5). */
.qc-run-summary {
font-size: 0.75rem;
color: var(--text-secondary);
margin-bottom: 0.5rem;
}
.qc-run {
border: 1px solid var(--border-dim, var(--border-color));
background: var(--bg-primary);
padding: 0.6rem 0.75rem;
margin-bottom: 0.6rem;
min-width: 0;
}
.qc-run-head {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.4rem 0.75rem;
}
.qc-run-time { color: var(--text-muted); font-size: 0.75rem; }
.qc-run-link { margin-left: auto; font-size: 0.75rem; }
.qc-run-body pre {
max-height: 24rem;
overflow: auto;
white-space: pre-wrap;
overflow-wrap: anywhere;
margin: 0.5rem 0 0;
}
.qc-out-err {
color: var(--accent-red);
border-left-color: var(--accent-red);
text-shadow: none;
}
.qc-out-note { color: var(--text-muted); font-size: 0.72rem; margin-top: 0.4rem; }
+108 -56
View File
@@ -166,65 +166,117 @@
/* -------------------------------------------------------------------
Result rendering
------------------------------------------------------------------- */
function renderSingleSuccess(executionId) {
const wrap = document.getElementById('qc-result');
if (!wrap) return;
wrap.innerHTML =
'<div class="lt-alert lt-alert--success">' +
'<span class="lt-alert-icon">&#x2713;</span>' +
'<div class="lt-alert-body">' +
'<div class="lt-alert-title">Command sent successfully</div>' +
'<div class="lt-alert-msg">Execution ID: <code>' + esc(executionId) + '</code> | ' +
'<a href="/executions?open=' + encodeURIComponent(executionId) + '">view in Executions</a>' +
'</div>' +
'</div>' +
'</div>';
/* Results show here as they arrive, per worker, instead of only in Executions (#5).
A card per run: "running" until its command_result comes in over the live
connection, or a poll finds it finished if that event was missed. */
const OUTPUT_MAX = 100000; // characters shown per stream
const _runs = new Map(); // execution id -> { card, startedAt, timer }
const _early = new Map(); // results that beat the POST response
function forgetRuns() {
_runs.forEach(r => clearTimeout(r.timer));
_runs.clear();
}
function renderSingleFailure(message) {
function renderRuns(entries, summary) {
forgetRuns();
const wrap = document.getElementById('qc-result');
if (!wrap) return;
wrap.innerHTML =
'<div class="lt-alert lt-alert--error">' +
'<span class="lt-alert-icon">&#x2715;</span>' +
'<div class="lt-alert-body">' +
'<div class="lt-alert-title">Command failed</div>' +
'<div class="lt-alert-msg">' + esc(message) + '</div>' +
'</div>' +
'</div>';
const head = summary ? '<div class="qc-run-summary">' + esc(summary) + '</div>' : '';
wrap.innerHTML = head + entries.map(runCard).join('');
entries.forEach((e, i) => {
if (!e.executionId) return;
const run = { card: document.getElementById('qc-run-' + i), startedAt: Date.now(), timer: null };
_runs.set(e.executionId, run);
if (_early.has(e.executionId)) { showResult(e.executionId, _early.get(e.executionId)); return; }
run.timer = setTimeout(() => pollRun(e.executionId, 0), 5000);
});
}
function renderMultiResult(results, successCount, failCount) {
const wrap = document.getElementById('qc-result');
if (!wrap) return;
const rows = results.map(r =>
'<tr>' +
'<td data-label="Worker">' + esc(r.worker) + '</td>' +
'<td data-label="Result">' +
(r.success
? '<span class="lt-status lt-status-completed">&#x2713; Sent (' + esc(String(r.executionId || '').slice(0, 8)) + '&hellip;)</span>'
: '<span class="lt-status lt-status-failed">&#x2715; ' + esc(r.error) + '</span>') +
'</td>' +
'</tr>'
).join('');
wrap.innerHTML =
'<div class="lt-alert' + (failCount === 0 ? ' lt-alert--success' : (successCount === 0 ? ' lt-alert--error' : ' lt-alert--warning')) + '">' +
'<div class="lt-alert-body">' +
'<div class="lt-alert-title">Multi-worker execution complete</div>' +
'<div class="lt-alert-msg">Success: ' + successCount + ' &nbsp;|&nbsp; Failed: ' + failCount + '</div>' +
'</div>' +
'</div>' +
'<table class="lt-table lt-table-sm lt-table-responsive">' +
'<thead><tr><th>Worker</th><th>Result</th></tr></thead>' +
'<tbody>' + rows + '</tbody>' +
'</table>';
function runCard(e, i) {
const id = e.executionId;
const worker = esc(e.worker);
if (!id) {
return '<div class="qc-run" id="qc-run-' + i + '"><div class="qc-run-head">' +
'<strong class="qc-run-worker">' + worker + '</strong>' +
'<span class="lt-status lt-status-failed qc-run-status">&#x2715; Not sent</span></div>' +
'<div class="qc-run-body"><pre class="lt-log-output qc-out-err">' + esc(e.error || 'Failed to send') + '</pre></div></div>';
}
return '<div class="qc-run" id="qc-run-' + i + '"><div class="qc-run-head">' +
'<strong class="qc-run-worker">' + worker + '</strong>' +
'<span class="lt-status lt-status-running qc-run-status">Running&hellip;</span>' +
'<span class="qc-run-time"></span>' +
'<a class="qc-run-link" href="/executions?open=' + encodeURIComponent(id) + '">view in Executions</a></div>' +
'<div class="qc-run-body"></div></div>';
}
function clip(text) {
const t = String(text || '');
if (t.length <= OUTPUT_MAX) return esc(t);
return esc(t.slice(0, OUTPUT_MAX)) + '\n<span class="qc-out-note">[' + (t.length - OUTPUT_MAX).toLocaleString() +
' more characters: see the full output in Executions]</span>';
}
function failureLabel(r) {
if (r.timed_out) return 'Timed out';
if (r.signal) return 'Killed (' + r.signal + ')';
if (typeof r.exit_code === 'number') return 'Failed (exit ' + r.exit_code + ')';
return 'Failed';
}
function showResult(executionId, r) {
const run = _runs.get(executionId);
if (!run || !run.card) return;
clearTimeout(run.timer);
_runs.delete(executionId);
_early.delete(executionId);
const status = run.card.querySelector('.qc-run-status');
const ok = Boolean(r.success);
const label = ok ? 'Completed' : failureLabel(r);
status.className = 'lt-status qc-run-status ' + (ok ? 'lt-status-completed' : 'lt-status-failed');
status.textContent = (ok ? '\u2713 ' : '\u2715 ') + label;
const ms = typeof r.duration === 'number' ? r.duration : Date.now() - run.startedAt;
run.card.querySelector('.qc-run-time').textContent = ms < 1000 ? ms + ' ms' : (ms / 1000).toFixed(1) + ' s';
const parts = [];
if (r.stdout) parts.push('<pre class="lt-log-output qc-out">' + clip(r.stdout) + '</pre>');
if (r.stderr) parts.push('<pre class="lt-log-output qc-out-err">' + clip(r.stderr) + '</pre>');
if (!r.success && r.error && !r.stderr) parts.push('<pre class="lt-log-output qc-out-err">' + esc(r.error) + '</pre>');
if (!parts.length) parts.push('<div class="qc-out-note">No output</div>');
const body = run.card.querySelector('.qc-run-body');
body.innerHTML = parts.join('');
}
// Fallback for a result event that never arrived (e.g. the live connection dropped).
async function pollRun(executionId, tries) {
const run = _runs.get(executionId);
if (!run) return;
try {
const ex = await Pulse.api.get('/api/executions/' + encodeURIComponent(executionId));
if (ex && ex.status !== 'running') {
const logs = Array.isArray(ex.logs) ? ex.logs : [];
const r = logs.filter(l => l.action === 'command_result').pop();
showResult(executionId, r || { success: ex.status === 'completed', error: 'No result recorded (' + ex.status + ')' });
return;
}
} catch (e) { /* try again */ }
if (tries < 180 && _runs.has(executionId)) run.timer = setTimeout(() => pollRun(executionId, tries + 1), 5000);
}
function onCommandResult(data) {
if (!data || !data.execution_id) return false;
if (_runs.has(data.execution_id)) { showResult(data.execution_id, data); return true; }
// Can arrive before the POST that started it returns: keep it briefly.
_early.set(data.execution_id, data);
if (_early.size > 100) _early.delete(_early.keys().next().value);
return false;
}
function renderExecuting(count) {
forgetRuns();
const wrap = document.getElementById('qc-result');
if (!wrap) return;
wrap.innerHTML = '<div class="lt-empty-state lt-empty-state--sm"><div class="lt-empty-state-title">Executing' +
(count > 1 ? ' on ' + count + ' worker(s)' : '') + '&hellip;</div></div>';
wrap.innerHTML = '<div class="lt-empty-state lt-empty-state--sm"><div class="lt-empty-state-title">Sending' +
(count > 1 ? ' to ' + count + ' workers' : '') + '&hellip;</div></div>';
}
/* -------------------------------------------------------------------
@@ -253,10 +305,9 @@
try {
const data = await Pulse.api.post('/api/workers/' + encodeURIComponent(workerId) + '/command', { command });
addToHistory(command, workerName);
renderSingleSuccess(data && data.execution_id);
Pulse.beep('success');
renderRuns([{ worker: workerName, executionId: data && data.execution_id }]);
} catch (e) {
renderSingleFailure(e.message || 'Failed to execute command');
renderRuns([{ worker: workerName, error: e.message || 'Failed to execute command' }]);
Pulse.beep('error');
}
return;
@@ -283,10 +334,10 @@
const successCount = results.filter(r => r.success).length;
const failCount = results.length - successCount;
addToHistory(command, workerIds.length + ' workers');
renderMultiResult(results, successCount, failCount);
if (failCount === 0) Pulse.beep('success');
else if (successCount > 0) Pulse.beep('info');
else Pulse.beep('error');
renderRuns(results, failCount === 0
? 'Sent to ' + successCount + ' workers'
: 'Sent to ' + successCount + ' of ' + results.length + ' workers; ' + failCount + ' could not be reached');
if (failCount > 0) Pulse.beep(successCount > 0 ? 'info' : 'error');
}
/* -------------------------------------------------------------------
@@ -375,11 +426,12 @@
return loadWorkers().then(() => { consumeRerun(); });
}
function onEvent(type) {
function onEvent(type, data) {
if (type === 'worker_update') {
loadWorkers();
return true;
}
if (type === 'command_result') return onCommandResult(data);
return false;
}