Hot-reload capability public toggles via settings/document-updated (0.1.52).

Subscribe to live settings events so opening/closing publish-to-other-presets remounts host tools and skills immediately without restarting Desktop.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-10-10 16:36:42 +08:00
parent 6c9f323368
commit e2e65b0324
7 changed files with 49 additions and 21 deletions

View file

@ -203,7 +203,7 @@ function healNetxopsProfileEntries(logger) {
continue;
writeFileSync(patchPath, normalized, "utf8");
rewritten += 1;
logger.info("netxops: healed sparse host entry in profiles/%s/cordis.patch.yml (restart %s to load capability defaults)", profileName, profileName === "desktop" ? "Desktop" : "dsh web");
logger.info("netxops: healed sparse host entry in profiles/%s/cordis.patch.yml " + "(public toggles hot-reload via settings; restart %s only if tools still missing after heal)", profileName, profileName === "desktop" ? "Desktop" : "dsh web");
}
return rewritten;
}
@ -6042,18 +6042,32 @@ function installNetxopsSettings(ctx, entry, hooks) {
hooks.setSource(readLive);
hooks.onChange();
let lastFingerprint = JSON.stringify(readLive());
const timer = setInterval(() => {
const bumpIfChanged = (reason) => {
const next = readLive();
const fingerprint = JSON.stringify(next);
if (fingerprint === lastFingerprint)
return;
lastFingerprint = fingerprint;
settingsCtx.logger.info("netxops: live settings changed (%s) → republish connection", reason);
hooks.onChange();
}, 2000);
settingsCtx.effect(() => () => {
clearInterval(timer);
}, "netxops: settings describe poll");
settingsCtx.logger.info("netxops: following settings via describe() (no installSection — DSH ≥0.1.7 path)");
};
settingsCtx.effect(() => {
const onDocumentUpdated = (ns) => {
if (ns !== NETXOPS_SETTINGS_NAMESPACE && ns !== "dsh-netxops")
return;
bumpIfChanged("document-updated");
};
const off = settingsCtx.on("settings/document-updated", onDocumentUpdated);
const timer = setInterval(() => {
bumpIfChanged("poll");
}, 2000);
return () => {
clearInterval(timer);
if (typeof off === "function")
off();
};
}, "netxops: settings live follow");
settingsCtx.logger.info("netxops: hot-following settings (document-updated + describe poll)");
});
}
function apply(ctx, config = Config({})) {