Adapt settings client for DSH 0.2.0 configForms without breaking boot.

Soft-inject configForms/settingsScope and mark Config fields volatile so desktop 0.2.0 no longer waits forever on the removed settingsScope service.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-10-09 15:31:31 +08:00
parent 30d4df23fa
commit 9b8e873c18
8 changed files with 358 additions and 166 deletions

View file

@ -2629,9 +2629,7 @@ var zh = {
var LOCALE_NS = "settings.netxops";
var inject = [
"slots",
"locale",
"remote",
"settingsScope"
"locale"
];
function apply(ctx) {
ctx.effect(() => {
@ -2646,53 +2644,79 @@ function apply(ctx) {
};
}
}, "netxops: locales");
const card = new NetxopsCardController(ctx.settingsScope.bind({ namespace: NETXOPS_NS }), ctx);
const t = ctx.locale.bind(LOCALE_NS);
ctx.inject(["remote.credentials"], (credCtx) => {
card.setCredentialsAvailable(true);
credCtx.effect(() => {
const off = credCtx.remote.$on("credentials/reference-updated", (ref) => {
card.refreshCredential(String(ref));
});
return () => {
off();
card.setCredentialsAvailable(false);
};
}, "netxops: credential invalidations");
});
ctx.inject(["connection"], (connCtx) => {
const call = connCtx.connection?.rpc?.call?.bind(connCtx.connection.rpc);
if (typeof call !== "function") {
connCtx.logger.warn("netxops: connection.rpc.call unavailable — alarm status UI disabled");
let mounted = false;
const mountCard = (scope) => {
if (mounted)
return;
mounted = true;
const card = new NetxopsCardController(scope, ctx);
ctx.inject(["remote.credentials"], (credCtx) => {
card.setCredentialsAvailable(true);
credCtx.effect(() => {
const off = credCtx.remote.$on("credentials/reference-updated", (ref) => {
card.refreshCredential(String(ref));
});
return () => {
off();
card.setCredentialsAvailable(false);
};
}, "netxops: credential invalidations");
});
ctx.inject(["connection"], (connCtx) => {
const call = connCtx.connection?.rpc?.call?.bind(connCtx.connection.rpc);
if (typeof call !== "function") {
connCtx.logger.warn("netxops: connection.rpc.call unavailable — alarm status UI disabled");
return;
}
card.setAlarmPushRpc(call);
connCtx.effect(() => () => {
card.setAlarmPushRpc(undefined);
}, "netxops: clear alarm-push rpc");
});
const bindDirectoryPicker = (picker) => {
if (!picker || typeof picker.pick !== "function")
return;
card.setDirectoryPicker(picker);
};
bindDirectoryPicker(ctx.remote?.directoryPicker);
ctx.inject(["remote.directoryPicker"], (dpCtx) => {
const viaGet = typeof dpCtx.get === "function" ? dpCtx.get("remote.directoryPicker") : undefined;
const viaNested = dpCtx.remote?.directoryPicker;
bindDirectoryPicker(viaGet ?? viaNested);
dpCtx.effect(() => () => {
card.setDirectoryPicker(undefined);
}, "netxops: clear directory picker");
});
ctx.slots.inject("settings.section", () => ctx.slots.register({
name: "settings.section",
id: NETXOPS_NS,
order: 24,
label: () => t("title"),
locale: LOCALE_NS,
inject: () => card.inject()
}, NetxopsCard));
};
ctx.inject(["configForms"], (formsCtx) => {
const forms = formsCtx.configForms;
if (!forms || typeof forms.get !== "function") {
formsCtx.logger?.warn?.("netxops: configForms present but .get missing");
return;
}
card.setAlarmPushRpc(call);
connCtx.effect(() => () => {
card.setAlarmPushRpc(undefined);
}, "netxops: clear alarm-push rpc");
formsCtx.logger?.info?.("netxops: settings card via configForms");
mountCard(forms.get(NETXOPS_NS));
});
const bindDirectoryPicker = (picker) => {
if (!picker || typeof picker.pick !== "function")
ctx.inject(["settingsScope"], (scopeCtx) => {
const binder = scopeCtx.settingsScope;
if (!binder || typeof binder.bind !== "function") {
scopeCtx.logger?.warn?.("netxops: settingsScope present but .bind missing");
return;
card.setDirectoryPicker(picker);
};
bindDirectoryPicker(ctx.remote?.directoryPicker);
ctx.inject(["remote.directoryPicker"], (dpCtx) => {
const viaGet = typeof dpCtx.get === "function" ? dpCtx.get("remote.directoryPicker") : undefined;
const viaNested = dpCtx.remote?.directoryPicker;
bindDirectoryPicker(viaGet ?? viaNested);
dpCtx.effect(() => () => {
card.setDirectoryPicker(undefined);
}, "netxops: clear directory picker");
}
if (mounted)
return;
scopeCtx.logger?.info?.("netxops: settings card via settingsScope");
mountCard(binder.bind({ namespace: NETXOPS_NS }));
});
ctx.slots.inject("settings.section", () => ctx.slots.register({
name: "settings.section",
id: NETXOPS_NS,
order: 24,
label: () => t("title"),
locale: LOCALE_NS,
inject: () => card.inject()
}, NetxopsCard));
}
return module.exports;