Updates
CI / test (push) Successful in 1m1s
Release rolling / release (push) Successful in 7m4s

This commit is contained in:
Raven Scott
2026-07-18 20:54:50 -04:00
parent d3edb56062
commit 66586d2181
2 changed files with 77 additions and 51 deletions
+29 -29
View File
@@ -115,6 +115,35 @@ try {
// ignore
}
/** @type {Record<string, object>} */
let chartCatalog = {}
let selectedCatalogChart = ''
let exploreChartId = settings.defaultExplore || 'system.io'
/** @type {Map<string, { severity: string, score: number, threshold: number|null, until: number }>} */
const anomalyByChart = new Map()
const ANOMALY_HOLD_MS = 60_000
let desktopNotifyReady = false
/** @type {Record<string, number[]>} */
const series = {
cpu: [],
cpuUser: [],
cpuSystem: [],
cpuIowait: [],
ram: [],
net: [],
netTx: [],
io: [],
ioWrite: [],
load: [],
explore: [],
detail: [],
}
/** Per-peer CPU series for compare mode @type {Map<string, number[]>} */
const peerCpu = new Map()
const metricsDashboard = createMetricsDashboard({
els: {
root: $('charts-view'),
@@ -168,35 +197,6 @@ const metricsDashboard = createMetricsDashboard({
getWeights: (args) => manager.request(Methods.getWeights, args || {}),
})
/** @type {Record<string, number[]>} */
const series = {
cpu: [],
cpuUser: [],
cpuSystem: [],
cpuIowait: [],
ram: [],
net: [],
netTx: [],
io: [],
ioWrite: [],
load: [],
explore: [],
detail: [],
}
/** Per-peer CPU series for compare mode @type {Map<string, number[]>} */
const peerCpu = new Map()
/** @type {Record<string, object>} */
let chartCatalog = {}
let selectedCatalogChart = ''
let exploreChartId = settings.defaultExplore || 'system.io'
/** @type {Map<string, { severity: string, score: number, threshold: number|null, until: number }>} */
const anomalyByChart = new Map()
const ANOMALY_HOLD_MS = 60_000
let desktopNotifyReady = false
function seriesMax() {
return Math.max(30, Math.min(300, Number(settings.chartPoints) || 90))
}
+47 -21
View File
@@ -99,35 +99,37 @@ function migrateLegacySettings() {
return null
}
export function loadSettings() {
const defaults = defaultSettings()
let fromFile = readSettingsFile(getSettingsCachePath())
if (!fromFile) {
fromFile = migrateLegacySettings()
if (fromFile) {
const merged = { ...defaults, ...fromFile }
saveSettings(merged)
return merged
}
}
function readLocalStorageMirror() {
try {
if (!fromFile && typeof localStorage !== 'undefined') {
if (typeof localStorage === 'undefined') return null
const mir = localStorage.getItem(SETTINGS_LOCALSTORAGE_KEY)
if (mir) fromFile = JSON.parse(mir)
}
if (!mir) return null
const parsed = JSON.parse(mir)
return parsed && typeof parsed === 'object' ? parsed : null
} catch {
// ignore
return null
}
}
/** Side-effect free merge of defaults + disk/legacy/LS. Never writes. */
function peekSettings() {
const defaults = defaultSettings()
const fromFile =
readSettingsFile(getSettingsCachePath()) ||
migrateLegacySettings() ||
readLocalStorageMirror()
return { ...defaults, ...(fromFile || {}) }
}
/** @param {Partial<UiSettings>} patch */
export function saveSettings(patch) {
const next = { ...loadSettings(), ...patch }
/**
* Persist settings envelope to disk + LS mirror. Does not call loadSettings.
* @param {UiSettings} settings
*/
function persistSettings(settings) {
const payload = {
version: SETTINGS_CACHE_VERSION,
updatedAt: new Date().toISOString(),
settings: next,
settings,
}
try {
atomicWriteJson(getSettingsCachePath(), payload)
@@ -136,15 +138,39 @@ export function saveSettings(patch) {
}
try {
if (typeof localStorage !== 'undefined') {
localStorage.setItem(SETTINGS_LOCALSTORAGE_KEY, JSON.stringify(next))
localStorage.setItem(SETTINGS_LOCALSTORAGE_KEY, JSON.stringify(settings))
localStorage.setItem(
'peardata-ui-boot',
JSON.stringify({ theme: next.theme })
JSON.stringify({ theme: settings.theme })
)
}
} catch {
// ignore
}
}
export function loadSettings() {
const defaults = defaultSettings()
const cached = readSettingsFile(getSettingsCachePath())
if (cached && typeof cached === 'object') {
return { ...defaults, ...cached }
}
const legacy = migrateLegacySettings()
if (legacy) {
const merged = { ...defaults, ...legacy }
persistSettings(merged)
return merged
}
const mir = readLocalStorageMirror()
return { ...defaults, ...(mir || {}) }
}
/** @param {Partial<UiSettings>} patch */
export function saveSettings(patch) {
const next = { ...peekSettings(), ...patch }
persistSettings(next)
return next
}