Keep tracked-entity state in app records instead of on Cesium entities

Flights, military, satellites, installations, local ADS-B and ALPR hung
gevTrackedId, gevDisplayPosition, gevVisualPosition, gevSelectionOrigin and
gevLabelModel on the Cesium entities they draw, and the tracked readout,
follow camera, cockpit, share links and awareness read them back. They now
live in src/data/entityRecords.js, an app-owned record per entity: layers
write entityRecord(entity), readers use readEntityRecord(entity). Nothing
changes on screen. This is the first slice of the renderer plan's state
mirror (P1).

The module is exported as ./data/entity-records so callers can read the
same records, and window.__godsEyeView.entityRecords gives the QA scripts
the same access from the page.
This commit is contained in:
Sameh Khamis committed 2026-11-03 08:09:00 -08:00
1 parent ea69bb4ce2
commit 65587f6c08
53 files changed
+408 -291

No files matched your search

+9 -10
View File
@@ -46,6 +46,7 @@ import {
presentAwarenessDistance,
} from '../layers/awareness/panel.js';
import { NAVIGATION_AUTHORITY_EVENT } from '../navigationPolicy.js';
import { withEntityRecord } from './entityRecords.js';
const militaryAwarenessSource = readLayerSource(
new URL('./militaryAwareness.js', import.meta.url),
@@ -823,9 +824,7 @@ for (const fixture of [
let retrackCalls = 0;
try {
const trackedEntity = {
gevTrackedId: `${subject.layerId}:${subject.id}`,
};
const trackedEntity = withEntityRecord({}, { trackedId: `${subject.layerId}:${subject.id}` });
runtime.viewer.trackedEntity = trackedEntity;
replaceMethod(
fixture.layer,
@@ -927,7 +926,7 @@ test('Contacts activation adopts the production military tracked-subject descrip
),
'mutating one accessor result must not alter the tracked source position',
);
runtime.viewer.trackedEntity = { gevTrackedId: `military:${id}` };
runtime.viewer.trackedEntity = withEntityRecord({}, { trackedId: `military:${id}` });
replaceMethod(flightsLayer, 'getTrackedSubject', () => null, restores);
replaceMethod(
flightsLayer,
@@ -1032,7 +1031,7 @@ test('production military tracked-subject label falls back to registration befor
'getAllPositions id stays the identity hex',
);
runtime.viewer.trackedEntity = { gevTrackedId: `military:${id}` };
runtime.viewer.trackedEntity = withEntityRecord({}, { trackedId: `military:${id}` });
replaceMethod(flightsLayer, 'getTrackedSubject', () => null, restores);
replaceMethod(flightsLayer, 'trackById', () => true, restores);
replaceMethod(militaryFlightsLayer, 'trackById', () => true, restores);
@@ -1104,7 +1103,7 @@ test('a cached Context subject re-reads its label when enrichment lands after se
meta,
});
runtime.viewer.trackedEntity = { gevTrackedId: `flights:${id}` };
runtime.viewer.trackedEntity = withEntityRecord({}, { trackedId: `flights:${id}` });
replaceMethod(
militaryFlightsLayer,
'getTrackedSubject',
@@ -1247,7 +1246,7 @@ test('Contacts activation adopts the production civilian tracked-subject descrip
),
'mutating one accessor result must not alter the tracked source position',
);
runtime.viewer.trackedEntity = { gevTrackedId: `flights:${id}` };
runtime.viewer.trackedEntity = withEntityRecord({}, { trackedId: `flights:${id}` });
replaceMethod(
militaryFlightsLayer,
'getTrackedSubject',
@@ -1334,7 +1333,7 @@ test('Contacts activation reconciles to a newer cross-layer tracked flight after
const restores = [];
try {
runtime.viewer.trackedEntity = { gevTrackedId: 'flights:first' };
runtime.viewer.trackedEntity = withEntityRecord({}, { trackedId: 'flights:first' });
replaceMethod(
flightsLayer,
'getTrackedSubject',
@@ -1357,7 +1356,7 @@ test('Contacts activation reconciles to a newer cross-layer tracked flight after
civilianTracked = null;
militaryTracked = awarenessSubject('military', 'latest', positions.latest);
runtime.viewer.trackedEntity = { gevTrackedId: 'military:latest' };
runtime.viewer.trackedEntity = withEntityRecord({}, { trackedId: 'military:latest' });
releaseDependencies();
await nextTurn();
await nextTurn();
@@ -1401,7 +1400,7 @@ test('tracked flight cleared during Contacts activation suppresses fallback auto
const focused = [];
try {
runtime.viewer.trackedEntity = { gevTrackedId: 'flights:selected' };
runtime.viewer.trackedEntity = withEntityRecord({}, { trackedId: 'flights:selected' });
replaceMethod(flightsLayer, 'getTrackedSubject', () => tracked, restores);
replaceMethod(
militaryFlightsLayer,