Refactor of monster to use the platform infrastructure (BaseDomain, BaseNodeAdapter, ChildRouter, commandRegistry, statusBadge). Extracts concerns into focused modules per .claude/refactor/MODULE_SPLIT.md generic template. Tests stay green; CONTRACT.md generated; legacy aliases preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
// Status-badge composition. Three states the editor cares about:
|
|
// - red ring : config error (flow bounds invalid)
|
|
// - yellow ring: sampling but cooldown is gating the next pulse
|
|
// - green dot : sampling normally
|
|
// - grey ring : idle
|
|
// Shape mirrors the legacy nodeClass._updateNodeStatus output verbatim.
|
|
|
|
const { statusBadge } = require('generalFunctions');
|
|
const params = require('../parameters/parameters');
|
|
|
|
function buildStatusBadge(m) {
|
|
if (m.invalidFlowBounds) {
|
|
return statusBadge.error(`Config error: nominalFlowMin (${m.nominalFlowMin}) >= flowMax (${m.flowMax})`);
|
|
}
|
|
if (m.running) {
|
|
const levelText = `${m.bucketVol}/${m.maxVolume} L`;
|
|
const cooldownMs = params.getSampleCooldownMs(m);
|
|
if (cooldownMs > 0) {
|
|
return statusBadge.compose([`SAMPLING (${Math.ceil(cooldownMs / 1000)}s)`, levelText], { fill: 'yellow', shape: 'ring' });
|
|
}
|
|
return statusBadge.compose([`AI: RUNNING`, levelText], { fill: 'green', shape: 'dot' });
|
|
}
|
|
return statusBadge.idle('AI: IDLE');
|
|
}
|
|
|
|
module.exports = { buildStatusBadge };
|