aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/index-dock-model.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/index-dock-model.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/index-dock-model.js25
1 files changed, 20 insertions, 5 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/index-dock-model.js b/packages/meshbay-hub/src/meshbay_hub/static/index-dock-model.js
index bd4586b..ed81e7c 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/index-dock-model.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/index-dock-model.js
@@ -91,8 +91,9 @@ function loud(job, since, now) {
*
* `memory` is per group: when the current walk was first seen, whether its row
* has been shown (a burst that crossed the threshold stays up until it ends),
- * whether the operator hid it, and when it finished. Pure: same arguments, same
- * answer, so a render that runs twice does not flash anything twice.
+ * whether the operator hid it, which walk they paused, and when it finished.
+ * Pure: same arguments, same answer, so a render that runs twice does not flash
+ * anything twice.
*/
export function dockRows(jobs, memory, now) {
const next = {};
@@ -105,9 +106,12 @@ export function dockRows(jobs, memory, now) {
const since = prev.busy && prev.sig === sig ? prev.since : now;
const shown = Boolean(prev.busy && prev.shown) || loud(job, since, now);
const hidden = Boolean(prev.busy && prev.hidden);
- next[gid] = { busy: true, sig, since, shown, hidden, doneAt: 0 };
- if (shown && !hidden) rows.push({ ...job, state: 'running' });
- } else if (prev.busy && prev.shown && !prev.hidden) {
+ // The node takes a moment to stop, and may go on to the next root
+ // queued: only the walk that was paused stays off screen.
+ const paused = prev.busy && prev.pausedSig === sig ? sig : '';
+ next[gid] = { busy: true, sig, since, shown, hidden, pausedSig: paused, doneAt: 0 };
+ if (shown && !hidden && !paused) rows.push({ ...job, state: 'running' });
+ } else if (prev.busy && prev.shown && !prev.hidden && !prev.pausedSig) {
next[gid] = { busy: false, doneAt: now };
rows.push({ ...job, state: 'done' });
} else if (prev.doneAt && now - prev.doneAt < DONE_MS) {
@@ -124,3 +128,14 @@ export function hideRow(memory, groupId) {
if (!prev || !prev.busy) return memory;
return { ...memory, [groupId]: { ...prev, hidden: true } };
}
+
+/**
+ * The operator paused the walk this row shows. Its row goes at once rather than
+ * when the node's next report arrives, and no "finished" follows it — the root
+ * is not finished, it is paused, and its settings row says so.
+ */
+export function pauseRow(memory, groupId) {
+ const prev = memory[groupId];
+ if (!prev || !prev.busy) return memory;
+ return { ...memory, [groupId]: { ...prev, pausedSig: prev.sig } };
+}