STATION and LIVE register with the panel chrome again; a failed model load is retried; LIVE stops with the briefing collapsed

Found by a review of the review fixes:
- PanelChrome finds collapsible panels once, at startup, and Context starts
  closed, so STATION and LIVE inside the Inspector view (mounted only while
  Context is open) were never registered: their +/- did nothing and their
  bodies stayed hidden. They sit beside Radio again, always in the page; a
  test mounts Context closed and finds their collapse buttons.
- A model whose load failed was never retried while the station stayed
  shown (the renderer retries only on an update, and a model not ready is
  not sent). It is now released 30 s after the failure and asked for again;
  a model still loading also counts as undrawn out of range.
- The Cockpit LIVE page counts as hidden while the briefing card is
  collapsed, so the player stops there too.
- Tests: the label-box gate through the real click handler (it fails on the
  code before the gate), and the STATION section republishing only when the
  pose age crosses a whole second.
- SECURITY.md: an oversized feed frame closes the socket; the unused import
  in issCommand.js goes.
This commit is contained in:
Denis Groshev committed 2026-11-17 17:27:59 +01:00
1 parent 7d0f9f677f
commit c8cc9c0b26
9 files changed
+116 -8

No files matched your search

@@ -233,3 +233,33 @@ test('a click on a site dot or its outline selects the site; another set does no
h.click({ id: { set: 'other:1', id: outline.id, meta: outline.meta } });
assert.equal(selectedNow(), false);
});
test('a click on the map itself reads the label box at the click; a click on something drawn there does not', (t) => {
const h = harness(t);
let answer = null;
const asked = [];
h.parts.controls = {
methods: {
findAt(position) {
asked.push(position);
return answer;
},
},
};
// Nothing picked and no label there: the selection is released.
h.click(undefined);
assert.equal(asked.length, 1);
assert.deepEqual(asked[0], { x: 640, y: 400 }, 'in CSS px, where clicked');
h.assertSelected(false);
// The site's label box at the click selects it.
answer = { id: 'base' };
h.click(undefined);
assert.equal(asked.length, 2);
h.assertSelected(true);
// Something else drawn under the click (an aircraft, a vessel): the label
// box is not read, and the site's selection is released as for any other
// contact.
h.click({ id: 'flight:abc123' });
assert.equal(asked.length, 2, 'the label box is not asked');
h.assertSelected(false);
});
-2
View File
@@ -1,5 +1,3 @@
import { t } from '../../i18n/index.js';
const unit = (v) => {
const n = Math.hypot(...v);
return v.map((c) => c / n);
+21 -1
View File
@@ -67,10 +67,18 @@ import { stationTrackedOn } from './policy.js';
* @property {number} [unloadAfterMs] How long the model may go undrawn (out
* of range, or hidden) before its draw set is released and its GPU memory
* with it; asked for again on the next approach. Default one minute.
* @property {number} [retryAfterMs] How long after a failed load the model
* is released and asked for again. Default 30 s.
*/
/** Default `unloadAfterMs`: a minute undrawn releases the model. */
export const STATION_MODEL_UNLOAD_AFTER_MS = 60_000;
/**
* A model that failed to load is released after this and asked for again
* on the next frame in range (the renderer retries a load only on an
* update, and a model that is not ready is not sent).
*/
export const STATION_MODEL_RETRY_AFTER_MS = 30_000;
/**
* Whether a station model may be drawn: the dot's own rules (layer on, points
@@ -229,6 +237,8 @@ export function createStationModel(
let ready = false;
let loading = false;
let failed = false;
/** When the renderer said the load failed (wall-clock ms), or null. */
let failedAt = null;
/** Turns the moving parts by where the Sun (and the relays) are. */
const articulation = spec.createArticulation();
/** Where the joint driver writes; kept for a renderer that poses nodes. */
@@ -315,8 +325,9 @@ export function createStationModel(
offFailed = set.on('loadFailed', (id, message) => {
if (id !== itemId) return;
// The dots keep drawing at every distance (the model is never ready);
// the next approach after the model is released tries again.
// after `retryAfterMs` the model is released and asked for again.
failed = true;
failedAt = Date.now();
loading = false;
console.warn(
`[Data:Satellites] ${spec.label} model failed to load:`,
@@ -668,6 +679,14 @@ export function createStationModel(
if (handedCompanions.size) _releaseCompanions();
handingOver = false;
_syncOrbitCloseUp(false);
if (
failedAt !== null &&
Date.now() - failedAt >=
(spec.retryAfterMs ?? STATION_MODEL_RETRY_AFTER_MS)
)
_unload(); // asked for again on the next frame in range
else if (cameraDistance > spec.maxDistanceM * 1.5) _undrawn();
else undrawnSince = null;
return;
}
// The docked dots are the model's within its range: handed over at
@@ -769,6 +788,7 @@ export function createStationModel(
handingOver = false;
loading = false;
failed = false;
failedAt = null;
ready = false;
visualValid = false;
undrawnSince = null;
+20 -1
View File
@@ -336,7 +336,14 @@ test('until the renderer has the model the dots stand at every distance, and sta
assert.equal(f.drawn(STATION).displayRange, undefined);
assert.equal(f.drawn(COMPANION).displayRange, undefined);
assert.equal(f.trackedDot().displayRange, undefined);
// A load that does finish hands them over.
// After the retry delay the model is released, and the next frame asks
// for it again: one transient failure does not cost the session.
f.model.spec.retryAfterMs = 0;
f.tick();
assert.equal(f.modelSet(), undefined, 'released after a failure');
f.tick();
assert.ok(f.modelItem(), 'asked for again');
// That load finishes: the dots are handed over.
f.readyModel();
f.tick();
assert.equal(f.modelItem().show, true);
@@ -344,6 +351,18 @@ test('until the renderer has the model the dots stand at every distance, and sta
assert.deepEqual(f.trackedDot().displayRange, FAR_RANGE);
});
test('a model still loading counts as undrawn out of range and is released', (t) => {
const f = fixture(t);
f.cameraAt(MAX_M * 1.4);
f.tick(); // asks for the model, which never answers
f.cameraAt(MAX_M * 5);
f.tick();
assert.ok(f.modelSet(), 'kept for a while');
f.model.spec.unloadAfterMs = 0;
f.tick();
assert.equal(f.modelSet(), undefined);
});
test('turning the layer off, or a while undrawn, releases the model; the next approach asks for it again', async (t) => {
const f = fixture(t);
await f.load();
@@ -348,3 +348,23 @@ test('actions without a station are refused; destroy publishes nothing', () => {
f.panel._destroyStationPanel();
assert.equal(f.view(), null);
});
test('frame after frame, the section is republished only when the age crosses a whole second', (t) => {
const f = fixture();
t.after(() => f.panel._destroyStationPanel());
f.select(true);
f.setTelemetry({ state: 'live', poseAgeMs: 3010, liveUntilMs: null });
f.panel._syncStationPanel();
const published = f.views.length;
assert.equal(f.view().telemetry.poseAgeMs, 3000, 'in whole seconds');
// The tick runs every frame; the age moves by milliseconds.
for (const age of [3020, 3150, 3600, 3999]) {
f.setTelemetry({ state: 'live', poseAgeMs: age, liveUntilMs: null });
f.panel._syncStationPanel();
}
assert.equal(f.views.length, published, 'nothing new to show');
f.setTelemetry({ state: 'live', poseAgeMs: 4001, liveUntilMs: null });
f.panel._syncStationPanel();
assert.equal(f.views.length, published + 1);
assert.equal(f.view().telemetry.poseAgeMs, 4000);
});