diff --git a/src/main/nodes/cockpit-snapshot/connection-summary.test.ts b/src/main/nodes/cockpit-snapshot/connection-summary.test.ts index a6545f1..b4ca4cc 100644 --- a/src/main/nodes/cockpit-snapshot/connection-summary.test.ts +++ b/src/main/nodes/cockpit-snapshot/connection-summary.test.ts @@ -200,3 +200,23 @@ describe('nodesSummary rows', () => { expect([s.rows, s.more, s.footer]).toEqual([[], 0, 'healthy nodes hidden']) }) }) + +describe('nodesSummary with no board of your cockpit (#160)', () => { + const panelNew = (nodeId: number) => node(nodeId, { source: 'new', identified: 'panel' }) + + it('points to the new boards on the bus — the Overview notice’s count — and where to add them', () => { + const one = summary([panelNew(41)]) + expect([one.known, one.newCount]).toEqual([0, 1]) + expect(one.empty).toBe('1 new board on the bus — add it from the Cockpit.') + const two = summary([panelNew(41), pdu(42, 'Left', { source: 'new', identified: 'pdu' })]) + expect(two.newCount).toBe(2) + expect(two.empty).toBe('2 new boards on the bus — add them from the Cockpit.') + }) + + it('says the bus reports nothing only when it does: none on it, or none identified yet', () => { + expect(summary([]).empty).toBe('No nodes reported. Power on a PanelGroup.') + // Still identifying: not news yet (isReportableNew), so not counted. + const s = summary([node(41, { source: 'new' })]) + expect([s.newCount, s.empty]).toEqual([0, 'No nodes reported. Power on a PanelGroup.']) + }) +}) diff --git a/src/main/nodes/cockpit-snapshot/summaries.ts b/src/main/nodes/cockpit-snapshot/summaries.ts index c135e74..8db0ef7 100644 --- a/src/main/nodes/cockpit-snapshot/summaries.ts +++ b/src/main/nodes/cockpit-snapshot/summaries.ts @@ -7,11 +7,14 @@ // adopted (node-model.ts newState), each one a board up and a warning, and an Attention item. // What is on the bus is one rule (node-model.ts onBusNow, X2): while the link is down the tile says // "no live node status", and the banner, the notice and Connected nodes say nothing. +// With none of your cockpit's boards to count, Connected nodes points to the new ones on the bus +// (#160): the same count as the Overview's notice and the Cockpit's "New on the bus". // A Connected nodes row names its board's resolved power zone (D7, the same one the Cockpit reads): // `PDU_Right`, `PDU_Right (hidden)`, else "no power zone". import { hhmmss, lastSeenLabel, plural } from '@shared/format' import { COCKPIT_IDLE, + NO_NODES, type AttentionItem, type AttentionSummary, type CockpitTile, @@ -139,6 +142,16 @@ export function overviewSummary( // ── Connection › Connected nodes ──────────────────────────────────────────── +/** + * The card's line with no board of your cockpit to count: the new boards on the bus and where to + * add them (#160) — `1 new board on the bus — add it from the Cockpit.` — else that the bus + * reports nothing. + */ +function emptyLine(newCount: number): string { + if (newCount === 0) return NO_NODES + return `${plural(newCount, 'new board')} on the bus — add ${newCount === 1 ? 'it' : 'them'} from the Cockpit.` +} + /** * Connected nodes: the counts and the rows that need attention, the Cockpit's strays included (X3: * each one a board up and a warning, with its Attention row). Quiet while the link is down — it @@ -157,6 +170,8 @@ export function nodesSummary( const byId = new Map(views.map((v) => [v.entry.nodeId, v.entry])) const items = attentionItems(views, outages, strays) const healthy = band.online - band.warn + // The Overview's notice's count (the Cockpit's "New on the bus · N"): one rule, isReportableNew. + const newCount = newDevices(views, live)?.count ?? 0 const rows = items.slice(0, ATTENTION_SHOWN).map((i): SummaryRow => { const e = byId.get(i.nodeId)! @@ -202,6 +217,8 @@ export function nodesSummary( watts: band.watts, rows, more, - footer + footer, + newCount, + empty: emptyLine(newCount) } } diff --git a/src/renderer/src/nodes/NodesCard.tsx b/src/renderer/src/nodes/NodesCard.tsx index 0743de6..e3b777e 100644 --- a/src/renderer/src/nodes/NodesCard.tsx +++ b/src/renderer/src/nodes/NodesCard.tsx @@ -25,7 +25,7 @@ export function NodesCard({ autoConnect }: { autoConnect: boolean }) { {!linkUp ? (