Fix Netx Ops settings card visibility and restore package.json.

Register settings.section eagerly (like im-ops) with multi-namespace configForms candidates so Desktop Settings shows Netx Ops; package.json had been overwritten to @deepseek-ai/dsh-desktop which broke local-path installs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-10-09 18:03:09 +08:00
parent 5dcce3c749
commit 3861006c13
3 changed files with 199 additions and 82 deletions

View file

@ -2631,11 +2631,30 @@ var inject = [
"slots", "slots",
"locale" "locale"
]; ];
function entryIdOf(ctx) { function namespaceCandidates(ctx) {
const fiber = ctx.fiber?.entry; const fiber = ctx.fiber?.entry;
const raw = fiber?.options?.id ?? fiber?.id ?? ctx.name ?? NETXOPS_NS; const raw = [
const id = String(raw).replace(/^:/, "").trim(); fiber?.options?.id,
return id.length > 0 ? id : NETXOPS_NS; fiber?.id,
fiber?.options?.name,
ctx.name,
NETXOPS_NS,
"dsh-netxops"
];
const out = [];
for (const item of raw) {
if (typeof item !== "string" || !item.trim())
continue;
const id = item.replace(/^:/, "").trim();
if (!id || out.includes(id))
continue;
if (id === "dsh-netxops" && !out.includes(NETXOPS_NS))
out.push(NETXOPS_NS);
out.push(id);
}
if (!out.includes(NETXOPS_NS))
out.push(NETXOPS_NS);
return out;
} }
function apply(ctx) { function apply(ctx) {
ctx.effect(() => { ctx.effect(() => {
@ -2653,6 +2672,8 @@ function apply(ctx) {
const t = ctx.locale.bind(LOCALE_NS); const t = ctx.locale.bind(LOCALE_NS);
let card; let card;
let wiredExtras = false; let wiredExtras = false;
let sectionRegistered = false;
let pluginsItemId;
const ensureCard = (scope) => { const ensureCard = (scope) => {
if (card) if (card)
return card; return card;
@ -2664,8 +2685,10 @@ function apply(ctx) {
return card; return card;
}; };
const registerSection = (owner) => { const registerSection = (owner) => {
if (sectionRegistered)
return () => {};
try { try {
return ctx.slots.inject("settings.section", () => ctx.slots.register({ const off = ctx.slots.inject("settings.section", () => ctx.slots.register({
name: "settings.section", name: "settings.section",
id: NETXOPS_NS, id: NETXOPS_NS,
order: 24, order: 24,
@ -2673,14 +2696,21 @@ function apply(ctx) {
locale: LOCALE_NS, locale: LOCALE_NS,
inject: () => owner.inject() inject: () => owner.inject()
}, NetxopsCard)); }, NetxopsCard));
sectionRegistered = true;
return () => {
sectionRegistered = false;
off();
};
} catch (error) { } catch (error) {
ctx.logger?.warn?.("netxops: settings.section unavailable: %s", error); ctx.logger?.warn?.("netxops: settings.section unavailable: %s", error);
return () => {}; return () => {};
} }
}; };
const registerPluginsItem = (owner, id) => { const registerPluginsItem = (owner, id) => {
if (pluginsItemId === id)
return () => {};
try { try {
return ctx.slots.inject("plugins.item", () => ctx.slots.register({ const off = ctx.slots.inject("plugins.item", () => ctx.slots.register({
name: "plugins.item", name: "plugins.item",
id, id,
order: 24, order: 24,
@ -2688,47 +2718,72 @@ function apply(ctx) {
locale: LOCALE_NS, locale: LOCALE_NS,
inject: () => owner.inject() inject: () => owner.inject()
}, NetxopsCard)); }, NetxopsCard));
pluginsItemId = id;
return () => {
if (pluginsItemId === id)
pluginsItemId = undefined;
off();
};
} catch (error) { } catch (error) {
ctx.logger?.warn?.("netxops: plugins.item unavailable: %s", error); ctx.logger?.warn?.("netxops: plugins.item unavailable: %s", error);
return () => {}; return () => {};
} }
}; };
const mountUi = (owner, ns, opts) => {
const offs = [];
if (opts.section)
offs.push(registerSection(owner));
if (opts.pluginsItem)
offs.push(registerPluginsItem(owner, ns));
return () => {
for (const off of offs)
off();
};
};
const tryGetForm = (forms, candidates) => {
if (typeof forms.get !== "function")
return;
for (const ns of candidates) {
try {
const scope = forms.get(ns);
if (scope && typeof scope.getSnapshot === "function")
return { ns, scope };
} catch {}
}
return;
};
ctx.inject(["configForms"], (formsCtx) => { ctx.inject(["configForms"], (formsCtx) => {
const forms = formsCtx.configForms; const forms = formsCtx.configForms;
if (!forms) { if (!forms) {
formsCtx.logger?.warn?.("netxops: configForms inject fired but service missing"); formsCtx.logger?.warn?.("netxops: configForms inject fired but service missing");
return; return;
} }
const entryId = entryIdOf(formsCtx); const candidates = namespaceCandidates(formsCtx);
const ns = entryId || NETXOPS_NS; formsCtx.logger?.info?.("netxops: configForms candidates=%s", candidates.join(","));
if (typeof forms.whileServed === "function" && typeof forms.get === "function") { if (typeof forms.whileServed === "function") {
formsCtx.logger?.info?.("netxops: settings card via configForms.whileServed (%s)", ns); formsCtx.effect(() => forms.whileServed(candidates, (served) => {
formsCtx.effect(() => forms.whileServed([ns], (served) => { const ns = candidates.find((id) => served.has(id));
if (!served.has(ns)) if (!ns) {
formsCtx.logger?.warn?.("netxops: whileServed fired but none of %s are served (have=%s)", candidates.join(","), [...served].join(",") || "(empty)");
return () => {}; return () => {};
const owner = ensureCard(forms.get(ns)); }
const offItem = registerPluginsItem(owner, ns); const hit = tryGetForm(forms, [ns, ...candidates]);
const offSection = registerSection(owner); if (!hit) {
return () => { formsCtx.logger?.warn?.("netxops: served %s but configForms.get failed", ns);
offItem(); return () => {};
offSection(); }
}; formsCtx.logger?.info?.("netxops: settings via whileServed (%s)", hit.ns);
}), "netxops: plugins.item whileServed"); const owner = ensureCard(hit.scope);
return; return mountUi(owner, hit.ns, { section: true, pluginsItem: true });
}), "netxops: configForms whileServed");
} }
if (typeof forms.get === "function") { const immediate = tryGetForm(forms, candidates);
formsCtx.logger?.info?.("netxops: settings card via configForms.get (%s)", ns); if (immediate) {
const owner = ensureCard(forms.get(ns)); formsCtx.logger?.info?.("netxops: settings eager mount (%s)", immediate.ns);
formsCtx.effect(() => { const owner = ensureCard(immediate.scope);
const offItem = registerPluginsItem(owner, ns); formsCtx.effect(() => mountUi(owner, immediate.ns, { section: true, pluginsItem: true }), "netxops: configForms eager slots");
const offSection = registerSection(owner); } else if (typeof forms.whileServed !== "function") {
return () => { formsCtx.logger?.warn?.("netxops: configForms present but no get/whileServed match for %s", candidates.join(","));
offItem();
offSection();
};
}, "netxops: configForms slots");
} else {
formsCtx.logger?.warn?.("netxops: configForms present but .get missing");
} }
}); });
ctx.inject(["settingsScope"], (scopeCtx) => { ctx.inject(["settingsScope"], (scopeCtx) => {

View file

@ -1,6 +1,6 @@
{ {
"name": "dsh-netxops", "name": "dsh-netxops",
"version": "0.1.43", "version": "0.1.44",
"description": "DeepSeek Harness Netx Ops: ops/topology + IM delivery + session export + knowledge-base MANIFEST/_skills + localSkills", "description": "DeepSeek Harness Netx Ops: ops/topology + IM delivery + session export + knowledge-base MANIFEST/_skills + localSkills",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",

View file

@ -5,11 +5,11 @@
* Do NOT hard-inject `settingsScope`: DSH ≥0.1.7 / 0.2.0 removed it * Do NOT hard-inject `settingsScope`: DSH ≥0.1.7 / 0.2.0 removed it
* (`configForms` replaced it) and a hard wait kills web boot. * (`configForms` replaced it) and a hard wait kills web boot.
* *
* Surfaces (dual-stack): * Surfaces (dual-stack), matching working plugins like dsh-im-ops:
* - DSH ≤0.1.5: `settings.section` + `settingsScope.bind({ namespace })` * - Always register `settings.section` once a form scope is available
* - DSH ≥0.1.7 / 0.2.0: `plugins.item` via `configForms.whileServed` + * (Settings sidebar — what operators look for).
* `configForms.get(entryId)` (Plugins page). Also keep `settings.section` * - On ≥0.1.7 also register `plugins.item` via `configForms.whileServed`
* when that slot still exists so older shells keep a top-level nav entry. * (Plugins page companion card).
*/ */
import type { Context as ClientContext } from '@deepseek-ai/cordis' import type { Context as ClientContext } from '@deepseek-ai/cordis'
@ -40,20 +40,33 @@ export const inject = [
] ]
/** /**
* Bare Loader entry id for this client half. * Candidate form namespaces for this host row.
* DSH 0.2.0 configForms namespaces are entry ids (not package names); * cordis.patch.yml uses `id: netxops` / `name: dsh-netxops`; Desktop may
* fiber scope keys may be prefixed with `:`. * expose either the bare entry id or the package name.
*/ */
function entryIdOf(ctx: ClientContext): string { function namespaceCandidates(ctx: ClientContext): string[] {
const fiber = (ctx as { const fiber = (ctx as {
fiber?: { entry?: { options?: { id?: string }, id?: string } } fiber?: { entry?: { options?: { id?: string, name?: string }, id?: string } }
}).fiber?.entry }).fiber?.entry
const raw = fiber?.options?.id const raw = [
?? fiber?.id fiber?.options?.id,
?? (ctx as { name?: string }).name fiber?.id,
?? NETXOPS_NS fiber?.options?.name,
const id = String(raw).replace(/^:/, '').trim() (ctx as { name?: string }).name,
return id.length > 0 ? id : NETXOPS_NS NETXOPS_NS,
'dsh-netxops',
]
const out: string[] = []
for (const item of raw) {
if (typeof item !== 'string' || !item.trim()) continue
const id = item.replace(/^:/, '').trim()
if (!id || out.includes(id)) continue
// Bare package name is not a configForms namespace; keep entry ids.
if (id === 'dsh-netxops' && !out.includes(NETXOPS_NS)) out.push(NETXOPS_NS)
out.push(id)
}
if (!out.includes(NETXOPS_NS)) out.push(NETXOPS_NS)
return out
} }
type ConfigFormsLike = { type ConfigFormsLike = {
@ -85,6 +98,8 @@ export function apply(ctx: ClientContext): void {
const t = ctx.locale.bind(LOCALE_NS) as (key: NetxopsLocaleKey) => string const t = ctx.locale.bind(LOCALE_NS) as (key: NetxopsLocaleKey) => string
let card: NetxopsCardController | undefined let card: NetxopsCardController | undefined
let wiredExtras = false let wiredExtras = false
let sectionRegistered = false
let pluginsItemId: string | undefined
const ensureCard = (scope: SettingsFormScope<NetxopsSettings>): NetxopsCardController => { const ensureCard = (scope: SettingsFormScope<NetxopsSettings>): NetxopsCardController => {
if (card) return card if (card) return card
@ -96,9 +111,11 @@ export function apply(ctx: ClientContext): void {
return card return card
} }
/** Settings sidebar page — same surface im-ops uses (must not wait on whileServed alone). */
const registerSection = (owner: NetxopsCardController): (() => void) => { const registerSection = (owner: NetxopsCardController): (() => void) => {
if (sectionRegistered) return () => {}
try { try {
return ctx.slots.inject('settings.section', () => ctx.slots.register({ const off = ctx.slots.inject('settings.section', () => ctx.slots.register({
name: 'settings.section', name: 'settings.section',
id: NETXOPS_NS, id: NETXOPS_NS,
order: 24, order: 24,
@ -106,15 +123,22 @@ export function apply(ctx: ClientContext): void {
locale: LOCALE_NS, locale: LOCALE_NS,
inject: () => owner.inject(), inject: () => owner.inject(),
}, NetxopsCard)) }, NetxopsCard))
sectionRegistered = true
return () => {
sectionRegistered = false
off()
}
} catch (error) { } catch (error) {
ctx.logger?.warn?.('netxops: settings.section unavailable: %s', error) ctx.logger?.warn?.('netxops: settings.section unavailable: %s', error)
return () => {} return () => {}
} }
} }
/** Plugins-page companion card (DSH ≥0.1.7 / 0.2.0). */
const registerPluginsItem = (owner: NetxopsCardController, id: string): (() => void) => { const registerPluginsItem = (owner: NetxopsCardController, id: string): (() => void) => {
if (pluginsItemId === id) return () => {}
try { try {
return ctx.slots.inject('plugins.item', () => ctx.slots.register({ const off = ctx.slots.inject('plugins.item', () => ctx.slots.register({
name: 'plugins.item', name: 'plugins.item',
id, id,
order: 24, order: 24,
@ -122,51 +146,89 @@ export function apply(ctx: ClientContext): void {
locale: LOCALE_NS, locale: LOCALE_NS,
inject: () => owner.inject(), inject: () => owner.inject(),
}, NetxopsCard)) }, NetxopsCard))
pluginsItemId = id
return () => {
if (pluginsItemId === id) pluginsItemId = undefined
off()
}
} catch (error) { } catch (error) {
ctx.logger?.warn?.('netxops: plugins.item unavailable: %s', error) ctx.logger?.warn?.('netxops: plugins.item unavailable: %s', error)
return () => {} return () => {}
} }
} }
// DSH ≥0.1.7 / 0.2.0 — Plugins page via configForms.whileServed + get(entryId). const mountUi = (
owner: NetxopsCardController,
ns: string,
opts: { section: boolean, pluginsItem: boolean },
): (() => void) => {
const offs: Array<() => void> = []
if (opts.section) offs.push(registerSection(owner))
if (opts.pluginsItem) offs.push(registerPluginsItem(owner, ns))
return () => {
for (const off of offs) off()
}
}
const tryGetForm = (
forms: ConfigFormsLike,
candidates: readonly string[],
): { ns: string, scope: SettingsFormScope<NetxopsSettings> } | undefined => {
if (typeof forms.get !== 'function') return undefined
for (const ns of candidates) {
try {
const scope = forms.get(ns)
if (scope && typeof scope.getSnapshot === 'function') return { ns, scope }
} catch {
// wrong ns — try next
}
}
return undefined
}
// DSH ≥0.1.7 / 0.2.0 — configForms.
ctx.inject(['configForms'], (formsCtx) => { ctx.inject(['configForms'], (formsCtx) => {
const forms = (formsCtx as { configForms?: ConfigFormsLike }).configForms const forms = (formsCtx as { configForms?: ConfigFormsLike }).configForms
if (!forms) { if (!forms) {
formsCtx.logger?.warn?.('netxops: configForms inject fired but service missing') formsCtx.logger?.warn?.('netxops: configForms inject fired but service missing')
return return
} }
const entryId = entryIdOf(formsCtx) const candidates = namespaceCandidates(formsCtx)
const ns = entryId || NETXOPS_NS formsCtx.logger?.info?.('netxops: configForms candidates=%s', candidates.join(','))
if (typeof forms.whileServed === 'function' && typeof forms.get === 'function') { if (typeof forms.whileServed === 'function') {
formsCtx.logger?.info?.('netxops: settings card via configForms.whileServed (%s)', ns) formsCtx.effect(() => forms.whileServed!(candidates, (served) => {
formsCtx.effect(() => forms.whileServed!([ns], (served) => { const ns = candidates.find((id) => served.has(id))
if (!served.has(ns)) return () => {} if (!ns) {
const owner = ensureCard(forms.get!(ns)) formsCtx.logger?.warn?.(
const offItem = registerPluginsItem(owner, ns) 'netxops: whileServed fired but none of %s are served (have=%s)',
// Keep top-level section when the shell still projects it. candidates.join(','),
const offSection = registerSection(owner) [...served].join(',') || '(empty)',
return () => { )
offItem() return () => {}
offSection()
} }
}), 'netxops: plugins.item whileServed') const hit = tryGetForm(forms, [ns, ...candidates])
return if (!hit) {
formsCtx.logger?.warn?.('netxops: served %s but configForms.get failed', ns)
return () => {}
}
formsCtx.logger?.info?.('netxops: settings via whileServed (%s)', hit.ns)
const owner = ensureCard(hit.scope)
return mountUi(owner, hit.ns, { section: true, pluginsItem: true })
}), 'netxops: configForms whileServed')
} }
if (typeof forms.get === 'function') { // Eager fallback: do not leave Settings blank if whileServed is late/empty.
formsCtx.logger?.info?.('netxops: settings card via configForms.get (%s)', ns) const immediate = tryGetForm(forms, candidates)
const owner = ensureCard(forms.get(ns)) if (immediate) {
formsCtx.effect(() => { formsCtx.logger?.info?.('netxops: settings eager mount (%s)', immediate.ns)
const offItem = registerPluginsItem(owner, ns) const owner = ensureCard(immediate.scope)
const offSection = registerSection(owner) formsCtx.effect(
return () => { () => mountUi(owner, immediate.ns, { section: true, pluginsItem: true }),
offItem() 'netxops: configForms eager slots',
offSection() )
} } else if (typeof forms.whileServed !== 'function') {
}, 'netxops: configForms slots') formsCtx.logger?.warn?.('netxops: configForms present but no get/whileServed match for %s', candidates.join(','))
} else {
formsCtx.logger?.warn?.('netxops: configForms present but .get missing')
} }
}) })