Compare commits

..
Author SHA1 Message Date
jared 7204c806df Merge pull request 'Readable command output: colours stripped, Copy / Wrap / Expand / .txt' (#83) from output-readability into main
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 25s
CI / Test (jest) (push) Successful in 26s
CI / Security (npm audit) (push) Successful in 14s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m44s
CI / Integration (api) (push) Successful in 3m22s
CI / UI (playwright) (push) Successful in 2m24s
CI / Deploy (push) Successful in 23s
CI / Deploy worker (push) Successful in 17s
CI / Notify (push) Successful in 4s
2026-11-23 16:18:44 -05:00
jaredandClaude Opus 5.5 ecc1b447be Readable command output: ANSI stripped, Copy / Wrap / Expand / .txt (#27)
CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 21s
CI / Security (npm audit) (pull_request) Successful in 15s
CI / Integration (api) (pull_request) Successful in 2m43s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m44s
CI / UI (playwright) (pull_request) Successful in 2m35s
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 1m54s
A shared output block (Pulse.output.render) now draws every command
output in Executions and Quick Command:
- ANSI escape codes (colours, cursor moves, titles, charset switches)
  are stripped, so systemctl, ls --color and docker read cleanly.
- Copy and .txt use the full, clean text; .txt downloads it as a file.
- Wrap turns long-line wrapping on or off for every block, remembered.
- Output over 25 lines starts at 24rem high with an Expand button.
- Over 100,000 characters, the display is cut with a notice saying how
  much is hidden; Copy and .txt still include all of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:10:52 -05:00
jared 64703482fd Merge pull request 'Fix a race in the cancel_command test' (#82) from fix-cancel-test-race into main
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 16s
CI / Test (jest) (push) Successful in 22s
CI / Security (npm audit) (push) Successful in 19s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m11s
CI / Integration (api) (push) Successful in 3m11s
CI / UI (playwright) (push) Successful in 2m36s
CI / Deploy (push) Successful in 17s
CI / Deploy worker (push) Successful in 10s
CI / Notify (push) Successful in 2s
2026-11-23 16:02:52 -05:00
jaredandClaude Opus 5.5 0412eeeb38 Fix a race in the cancel_command test
CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 19s
CI / Security (npm audit) (pull_request) Successful in 12s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 3m9s
CI / Integration (api) (pull_request) Successful in 4m1s
CI / UI screenshots (before/after) (pull_request) Successful in 11s
CI / UI (playwright) (pull_request) Successful in 2m38s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
The shell creates a redirect target before writing to it, so the test
could read an empty pid file, take pid 0, and decide the child was not
running. This failed the push run of #80's merge, so that commit was not
deployed. The command now writes the pid to a temporary file and renames
it into place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 15:54:53 -05:00
jared 33a3f7c0b9 Merge pull request 'Quick Command shows the output right under the form' (#81) from quick-inline-output into main
CI / UI screenshots (before/after) (push) Skipped
CI / Security (npm audit) (push) Successful in 33s
CI / Test (jest) (push) Failing after 35s
CI / Lint (eslint) (push) Canceled after 0s
CI / Integration (api) (push) Canceled after 1m56s
CI / Scan (secrets, workflows, shell) (push) Canceled after 1m55s
CI / UI (playwright) (push) Canceled after 0s
CI / Deploy (push) Canceled after 0s
CI / Deploy worker (push) Canceled after 0s
CI / Notify (push) Successful in 4s
2026-11-23 15:53:34 -05:00
jaredandClaude Opus 5.5 c01e3ead32 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>
2026-11-23 15:27:28 -05:00
jared 156c311217 Merge pull request 'Live updates keep the rows brought in with Load More' (#80) from keep-loaded-rows into main
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Failing after 46s
CI / Lint (eslint) (push) Successful in 49s
CI / Security (npm audit) (push) Successful in 37s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m35s
CI / Integration (api) (push) Successful in 3m43s
CI / UI (playwright) (push) Successful in 2m28s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Successful in 3s
2026-11-23 15:27:10 -05:00
jaredandClaude Opus 5.5 9f6b34b55a Live updates keep the rows brought in with Load More (#17)
CI / Lint (eslint) (pull_request) Successful in 18s
CI / Test (jest) (pull_request) Successful in 21s
CI / Security (npm audit) (pull_request) Successful in 11s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m8s
CI / Integration (api) (pull_request) Successful in 2m53s
CI / UI (playwright) (pull_request) Successful in 2m24s
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 2m57s
A live event reloaded only the first page of the Executions list, so
rows brought in with Load More vanished whenever Gandalf or anyone else
ran something. Live refreshes now fetch as many rows as are shown (up to
the server's 1000); search and filters still start from the first page.

The rest of #17 was already fixed: reloads are throttled (#10), each tab
keeps its own state, and selections survive a refresh. The new UI test
fails without this change (100 rows drop to 50).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 14:40:35 -05:00
jared e92fa42b4e Merge pull request 'Quick Command remembers the mode and workers' (#79) from quick-remember into main
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 22s
CI / Security (npm audit) (push) Successful in 17s
CI / Test (jest) (push) Successful in 23s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m14s
CI / Integration (api) (push) Successful in 3m43s
CI / UI (playwright) (push) Successful in 2m9s
CI / Deploy (push) Successful in 19s
CI / Deploy worker (push) Successful in 8s
CI / Notify (push) Successful in 3s
2026-11-23 14:33:57 -05:00
jaredandClaude Opus 5.5 5d1cdf9da0 Quick Command remembers the mode and workers (#31)
CI / Lint (eslint) (pull_request) Successful in 23s
CI / Test (jest) (pull_request) Successful in 23s
CI / Security (npm audit) (pull_request) Successful in 10s
CI / Integration (api) (pull_request) Successful in 2m40s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m51s
CI / UI (playwright) (pull_request) Successful in 4m32s
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 4m43s
The mode (single or multi), the single worker and the multi-worker
selection are saved in localStorage (pulse_qc_prefs): the mode when it
changes, the workers when a command is sent. A reload starts from that
choice instead of the first worker; a Re-run from Executions still
overrides it. The Ctrl+Enter hint and shortcut already existed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 14:19:02 -05:00
9 changed files with 427 additions and 75 deletions

No files matched your search

+38
View File
@@ -182,3 +182,41 @@ html[data-theme="light"] .pulse-dim { color: var(--text-muted); }
html[data-theme="light"] .pulse-running {
box-shadow: none;
}
/* The `hidden` attribute must win over component display rules such as
.lt-form-group { display: flex }, or hidden sections still show (both
Quick Command worker pickers were visible in either mode). */
[hidden] { display: none !important; }
/* Command output blocks (#27): toolbar above a wrapping, collapsible <pre>. */
.pl-out { margin-top: 0.4rem; min-width: 0; }
.pl-out-bar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 0.3rem;
}
.pl-out-label {
margin-right: auto;
font-size: 0.65rem;
letter-spacing: 0.05em;
text-transform: uppercase;
color: var(--text-muted);
}
.pl-out-btn { padding: 0.1rem 0.5rem; font-size: 0.62rem; }
.pl-out-pre {
margin: 0.3rem 0 0;
white-space: pre-wrap;
overflow-wrap: anywhere;
overflow: auto;
}
.pl-out-pre.is-nowrap { white-space: pre; overflow-wrap: normal; }
.pl-out-pre.is-tall { max-height: 24rem; }
.pl-out-pre.is-tall.is-expanded { max-height: none; }
.pl-out-err {
color: var(--accent-red);
border-left-color: var(--accent-red);
text-shadow: none;
}
.pl-out-note { margin-top: 0.3rem; font-size: 0.7rem; color: var(--text-muted); }
+84 -1
View File
@@ -163,6 +163,87 @@
}
}
/* -------------------------------------------------------------------
Command output blocks (#27): ANSI codes stripped, Copy / Wrap / Expand /
.txt controls, and a notice when the display is cut short. Copy and the
download always use the full text, which is kept here by block id.
------------------------------------------------------------------- */
const OUT_MAX = 100000; // characters drawn per block
const OUT_TALL_LINES = 25; // taller than this starts collapsed
const OUT_WRAP_KEY = 'pulse_output_wrap';
// CSI (colours, cursor moves), OSC (titles, links), charset switches (ESC ( B)
// and other two-byte escapes.
// eslint-disable-next-line no-control-regex -- matching ESC/BEL is the point
const ANSI_RE = /\u001b(?:\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\[[0-?]*[ -/]*[@-~]|[()*+][0-9A-Za-z]|[@-Z\\-_])/g;
const _outTexts = new Map();
let _outSeq = 0;
function stripAnsi(text) {
return String(text == null ? '' : text).replace(ANSI_RE, '');
}
function outButton(action, id, label, title) {
return '<button type="button" class="lt-btn lt-btn-ghost lt-btn-sm pl-out-btn" data-action="' + action +
'" data-out="' + id + '" title="' + title + '">' + label + '</button>';
}
/** HTML for one output block. opts: { err, label, name (download file name), cls } */
function renderOutput(text, opts) {
const o = opts || {};
const clean = stripAnsi(text);
const id = 'pl-out-' + (++_outSeq);
_outTexts.set(id, { text: clean, name: String(o.name || 'output').replace(/[^\w.-]+/g, '-') });
if (_outTexts.size > 500) _outTexts.delete(_outTexts.keys().next().value);
const shown = clean.length > OUT_MAX ? clean.slice(0, OUT_MAX) : clean;
const tall = shown.split('\n').length > OUT_TALL_LINES;
const cls = ['lt-log-output', 'pl-out-pre'];
if (o.err) cls.push('pl-out-err');
if (o.cls) cls.push(o.cls);
if (storage.get(OUT_WRAP_KEY, true) === false) cls.push('is-nowrap');
if (tall) cls.push('is-tall');
return '<div class="pl-out" id="' + id + '">' +
'<div class="pl-out-bar">' +
(o.label ? '<span class="pl-out-label">' + esc(o.label) + '</span>' : '') +
outButton('out:copy', id, 'Copy', 'Copy the full output') +
outButton('out:wrap', id, 'Wrap', 'Wrap long lines on or off') +
(tall ? outButton('out:expand', id, 'Expand', 'Show every line') : '') +
outButton('out:download', id, '.txt', 'Download as a text file') +
'</div>' +
'<pre class="' + cls.join(' ') + '">' + esc(shown) + '</pre>' +
(clean.length > OUT_MAX
? '<div class="pl-out-note">Showing the first ' + OUT_MAX.toLocaleString() + ' of ' +
clean.length.toLocaleString() + ' characters. Copy and .txt include all of it.</div>'
: '') +
'</div>';
}
function outEntry(el) {
return _outTexts.get(el.getAttribute('data-out')) || { text: '', name: 'output' };
}
const outputActions = {
'out:copy': async (el) => {
const ok = LT().clipboard ? await LT().clipboard.copy(outEntry(el).text) : false;
toastSafe(ok ? 'success' : 'error', ok ? 'Output copied' : 'Copy failed');
},
'out:wrap': () => {
const wrap = storage.get(OUT_WRAP_KEY, true) === false; // currently off: turn on
storage.set(OUT_WRAP_KEY, wrap);
document.querySelectorAll('.pl-out-pre').forEach(p => p.classList.toggle('is-nowrap', !wrap));
},
'out:expand': (el) => {
const block = document.getElementById(el.getAttribute('data-out'));
const pre = block && block.querySelector('.pl-out-pre');
if (!pre) return;
const open = pre.classList.toggle('is-expanded');
el.textContent = open ? 'Collapse' : 'Expand';
},
'out:download': (el) => {
const e = outEntry(el);
download(e.name + '.txt', e.text);
},
};
/* Verbatim localStorage keys: `commandHistory` and `pulse_executionView`
must keep working across the redesign, so NO prefix is applied. */
const storage = {
@@ -673,7 +754,8 @@
get beep() { return LT().beep; },
esc: esc,
fmt: fmt,
util: { download: download, storage: storage, throttle: throttle },
util: { download: download, storage: storage, throttle: throttle, stripAnsi: stripAnsi },
output: { render: renderOutput },
/** Escape hatch for pages that need to push a frame upstream. */
ws: { send(d) { return _wsHandle && _wsHandle.send ? _wsHandle.send(d) : false; }, get handle() { return _wsHandle; } },
@@ -691,6 +773,7 @@
'open-cmdpalette': () => { if (LT().cmdPalette) LT().cmdPalette.open(); },
'app:keys-help': openKeysHelp,
});
actions.registerAll(outputActions);
installDelegation();
+16 -8
View File
@@ -71,10 +71,13 @@
/* ------------------------------------------------------------------
Loading
------------------------------------------------------------------ */
async function loadView(view, append) {
// keepLoaded: a live refresh fetches as many rows as are already shown, so
// rows brought in with Load More don't vanish when an event arrives (#17).
async function loadView(view, append, keepLoaded) {
const st = state[view];
const offset = append ? st.offset : 0;
const params = new URLSearchParams({ limit: String(LIMIT), offset: String(offset) });
const limit = keepLoaded ? Math.min(Math.max(LIMIT, st.rows.length), 1000) : LIMIT;
const params = new URLSearchParams({ limit: String(limit), offset: String(offset) });
if (view === 'manual') params.set('hide_internal', 'true');
if (view === 'automated') params.set('only_internal', 'true'); // server-side (#4)
const term = searchTerm();
@@ -102,8 +105,12 @@
await loadView(state.view, false);
render();
}
// Live events trigger this; coalesce bursts into at most one reload per 2 s (#10).
const reloadCurrent = Pulse.util.throttle(reloadNow, 2000);
// Live events trigger this; coalesce bursts into at most one reload per 2 s (#10),
// keeping however many rows are loaded (#17).
const reloadCurrent = Pulse.util.throttle(async () => {
await loadView(state.view, false, true);
render();
}, 2000);
// Typing in the search box: search on the server once typing pauses (#16).
let searchTimer = null;
@@ -275,8 +282,9 @@
return '<div class="ex-log-field"><span class="ex-log-label">' + esc(label) + ':</span> ' + value + '</div>';
}
function out(text, isErr) {
return '<pre class="lt-log-output' + (isErr ? ' ex-log-output-err' : '') + '">' + esc(text) + '</pre>';
// Shared output block: ANSI stripped, Copy / Wrap / Expand / .txt (#27).
function out(text, isErr, name) {
return Pulse.output.render(text, { err: isErr, name: (name || 'pulse-output') + (isErr ? '-stderr' : '') });
}
function promptOptions(options, executionId) {
@@ -307,8 +315,8 @@
(ok ? '&#x2713;' : '&#x2717;') + ' Command Result',
field('Status', ok ? 'Success' : 'Failed') +
(log.duration ? field('Duration', esc(log.duration) + 'ms') : '') +
(log.stdout ? field('Output', out(log.stdout, false)) : '') +
(log.stderr ? field('Errors', out(log.stderr, true)) : '') +
(log.stdout ? field('Output', out(log.stdout, false, 'pulse-' + String(log.command_id || '').slice(0, 8))) : '') +
(log.stderr ? field('Errors', out(log.stderr, true, 'pulse-' + String(log.command_id || '').slice(0, 8))) : '') +
(log.error ? field('Error', esc(log.error)) : ''));
}
+28
View File
@@ -83,3 +83,31 @@
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-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; }
+127 -59
View File
@@ -48,6 +48,16 @@
/* -------------------------------------------------------------------
Worker select / checkbox list
------------------------------------------------------------------- */
/* Last mode and worker choice, kept across reloads (#31). */
const PREFS_KEY = 'pulse_qc_prefs';
function loadPrefs() {
const p = Pulse.util.storage.get(PREFS_KEY, null);
return p && typeof p === 'object' ? p : {};
}
function savePrefs(patch) {
Pulse.util.storage.set(PREFS_KEY, Object.assign(loadPrefs(), patch));
}
function currentMode() {
const checked = document.querySelector('input[name="qc-exec-mode"]:checked');
return checked ? checked.value : 'single';
@@ -99,10 +109,18 @@
return Array.from(document.querySelectorAll('input[name="qc-worker-cb"]:checked')).map(cb => cb.value);
}
let _restored = false;
async function loadWorkers() {
const select = document.getElementById('qc-worker');
const preserveSingle = select ? select.value : '';
const preserveMulti = new Set(selectedWorkerCheckboxIds());
let preserveSingle = select ? select.value : '';
let preserveMulti = new Set(selectedWorkerCheckboxIds());
if (!_restored) {
// First load: start from the saved choice rather than the first worker.
_restored = true;
const prefs = loadPrefs();
preserveSingle = prefs.worker || preserveSingle;
if (Array.isArray(prefs.workers)) preserveMulti = new Set(prefs.workers);
}
try {
_workers = await Pulse.api.get('/api/workers') || [];
} catch (e) {
@@ -148,65 +166,110 @@
/* -------------------------------------------------------------------
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 _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 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 = [];
const name = 'pulse-' + String(executionId).slice(0, 8);
if (r.stdout) parts.push(Pulse.output.render(r.stdout, { cls: 'qc-out', name: name }));
if (r.stderr) parts.push(Pulse.output.render(r.stderr, { err: true, cls: 'qc-out-err', name: name + '-stderr' }));
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>';
}
/* -------------------------------------------------------------------
@@ -230,14 +293,14 @@
}
const worker = _workers.find(w => w.id === workerId);
const workerName = worker ? worker.name : 'Unknown';
savePrefs({ mode: 'single', worker: workerId });
renderExecuting(1);
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;
@@ -248,6 +311,7 @@
Pulse.toast.error('Please select at least one worker');
return;
}
savePrefs({ mode: 'multi', workers: workerIds });
renderExecuting(workerIds.length);
// Send to every selected worker at once (#26); results keep the selection order.
const results = await Promise.all(workerIds.map(async (workerId) => {
@@ -263,10 +327,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');
}
/* -------------------------------------------------------------------
@@ -310,7 +374,7 @@
function init() {
Pulse.actions.registerAll({
'qc:mode': applyMode,
'qc:mode': () => { applyMode(); savePrefs({ mode: currentMode() }); },
'qc:templates-open': () => { renderTemplates(); if (window.lt && lt.modal) lt.modal.open('qc-templates-modal'); },
'qc:template-use': (el) => {
const idx = Number(el.getAttribute('data-index'));
@@ -348,15 +412,19 @@
lt.keys.on('ctrl+enter', () => { execute(); });
}
const saved = loadPrefs().mode;
const savedRadio = saved && document.querySelector('input[name="qc-exec-mode"][value="' + (saved === 'multi' ? 'multi' : 'single') + '"]');
if (savedRadio) savedRadio.checked = true;
applyMode();
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;
}
+1
View File
@@ -630,6 +630,7 @@ wss.on('connection', (ws, req) => {
stdout: stdout,
stderr: stderr,
...failure,
duration: duration,
is_automated: isAutomated,
});
+1
View File
@@ -89,6 +89,7 @@ test('empty states say what to do next (#33)', async ({ page }) => {
await page.keyboard.press('Escape');
await page.goto('/quick');
await page.locator('#qc-mode-multi').check(); // the checkbox list is the multi-worker picker
await expect(page.locator('#qc-worker-list').getByRole('link', { name: 'Workers' })).toHaveAttribute('href', '/workers');
await page.goto('/workflows');
+129 -6
View File
@@ -13,8 +13,11 @@ test('a quick command runs on a worker and its output shows in Executions', asyn
await page.locator('#qc-command').fill(`echo ${marker}`);
await page.locator('#qc-execute-btn').click();
// The output shows right under the form (#5), with a link to the full record.
const result = page.locator('#qc-result');
await expect(result).toContainText('Command sent successfully');
await expect(result.locator('.qc-run-status')).toHaveText(/Completed/);
await expect(result.locator('pre.qc-out')).toHaveText(marker);
await expect(result).toContainText('node-02');
await result.getByRole('link', { name: 'view in Executions' }).click();
await expect(page).toHaveURL(/\/executions/);
@@ -34,7 +37,10 @@ test('a failing command is reported as failed with its stderr', async ({ page })
await page.locator('#qc-command').fill(`echo ${marker} >&2; exit 3`);
await page.locator('#qc-command').press('Control+Enter'); // the documented shortcut
await page.locator('#qc-result').getByRole('link', { name: 'view in Executions' }).click();
const result = page.locator('#qc-result');
await expect(result.locator('.qc-run-status')).toHaveText(/Failed \(exit 3\)/);
await expect(result.locator('pre.qc-out-err')).toHaveText(marker);
await result.getByRole('link', { name: 'view in Executions' }).click();
const detail = page.locator('#ex-detail-body');
await expect(detail).toContainText(marker);
await expect(detail).toContainText(/failed/i);
@@ -44,13 +50,19 @@ test('multi-worker mode sends the command to every selected worker', async ({ pa
await page.goto('/quick');
await page.locator('label[for="qc-mode-multi"], #qc-mode-multi').first().click();
await page.getByRole('button', { name: /select all/i }).click();
await page.locator('#qc-command').fill(`echo ${token()}`);
await page.locator('#qc-command').fill('echo "$WORKER_NAME says hi"');
await page.locator('#qc-execute-btn').click();
// One card per worker, each with its own output (#5).
const result = page.locator('#qc-result');
await expect(result).toContainText('Success: 3');
await expect(result).toContainText('Failed: 0');
await expect(result.locator('tbody tr')).toHaveCount(3);
await expect(result).toContainText('Sent to 3 workers');
const runs = result.locator('.qc-run');
await expect(runs).toHaveCount(3);
for (const n of ['node-01', 'node-02', 'node-03']) {
const card = runs.filter({ hasText: n });
await expect(card.locator('.qc-run-status')).toHaveText(/Completed/);
await expect(card.locator('pre.qc-out')).toHaveText(`${n} says hi`);
}
});
test('Executions updates live when a command starts elsewhere', async ({ page, request }) => {
@@ -80,3 +92,114 @@ test('searching Executions finds a run by its command (#16)', async ({ page, req
await expect(rows).toHaveCount(1);
await expect(rows.first()).toHaveAttribute('data-execution-id', id);
});
test('Quick Command remembers the mode and workers after a reload (#31)', async ({ page }) => {
await page.goto('/quick');
await page.locator('#qc-mode-multi').check();
const boxes = page.locator('#qc-worker-list label');
await boxes.filter({ hasText: 'node-02' }).locator('input').check();
await boxes.filter({ hasText: 'node-03' }).locator('input').check();
await page.locator('#qc-command').fill('true');
await page.locator('#qc-execute-btn').click();
await expect(page.locator('#qc-result')).toContainText('Sent to 2 workers');
await page.reload();
await expect(page.locator('#qc-mode-multi')).toBeChecked();
await expect(boxes.filter({ hasText: 'node-02' }).locator('input')).toBeChecked();
await expect(boxes.filter({ hasText: 'node-03' }).locator('input')).toBeChecked();
await expect(boxes.filter({ hasText: 'node-01' }).locator('input')).not.toBeChecked();
// Single mode remembers its worker too.
await page.locator('#qc-mode-single').check();
const node3 = await page.locator('#qc-worker option', { hasText: 'node-03' }).getAttribute('value');
await page.locator('#qc-worker').selectOption(node3);
await page.locator('#qc-command').fill('true'); // the reload emptied it
await page.locator('#qc-execute-btn').click();
await expect(page.locator('#qc-result .qc-run-status')).toHaveText(/Completed/);
await page.reload();
await expect(page.locator('#qc-mode-single')).toBeChecked();
await expect(page.locator('#qc-worker option:checked')).toContainText('node-03');
});
test('a live update keeps the rows brought in with Load More (#17)', async ({ page, request }) => {
const workers = await (await request.get('/api/workers')).json();
const id = workers.find(w => w.name === 'node-01').id;
const send = () => request.post(`/api/workers/${id}/command`, { data: { command: 'true' } });
for (let i = 0; i < 60; i++) await send();
await page.goto('/executions');
const rows = page.locator('#ex-list-manual .ex-row');
await expect(rows).toHaveCount(50);
await page.getByRole('button', { name: 'Load More Executions' }).click();
await expect.poll(() => rows.count()).toBeGreaterThan(50);
const shown = await rows.count();
// A live event: the list refreshes with the new run on top, and still shows
// as many rows as before rather than dropping back to the first 50.
const marker = `live-${Date.now().toString(36)}`;
await request.post(`/api/workers/${id}/command`, { data: { command: `echo ${marker}` } });
await expect(rows.first()).toContainText(marker, { timeout: 10_000 });
await expect(rows).toHaveCount(shown);
});
test('the result still shows when the live update is missed (#5)', async ({ page }) => {
// No live connection at all: the page has to find the result by polling.
await page.routeWebSocket(/.*/, () => { /* never connects to the server */ });
const marker = token();
await page.goto('/quick');
await page.locator('#qc-worker').selectOption({ label: 'node-03 (online)' });
await page.locator('#qc-command').fill(`echo ${marker}`);
await page.locator('#qc-execute-btn').click();
const result = page.locator('#qc-result');
await expect(result.locator('.qc-run-status')).toHaveText(/Running/);
await expect(result.locator('pre.qc-out')).toHaveText(marker, { timeout: 15_000 });
await expect(result.locator('.qc-run-status')).toHaveText(/Completed/);
});
test('only the worker picker for the chosen mode is shown', async ({ page }) => {
await page.goto('/quick');
await page.locator('#qc-mode-single').check();
await expect(page.locator('#qc-single-mode')).toBeVisible();
await expect(page.locator('#qc-multi-mode')).toBeHidden();
await page.locator('#qc-mode-multi').check();
await expect(page.locator('#qc-multi-mode')).toBeVisible();
await expect(page.locator('#qc-single-mode')).toBeHidden();
});
test('output is readable: colours stripped, Copy / Wrap / Expand / .txt (#27)', async ({ page, context }) => {
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
await page.goto('/quick');
await page.locator('#qc-mode-single').check();
await page.locator('#qc-worker').selectOption({ label: 'node-01 (online)' });
await page.locator('#qc-command').fill(`printf '\\033[1;32mgreen\\033[0m plain\\n'; seq 1 40`);
await page.locator('#qc-execute-btn').click();
const block = page.locator('#qc-result .pl-out').first();
const pre = block.locator('pre');
await expect(pre).toContainText('green plain');
expect(await pre.textContent()).not.toContain('\u001b'); // no raw escape codes
// 41 lines: starts collapsed, Expand shows everything.
await expect(pre).toHaveClass(/is-tall/);
await block.getByRole('button', { name: 'Expand' }).click();
await expect(pre).toHaveClass(/is-expanded/);
await expect(block.getByRole('button', { name: 'Collapse' })).toBeVisible();
// Wrap toggles long-line wrapping, and the choice sticks.
await block.getByRole('button', { name: 'Wrap' }).click();
await expect(pre).toHaveClass(/is-nowrap/);
await block.getByRole('button', { name: 'Wrap' }).click();
await expect(pre).not.toHaveClass(/is-nowrap/);
// Copy gives the full, clean text.
await block.getByRole('button', { name: 'Copy' }).click();
const copied = await page.evaluate(() => navigator.clipboard.readText());
expect(copied.startsWith('green plain\n1\n2\n')).toBe(true);
expect(copied.trim().endsWith('40')).toBe(true);
// .txt downloads the same text.
const [dl] = await Promise.all([page.waitForEvent('download'), block.getByRole('button', { name: '.txt' }).click()]);
expect(dl.suggestedFilename()).toMatch(/^pulse-[0-9a-f]{8}\.txt$/);
expect(require('fs').readFileSync(await dl.path(), 'utf8')).toBe(copied);
});
+3 -1
View File
@@ -126,7 +126,9 @@ describe('cancel_command (#8)', () => {
test('cancelling stops the command and everything it started', async () => {
const w = makeWorker();
const pidFile = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'pulse-cancel-')), 'pid');
const pending = w.executeCommand({ command: `sleep 30 & echo $! > ${pidFile}; wait`, execution_id: 'ex-c', command_id: 'cmd-c' });
// Write then rename: the shell creates a redirect target before writing to it,
// so reading ${pidFile} directly could see an empty file (pid 0).
const pending = w.executeCommand({ command: `sleep 30 & echo $! > ${pidFile}.tmp && mv ${pidFile}.tmp ${pidFile}; wait`, execution_id: 'ex-c', command_id: 'cmd-c' });
for (let i = 0; i < 50 && !fs.existsSync(pidFile); i++) await new Promise(r => setTimeout(r, 50));
const childPid = Number(fs.readFileSync(pidFile, 'utf8'));
expect(alive(childPid)).toBe(true);