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

@ -102,7 +102,7 @@ export const en: Record<NetxopsLocaleKey, string> = {
groupBizMonitor: 'bizMonitor',
groupKb: 'Knowledge skills',
groupInPreset: 'In Netx Ops preset',
groupPublic: 'Publish to other presets (auto-saves; new sessions)',
groupPublic: 'Publish to other presets (auto-saves; hot-reloads)',
kbRoot: 'Package root',
kbRootHint: 'Folder with MANIFEST.json (operator-subset v1.0). Browse auto-saves. Pack skills load from paths.skills/_skills and paths.localSkills when hasSkills.',
kbBrowse: 'Browse…',
@ -181,7 +181,7 @@ export const zh: Record<NetxopsLocaleKey, string> = {
groupBizMonitor: 'bizMonitor',
groupKb: '知识库技能',
groupInPreset: '在 Netx Ops 预设中启用',
groupPublic: '对其他预设公开(勾选后自动保存;新会话生效)',
groupPublic: '对其他预设公开(自动保存,即时挂载/卸载)',
kbRoot: '知识包根目录',
kbRootHint: '含 MANIFEST.json 的运营商子集包(v1.0)。浏览选目录后会自动保存;hasSkills 时加载 paths.skills/_skills 与 paths.localSkills。',
kbBrowse: '浏览…',

View file

@ -273,7 +273,9 @@ function installNetxopsSettings(
return
}
// DSH ≥0.1.7: profile Config projection — follow describe() for live values.
// DSH ≥0.1.7: profile Config projection — follow live fiber config.
// `settings/document-updated` fires right after configForms save → remount
// public tools/skills without restart (poll is a slow backup only).
const readLive = (): Config => {
const row = describeRows(settings.describe).find(item => item.ns === NETXOPS_SETTINGS_NAMESPACE)
if (row?.value !== null && typeof row?.value === 'object' && !Array.isArray(row.value)) {
@ -285,18 +287,29 @@ function installNetxopsSettings(
hooks.onChange()
let lastFingerprint = JSON.stringify(readLive())
const timer = setInterval(() => {
const bumpIfChanged = (reason: string): void => {
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()
}, 2_000)
settingsCtx.effect(() => () => {
clearInterval(timer)
}, 'netxops: settings describe poll')
}
settingsCtx.effect(() => {
const onDocumentUpdated = (ns: string): void => {
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') }, 2_000)
return () => {
clearInterval(timer)
if (typeof off === 'function') off()
}
}, 'netxops: settings live follow')
settingsCtx.logger.info(
'netxops: following settings via describe() (no installSection — DSH ≥0.1.7 path)',
'netxops: hot-following settings (document-updated + describe poll)',
)
})
}

View file

@ -194,7 +194,8 @@ export function healNetxopsProfileEntries(logger: Context['logger']): number {
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)',
'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',
)