From bbe33b48c7bcebb5007ddb8a802264737330be16 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sun, 8 Nov 2026 13:26:45 -0800 Subject: [PATCH] fix(vessels): hide the ridden ship's trail while its bridge is held The sprite and card were hidden from the bridge but the selected-vessel trail was not: at sea it ran astern from under the eye, and on a raised river it lay buried under the water. It is now hidden while the bridge holds its ship, keeping its history, and shown again on release. --- src/layers/vessels/queries.js | 3 +++ src/layers/vessels/radarContacts.test.mjs | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/layers/vessels/queries.js b/src/layers/vessels/queries.js index 8f1f874e0..710e7cccd 100644 --- a/src/layers/vessels/queries.js +++ b/src/layers/vessels/queries.js @@ -563,6 +563,9 @@ export function createQueries({ const next = normalizeSelectionMmsi(mmsi); if (state.cockpitSubjectMmsi === next) return true; state.cockpitSubjectMmsi = next; + // The ridden ship's trail runs from under the eye: hidden, its history + // kept, while the bridge holds the ship it belongs to. + state.trail?.setVisible?.(!next || next !== state.trailMmsi); components.rendering.updateVisibility(true); return true; }, diff --git a/src/layers/vessels/radarContacts.test.mjs b/src/layers/vessels/radarContacts.test.mjs index d0797aae1..86855b512 100644 --- a/src/layers/vessels/radarContacts.test.mjs +++ b/src/layers/vessels/radarContacts.test.mjs @@ -1,5 +1,6 @@ // src/layers/vessels/radarContacts.test.mjs — the vessels the Cockpit bridge -// radar draws: within range, nearest first, without the ship it rides. +// radar draws: within range, nearest first, without the ship it rides; and +// the ridden ship's own trail, hidden while the bridge holds it. import test from 'node:test'; import assert from 'node:assert/strict'; import { createVesselLayer } from './index.js'; @@ -128,6 +129,24 @@ test('ships with no MMSI each keep a key of their own', () => { assert.ok(ids.every((id) => id.startsWith('unkeyed:'))); }); +test("the ridden ship's trail is hidden while the bridge holds it", () => { + const shown = []; + const trail = { + setPositions() {}, + clear() {}, + destroy() {}, + setVisible: (visible) => shown.push(visible), + }; + const layer = layerWith([record('own', 0), record('other', 2)], { + trail, + trailMmsi: 'own', + }); + layer.setCockpitSubject('own'); + assert.deepEqual(shown, [false]); + layer.setCockpitSubject(null); + assert.deepEqual(shown, [false, true]); +}); + test('a disabled layer has no radar contacts', () => { const layer = layerWith([record('1', 1)], { enabled: false }); assert.deepEqual(layer.getRadarContacts(54.5, 10.2, 6 * 1852), []);