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>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 14:19:02 -05:00
1 parent 09a9d69102
commit 5d1cdf9da0
2 files changed
+54 -3

No files matched your search

+26 -3
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) {
@@ -230,6 +248,7 @@
}
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 });
@@ -248,6 +267,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) => {
@@ -310,7 +330,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,6 +368,9 @@
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(); });
}
+28
View File
@@ -80,3 +80,31 @@ 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(/2/);
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')).toContainText('Command sent successfully');
await page.reload();
await expect(page.locator('#qc-mode-single')).toBeChecked();
await expect(page.locator('#qc-worker option:checked')).toContainText('node-03');
});