Satellite class pills carry their colour and count

Each satellite class chip in the Satellites row now shows the colour its
satellites draw in, its name and how many are loaded, in one pill. The
separate list of coloured counts under the chips is gone. A class that is
off shows only its name, as a plain chip.

The class chips gain two optional fields, `swatch` and `count`, which
RailChips draws; the layer panel shortens the count as it does a row's
(10.7K). A class that is on with nothing loaded yet shows its colour
without a count.
This commit is contained in:
Sameh Khamis committed 2026-11-23 18:22:53 -08:00
1 parent fca2c81d86
commit d1ea26ab92
8 files changed
+189 -68

No files matched your search

+30 -36
View File
@@ -105,7 +105,7 @@ export function createControls({ state: layerState, services, parts, source }) {
};
}
/** Tell the manager to re-render this layer's row (chip state / legend counts). */
/** Tell the manager to re-render this layer's row (chip state and counts). */
function _notifyRowControls() {
try {
@@ -116,7 +116,7 @@ export function createControls({ state: layerState, services, parts, source }) {
}
/**
* Per-class tally for the row legend, cached against the catalog revision.
* Per-class tally for the row's class chips, cached against the catalog revision.
* Without the cache this scans ~10.7k entries in dense mode on every panel
* refresh, and any layer polling on the 1s stats timer refreshes the panel.
* @returns {Record<string, number>} Class key → count.
@@ -712,8 +712,10 @@ export function createControls({ state: layerState, services, parts, source }) {
/**
* Layer-row sub-controls (DataLayerManager row-controls contract): one
* toggle chip per satellite class (src/layers/satellites/classes.js), and a legend
* of the classes on screen so the point colours are learnable.
* toggle chip per satellite class (src/layers/satellites/classes.js). A
* class that is on carries its point colour (`swatch`) and, once any of
* it is loaded, its count, so the point colours are learnable; a class
* that is off carries only its name.
*
* Chips are stateless — each declares the params to apply and the manager
* owns the write, so the Space Missions snapshot/restore path (which drives
@@ -723,49 +725,41 @@ export function createControls({ state: layerState, services, parts, source }) {
* STARLINK is the dense catalog (chip id `catalog`) and reports the dense
* LOAD state, not the param: the param flips synchronously while the shell
* takes seconds to arrive and frequently 502s, so ACTIVE means "Starlink
* points are on screen" and nothing less. The legend tally is cached
* points are on screen" and nothing less. The class tally is cached
* against the catalog revision. While SATCAT is stale or unavailable the
* info line says the classes may lag (see `classEvidenceNotice`).
* @returns {{ chips: Array<object>, legend: Array<object>, info: string,
* infoTitle: string }} Row controls.
* @returns {{ chips: Array<object>, info: string, infoTitle: string }}
* Row controls.
*/
getRowControls() {
// A dependency owner (Space Missions) borrows this layer for TLE lookup
// with showPoints:false. Nothing is rendered, so a legend would describe an
// with showPoints:false. Nothing is rendered, so a count would describe an
// empty sky and a chip write would be silently reverted by that owner's
// restore. Surrender the row rather than lie about it.
if (!layerState._params.showPoints) return { chips: [], legend: [] };
if (!layerState._params.showPoints) return { chips: [] };
const classes = _classes();
const chips = SATELLITE_CLASS_IDS.map((id) =>
id === 'starlink'
? _starlinkChip()
: {
id: `class-${id}`,
label: t(SATELLITE_CLASS_DISPLAY[id].label),
active: classes[id] === true,
state: classes[id] === true ? 'active' : 'idle',
title: t(SATELLITE_CLASS_DISPLAY[id].blurb),
params: { classes: { [id]: classes[id] !== true } },
},
);
const counts = _classTally();
const legend = [];
for (const id of SATELLITE_CLASS_IDS) {
const shown =
const chips = SATELLITE_CLASS_IDS.map((id) => {
const chip =
id === 'starlink'
? layerState._params.catalog === 'dense'
: classes[id] === true;
if (!shown || !(counts[id] > 0)) continue;
legend.push({
klass: id,
label: t(SATELLITE_CLASS_DISPLAY[id].label),
color: SATELLITE_CLASS_DISPLAY[id].color,
blurb: t(SATELLITE_CLASS_DISPLAY[id].blurb),
count: counts[id],
});
}
return { chips, legend, ...classEvidenceNotice() };
? _starlinkChip()
: {
id: `class-${id}`,
label: t(SATELLITE_CLASS_DISPLAY[id].label),
active: classes[id] === true,
state: classes[id] === true ? 'active' : 'idle',
title: t(SATELLITE_CLASS_DISPLAY[id].blurb),
params: { classes: { [id]: classes[id] !== true } },
};
// The colour key and count ride on a class that is on; an off
// class is its name alone.
if (!chip.active) return chip;
chip.swatch = SATELLITE_CLASS_DISPLAY[id].color;
if (counts[id] > 0) chip.count = counts[id];
return chip;
});
return { chips, ...classEvidenceNotice() };
},
/**