Merge origin/main into space-missions-fixes

Main's single click rule (the card or label on top takes the click, read
once per click through clickCard and isUnderOtherCard in
src/data/pickRegistry.js) covers a click on a Space Missions label: a
mission marker label is an interactive world-overlay entry, so the
host's hit test names it as the card on top for every other layer. The
per-layer label guards in CCTV, Drone Airspace, FIRMS, Ghost Maps, News,
Perimeters, Shipwrecks, Vessels, Wildlife Sightings, ALPR, Local ADS-B
and the cockpit orbital focus are dropped for main's versions.

The mission-label tests are kept on main's API: fakeInputUnderLabel now
also names the label as the card on top, and each test shows a click on
the label never acts on the card, camera, vessel, fire, reader, aircraft
or report under it, and leaves the selection as it is. A launches test
checks that a mission label is interactive and is the card on top for
every other layer. Docs, changelog and the dispatcher's `overlay` note
describe the merged behaviour.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 20:00:25 -08:00
commit 0e5c5e624c
146 files changed
+9734 -1157

No files matched your search

+4 -1
View File
@@ -76,7 +76,10 @@ export function createCards({
const height = canvas.clientHeight;
let ambientCount = 0;
for (const candidate of layerState._labelCandidates) {
// An application drawing the detections in place of the markers draws
// them unlabelled: only the selected fire's card shows then.
const candidates = layerState._standIn ? [] : layerState._labelCandidates;
for (const candidate of candidates) {
if (ambientCount >= MAX_AMBIENT_LABELS) break;
if (candidate.fire && candidate.fire === layerState._selectedFire)
continue;
+31 -2
View File
@@ -52,10 +52,12 @@ export function createLifecycle({
if (layerState._cells) layerState._cells.show = true;
// The GPU culls the far side each frame, so retained rows are right
// for wherever the camera went while the layer was off.
if (layerState._icons) layerState._icons.show = true;
if (layerState._icons) layerState._icons.show = !layerState._standIn;
overlayHost.setVisible(FIRMS_OVERLAY_SOURCE_ID, true);
// A filter can leave an old raster cached while the current set is empty.
layerState._heatImagery?.setShow(layerState._fires.length > 0);
layerState._heatImagery?.setShow(
layerState._fires.length > 0 && !layerState._standIn,
);
// The camera can have crossed the hand-off while the layer was off.
components.rendering.applyHandoffFade(true);
components.viewport.installLodWatcher();
@@ -68,6 +70,32 @@ export function createLifecycle({
await components.ingestion.loadHeatmap();
},
/**
* Let an application draw the detections in place of the layer's
* markers. While a stand-in is set, the glows, the heatmap and the
* ambient cards are hidden and everything else works as before: a click
* on a fire the stand-in draws (`standIn.hitTest(screenPosition)`, which
* answers a detection record from the same source, or null) selects it
* and moves the camera to it as a click on its marker does, the selected
* fire's card shows, and a click on empty space clears the selection.
* Its optional `focusRangeM(record)` gives how far, in metres, the camera
* stands from a fire it draws when moving to it, for fires drawn larger
* than a marker; without one, or for null, the usual fire framing holds.
* `null` brings the markers back. The selection is kept either way.
* @param {?{hitTest: (screenPosition: {x: number, y: number}) => ?Object, focusRangeM?: (record: Object) => ?number}} standIn
*/
setMarkerStandIn(standIn) {
layerState._standIn =
typeof standIn?.hitTest === 'function' ? standIn : null;
layerState._heatImagery?.setShow(
layerState._enabled &&
layerState._fires.length > 0 &&
!layerState._standIn,
);
components.rendering.applyHandoffFade(true);
components.cards.rebuildAmbientLabels();
},
disable() {
layerState.request?.abort();
layerState.request = null;
@@ -129,6 +157,7 @@ export function createLifecycle({
layerState._currentLodIndex = -1;
layerState._lastViewRect = null;
layerState._selectedFire = null;
layerState._standIn = null;
layerState._labelCandidates = [];
layerState._labelLodDistance = 0;
layerState._pickIndexById.clear();
+6 -3
View File
@@ -122,7 +122,7 @@ export function createRendering({
glowAlpha = alpha;
const set = layerState._icons;
if (!set) return;
set.show = layerState._enabled && heat < 1;
set.show = layerState._enabled && !layerState._standIn && heat < 1;
if (!changed || !drawnGlows.size) return;
const faded = [];
for (const drawn of drawnGlows.values()) {
@@ -273,7 +273,7 @@ export function createRendering({
// The map stack may have changed since the last render.
imagery.rehome();
ensureHeatRaster(now);
imagery.setShow(layerState._enabled);
imagery.setShow(layerState._enabled && !layerState._standIn);
}
/**
@@ -469,7 +469,10 @@ export function createRendering({
// Blended as one translucent pass, as its billboards were.
blend: 'translucent',
horizonCull: true,
show: layerState._enabled && !(layerState._handoffHeat >= 1),
show:
layerState._enabled &&
!layerState._standIn &&
!(layerState._handoffHeat >= 1),
drawOrder: spriteDrawOrder?.('firms') ?? 0,
});
// Columns of no rows put the set's host in the scene now, rather than
+56 -25
View File
@@ -13,7 +13,7 @@ export function createSelection({
config,
feed,
}) {
const { resolvePickId, isOwnedByOtherLayer } = services.picking;
const { resolvePickId, isOwnedByOtherLayer, clickCard } = services.picking;
const { requestWorldFocus } = services.focus;
const {
selectEntityContext,
@@ -21,7 +21,7 @@ export function createSelection({
getContextStore,
registerEntityContext,
} = services.context;
const { id, name, overlayHost } = config;
const { id, name } = config;
/**
* Install the LEFT_CLICK handler for fire selection (enable-time only,
@@ -34,33 +34,33 @@ export function createSelection({
if (layerState._clickSubscription || !layerState._viewer) return;
const input = inputFor(layerState._viewer);
layerState._clickSubscription = input.onClick((event) => {
const picked = event.topHit;
const fire = pickedFire(event.drawHit);
// The card or label painted on top takes the click, read once per
// click so every layer agrees: ours acts whatever is drawn under it;
// another layer's is that layer's click.
const top = clickCard?.(event) ?? null;
if (top) {
if (top.sourceId !== FIRMS_OVERLAY_SOURCE_ID) return;
const carded = layerState._fireByCardId.get(top.entryId);
if (carded) selectAndFocusFire(carded);
return;
}
const pickedId = resolvePickId(event.topHit ?? null);
// A pick that belongs to a sibling layer (an aircraft, a flight trail)
// is not "empty space": leave the selection alone.
const otherLayer = Boolean(pickedId && isOwnedByOtherLayer(id, pickedId));
// The stand-in is asked where markers are picked: the click corrected
// for the sensor style (`event.position`), and only when no sibling
// layer's item is on top, as a marker under that item would not be hit.
const fire = layerState._standIn
? otherLayer
? null
: standInFire(event.position ?? event.screenPosition)
: pickedFire(event.drawHit);
if (fire) {
selectAndFocusFire(fire);
return;
}
// A pick that belongs to a sibling layer (e.g. an aircraft) is not
// "empty space" — leave the selection alone and let that layer handle it.
if (picked) {
const pickedId = resolvePickId(picked);
if (pickedId && isOwnedByOtherLayer(id, pickedId)) return;
}
// A click a label painted over the cards took is not on a card.
const cardHit = event.overlay
? null
: overlayHost.hitTest?.(
event.screenPosition?.x,
event.screenPosition?.y,
{
sourceId: FIRMS_OVERLAY_SOURCE_ID,
},
);
if (cardHit) {
const carded = layerState._fireByCardId.get(cardHit.entryId);
if (carded) selectAndFocusFire(carded);
return;
}
if (otherLayer) return;
clearFireSelection();
});
}
@@ -74,11 +74,15 @@ export function createSelection({
function selectAndFocusFire(fire) {
selectFire(fire);
// A stand-in that draws the fire larger than a marker says how far the
// camera stands from it (`setMarkerStandIn`).
const rangeM = layerState._standIn?.focusRangeM?.(fire);
requestWorldFocus({
kind: 'fire',
id: fireDetectionKey(fire),
label: t('FIRE'),
position: components.model.firePosition(fire),
...(Number.isFinite(rangeM) && rangeM > 0 ? { rangeM } : {}),
});
}
@@ -96,6 +100,32 @@ export function createSelection({
return layerState._pickIndexById.get(hit.id) ?? null;
}
/** The shown detections by their key, for the shown set they were made from. */
let keyed = { fires: null, byKey: null };
/**
* Resolve a click to one of this layer's fire records through the
* application's stand-in for its markers (`setMarkerStandIn`), or null:
* the record its hit test answers, matched by its detection key to a fire
* the layer shows now (so one the filter hides is not selected).
* @param {?{x: number, y: number}} screenPosition - Where the user clicked.
* @returns {?Object} Fire record.
*/
function standInFire(screenPosition) {
if (!screenPosition) return null;
const record = layerState._standIn?.hitTest(screenPosition);
if (!record) return null;
if (keyed.fires !== layerState._fires)
keyed = {
fires: layerState._fires,
byKey: new Map(
layerState._fires.map((fire) => [fireDetectionKey(fire), fire]),
),
};
return keyed.byKey.get(fireDetectionKey(record)) ?? null;
}
/**
* Select a fire: show its detail label and mark it selected in the shared
* context store so voice "what's selected" resolves to it.
@@ -232,6 +262,7 @@ export function createSelection({
removeClickHandler,
selectAndFocusFire,
pickedFire,
standInFire,
selectFire,
clearFireSelection,
refreshContextRegistrations,
+15 -15
View File
@@ -1,15 +1,20 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { FIRMS_OVERLAY_SOURCE_ID } from '../../data/firmsLabels.js';
import { resolvePickId } from '../../data/pickRegistry.js';
import { clickCard, resolvePickId } from '../../data/pickRegistry.js';
import { fakeInputUnderLabel } from '../../input/testDoubles.mjs';
import { createSelection } from './selection.js';
/** The fire selection over a viewer whose clicks a label may take, with a
* fire's card under every click. */
/** The fire selection over a viewer whose clicks a Space Missions label may
* take, with a fire's card under every click. */
function selectionHarness(t) {
const viewer = { scene: { canvas: {}, pick: () => null } };
const fake = fakeInputUnderLabel(viewer);
const fake = fakeInputUnderLabel(viewer, {
beneath: () => ({
sourceId: FIRMS_OVERLAY_SOURCE_ID,
entryId: 'firms-card:1',
}),
});
t.after(() => fake.destroy());
const fire = { lat: 1, lon: 2, acqMs: 3, frp: 40, satellite: 'N' };
const focused = [];
@@ -25,7 +30,7 @@ function selectionHarness(t) {
const selection = createSelection({
layerState,
services: {
picking: { resolvePickId, isOwnedByOtherLayer: () => false },
picking: { resolvePickId, isOwnedByOtherLayer: () => false, clickCard },
focus: { requestWorldFocus: (request) => focused.push(request.kind) },
context: {
selectEntityContext() {},
@@ -45,12 +50,6 @@ function selectionHarness(t) {
config: {
id: 'firms',
name: 'Fires',
overlayHost: {
hitTest: (_x, _y, { sourceId }) =>
sourceId === FIRMS_OVERLAY_SOURCE_ID
? { entryId: 'firms-card:1' }
: null,
},
},
});
selection.installClickHandler();
@@ -58,7 +57,7 @@ function selectionHarness(t) {
return { fake, layerState, fire, focused, cleared };
}
test("a click a label painted over a fire's card takes never selects or focuses the fire", (t) => {
test("a click on a mission label over a fire's card never selects or focuses the fire", (t) => {
const h = selectionHarness(t);
h.fake.label.over = true;
h.fake.click();
@@ -66,15 +65,16 @@ test("a click a label painted over a fire's card takes never selects or focuses
assert.deepEqual(h.focused, [], 'the camera is not sent to the fire');
});
test('a click a label painted over the map takes lets go of the selected fire', (t) => {
test('a click on a mission label keeps the selected fire', (t) => {
const h = selectionHarness(t);
// Off the label, a click on the card selects and focuses its fire.
h.fake.click();
assert.equal(h.layerState._selectedFire, h.fire);
assert.deepEqual(h.focused, ['fire']);
// The label on top is its own click: the fire stays selected.
h.fake.label.over = true;
h.fake.click();
assert.equal(h.layerState._selectedFire, null);
assert.deepEqual(h.cleared, ['firms']);
assert.equal(h.layerState._selectedFire, h.fire);
assert.deepEqual(h.cleared, []);
assert.deepEqual(h.focused, ['fire']);
});
+8
View File
@@ -98,6 +98,14 @@ export function createFirmsState({ services, config }) {
layerState._selectedFire = null;
/**
* What an application draws in place of the markers (`setMarkerStandIn`):
* while set, the glows, heatmap and ambient cards are hidden and clicks
* resolve through its `hitTest`.
*/
layerState._standIn = null;
/** Priority-ordered label candidates from the last rebuild (detections or cells). */
layerState._labelCandidates = [];