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

@@ -196,8 +196,9 @@ function harness(
},
setVisible: (id, value) => overlay.visible.set(id, value),
clearSource: (id) => overlay.entries.delete(id),
hitTest: (_x, _y, { sourceId }) =>
cardHit?.sourceId === sourceId ? cardHit : null,
// As the host does: unfiltered, the topmost entry.
hitTest: (_x, _y, { sourceId } = {}) =>
!sourceId || cardHit?.sourceId === sourceId ? cardHit : null,
},
input: () => ({
onClick(fn) {
@@ -220,6 +221,8 @@ function harness(
unregisterPickOwner: (id) => owners.delete(id),
resolvePickId: (pick) => pick?.id ?? pick?.primitive?.id,
isOwnedByOtherLayer: (_layerId, id) => id?.startsWith('other:'),
// The card on top at a click, as the registry answers from the host.
clickCard: () => cardHit,
},
sprites: { spriteDrawOrder: () => -9 },
render: { governorRequestRender: (reason) => renders.push(reason) },
+6 -14
View File
@@ -482,21 +482,13 @@ export function createSelection({ state, services, parts }) {
state.clickHandler = input.onClick((click) => {
if (!state.enabled || services.pointer?.isPointerFree?.() === false)
return;
const at = click.screenPosition;
// A click a label painted over the cards took is not on a card.
const hit =
!click.overlay &&
(overlay?.hitTest?.(at?.x, at?.y, {
sourceId: WILDLIFE_SELECTED_SOURCE_ID,
}) ||
overlay?.hitTest?.(at?.x, at?.y, {
sourceId: WILDLIFE_OVERLAY_SOURCE_ID,
}) ||
overlay?.hitTest?.(at?.x, at?.y, {
sourceId: WILDLIFE_LABEL_SOURCE_ID,
}));
// 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, so the sightings under it do
// not act and the selection stays.
const hit = services.picking?.clickCard?.(click) ?? null;
if (hit) {
hit.entry?.activate?.();
if (sourceIds.includes(hit.sourceId)) hit.entry?.activate?.();
return;
}
// A sighting icon's item id is its pick id, `wildlife:<stableId>`.
+65 -10
View File
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import { createSelection } from './selection.js';
import { bindWildlifeViewer } from '../../testSupport/wildlifeViewer.mjs';
import { clickCard } from '../../data/pickRegistry.js';
import { fakeInputUnderLabel } from '../../input/testDoubles.mjs';
const row = {
@@ -22,6 +23,7 @@ function fixture(sighting = row, extraServices = {}) {
const seen = [];
const painted = new Set();
let hit = null;
let coveringHit = null;
let projections = 0;
let click;
const state = {
@@ -43,16 +45,17 @@ function fixture(sighting = row, extraServices = {}) {
},
};
bindWildlifeViewer(state.viewer);
const overlayHost = {
setEntries: (id, value) => entries.set(id, value),
clearSource: (id) => entries.delete(id),
setVisible() {},
hitTest: (_x, _y, { sourceId } = {}) =>
sourceId ? (hit?.sourceId === sourceId ? hit : null) : coveringHit || hit,
};
const selection = createSelection({
state,
services: {
overlayHost: {
setEntries: (id, value) => entries.set(id, value),
clearSource: (id) => entries.delete(id),
setVisible() {},
hitTest: (_x, _y, { sourceId }) =>
hit?.sourceId === sourceId ? hit : null,
},
overlayHost,
now: () => row.observedAt + 60_000,
project: (_scene, anchor) => {
projections++;
@@ -67,6 +70,14 @@ function fixture(sighting = row, extraServices = {}) {
}),
eventTarget: new EventTarget(),
...extraServices,
// The card on top at a click, as the registry answers from the host;
// a mission label painted over everything comes first.
picking: {
clickCard: (c) =>
clickCard(c) ??
overlayHost.hitTest(c.screenPosition?.x, c.screenPosition?.y),
...extraServices.picking,
},
},
parts: {
rendering: {
@@ -95,6 +106,9 @@ function fixture(sighting = row, extraServices = {}) {
?.find((entry) => entry.id === entryId);
hit = entry ? { sourceId, entryId, entry } : null;
},
cover(value) {
coveringHit = value;
},
paint(ids) {
painted.clear();
for (const id of ids) painted.add(id);
@@ -180,6 +194,38 @@ test('selected photo and name cards use the selected lane, select on click and n
}
});
test('a covered sighting label and icon yield; the top label acts over trails and other scene items', () => {
const f = fixture(row, {
// Registered owners, as the app has them: an aircraft, and the flight
// trails every layer reads as a no-op (src/data/trailRenderer.js).
picking: {
isOwnedByOtherLayer: (_layer, id) =>
id === 'other:aircraft' || String(id).startsWith('gev-trail:'),
},
});
f.selection.install();
f.selection.refreshAmbient();
f.hit('wildlife-sightings-labels', 'wildlife-sightings-label:inat:123');
f.click(null);
assert.equal(f.flights.length, 1);
f.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
f.click(null);
assert.equal(f.flights.length, 1);
assert.equal(f.state.selectedRow, row);
// A sighting icon under another layer's card is that card's click too.
f.click();
assert.equal(f.flights.length, 1, 'a covered sighting does not act');
f.cover(null);
// The top label acts over a flight trail: never a dead click.
f.click('gev-trail:fl-a1b2c3:head');
assert.equal(f.flights.length, 2, 'the label acts over a flight trail');
// And over another layer's scene item.
f.click('other:aircraft');
assert.equal(f.flights.length, 3, 'the top label acts');
assert.equal(f.state.selectedRow, row);
f.selection.remove();
});
test('nearby duplicate display names yield to painted cards and higher-ranked labels using cached screens', () => {
const low = {
...row,
@@ -305,7 +351,7 @@ test('empty clicks and layer removal release the selected row and its overlay',
assert.equal(f.entries.size, 0);
});
test("a click a label painted over a sighting's card takes never selects the sighting, and lets go of the selected one", (t) => {
test("a click on a mission label over a sighting's card never selects the sighting, and keeps the selected one", (t) => {
let fake = null;
const f = fixture(row, {
input: (viewer) => {
@@ -322,15 +368,24 @@ test("a click a label painted over a sighting's card takes never selects the sig
// The sighting's name card lies under every click.
f.hit('wildlife-sightings-labels', 'wildlife-sightings-label:inat:123');
// Under the label, the card beneath it selects nothing.
fake.label.over = true;
fake.click();
assert.equal(f.state.selectedId, null);
assert.equal(f.flights.length, 0);
// Off the label, a click on the card selects and focuses the sighting.
fake.label.over = false;
fake.click();
assert.equal(f.state.selectedId, row.stableId);
assert.equal(f.flights.length, 1);
// The label on top is its own click: the sighting stays selected, and
// the camera is not sent to it again.
fake.label.over = true;
fake.click();
assert.equal(f.state.selectedId, null, 'the selected sighting is let go');
assert.equal(f.state.selectedRow, null);
assert.equal(f.state.selectedId, row.stableId, 'the sighting stays');
assert.equal(f.state.selectedRow, row);
assert.equal(f.flights.length, 1, 'the camera is not sent to the sighting');
});