mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
* feat(herdr): hide disabled rows and group In sync by source A source with many disabled skills buries the few rows that need attention, and a long In sync list gives no sense of where skills came from. - Disabled rows are hidden by default; "Show disabled · n" lists them again and the choice is kept. A disabled hook with pending changes stays visible because it still needs a sync. - In sync skills and agents can be grouped by their source repository (By source) or shown flat (List); a source with one row stays a plain row, and a filter opens every group. - Opened plugin and MCP rows show their source, version and targets instead of an empty detail area. * refactor(herdr): move the panel's logic out of main.js into testable modules The bugs fixed in #773, #774 and #775 sat in main.js code that imports Herdr, so node could not test it: the detached-job polling, the busy state, and perform's op chain. Only model.js's parsing had tests. Each concern now lives in a module that takes Herdr's functions as arguments, so herdr/tests runs it: - jobs.js runs skillshare: short reads as one exec, longer work detached and polled, with the sweep of old job folders and one JOB_MINUTES limit shared with SWEEP. - channel.js carries requests, notices and one lock per machine through shared values. The install dialog used to check only a global busy string and then run without the lock; it now takes that machine's lock. Holders refresh the lock before each command and an untouched lock expires after a minute, because a dialog's task ends without cleanup when it closes. - operations.js holds what each request runs and the conflict handling of a pull; perform only takes the lock and shows progress and the result. - loader.js reads the Resources data and the Machines cards, and runs status alongside the snapshots.
67 lines
2.5 KiB
JavaScript
67 lines
2.5 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { createChannel, BUSY } from "../skillshare/mods/skillshare/channel.js";
|
|
|
|
// A channel over an in-memory map, standing in for Herdr's shared values. One map shared by
|
|
// several channels is the panel and a dialog.
|
|
function channels(n = 1, start = 0) {
|
|
const store = new Map();
|
|
const clock = { t: start };
|
|
const make = () => createChannel({ get: (k) => store.get(k), set: (k, v) => store.set(k, v), now: () => clock.t });
|
|
return { store, clock, list: Array.from({ length: n }, make) };
|
|
}
|
|
|
|
test("the panel gets each request made after it listened, once", () => {
|
|
const { list: [panel, dialog] } = channels(2);
|
|
dialog.request({ op: "old" });
|
|
const next = panel.listen();
|
|
dialog.request({ op: "pull" });
|
|
assert.deepEqual([next()?.op, next()], ["pull", null]);
|
|
});
|
|
|
|
test("a dialog cannot claim a machine the panel is working on", () => {
|
|
const { list: [panel, dialog] } = channels(2);
|
|
panel.claim("mini", "Syncing global…");
|
|
assert.equal(dialog.claim("mini", "Installing…"), false);
|
|
});
|
|
|
|
test("other machines stay free while one is busy", () => {
|
|
const { list: [panel, dialog] } = channels(2);
|
|
panel.claim("mini", "Syncing global…");
|
|
assert.equal(dialog.claim(null, "Installing…"), true);
|
|
});
|
|
|
|
test("a released machine can be claimed again", () => {
|
|
const { list: [panel, dialog] } = channels(2);
|
|
panel.claim("mini", "Syncing global…");
|
|
panel.release("mini");
|
|
assert.equal(dialog.claim("mini", "Installing…"), true);
|
|
});
|
|
|
|
test("busy text lists what every machine is doing", () => {
|
|
const { list: [panel] } = channels();
|
|
panel.claim(null, "Pulling…");
|
|
panel.claim("mini", "Updating figlens…");
|
|
assert.equal(panel.busyText(), "Pulling… · Updating figlens…");
|
|
});
|
|
|
|
test("a lock whose holder went away stops blocking after a minute", () => {
|
|
const { clock, list: [dialog] } = channels();
|
|
dialog.claim("mini", "Installing figlens…");
|
|
clock.t += 61 * 1000;
|
|
assert.equal(dialog.busyAt("mini"), false);
|
|
});
|
|
|
|
test("a holder that keeps touching its lock keeps it through a long job", () => {
|
|
const { clock, list: [dialog, panel] } = channels(2);
|
|
dialog.claim("mini", "Installing figlens…");
|
|
for (let i = 0; i < 60; i++) { clock.t += 30 * 1000; dialog.touch("mini"); }
|
|
assert.equal(panel.claim("mini", "Syncing global…"), false);
|
|
});
|
|
|
|
test("a busy value left by an older panel reads as free", () => {
|
|
const { store, list: [panel] } = channels();
|
|
store.set(BUSY, "Syncing global…");
|
|
assert.equal(panel.claim(null, "Installing…"), true);
|
|
});
|