From ee37511332479cc3798d803d86fa88c057825a03 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 16:35:52 -0800 Subject: [PATCH 01/15] Keep the saved Satellites state when Satellites is still busy as Space Missions turns off When Satellites had not settled within the 30 s limit, turning Space Missions off cleared the saved Satellites state and put the parameters back before failing, so Satellites stayed on as Space Missions had switched it with nothing left to retry. Now a busy Satellites layer is left untouched and the saved state is kept, so turning Space Missions off again finishes the restore. A Satellites action the person took still gets its parameters back. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 4 ++- src/layers/launches/failedEntry.test.mjs | 7 +++++ src/layers/launches/ingestion.js | 15 ++++++---- src/layers/launches/missionCycler.test.mjs | 33 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 64207f325a..7661e19e7c 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -5592,7 +5592,9 @@ activeCameraCardEnabled: true })` may publish it through the retained > switching Space Missions off restores the pre-mission Satellite enabled > state and presentation parameters, except that an explicit Satellites action > taken while it ran is kept. Restored parameters never re-show primitives -> while the Satellite layer is disabled. +> while the Satellite layer is disabled. When Satellites is still busy after +> the 30 s limit, the restore changes nothing and keeps the saved state, so +> switching Space Missions off again finishes it. > - **Flights 3D/cockpit hardening:** the destination-direction cue is an > inline SVG rather than a remotely loaded Material Icons ligature, so a > blocked or late font can no longer expand the literal word `navigation` diff --git a/src/layers/launches/failedEntry.test.mjs b/src/layers/launches/failedEntry.test.mjs index de7b8719b3..eba7a917f9 100644 --- a/src/layers/launches/failedEntry.test.mjs +++ b/src/layers/launches/failedEntry.test.mjs @@ -623,6 +623,13 @@ test('a Satellites enable that never settles still lets mission disable complete stuck.resolve(); } await f.settle(); + // The saved Satellites state was kept: turning Space Missions off again + // once Satellites settles gives back the Satellites it turned on. + assert.equal(f.manager.isEnabled('satellites'), true); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + await f.settle(); + assert.equal(f.manager.isEnabled('rocket-launches'), false); + assert.equal(f.manager.isEnabled('satellites'), false); }); test('a failed Satellites restore still clears the selected mission panel', async (t) => { diff --git a/src/layers/launches/ingestion.js b/src/layers/launches/ingestion.js index 35a4c47771..d328700b2f 100644 --- a/src/layers/launches/ingestion.js +++ b/src/layers/launches/ingestion.js @@ -179,18 +179,21 @@ export function createIngestion({ layerState._satelliteStateBeforeMission !== snapshot ) return; + // An accepted Satellites action owns visibility through mission teardown. + const restoreVisibility = snapshot.restoreVisibility !== false; + // Satellites is still busy: change nothing and keep the saved state, so + // turning Space Missions off again can finish the restore. + if (restoreVisibility && !idle) + throw new Error( + 'Space Missions could not restore the satellites layer: it did not settle', + ); layerState._satelliteStateBeforeMission = null; layerState._satelliteActivationPromise = null; manager.setLayerParams( 'satellites', parts.policyHelpers.satelliteParamsAfterSpaceMissions(snapshot.params), ); - // An accepted Satellites action owns visibility through mission teardown. - if (snapshot.restoreVisibility === false) return; - if (!idle) - throw new Error( - 'Space Missions could not restore the satellites layer: it did not settle', - ); + if (!restoreVisibility) return; const restored = await manager.setEnabled('satellites', snapshot.enabled); if ( restored === false || diff --git a/src/layers/launches/missionCycler.test.mjs b/src/layers/launches/missionCycler.test.mjs index 1f07a12cff..06bf4bf0bf 100644 --- a/src/layers/launches/missionCycler.test.mjs +++ b/src/layers/launches/missionCycler.test.mjs @@ -177,3 +177,36 @@ test('without a Satellites action the exit restores the pre-mission visibility', ['enabled', 'satellites', false], ]); }); + +test('a Satellites layer that does not settle keeps the saved state for the next exit', async () => { + const r = satelliteRig({ enabledBefore: false }); + let idle = false; + r.state._dataManager.waitForLayerIdle = async () => idle; + await assert.rejects( + r.ingestion.restoreSatelliteDependency(), + /did not settle/, + ); + assert.deepEqual(r.calls, [], 'nothing changes while Satellites is busy'); + assert.deepEqual(r.state._satelliteStateBeforeMission, { + enabled: false, + params: { mode: 'before' }, + }); + + // Turning Space Missions off again once Satellites settles finishes it. + idle = true; + await r.ingestion.restoreSatelliteDependency(); + assert.deepEqual(r.calls, [ + ['params', 'satellites', { mode: 'before' }], + ['enabled', 'satellites', false], + ]); + assert.equal(r.state._satelliteStateBeforeMission, null); +}); + +test('a Satellites action the person took still gets its parameters back when Satellites is busy', async () => { + const r = satelliteRig({ enabledBefore: false }); + r.state._dataManager.waitForLayerIdle = async () => false; + r.state._satelliteStateBeforeMission.restoreVisibility = false; + await r.ingestion.restoreSatelliteDependency(); + assert.deepEqual(r.calls, [['params', 'satellites', { mode: 'before' }]]); + assert.equal(r.state._satelliteStateBeforeMission, null); +}); From 9ac937af82293d5dd1ab447da3171452b6a66a5d Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 16:36:00 -0800 Subject: [PATCH 02/15] Let every click subscriber hear a mission-label click A click a painted overlay handled, such as a Space Missions label, returned before any click subscriber ran, so the layers that close their cards or let go of their selection on a click never heard it. Now only the picking the label replaces is skipped: subscribers still hear the click, marked as an overlay click whose hit is the label (no draw set, no id, nothing drilled), and the geometry beneath it is not picked. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 2 +- src/input/dispatcher.js | 43 ++++++++++++++--- src/input/dispatcher.test.mjs | 62 ++++++++++++++++++++++++- src/layers/launches/labelClick.test.mjs | 15 ++++-- 4 files changed, 109 insertions(+), 13 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 7661e19e7c..3fc14cfa37 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7493,7 +7493,7 @@ silently demoting every later lookup for the session. protected-card path. Disable tears the tier down completely. Coverage/viewshed semantics unchanged. - **Satellites**: every point moves every frame. Each satellite's SGP4 sample (position, velocity, gravity and its rate of change; `src/layers/satellites/motion.js`) is reckoned forward or back to the world time and turned into the Earth-fixed frame, so points glide at any play speed instead of stepping once a second. Core satellites take a fresh sample every second, or as soon as the world time is 30 s from their sample (fast play, a seek), which keeps every point within about 10 m of SGP4; Starlink extras are sampled round-robin, more per frame the faster time plays, and a point more than two minutes from its sample waits for the next one. Hidden points are not moved until shown. Orbit rings rotate about Earth's Z by ΔGMST every ~1s (exact inertial→ECEF compensation; no SGP4 re-runs); the tracked satellite propagates per frame with one shared epoch for dot/label/camera. Verified: ISS holds <1km perpendicular to its ring while tracked. Pass prediction (`src/data/satellitePass.js`; `getNextSatellitePass`, `getNextIssPass`) scans at 20s, bisects rise/set to ~0.2s, fits the peak with a parabola, and marks a pass visible when the satellite is outside a cylindrical Earth shadow while the observer's Sun is at or below −6°. `next_iss_pass` preserves its geometric-pass ordering and appends visibility metadata. General `next_satellite_pass` accepts a loaded NORAD ID or unambiguous name, searches 24 hours and optionally requires estimated visibility. These estimates do not account for weather or satellite brightness. -- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. +- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot; what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name, so they close their cards or let go of their selection as for any other click. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. When no mission is selected, the Space Missions panel presents a scrollable newest-first roster of every launch in the rolling window, including the smaller 5 px operator-colored marker, provider, and launch date. Hovering or keyboard-focusing a row shows four compact cyan corner brackets on both that roster row and its corresponding globe dot, rotates the globe at the current zoom to center it, and gives its label declutter priority without selecting it; the globe label remains unbracketed. Selecting a roster row invokes the same mission isolation and full-orbit framing as clicking its globe marker. The replay vehicle is one screen-space SVG/CSS HUD overlay rather than separate Cesium billboard, label, and reticle graphics. It is hidden during ordinary Focus and manual close views, where the standard selected launch-site label remains visible, and exists only while ascent replay is active. Its fixed pixel scale is shared by ascent and insertion, so camera range never resizes the rocket on screen before the phase boundary. Generic Launch Library pad names are reduced to their identifying suffix, and replay timestamps use a cyan state title over unprefixed white UTC date/time values. `REPLAY ASCENT` holds the unframed cyan/white rocket at the pad for a real-time `T−10` countdown, transitions through `LIFTOFF`, and attaches six tapered cyan/white ellipse waves directly below it from liftoff through insertion to convey thrust without adding scene geometry. While replay is active, the single start button is replaced by compact Play, Pause, and Cancel icon controls. Pause freezes countdown or mission time, vehicle/stage positions, camera target, labels, and thrust-wave animation; Play resumes from that exact frame, and Cancel releases replay camera ownership. The rocket and thrust group rotates from the path's live screen-space tangent, so its nose follows the visible ascent curve while the adjacent text remains upright. The camera begins as a close oblique launch chase, then smoothly widens between roughly 120 and 420 km vehicle altitude into a higher oblique context view that keeps the moving rocket targeted while exposing the ascent bend and orbit connection. At insertion the rocket/thrust glyph is replaced by the fixed-size cyan orbit dot, which the camera follows through the existing globe-scale orbit pullback. The chase camera limits per-frame yaw changes across heading wraps so it cannot abruptly cross in front of the vehicle and make ascent read in reverse; the replay-speed slider affects mission playback but not countdown duration. Mission world text has no native `LabelGraphics`: overview launch markers publish at most 48 ambient candidates for a 24-winner budget, while selecting a mission clears that overview source and publishes its launch-site callout, stage re-entry annotations, live/estimated payload-position readout, and orbit annotation as protected selected-lane entries. The source retains the exact former strings and colors. Static anchors reuse the Cartesian values used to build their mission geometry; the moving payload entry reads the layer's per-frame live-position cache; catalog-backed orbit annotation positions are cached in the same one-second matrix update that realigns the orbit primitive. Keyhole edge fade, horizon culling, final collision placement, and UI exclusion are owned by the shared host. Deselect restores the bounded overview, and refresh, disable, and destroy replace or clear both mission sources. A selected mission renders its orbit as four repeating tactical sectors, each containing one prominent cyan dot followed by one hundred thin translucent dashes. The bright dots act as orbit anchors while the subdued dash field remains depth-tested against the globe and is shown only for the selected mission. diff --git a/src/input/dispatcher.js b/src/input/dispatcher.js index b5c8fa86cf..32ae401c47 100644 --- a/src/input/dispatcher.js +++ b/src/input/dispatcher.js @@ -182,6 +182,9 @@ function topHitOf(hit, foreign) { * when the adapter has none. * @property {unknown} pick `native.pick`, for code still bound to the * engine's pick objects that reads it here. + * @property {boolean} overlay Whether a painted overlay target took the + * click ({@link InputDispatcher.onOverlayClick}). Its hits then name only + * that target: something drawn outside the draw port, with no id. * @property {(width: number, height: number) => unknown} pickWindow * `native.pickWindow`, the same. */ @@ -192,7 +195,9 @@ function topHitOf(hit, foreign) { * Ambient click subscription. Returns its unsubscribe. * @property {(fn: (event: ClickEvent) => boolean) => () => void} onOverlayClick * Hit-test a painted overlay before ambient clicks. Return true after - * handling its topmost target to stop delivery to the geometry beneath it. + * handling its topmost target: the geometry beneath it is not picked, and + * the click subscribers hear the click as one on that target (`overlay` + * true, `topHit` a hit with no set and no id, nothing drilled). * @property {(type: 'down'|'move'|'up'|'click'|'dblclick', fn: Function, options?: {lease?: object|(() => object|null)}) => () => void} onPointer * Raw pointer subscription: `click` gets the {@link ClickEvent}, the others * `{position}` (`move`: `{startPosition, endPosition, pickPosition}`, its @@ -331,7 +336,7 @@ function createDispatcher(viewer, { query: givenQuery, ...portOptions } = {}) { click: (ev) => { if (!unmodifiedLeft(ev)) return; const ambient = free(); - const event = createClickEvent( + const { event, cover } = createClickEvent( viewer, queryOf, xy(ev.position), @@ -340,7 +345,12 @@ function createDispatcher(viewer, { query: givenQuery, ...portOptions } = {}) { if (ambient) { for (const handle of [...overlayClicks]) { try { - if (handle(event) === true) return; + // A handled overlay target hides the geometry beneath it; every + // subscriber still hears the click, as a click on that target. + if (handle(event) === true) { + cover(); + break; + } } catch (error) { console.error('Pointer input handler failed', error); } @@ -437,6 +447,10 @@ function createDispatcher(viewer, { query: givenQuery, ...portOptions } = {}) { return self; } +/** What a click handled by a painted overlay target hits: that target, + * drawn outside the draw port and named by no pick id. */ +const OVERLAY_HIT = Object.freeze({ set: '', id: null, surface: false }); + /** A drill is run at least this deep and sliced, so callers asking for * different depths on one click share one pass. */ const DRILL_DEPTH = 16; @@ -446,7 +460,8 @@ const DRILL_DEPTH = 16; * @param {() => import('../render/contract/query').QueryPort|null} queryOf * @param {{x: number, y: number}} at Where the click is, CSS pixels. * @param {ClickGesture} gesture - * @returns {ClickEvent} + * @returns {{event: ClickEvent, cover: () => void}} The click, and how a + * handled overlay target hides the geometry beneath it from the click. */ function createClickEvent(viewer, queryOf, at, gesture) { const position = sensorPickPosition(viewer, at, canvasOf(viewer)); @@ -465,11 +480,25 @@ function createClickEvent(viewer, queryOf, at, gesture) { }; /** @type {Map} */ const drills = new Map(); + let covered = false; + const cover = () => { + covered = true; + memo.clear(); + drills.clear(); + memo.set('top', OVERLAY_HIT); + memo.set('hit', OVERLAY_HIT); + memo.set('id', null); + memo.set('ownerId', null); + memo.set('native', null); + }; - return { + const event = { screenPosition: at, position, gesture, + get overlay() { + return covered; + }, get topHit() { return once('top', () => { const hit = pick(); @@ -515,6 +544,7 @@ function createClickEvent(viewer, queryOf, at, gesture) { return !this.hit; }, windowHit(width, height) { + if (covered) return { id: null, drawHit: null, surface: false }; return once(`windowHit:${width}x${height}`, () => { const picked = pick({ width, height }); void native()?.native.pickWindow(width, height); @@ -535,7 +565,7 @@ function createClickEvent(viewer, queryOf, at, gesture) { // A deeper pass already made holds these. (One that came back short // may not hold every hit: it drops what is not a draw-set item.) if (done && limit <= done.limit) return done.hits.slice(0, limit); - const q = query(); + const q = covered ? null : query(); if (!q) return []; // Only the default window is shared between layers; round that one up. const depth = @@ -568,4 +598,5 @@ function createClickEvent(viewer, queryOf, at, gesture) { return native()?.native.pickWindow(width, height); }, }; + return { event, cover }; } diff --git a/src/input/dispatcher.test.mjs b/src/input/dispatcher.test.mjs index c88e1af8b1..965c63374d 100644 --- a/src/input/dispatcher.test.mjs +++ b/src/input/dispatcher.test.mjs @@ -145,7 +145,8 @@ test('a painted overlay can claim a click before its underlying owner', (t) => { h.input.onPointer('click', () => clicks.push('ambient pointer')); h.click(); - assert.deepEqual(clicks, ['mission label']); + // The click still reaches every subscriber, as one on the label. + assert.deepEqual(clicks, ['mission label', 'ambient pointer', null]); assert.equal(h.calls.pick, 0); h.click(11, 10); @@ -154,12 +155,71 @@ test('a painted overlay can claim a click before its underlying owner', (t) => { assert.deepEqual(clicks, [ 'mission label', 'ambient pointer', + null, + 'ambient pointer', 'satellites', 'ambient pointer', 'satellites', ]); }); +test('a click a painted overlay handles still reaches subscribers that clear selection', (t) => { + const h = harness({ + pick: () => ({ set: 'flights', id: 'abc123' }), + drillPick: () => [{ set: 'flights', id: 'abc123' }], + }); + t.after(() => h.input.destroy()); + let seenByOverlay = null; + h.input.onOverlayClick((event) => { + seenByOverlay = event; + return true; + }); + const seen = []; + h.input.onClick((event) => { + seen.push({ + same: event === seenByOverlay, + overlay: event.overlay, + topHit: event.topHit, + drawHit: event.drawHit, + hit: event.hit, + id: event.id, + ownerId: event.ownerId, + surface: event.surface, + drill: event.drill(4), + windowHit: event.windowHit(8, 8), + pick: event.pick, + }); + }); + h.click(); + assert.deepEqual(seen, [ + { + same: true, + overlay: true, + topHit: { set: '', id: null, surface: false }, + drawHit: null, + hit: { set: '', id: null, surface: false }, + id: null, + ownerId: null, + surface: false, + drill: [], + windowHit: { id: null, drawHit: null, surface: false }, + pick: undefined, + }, + ]); + assert.equal(h.calls.pick, 0, 'the geometry beneath is not picked'); + assert.equal(h.calls.drillPick, 0); + + // Without an overlay target the same click picks the geometry. + seen.length = 0; + h.input.destroy(); + const g = harness({ pick: () => ({ set: 'flights', id: 'abc123' }) }); + t.after(() => g.input.destroy()); + g.input.onClick((event) => seen.push([event.overlay, event.topHit])); + g.click(); + assert.equal(seen[0][0], false); + assert.equal(g.calls.pick, 1); +}); + test('the gesture carries summed travel and press time', (t) => { const h = harness(); t.after(() => h.input.destroy()); diff --git a/src/layers/launches/labelClick.test.mjs b/src/layers/launches/labelClick.test.mjs index 592b5ccaaf..7c50f3fdb0 100644 --- a/src/layers/launches/labelClick.test.mjs +++ b/src/layers/launches/labelClick.test.mjs @@ -118,11 +118,15 @@ const label = ( entryId, }); -test('a mission label click focuses its launch and stops the click there', (t) => { - const r = rig(t, { overlayHit: label('launch:L2') }); +test('a mission label click focuses its launch and covers the geometry beneath', (t) => { + const r = rig(t, { overlayHit: label('launch:L2'), geometryLaunchId: 'L1' }); r.click(); - assert.deepEqual(r.focused, ['L2']); - assert.equal(r.ambient.length, 0, 'the layers beneath do not see it'); + assert.deepEqual(r.focused, ['L2'], 'the mission beneath is not picked'); + // Other layers still hear it, to close their cards or clear selection, + // as a click on the label rather than on the geometry beneath. + assert.equal(r.ambient.length, 1); + assert.equal(r.ambient[0].overlay, true); + assert.equal(r.ambient[0].drawHit, null); r.setHit(label('launch:L1', ROCKET_MISSION_SELECTED_OVERLAY_SOURCE_ID)); r.click(); @@ -156,7 +160,8 @@ test('a throwing globe-pick listener does not stop the pick', (t) => { r.click(); assert.deepEqual(r.focused, ['L1']); assert.deepEqual(heard, ['L1']); - assert.equal(r.ambient.length, 0); + assert.equal(r.ambient.length, 1); + assert.equal(r.ambient[0].overlay, true); }); test('a mission label for an unknown launch falls through to other layers', (t) => { From 8675ead171d15676433695f69694531c425b709b Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 16:37:48 -0800 Subject: [PATCH 03/15] Stop roster hover and focus from moving the camera while Space Missions goes off While Space Missions was going off (its Satellites restore still running, the panel still shown), hovering or keyboard-focusing a roster row still scheduled the roster preview, which flew the camera to that launch with nothing left to end it. The preview is no longer scheduled once the layer is going off, and one already pending is dropped. Selection, focus, replay and stepping from the Data Layers row were already refused then. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 4 +++- src/layers/launches/panel.js | 10 ++++++++-- src/layers/launches/panel.test.mjs | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 3fc14cfa37..38d838d0e2 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -5594,7 +5594,9 @@ activeCameraCardEnabled: true })` may publish it through the retained > taken while it ran is kept. Restored parameters never re-show primitives > while the Satellite layer is disabled. When Satellites is still busy after > the 30 s limit, the restore changes nothing and keeps the saved state, so -> switching Space Missions off again finishes it. +> switching Space Missions off again finishes it. While Space Missions goes +> off, its panel's roster and controls select, focus, preview and replay +> nothing, so no camera move starts that nothing would end. > - **Flights 3D/cockpit hardening:** the destination-direction cue is an > inline SVG rather than a remotely loaded Material Icons ligature, so a > blocked or late font can no longer expand the literal word `navigation` diff --git a/src/layers/launches/panel.js b/src/layers/launches/panel.js index 470adc9d9e..9dc827d5ca 100644 --- a/src/layers/launches/panel.js +++ b/src/layers/launches/panel.js @@ -380,14 +380,20 @@ export function createPanel({ state: layerState, services, parts, source }) { function scheduleMissionRosterPreview(index) { const launch = layerState._launches[index]; - if (!launch || layerState._selectedLaunchId) return; + // Once the layer is going off (its Satellites restore may still be + // running) hovering or focusing a roster row moves no camera. + if (!launch || layerState._selectedLaunchId || !layerState._enabled) return; if (layerState._missionRosterHoverTimer) clearTimeout(layerState._missionRosterHoverTimer); layerState._hoveredRosterLaunchId = launch.id; parts.overlays.syncMissionOverlayEntries(); layerState._missionRosterHoverTimer = setTimeout(() => { layerState._missionRosterHoverTimer = null; - if (layerState._hoveredRosterLaunchId !== launch.id) return; + if ( + layerState._hoveredRosterLaunchId !== launch.id || + !layerState._enabled + ) + return; const currentLaunch = resolveMissionRosterPreviewLaunch( layerState._launches, launch.id, diff --git a/src/layers/launches/panel.test.mjs b/src/layers/launches/panel.test.mjs index 9075d5e5cb..4e0a558944 100644 --- a/src/layers/launches/panel.test.mjs +++ b/src/layers/launches/panel.test.mjs @@ -9,6 +9,7 @@ function fixture() { const state = createState({ services: { overlays: {}, render: {} }, }); + state._enabled = true; const calls = []; const parts = { overlays: { @@ -194,3 +195,26 @@ test('the panel commands act on the selected mission', () => { ['select', null, undefined], ]); }); + +test('a roster row hovered or focused while the layer goes off moves no camera', async () => { + const { state, panel, calls } = fixture(); + state._launches = [launch('a'), launch('b')]; + panel.createMissionPanel(); + panel.renderMissionRoster(); + + // Hovered just before the layer goes off: the pending preview is dropped. + panel.commands.rosterPointerEnter(0); + state._enabled = false; + await new Promise((resolve) => setTimeout(resolve, 160)); + + // Hovered or focused after it went off, while the panel still shows. + panel.commands.rosterPointerEnter(1); + panel.commands.rosterFocus(1); + assert.equal(state._missionRosterHoverTimer, null, 'no preview is pending'); + await new Promise((resolve) => setTimeout(resolve, 160)); + assert.deepEqual( + calls.filter(([name]) => name === 'preview'), + [], + ); + panel.clearMissionPanel(); +}); From 5feac417d6de679b9bbf869fd316764b482beb5a Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:05:43 -0800 Subject: [PATCH 04/15] Never act on what lies under a mission label when it is clicked A click on a Space Missions label reaches every click subscriber so they can let go of their selection, but the layers that test their own painted cards or pick the scene themselves still found what lay under the label: CCTV turned that camera on, FIRMS and Vessels selected and flew to theirs, News and Wildlife Sightings opened their item, Perimeters, Ghost Maps and Shipwrecks opened the card's link, ALPR selected its reader, and Local ADS-B drilled the scene itself and selected the aircraft. Each now skips its own test on such a click, and Local ADS-B drills through the click, so the click only releases selections, as a click on empty map or another layer's contact does. Ordinary clicks behave as before. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 2 +- scripts/format-scope.json | 4 +- src/input/dispatcher.js | 4 +- src/input/testDoubles.mjs | 15 ++++ src/layers/alpr/presentation.js | 3 +- src/layers/cctv/lifecycle.js | 15 ++-- src/layers/cctv/lifecycle.test.mjs | 81 +++++++++++++++++++++ src/layers/droneAirspace/index.js | 13 ++-- src/layers/firms/selection.js | 17 +++-- src/layers/firms/selection.test.mjs | 80 ++++++++++++++++++++ src/layers/ghostMaps/index.js | 13 ++-- src/layers/localAdsb/index.js | 13 +--- src/layers/localAdsb/index.test.mjs | 39 +++++++++- src/layers/news/index.js | 9 ++- src/layers/perimeters/index.js | 13 ++-- src/layers/shipwrecks/index.js | 9 ++- src/layers/shipwrecks/index.test.mjs | 49 +++++++++++++ src/layers/vessels/selection.js | 24 +++--- src/layers/vessels/selection.test.mjs | 89 +++++++++++++++++++++++ src/layers/wildlifeSightings/selection.js | 16 ++-- src/ui/cockpitController.js | 6 +- src/ui/cockpitOrbitalFocus.js | 11 ++- 22 files changed, 453 insertions(+), 72 deletions(-) create mode 100644 src/layers/firms/selection.test.mjs create mode 100644 src/layers/vessels/selection.test.mjs diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 38d838d0e2..789c158529 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7495,7 +7495,7 @@ silently demoting every later lookup for the session. protected-card path. Disable tears the tier down completely. Coverage/viewshed semantics unchanged. - **Satellites**: every point moves every frame. Each satellite's SGP4 sample (position, velocity, gravity and its rate of change; `src/layers/satellites/motion.js`) is reckoned forward or back to the world time and turned into the Earth-fixed frame, so points glide at any play speed instead of stepping once a second. Core satellites take a fresh sample every second, or as soon as the world time is 30 s from their sample (fast play, a seek), which keeps every point within about 10 m of SGP4; Starlink extras are sampled round-robin, more per frame the faster time plays, and a point more than two minutes from its sample waits for the next one. Hidden points are not moved until shown. Orbit rings rotate about Earth's Z by ΔGMST every ~1s (exact inertial→ECEF compensation; no SGP4 re-runs); the tracked satellite propagates per frame with one shared epoch for dot/label/camera. Verified: ISS holds <1km perpendicular to its ring while tracked. Pass prediction (`src/data/satellitePass.js`; `getNextSatellitePass`, `getNextIssPass`) scans at 20s, bisects rise/set to ~0.2s, fits the peak with a parabola, and marks a pass visible when the satellite is outside a cylindrical Earth shadow while the observer's Sun is at or below −6°. `next_iss_pass` preserves its geometric-pass ordering and appends visibility metadata. General `next_satellite_pass` accepts a loaded NORAD ID or unambiguous name, searches 24 hours and optionally requires estimated visibility. These estimates do not account for weather or satellite brightness. -- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot; what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name, so they close their cards or let go of their selection as for any other click. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. +- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot; what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name, so they close their cards or let go of their selection as for any other click, but never select, turn on, focus or open the link of a contact, card or camera that lies under the name. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. When no mission is selected, the Space Missions panel presents a scrollable newest-first roster of every launch in the rolling window, including the smaller 5 px operator-colored marker, provider, and launch date. Hovering or keyboard-focusing a row shows four compact cyan corner brackets on both that roster row and its corresponding globe dot, rotates the globe at the current zoom to center it, and gives its label declutter priority without selecting it; the globe label remains unbracketed. Selecting a roster row invokes the same mission isolation and full-orbit framing as clicking its globe marker. The replay vehicle is one screen-space SVG/CSS HUD overlay rather than separate Cesium billboard, label, and reticle graphics. It is hidden during ordinary Focus and manual close views, where the standard selected launch-site label remains visible, and exists only while ascent replay is active. Its fixed pixel scale is shared by ascent and insertion, so camera range never resizes the rocket on screen before the phase boundary. Generic Launch Library pad names are reduced to their identifying suffix, and replay timestamps use a cyan state title over unprefixed white UTC date/time values. `REPLAY ASCENT` holds the unframed cyan/white rocket at the pad for a real-time `T−10` countdown, transitions through `LIFTOFF`, and attaches six tapered cyan/white ellipse waves directly below it from liftoff through insertion to convey thrust without adding scene geometry. While replay is active, the single start button is replaced by compact Play, Pause, and Cancel icon controls. Pause freezes countdown or mission time, vehicle/stage positions, camera target, labels, and thrust-wave animation; Play resumes from that exact frame, and Cancel releases replay camera ownership. The rocket and thrust group rotates from the path's live screen-space tangent, so its nose follows the visible ascent curve while the adjacent text remains upright. The camera begins as a close oblique launch chase, then smoothly widens between roughly 120 and 420 km vehicle altitude into a higher oblique context view that keeps the moving rocket targeted while exposing the ascent bend and orbit connection. At insertion the rocket/thrust glyph is replaced by the fixed-size cyan orbit dot, which the camera follows through the existing globe-scale orbit pullback. The chase camera limits per-frame yaw changes across heading wraps so it cannot abruptly cross in front of the vehicle and make ascent read in reverse; the replay-speed slider affects mission playback but not countdown duration. Mission world text has no native `LabelGraphics`: overview launch markers publish at most 48 ambient candidates for a 24-winner budget, while selecting a mission clears that overview source and publishes its launch-site callout, stage re-entry annotations, live/estimated payload-position readout, and orbit annotation as protected selected-lane entries. The source retains the exact former strings and colors. Static anchors reuse the Cartesian values used to build their mission geometry; the moving payload entry reads the layer's per-frame live-position cache; catalog-backed orbit annotation positions are cached in the same one-second matrix update that realigns the orbit primitive. Keyhole edge fade, horizon culling, final collision placement, and UI exclusion are owned by the shared host. Deselect restores the bounded overview, and refresh, disable, and destroy replace or clear both mission sources. A selected mission renders its orbit as four repeating tactical sectors, each containing one prominent cyan dot followed by one hundred thin translucent dashes. The bright dots act as orbit anchors while the subdued dash field remains depth-tested against the globe and is shown only for the selected mission. diff --git a/scripts/format-scope.json b/scripts/format-scope.json index 78f3edbf24..6b0b12a9a8 100644 --- a/scripts/format-scope.json +++ b/scripts/format-scope.json @@ -1599,5 +1599,7 @@ "src/ui/omnibarRows.test.mjs", "src/ui/styles/omnibar-dock.css", "src/ui/styles/guide.css", - "src/ui/commandDock.test.mjs" + "src/ui/commandDock.test.mjs", + "src/layers/firms/selection.test.mjs", + "src/layers/vessels/selection.test.mjs" ] diff --git a/src/input/dispatcher.js b/src/input/dispatcher.js index 32ae401c47..9baea74c55 100644 --- a/src/input/dispatcher.js +++ b/src/input/dispatcher.js @@ -184,7 +184,9 @@ function topHitOf(hit, foreign) { * engine's pick objects that reads it here. * @property {boolean} overlay Whether a painted overlay target took the * click ({@link InputDispatcher.onOverlayClick}). Its hits then name only - * that target: something drawn outside the draw port, with no id. + * that target: something drawn outside the draw port, with no id. A + * subscriber with its own hit test (painted cards, a pick of its own) + * skips it then: what lies under the target is not clicked. * @property {(width: number, height: number) => unknown} pickWindow * `native.pickWindow`, the same. */ diff --git a/src/input/testDoubles.mjs b/src/input/testDoubles.mjs index 028e88e5fa..6812b2fbd3 100644 --- a/src/input/testDoubles.mjs +++ b/src/input/testDoubles.mjs @@ -140,3 +140,18 @@ export function fakeInput(viewer, { now } = {}) { destroy: () => input.destroy(), }; } + +/** + * `fakeInput` with a label painted over the map, as a Space Missions label + * is: while `label.over` is true the label takes each click, so every click + * subscriber hears it as an overlay click (`event.overlay`), and the + * geometry beneath it is not picked. + * @param {object} viewer + * @param {{now?: () => number}} [options] + */ +export function fakeInputUnderLabel(viewer, options) { + const fake = fakeInput(viewer, options); + const label = { over: false }; + fake.input.onOverlayClick(() => label.over); + return { ...fake, label }; +} diff --git a/src/layers/alpr/presentation.js b/src/layers/alpr/presentation.js index 72aa334c5c..4f9bb80193 100644 --- a/src/layers/alpr/presentation.js +++ b/src/layers/alpr/presentation.js @@ -582,9 +582,10 @@ export function createAlprPresentation({ state, services, source }) { state.clickSubscription = inputFor(viewer).onClick((event) => { if (!state.enabled) return; // The painted overlay answers first; the scene is picked only if not. + // A click a label painted over both took is on neither. const hit = event.drawHit; const id = - overlay.pick(event.screenPosition) || + (!event.overlay && overlay.pick(event.screenPosition)) || (hit && hit.set === markers.icons?.id ? hit.id : null); if ( id && diff --git a/src/layers/cctv/lifecycle.js b/src/layers/cctv/lifecycle.js index 233a2b38e7..f6f8ca4c57 100644 --- a/src/layers/cctv/lifecycle.js +++ b/src/layers/cctv/lifecycle.js @@ -411,12 +411,15 @@ export function createLifecycle({ // painted ambient cards. The cards canvas is pointer-events:none (this // handler owns the events), so a click landing on a card's rect selects // its camera exactly like a click on the icon. Click positions - // and the recorded rects are both CSS px — direct comparison. - const cardId = layerState._cctvOverlayHost.hitTest( - event.screenPosition.x, - event.screenPosition.y, - { sourceId: CCTV_OVERLAY_SOURCE_ID }, - )?.entryId; + // and the recorded rects are both CSS px — direct comparison. A + // click a label painted over the cards took is not on a card. + const cardId = event.overlay + ? null + : layerState._cctvOverlayHost.hitTest( + event.screenPosition.x, + event.screenPosition.y, + { sourceId: CCTV_OVERLAY_SOURCE_ID }, + )?.entryId; if (cardId && layerState._recordById.has(cardId)) { activateCctvCameraFromWorldClick( cardId, diff --git a/src/layers/cctv/lifecycle.test.mjs b/src/layers/cctv/lifecycle.test.mjs index 205997721b..f2b5411e2e 100644 --- a/src/layers/cctv/lifecycle.test.mjs +++ b/src/layers/cctv/lifecycle.test.mjs @@ -3,6 +3,9 @@ import assert from 'node:assert/strict'; import { createLifecycle } from './lifecycle.js'; import { bindRenderer } from '../../render/rendererOf.js'; import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs'; +import { CCTV_OVERLAY_SOURCE_ID } from '../../data/cctvCards.js'; +import { resolvePickId } from '../../data/pickRegistry.js'; +import { fakeInputUnderLabel } from '../../input/testDoubles.mjs'; function viewerWithCamera() { const camera = fakeCameraPort(); @@ -72,3 +75,81 @@ test('the view listeners follow the camera port and let go on teardown', () => { assert.deepEqual(counts(second.camera), [0, 0]); assert.equal(state._viewListenerCamera, null); }); + +/** A part whose members are `own`'s, and any other a function that does + * nothing. */ +const inert = (own = {}) => + new Proxy(own, { + get: (target, name) => (name in target ? target[name] : () => {}), + }); + +test("a click a label painted over a camera's card takes never turns that camera on, and lets go of the active one", async (t) => { + const { viewer } = viewerWithCamera(); + viewer.scene = { canvas: {}, pick: () => null }; + const fake = fakeInputUnderLabel(viewer); + t.after(() => fake.destroy()); + const activated = []; + const deactivated = []; + const state = {}; + const lifecycle = createLifecycle({ + state, + services: { + activation: { + activateCctvCameraFromWorldClick: (id) => activated.push(id), + }, + picking: { resolvePickId }, + focus: {}, + render: {}, + }, + parts: { + calibration: { loadCalibrationStore: () => new Map() }, + catalog: { + loadCameraSources: async () => [], + buildCatalogFromSources: () => [], + seedCatalog: () => [], + }, + ground: { + resolveGroundPriors: async () => [], + currentSurfaceRegime: () => null, + }, + rendering: inert({ refreshHorizonCulling: () => false }), + health: { syncHealthState: async () => {} }, + geometryQueue: inert(), + cards: inert(), + projection: inert(), + presentation: inert(), + navigation: inert(), + hover: inert(), + selection: { + // The camera's own gate takes only clean clicks; these are. + bindCctvWorldClickGesture: (input, onClick) => input.onClick(onClick), + extractPickedCameraId: () => null, + cctvEmptyClickDeselects: (picked, { activeCameraId }) => + Boolean(activeCameraId) && resolvePickId(picked) === null, + deactivateActiveCamera: () => deactivated.push(state._activeCameraId), + }, + }, + }); + // Init's bounded wait for ground heights never runs out here: they are in. + t.mock.timers.enable({ apis: ['setTimeout'] }); + await lifecycle.methods.init(viewer); + t.after(() => state._clickSubscription?.()); + state._enabled = true; + state._activeCameraId = 'cam-0'; + state._recordById.set('cam-1', {}); + // The card of camera `cam-1` lies under every click. + state._cctvOverlayHost = { + hitTest: (_x, _y, { sourceId }) => + sourceId === CCTV_OVERLAY_SOURCE_ID ? { entryId: 'cam-1' } : null, + }; + + fake.label.over = true; + fake.click(); + assert.deepEqual(activated, [], 'the camera under the label stays off'); + assert.deepEqual(deactivated, ['cam-0'], 'the active camera is let go'); + + // Off the label, a click on the card turns its camera on. + fake.label.over = false; + fake.click(); + assert.deepEqual(activated, ['cam-1']); +}); diff --git a/src/layers/droneAirspace/index.js b/src/layers/droneAirspace/index.js index 8bb8b72423..899a4c8b51 100644 --- a/src/layers/droneAirspace/index.js +++ b/src/layers/droneAirspace/index.js @@ -130,11 +130,14 @@ export function createDroneAirspaceLayer({ // cards inert anywhere over a zone. Unowned, our picks read as // "empty space" to siblings — the same contract as fire perimeters. _clickSubscription = inputFor(_viewer).onClick((event) => { - const cardHit = overlayHost.hitTest?.( - event.screenPosition?.x, - event.screenPosition?.y, - { sourceId: DRONE_AIRSPACE_OVERLAY_SOURCE_ID }, - ); + // 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: DRONE_AIRSPACE_OVERLAY_SOURCE_ID }, + ); if (cardHit && cardHit.entryId === _selectedCardId) return; const picked = event.topHit; const zoneId = picked ? pickedZoneId(event.drawHit) : null; diff --git a/src/layers/firms/selection.js b/src/layers/firms/selection.js index db80cef722..67f772361a 100644 --- a/src/layers/firms/selection.js +++ b/src/layers/firms/selection.js @@ -46,13 +46,16 @@ export function createSelection({ const pickedId = resolvePickId(picked); if (pickedId && isOwnedByOtherLayer(id, pickedId)) return; } - const cardHit = overlayHost.hitTest?.( - event.screenPosition?.x, - event.screenPosition?.y, - { - sourceId: FIRMS_OVERLAY_SOURCE_ID, - }, - ); + // 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); diff --git a/src/layers/firms/selection.test.mjs b/src/layers/firms/selection.test.mjs new file mode 100644 index 0000000000..19dae5ffca --- /dev/null +++ b/src/layers/firms/selection.test.mjs @@ -0,0 +1,80 @@ +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 { 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. */ +function selectionHarness(t) { + const viewer = { scene: { canvas: {}, pick: () => null } }; + const fake = fakeInputUnderLabel(viewer); + t.after(() => fake.destroy()); + const fire = { lat: 1, lon: 2, acqMs: 3, frp: 40, satellite: 'N' }; + const focused = []; + const cleared = []; + const layerState = { + _viewer: viewer, + _icons: { id: 'firms:icons' }, + _pickIndexById: new Map(), + _fireByCardId: new Map([['firms-card:1', fire]]), + _selectedFire: null, + _contextIds: new Set(), + }; + const selection = createSelection({ + layerState, + services: { + picking: { resolvePickId, isOwnedByOtherLayer: () => false }, + focus: { requestWorldFocus: (request) => focused.push(request.kind) }, + context: { + selectEntityContext() {}, + clearSelectedEntityContextForLayer: (id) => cleared.push(id), + getContextStore() {}, + registerEntityContext() {}, + }, + }, + components: { + model: { + firePosition: () => ({ x: 0, y: 0, z: 0 }), + formatFrp: String, + confidenceBucket: String, + }, + cards: { rebuildAmbientLabels() {} }, + }, + config: { + id: 'firms', + name: 'Fires', + overlayHost: { + hitTest: (_x, _y, { sourceId }) => + sourceId === FIRMS_OVERLAY_SOURCE_ID + ? { entryId: 'firms-card:1' } + : null, + }, + }, + }); + selection.installClickHandler(); + t.after(() => selection.removeClickHandler()); + 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) => { + const h = selectionHarness(t); + h.fake.label.over = true; + h.fake.click(); + assert.equal(h.layerState._selectedFire, null); + 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) => { + 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']); + h.fake.label.over = true; + h.fake.click(); + assert.equal(h.layerState._selectedFire, null); + assert.deepEqual(h.cleared, ['firms']); + assert.deepEqual(h.focused, ['fire']); +}); diff --git a/src/layers/ghostMaps/index.js b/src/layers/ghostMaps/index.js index df94883845..4d218032ed 100644 --- a/src/layers/ghostMaps/index.js +++ b/src/layers/ghostMaps/index.js @@ -707,11 +707,14 @@ export function createGhostMapsLayer({ typeof pickedId === 'string' && pickedId.startsWith(PICK_PREFIX), ); _clickSubscription = inputFor(_viewer).onClick((event) => { - const cardHit = overlayHost.hitTest?.( - event.screenPosition?.x, - event.screenPosition?.y, - { sourceId: GHOSTMAPS_OVERLAY_SOURCE_ID }, - ); + // 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: GHOSTMAPS_OVERLAY_SOURCE_ID }, + ); if (cardHit && cardHit.entryId === _selectedCardId) { if (_selectedLink && openExternal) openExternal(_selectedLink); return; diff --git a/src/layers/localAdsb/index.js b/src/layers/localAdsb/index.js index 4d550bd08a..fcc83c9f72 100644 --- a/src/layers/localAdsb/index.js +++ b/src/layers/localAdsb/index.js @@ -8,12 +8,7 @@ import { } from '../../data/screenRotation.js'; import { fromDegreesInto, toLonLatH } from '../../geo/ellipsoid.js'; import { hexColor } from '../../render/color.js'; -import { - drawOf, - findCamera, - findFrame, - findQuery, -} from '../../render/rendererOf.js'; +import { drawOf, findCamera, findFrame } from '../../render/rendererOf.js'; import { inputFor } from '../../input/dispatcher.js'; import { pickRenderAltitudeM } from '../../data/renderAltitude.js'; import { routePlausible } from '../../data/routePlausible.js'; @@ -682,10 +677,8 @@ export function createLocalAdsbLayer({ if (ownedElsewhere(topId) && !trail) return 'other'; let hits = []; try { - hits = - findQuery(viewer)?.drillPick(event.position.x, event.position.y, { - limit: CLICK_DRILL_LIMIT, - }) ?? []; + // The click's own drill: none under a label painted over the map. + hits = event.drill(CLICK_DRILL_LIMIT); } catch { hits = []; } diff --git a/src/layers/localAdsb/index.test.mjs b/src/layers/localAdsb/index.test.mjs index 3e53c9bbeb..4bce75250a 100644 --- a/src/layers/localAdsb/index.test.mjs +++ b/src/layers/localAdsb/index.test.mjs @@ -17,6 +17,7 @@ import { createLocalAdsbModels } from './models.js'; import { entityRecord, readEntityRecord } from '../../data/entityRecords.js'; import { resolvePickId } from '../../data/pickRegistry.js'; import { fromDegrees, toLonLatH } from '../../geo/ellipsoid.js'; +import { inputFor } from '../../input/dispatcher.js'; import { fakeInput } from '../../input/testDoubles.mjs'; import { hexColor } from '../../render/color.js'; import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs'; @@ -1174,7 +1175,8 @@ function iconPick(draw, id) { return { primitive: {}, id: { set: layerSet(draw, ':markers').spec.id, id } }; } -/** A viewer with a canvas and scripted picks, plus the layer's click action. */ +/** A viewer with a canvas and scripted picks, plus the layer's click action. + * A click drills through the viewer's `drillHits`. */ function clickHarness() { const scene = { canvas: {}, @@ -1182,6 +1184,8 @@ function clickHarness() { pick() { return scene.pickResult; }, + drillPick: () => + (base.viewer.drillHits ?? []).map((hit) => ({ primitive: {}, id: hit })), }; const base = fakeViewer({ scene }); return { @@ -1265,6 +1269,39 @@ test('a click on a local aircraft under an unowned or trail pick still selects i assert.equal(calls.selected.length, 2, 'the Flights contact is not taken'); }); +test('a click a label painted over a local aircraft takes never selects the aircraft, and lets go of the selection', async (t) => { + const receiver = fakeReceiver({ mode: 'adsb', connected: true }); + const clock = { now: 100_000 }; + const harness = clickHarness(); + const { layer, calls, draw } = await enabledLayer(receiver, clock, null, { + viewer: harness.viewer, + }); + t.after(() => layer.destroy()); + receiver.set({ aircraft: [record()] }); + await layer.update(); + const label = { over: true }; + inputFor(harness.viewer.viewer).onOverlayClick(() => label.over); + const model = { + set: layerSet(draw, ':models').spec.id, + id: 'local-adsb:abc123', + surface: false, + }; + // The aircraft is under the label, both exactly and in the drill. + harness.scene.pickResult = iconPick(draw, 'local-adsb:abc123'); + harness.viewer.viewer.drillHits = [model]; + harness.click(); + assert.deepEqual(calls.selected, [], 'the aircraft beneath is not taken'); + + // Off the label the same click selects it; on the label it lets go. + label.over = false; + harness.click(); + assert.deepEqual(calls.selected, ['local-adsb:abc123']); + label.over = true; + harness.click(); + assert.deepEqual(calls.selected, ['local-adsb:abc123']); + assert.equal(calls.cleared.length, 1, 'the selection is released'); +}); + test('a grounded aircraft changing type keeps its drawn model on its own belly offset until the new one is ready', () => { const { draw, viewer, camera } = modelViewer(); const models = createLocalAdsbModels({ diff --git a/src/layers/news/index.js b/src/layers/news/index.js index 4ad5826c27..4e4afc9818 100644 --- a/src/layers/news/index.js +++ b/src/layers/news/index.js @@ -1348,9 +1348,12 @@ export function createNewsLayer({ clickOff = inputFor(viewer).onClick((event) => { const at = event?.screenPosition; if (!enabled || destroyed || !isPointerFree() || !at) return; - const card = hitTestOverlay(at.x, at.y, { - sourceId: NEWS_OVERLAY_SOURCE_ID, - }); + // A click a label painted over the cards took is not on a card. + const card = event.overlay + ? null + : hitTestOverlay(at.x, at.y, { + sourceId: NEWS_OVERLAY_SOURCE_ID, + }); if (card?.entry?.activate) { card.entry.activate(); return; diff --git a/src/layers/perimeters/index.js b/src/layers/perimeters/index.js index 3a5a180c48..460c7c534d 100644 --- a/src/layers/perimeters/index.js +++ b/src/layers/perimeters/index.js @@ -218,11 +218,14 @@ export function createFirePerimetersLayer({ _clickSubscription = inputFor(_viewer).onClick((event) => { // A click on the incident card itself opens its InciWeb page (when the // incident has one) and never disturbs the selection. - const cardHit = overlayHost.hitTest?.( - event.screenPosition?.x, - event.screenPosition?.y, - { sourceId: PERIMETER_OVERLAY_SOURCE_ID }, - ); + // 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: PERIMETER_OVERLAY_SOURCE_ID }, + ); if (cardHit && cardHit.entryId === _selectedCardId) { if (_selectedLink && openExternal) openExternal(_selectedLink); return; diff --git a/src/layers/shipwrecks/index.js b/src/layers/shipwrecks/index.js index c2c2db2814..c61a956a04 100644 --- a/src/layers/shipwrecks/index.js +++ b/src/layers/shipwrecks/index.js @@ -278,9 +278,12 @@ export function createShipwrecksLayer({ _clickHandler = clicks.onClick((click) => { if (pointer && !pointer.isPointerFree()) return; const at = click.screenPosition; - const cardHit = overlayHost.hitTest?.(at?.x, at?.y, { - sourceId: SHIPWRECKS_OVERLAY_SOURCE_ID, - }); + // A click a label painted over the cards took is not on a card. + const cardHit = click.overlay + ? null + : overlayHost.hitTest?.(at?.x, at?.y, { + sourceId: SHIPWRECKS_OVERLAY_SOURCE_ID, + }); if (cardHit && cardHit.entryId === _selectedCardId) { if (_selectedLink) openExternal(_selectedLink); return; diff --git a/src/layers/shipwrecks/index.test.mjs b/src/layers/shipwrecks/index.test.mjs index 7d69f2b457..b2e45a68a1 100644 --- a/src/layers/shipwrecks/index.test.mjs +++ b/src/layers/shipwrecks/index.test.mjs @@ -2,6 +2,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs'; import * as picking from '../../data/pickRegistry.js'; +import { fakeInputUnderLabel } from '../../input/testDoubles.mjs'; import { createShipwrecksLayer, markerPixelSize, @@ -393,3 +394,51 @@ test('the page deadline subtracts the newest available source age from the limit ); assert.equal(snapshotDeadline({ sources: both }, 0), 7 * DAY, 'defaults'); }); + +test("a click a label painted over the open card takes never opens the card's link, and closes the card", async (t) => { + let picked = null; + const viewer = { scene: { canvas: {}, pick: () => picked } }; + bindFakeDraw(viewer); + const fake = fakeInputUnderLabel(viewer); + t.after(() => fake.destroy()); + const cards = []; + const opened = []; + let cardUnder = null; + const layer = createShipwrecksLayer({ + source: { getSnapshot: () => Promise.resolve(snapshot([wreck('a')])) }, + overlayHost: { + setEntries: (_source, entries) => cards.push(entries), + setVisible() {}, + hitTest: () => (cardUnder ? { entryId: cardUnder } : null), + }, + input: () => fake.input, + picking, + pointer: { isPointerFree: () => true }, + openExternal: (url) => opened.push(url), + now: () => 1, + }); + layer.init(viewer); + t.after(() => layer.destroy()); + layer.enable(); + await layer.update(); + picked = { primitive: {}, id: { set: 'shipwrecks:', id: 'shipwreck:a' } }; + fake.click(); + const [card] = cards.at(-1); + assert.equal(card.id, 'shipwreck-card:a'); + + // The open card lies under the label: the click opens nothing. + picked = null; + cardUnder = card.id; + fake.label.over = true; + fake.click(); + assert.deepEqual(opened, [], 'the link beneath the label is not opened'); + assert.deepEqual(cards.at(-1), [], 'the card is closed'); + + // Off the label, a click on the open card opens its link. + fake.label.over = false; + picked = { primitive: {}, id: { set: 'shipwrecks:', id: 'shipwreck:a' } }; + fake.click(); + picked = null; + fake.click(); + assert.equal(opened.length, 1); +}); diff --git a/src/layers/vessels/selection.js b/src/layers/vessels/selection.js index 7f8ddab832..e3009a1073 100644 --- a/src/layers/vessels/selection.js +++ b/src/layers/vessels/selection.js @@ -64,17 +64,19 @@ export function createSelection({ // Cards are painted on a pointer-events:none canvas, so the scene pick is // usually terrain behind the card. Resolve against the host's current // actionable hit rectangles before treating the click as empty space. - const cardHit = !record - ? vesselState._vesselOverlayHost.hitTest?.( - event.screenPosition?.x, - event.screenPosition?.y, - { - ...(cycloneBackground - ? {} - : { sourceId: VESSEL_OVERLAY_SOURCE_ID }), - }, - ) - : null; + // A click a label painted over the cards took is not on a card. + const cardHit = + !record && !event.overlay + ? vesselState._vesselOverlayHost.hitTest?.( + event.screenPosition?.x, + event.screenPosition?.y, + { + ...(cycloneBackground + ? {} + : { sourceId: VESSEL_OVERLAY_SOURCE_ID }), + }, + ) + : null; if (cycloneBackground && cardHit?.sourceId !== VESSEL_OVERLAY_SOURCE_ID) return; if (!record && cardHit) { diff --git a/src/layers/vessels/selection.test.mjs b/src/layers/vessels/selection.test.mjs new file mode 100644 index 0000000000..941b7118d9 --- /dev/null +++ b/src/layers/vessels/selection.test.mjs @@ -0,0 +1,89 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { VESSEL_OVERLAY_SOURCE_ID } from '../../data/vesselLabels.js'; +import { fakeInputUnderLabel } from '../../input/testDoubles.mjs'; +import { createSelection } from './selection.js'; + +/** Calls on any member are recorded by name and do nothing else. */ +function recorder(calls) { + return new Proxy( + {}, + { + get: + (_target, name) => + (...args) => + calls.push([name, ...args]), + }, + ); +} + +/** The vessel selection over a viewer whose clicks a label may take. */ +function selectionHarness(t) { + const viewer = { scene: { canvas: {}, pick: () => null } }; + const fake = fakeInputUnderLabel(viewer); + t.after(() => fake.destroy()); + const vessel = { id: 'v1', name: 'NORTHERN STAR', lat: 0, lon: 0 }; + const focused = []; + const calls = []; + const state = { + feed: { enabled: true }, + records: { byId: new Map([[vessel.id, vessel]]) }, + icons: { setId: 'vessels:icons', has: () => false }, + selectedRecord: null, + interactionKeyTarget: new EventTarget(), + }; + const vesselState = { + state, + // The vessel's card lies under the click. + _vesselOverlayHost: { + hitTest: (_x, _y, { sourceId } = {}) => + sourceId === VESSEL_OVERLAY_SOURCE_ID + ? { sourceId, entryId: `vessel:${vessel.id}` } + : null, + }, + }; + const selection = createSelection({ + vesselState, + services: { + picking: { isOwnedByOtherLayer: () => false }, + worldFocus: { requestWorldFocus: (request) => focused.push(request.id) }, + context: recorder(calls), + }, + parts: { + queries: { + reduceVesselSelection: ({ selectedId, pickedId }) => + pickedId + ? { action: pickedId === selectedId ? 'none' : 'select' } + : { action: selectedId ? 'deselect' : 'none' }, + }, + rendering: recorder(calls), + cards: recorder(calls), + photos: recorder(calls), + tracking: recorder(calls), + }, + layer: { source: 'AIS' }, + }); + selection.installInteraction(viewer); + t.after(() => selection.removeVesselInteraction()); + return { fake, state, vessel, focused }; +} + +test("a click a label painted over a vessel's card takes never selects or focuses the vessel", (t) => { + const h = selectionHarness(t); + h.fake.label.over = true; + h.fake.click(); + assert.equal(h.state.selectedRecord, null); + assert.deepEqual(h.focused, [], 'the camera is not sent to the vessel'); +}); + +test('a click a label painted over the map takes lets go of the selected vessel', (t) => { + const h = selectionHarness(t); + // Off the label, a click on the card selects and focuses its vessel. + h.fake.click(); + assert.equal(h.state.selectedRecord, h.vessel); + assert.deepEqual(h.focused, ['v1']); + h.fake.label.over = true; + h.fake.click(); + assert.equal(h.state.selectedRecord, null); + assert.deepEqual(h.focused, ['v1']); +}); diff --git a/src/layers/wildlifeSightings/selection.js b/src/layers/wildlifeSightings/selection.js index dc0b7c126c..7db90766aa 100644 --- a/src/layers/wildlifeSightings/selection.js +++ b/src/layers/wildlifeSightings/selection.js @@ -483,16 +483,18 @@ export function createSelection({ state, services, parts }) { 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 = - overlay?.hitTest?.(at?.x, at?.y, { + !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, - }); + overlay?.hitTest?.(at?.x, at?.y, { + sourceId: WILDLIFE_OVERLAY_SOURCE_ID, + }) || + overlay?.hitTest?.(at?.x, at?.y, { + sourceId: WILDLIFE_LABEL_SOURCE_ID, + })); if (hit) { hit.entry?.activate?.(); return; diff --git a/src/ui/cockpitController.js b/src/ui/cockpitController.js index 6bdd97f5f0..6139e51bf3 100644 --- a/src/ui/cockpitController.js +++ b/src/ui/cockpitController.js @@ -483,10 +483,12 @@ export class CockpitViewController { * A click on the orbital picture: on a mapped point in reach it keeps the * camera on that point; anywhere else it ends such a focus. * @param {{x: number, y: number}|null|undefined} position + * @param {{overlay?: boolean}} [options] `overlay`: a label painted over + * the map took the click, which then only ends a focus. * @returns {boolean} True when the click focused a point. */ - onOrbitalClick(position) { - return onOrbitalClick.call(this, position); + onOrbitalClick(position, options) { + return onOrbitalClick.call(this, position, options); } /** * A double-click on the orbital picture: on a mapped ground point it keeps diff --git a/src/ui/cockpitOrbitalFocus.js b/src/ui/cockpitOrbitalFocus.js index 5b97c34838..7452f47901 100644 --- a/src/ui/cockpitOrbitalFocus.js +++ b/src/ui/cockpitOrbitalFocus.js @@ -256,13 +256,16 @@ export function onOrbitalDoubleClick(position) { * focuses it; any other click ends a focus. A click a tool owns (drawing) * is left alone, as is every click outside orbit. * @param {{x: number, y: number}|null|undefined} position Canvas position. + * @param {{overlay?: boolean}} [options] `overlay`: a label painted over the + * map took the click, so it is on no site and only ends a focus. * @returns {boolean} True when the click focused a point. */ -export function onOrbitalClick(position) { +export function onOrbitalClick(position, { overlay = false } = {}) { if (!inOrbit(this) || !isPointerFree()) return false; if (!Number.isFinite(position?.x) || !Number.isFinite(position?.y)) return false; - const site = siteAt(this, position); + // A click a label painted over the map took is on no site. + const site = overlay ? null : siteAt(this, position); const state = this.orbital; if (site) { if (state.focus?.key === String(site.id)) return true; @@ -286,7 +289,9 @@ export function routeSceneClick() { // A viewer with no input (headless tools, partial stubs) has no clicks. return () => {}; } - return input.onClick((event) => this.onOrbitalClick(event?.position)); + return input.onClick((event) => + this.onOrbitalClick(event?.position, { overlay: event?.overlay === true }), + ); } /** From 71229c85496092410c4e259d415a890391b145d1 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:08:00 -0800 Subject: [PATCH 05/15] Add the changelog entry for the Space Missions fixes Co-authored-by: Manjunath Paparaju --- changelog.d/1829-space-missions-fixes.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog.d/1829-space-missions-fixes.md diff --git a/changelog.d/1829-space-missions-fixes.md b/changelog.d/1829-space-missions-fixes.md new file mode 100644 index 0000000000..621df858c2 --- /dev/null +++ b/changelog.d/1829-space-missions-fixes.md @@ -0,0 +1,6 @@ +- Space Missions finishes switching off before anything else runs: a launch + hovered while the layer is going off shows no preview, and Satellites + keeps the state it was saved with when it is still busy. A click on a + mission label reaches every layer so each can let go of what it had + selected, and none of them selects, turns on, flies to or opens the link + of what lies under the label (manjunath22466, samehkhamis, #1829). From 74d38e6d1473367628791de732749e13ca0404a9 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:14:04 -0800 Subject: [PATCH 06/15] Switch Satellites on again when Space Missions returns after a busy restore A restore that found Satellites still busy keeps the saved state, and the next Space Missions start then skipped switching Satellites on, so it came up with no satellites. It now keeps that saved state (still the one from before the mission) and switches Satellites on for the mission again. Co-authored-by: Manjunath Paparaju --- src/layers/launches/failedEntry.test.mjs | 38 ++++++++++++++++++++++++ src/layers/launches/ingestion.js | 18 ++++++----- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/layers/launches/failedEntry.test.mjs b/src/layers/launches/failedEntry.test.mjs index eba7a917f9..1458da4670 100644 --- a/src/layers/launches/failedEntry.test.mjs +++ b/src/layers/launches/failedEntry.test.mjs @@ -632,6 +632,44 @@ test('a Satellites enable that never settles still lets mission disable complete assert.equal(f.manager.isEnabled('satellites'), false); }); +test('Space Missions turned on again after a busy restore switches Satellites on', async (t) => { + const f = await fixture(t); + f.upstream.status = 200; + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + f.state.satelliteSettleTimeoutMs = 50; + const satellites = f.manager.layers.get('satellites').module; + const enable = satellites.enable; + const stuck = Promise.withResolvers(); + satellites.enable = () => stuck.promise; + try { + await f.manager.setEnabled('satellites', false); + void f.manager.setEnabled('satellites', true); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + } finally { + satellites.enable = enable; + stuck.resolve(); + } + await f.settle(); + // Something else switches Satellites off, then Space Missions comes back. + await f.manager.setEnabled('satellites', false); + await f.settle(); + assert.equal(f.manager.isEnabled('satellites'), false); + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + assert.equal(f.manager.isEnabled('satellites'), true); + // Its own off still gives back the Satellites from before the first start. + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + await f.settle(); + assert.equal(f.manager.isEnabled('satellites'), false); +}); + test('a failed Satellites restore still clears the selected mission panel', async (t) => { const f = await fixture(t); f.upstream.status = 200; diff --git a/src/layers/launches/ingestion.js b/src/layers/launches/ingestion.js index d328700b2f..58135ad991 100644 --- a/src/layers/launches/ingestion.js +++ b/src/layers/launches/ingestion.js @@ -108,7 +108,7 @@ export function createIngestion({ async function captureSatelliteDependency() { const manager = layerState._dataManager; - if (!manager || layerState._satelliteStateBeforeMission) return; + if (!manager) return; const token = layerState._lifecycleToken; // Let a pending Satellites action finish before reserving dependency ON. // A successful explicit OFF can cancel this mission entry while we wait. @@ -127,12 +127,16 @@ export function createIngestion({ !manager.isEffectivelyEnabled('rocket-launches')) ) return; - layerState._satelliteStateBeforeMission = { - enabled: manager.isEnabled('satellites'), - params: parts.policyHelpers.satelliteParamsAfterSpaceMissions( - manager.getLayerParams('satellites'), - ), - }; + // A saved state kept by a restore that could not finish (Satellites was + // busy) is still the one from before the mission: keep it, and switch + // Satellites on for the mission again. + if (!layerState._satelliteStateBeforeMission) + layerState._satelliteStateBeforeMission = { + enabled: manager.isEnabled('satellites'), + params: parts.policyHelpers.satelliteParamsAfterSpaceMissions( + manager.getLayerParams('satellites'), + ), + }; manager.setLayerParams( 'satellites', parts.policyHelpers.satelliteParamsForSpaceMissions( From c53a6d1c51e301d63543264da790c03acc5fd115 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:23:35 -0800 Subject: [PATCH 07/15] Test that a mission label's click never acts on the card or reader beneath it ALPR, News, Wildlife Sightings, Fire Perimeters, GhostMaps and Drone Airspace each skip their own card or overlay hit test when a painted label took the click. Each now has a test that a click the label took does not select the camera or sighting, open the report, or open the card's link, and lets go of the current selection, while the same click off the label still acts. ALPR's presentation gets its first test file. Co-authored-by: Manjunath Paparaju --- scripts/format-scope.json | 1 + src/layers/alpr/presentation.test.mjs | 122 ++++++++++++++++++ src/layers/droneAirspace/ownership.test.mjs | 38 +++++- src/layers/ghostMaps/lifecycle.test.mjs | 47 +++++++ src/layers/news/layer.test.mjs | 45 ++++++- src/layers/perimeters/ownership.test.mjs | 56 +++++++- .../wildlifeSightings/selection.test.mjs | 30 +++++ 7 files changed, 331 insertions(+), 8 deletions(-) create mode 100644 src/layers/alpr/presentation.test.mjs diff --git a/scripts/format-scope.json b/scripts/format-scope.json index 6b0b12a9a8..ccf8f554c6 100644 --- a/scripts/format-scope.json +++ b/scripts/format-scope.json @@ -660,6 +660,7 @@ "src/layers/alpr/model.js", "src/layers/alpr/policy.js", "src/layers/alpr/presentation.js", + "src/layers/alpr/presentation.test.mjs", "src/layers/alpr/visuals.js", "src/layers/alpr/overlay.js", "src/layers/alpr/overlay.test.mjs", diff --git a/src/layers/alpr/presentation.test.mjs b/src/layers/alpr/presentation.test.mjs new file mode 100644 index 0000000000..223083a150 --- /dev/null +++ b/src/layers/alpr/presentation.test.mjs @@ -0,0 +1,122 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import * as Cesium from 'cesium'; +import { fakeInputUnderLabel } from '../../input/testDoubles.mjs'; +import { fakeDrawPort } from '../../testSupport/fakeDrawPort.mjs'; +import { bindFakeCesiumScene } from '../../testSupport/fakeCesiumScene.mjs'; +import { createAlprMarkerSet } from './markerState.js'; +import { createAlprPresentation } from './presentation.js'; + +/** One camera drawn and painted at (100, 100), over a viewer whose clicks a + * label may take. */ +function harness(t) { + const previousImage = globalThis.Image; + const project = Cesium.SceneTransforms.worldToWindowCoordinates; + globalThis.Image = class { + complete = true; + naturalWidth = 128; + }; + Cesium.SceneTransforms.worldToWindowCoordinates = () => ({ x: 100, y: 100 }); + const record = { + id: 'camera:0', + latitude: 30, + longitude: -97, + directionDeg: 90, + }; + const drawPort = fakeDrawPort(); + const markers = createAlprMarkerSet(); + markers.attach(drawPort.icons({ id: 'alpr-cameras:test:markers' })); + const viewer = { + camera: { + positionWC: Cesium.Cartesian3.fromDegrees(-97, 30, 500), + pickEllipsoid: () => Cesium.Cartesian3.fromDegrees(-97, 30), + }, + scene: { + canvas: { clientWidth: 800, clientHeight: 600 }, + globe: { show: true, getHeight: () => 150 }, + pick: () => null, + }, + }; + const { unbind } = bindFakeCesiumScene(viewer, { draw: drawPort }); + const fake = fakeInputUnderLabel(viewer); + const state = { + viewer, + enabled: true, + selectedId: null, + markers, + records: [record], + recordById: new Map([[record.id, record]]), + renderRevision: 0, + lastAnchorSampleAt: 0, + }; + let selected = null; + let paint; + const presentation = createAlprPresentation({ + state, + source: { label: 'Test cameras' }, + services: { + render: { governorRequestRender() {} }, + context: { + clearSelectedEntityContextForLayer() { + selected = null; + }, + getSelectedEntityContext: () => selected, + registerEntityContext() {}, + removeEntityContextsForLayer() {}, + selectEntityContext(carrier) { + selected = { id: carrier.id, layerId: 'alpr-cameras' }; + }, + }, + groundFloor: { cachedGroundFloor: () => 150 }, + overlays: { + registerPaintLane(_lane, painter) { + paint = painter; + return { setActive() {}, requestPaint() {}, unregister() {} }; + }, + keyholeAlpha: () => 1, + }, + }, + }); + presentation.initOverlay(); + presentation.installInteraction(viewer); + t.after(() => { + presentation.destroyOverlay(); + fake.destroy(); + unbind(); + if (previousImage === undefined) delete globalThis.Image; + else globalThis.Image = previousImage; + Cesium.SceneTransforms.worldToWindowCoordinates = project; + }); + presentation.renderRecords(); + const ctx = { + globalAlpha: 1, + save() {}, + restore() {}, + beginPath() {}, + moveTo() {}, + lineTo() {}, + closePath() {}, + stroke() {}, + fill() {}, + createLinearGradient: () => ({ addColorStop() {} }), + drawImage() {}, + }; + paint({ ctx, width: 800, height: 600 }); + return { state, fake, at: { x: 100, y: 100 } }; +} + +test('a click a label painted over a camera takes never selects it, and lets go of the selected camera', (t) => { + const h = harness(t); + h.fake.label.over = true; + h.fake.click(h.at); + assert.equal(h.state.selectedId, null, 'the camera under the label'); + + // Off the label, the same click selects the camera. + h.fake.label.over = false; + h.fake.click(h.at); + assert.equal(h.state.selectedId, 'camera:0'); + + h.fake.label.over = true; + h.fake.click(h.at); + assert.equal(h.state.selectedId, null, 'the selection is let go'); +}); diff --git a/src/layers/droneAirspace/ownership.test.mjs b/src/layers/droneAirspace/ownership.test.mjs index 3dbb16a583..2f52148c40 100644 --- a/src/layers/droneAirspace/ownership.test.mjs +++ b/src/layers/droneAirspace/ownership.test.mjs @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import test from 'node:test'; import { createDroneAirspaceLayer } from './index.js'; import { layerFeedState } from '../../data/feedState.js'; -import { fakeInput } from '../../input/testDoubles.mjs'; +import { fakeInputUnderLabel } from '../../input/testDoubles.mjs'; import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs'; // The fills set of the layer the last harness made: zone picks name it. @@ -19,11 +19,12 @@ function harness(source, { pick = () => null, cardHit = () => null } = {}) { const owners = new Map(); const viewer = { scene: { pick } }; const { draw } = bindFakeDraw(viewer); - const input = fakeInput(viewer); + const input = fakeInputUnderLabel(viewer); const clicks = { handler: (click) => input.click(click.position), + // Only the label's own overlay handler is left. get destroyed() { - return input.input.subscriberCount() === 0 ? 1 : 0; + return input.input.subscriberCount() === 1 ? 1 : 0; }, }; const layer = createDroneAirspaceLayer({ @@ -61,6 +62,8 @@ function harness(source, { pick = () => null, cardHit = () => null } = {}) { overlay, clicks, owners, + /** A label painted over the map: while `over`, it takes each click. */ + label: input.label, }; } @@ -143,6 +146,35 @@ test('clicking a zone publishes its card; empty space clears it', async () => { assert.equal(h.overlay.entries.get('drone-airspace')?.length ?? 0, 0); }); +test('a click a label painted over the open zone card takes closes the card, as a click beside it does', async () => { + let pickResult = null; + let cardHitResult = null; + const h = harness( + { getSnapshot: async () => [row] }, + { pick: () => pickResult, cardHit: () => cardHitResult }, + ); + await h.layer.update(h.viewer); + pickResult = zonePick('drone-airspace:310:0'); + h.clicks.handler({ position: { x: 10, y: 10 } }); + const [card] = h.overlay.entries.get('drone-airspace'); + + // Off the label, a click on the open card keeps it open. + pickResult = null; + cardHitResult = { entryId: card.id }; + h.clicks.handler({ position: { x: 12, y: 12 } }); + assert.equal(h.overlay.entries.get('drone-airspace')?.length, 1); + + // The open card lies under the label: the click is not on the card. + h.label.over = true; + h.clicks.handler({ position: { x: 12, y: 12 } }); + assert.equal( + h.overlay.entries.get('drone-airspace')?.length ?? 0, + 0, + 'the card is closed', + ); + h.layer.destroy(); +}); + test('late refresh cannot publish after disable or destroy', async () => { for (const action of ['disable', 'destroy']) { let resolve, signal; diff --git a/src/layers/ghostMaps/lifecycle.test.mjs b/src/layers/ghostMaps/lifecycle.test.mjs index 675bdefa24..e1276f963c 100644 --- a/src/layers/ghostMaps/lifecycle.test.mjs +++ b/src/layers/ghostMaps/lifecycle.test.mjs @@ -3,6 +3,7 @@ import test from 'node:test'; import { setLocale } from '../../i18n/index.js'; import { createGhostMapsLayer } from './index.js'; import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs'; +import { inputFor } from '../../input/dispatcher.js'; import { GHOSTMAPS_PRODUCTS, GHOSTMAPS_LATEST_DROP } from './catalog.js'; function element(localName, children = [], value = '', attributes = {}) { @@ -672,3 +673,49 @@ test('narrowing to a window the loaded data covers clears a failed wider reload' assert.equal(layer.getStats().error, null); assert.equal(layer.getStats().count, 1); }); + +test("a click a label painted over the open card takes never opens the card's link, and closes the card", async (t) => { + const cards = []; + const opened = []; + let cardUnder = null; + const { layer, viewer, click } = fixture(t, { + now: () => Date.UTC(2026, 10, 3, 12), + reports: [ + { + name: 'Linked', + description: + '' + + '
Date11/2/2026
Sourcereport
', + }, + ], + controls: { + overlayHost: { + setEntries: (_id, entries) => cards.push(entries), + hitTest: () => (cardUnder ? { entryId: cardUnder } : null), + }, + picking: { resolvePickId: (picked) => picked?.id ?? null }, + openExternal: (url) => opened.push(url), + }, + }); + // A label painted over the map, as a Space Missions label is: while it is + // over, it takes each click. + let labelOver = false; + inputFor(viewer).onOverlayClick(() => labelOver); + await layer.update(viewer); + click('ghostmaps:cip:0:0'); + const [card] = cards.at(-1); + assert.equal(card.interactive, true); + + // The open card lies under the label: the click opens nothing. + cardUnder = card.id; + labelOver = true; + click(null); + assert.deepEqual(opened, [], 'the link beneath the label is not opened'); + assert.deepEqual(cards.at(-1), [], 'the card is closed'); + + // Off the label, a click on the open card opens its link. + labelOver = false; + click('ghostmaps:cip:0:0'); + click(null); + assert.deepEqual(opened, ['https://example.com/report']); +}); diff --git a/src/layers/news/layer.test.mjs b/src/layers/news/layer.test.mjs index 9804011d77..824de5a9f9 100644 --- a/src/layers/news/layer.test.mjs +++ b/src/layers/news/layer.test.mjs @@ -6,6 +6,8 @@ import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs'; import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs'; import { NEWS_KEY_PROVIDERS, createNewsLayer } from './index.js'; import { getSelectedEntityContext } from '../../data/contextStore.js'; +import { fakeInputUnderLabel } from '../../input/testDoubles.mjs'; +import { NEWS_OVERLAY_SOURCE_ID } from './model.js'; const NOW = Date.parse('2026-10-28T10:00:00Z'); const hotspotsPayload = { @@ -51,6 +53,8 @@ function fixture( now = () => NOW, quality, pictureCards, + underLabel = false, + hitTestOverlay = () => null, } = {}, ) { const calls = { feed: [], hotspots: 0, outline: 0 }; @@ -137,11 +141,18 @@ function fixture( for (const fn of [...clickHandlers]) fn({ screenPosition: { x: 10, y: 10 }, topHit }); }; + // Or the scene's own dispatcher, with a label that may be painted over + // the map (`fake.label.over`). + let fake = null; + if (underLabel) { + viewer.scene = { canvas: {}, pick: () => null }; + fake = fakeInputUnderLabel(viewer); + } const layer = createNewsLayer({ source, overlayHost, - inputFor: () => input, - hitTestOverlay: () => null, + inputFor: () => fake?.input ?? input, + hitTestOverlay, now, matchMedia: () => ({ matches: reduced }), getViewCentre: () => centre(), @@ -158,6 +169,7 @@ function fixture( layer.attachShellServices({ runNavigation: (navigate) => navigate() }); t.after(() => { layer.destroy(); + fake?.destroy(); unbind(); if (originalWindow === undefined) delete globalThis.window; else globalThis.window = originalWindow; @@ -172,6 +184,7 @@ function fixture( items, click, clickHandlers, + fake, }; } @@ -1285,6 +1298,34 @@ test('a click on a marker selects its report, on a beacon chooses its hotspot, o assert.equal(clickHandlers.size, 0); }); +test("a click a label painted over a report's card takes never opens the card, and lets go of the report", async (t) => { + let activated = 0; + const { layer, fake } = fixture(t, { + height: 500_000, + underLabel: true, + // A report's card lies under every click. + hitTestOverlay: (_x, _y, { sourceId }) => + sourceId === NEWS_OVERLAY_SOURCE_ID + ? { entry: { activate: () => activated++ } } + : null, + }); + layer.enable(); + await layer.update(); + await flush(); + layer.setParams({ reportId: 'major', pin: 0 }); + assert.equal(layer.getRowControls().feed.selected.id, 'major'); + + fake.label.over = true; + fake.click(); + assert.equal(activated, 0, 'the card beneath the label is not opened'); + assert.equal(layer.getRowControls().feed.selected, null); + + // Off the label, the same click opens the card. + fake.label.over = false; + fake.click(); + assert.equal(activated, 1); +}); + test('zoomed out, a hotspot is one beacon; off, nothing draws; destroyed, the sets go', async (t) => { const { layer, items } = fixture(t); assert.deepEqual(items('points'), []); diff --git a/src/layers/perimeters/ownership.test.mjs b/src/layers/perimeters/ownership.test.mjs index 61cfde2bbf..a996eedeb7 100644 --- a/src/layers/perimeters/ownership.test.mjs +++ b/src/layers/perimeters/ownership.test.mjs @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import test from 'node:test'; import { createFirePerimetersLayer } from './index.js'; -import { fakeInput } from '../../input/testDoubles.mjs'; +import { fakeInput, fakeInputUnderLabel } from '../../input/testDoubles.mjs'; import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs'; // The fills set of the layer the last harness made: perimeter picks name it. @@ -30,11 +30,12 @@ function harness( const opened = []; const viewer = { scene: { pick } }; const { draw } = bindFakeDraw(viewer); - const input = fakeInput(viewer); + const input = fakeInputUnderLabel(viewer); const clicks = { handler: (click) => input.click(click.position), + // Only the label's own overlay handler is left. get destroyed() { - return input.input.subscriberCount() === 0 ? 1 : 0; + return input.input.subscriberCount() === 1 ? 1 : 0; }, }; const layer = createFirePerimetersLayer({ @@ -78,6 +79,8 @@ function harness( clicks, owners, opened, + /** A label painted over the map: while `over`, it takes each click. */ + label: input.label, }; } @@ -311,6 +314,53 @@ test('a matched incident card carries the InciWeb line and click-through', async ); }); +test('a click a label painted over the incident card takes never opens its InciWeb page, and closes the card', async () => { + let cardHitResult = null; + const h = harness( + { getSnapshot: async () => [row] }, + { + pick: () => perimeterPick('fire-perimeter:2026-NMGNF-000123:0'), + inciwebIndex: [ + { + incident_id: '329300', + tau: 'NMGNF Fixture Fire', + incident_title: 'Fixture Fire', + }, + ], + cardHit: () => cardHitResult, + }, + ); + await h.layer.update(h.viewer); + h.clicks.handler({ position: { x: 10, y: 10 } }); + await new Promise((done) => setTimeout(done, 0)); + const [card] = h.overlay.entries.get('fire-perimeters'); + assert.equal(card.details.at(-1), 'InciWeb ↗ · click card to open'); + + // The open card lies under the label: the click opens nothing. + cardHitResult = { entryId: card.id }; + h.viewer.scene.pick = () => null; + h.label.over = true; + h.clicks.handler({ position: { x: 12, y: 12 } }); + assert.deepEqual(h.opened, [], 'the page beneath the label is not opened'); + assert.equal( + h.overlay.entries.get('fire-perimeters')?.length ?? 0, + 0, + 'the card is closed', + ); + + // Off the label, a click on the open card opens its page. + h.label.over = false; + h.viewer.scene.pick = () => + perimeterPick('fire-perimeter:2026-NMGNF-000123:0'); + h.clicks.handler({ position: { x: 10, y: 10 } }); + await new Promise((done) => setTimeout(done, 0)); + cardHitResult = { entryId: h.overlay.entries.get('fire-perimeters')[0].id }; + h.viewer.scene.pick = () => null; + h.clicks.handler({ position: { x: 12, y: 12 } }); + assert.deepEqual(h.opened, ['https://inciweb.wildfire.gov/node/329300']); + h.layer.destroy(); +}); + test('an unmatched incident renders no InciWeb line and card clicks stay inert', async () => { let cardHitResult = null; const h = harness( diff --git a/src/layers/wildlifeSightings/selection.test.mjs b/src/layers/wildlifeSightings/selection.test.mjs index bf623526bb..e2c3761cfd 100644 --- a/src/layers/wildlifeSightings/selection.test.mjs +++ b/src/layers/wildlifeSightings/selection.test.mjs @@ -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 { fakeInputUnderLabel } from '../../input/testDoubles.mjs'; const row = { stableId: 'inat:123', @@ -304,6 +305,35 @@ 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) => { + let fake = null; + const f = fixture(row, { + input: (viewer) => { + fake ??= fakeInputUnderLabel(viewer); + return fake.input; + }, + }); + f.selection.install(); + t.after(() => { + f.selection.remove(); + fake.destroy(); + }); + f.selection.refreshAmbient(); + // The sighting's name card lies under every click. + f.hit('wildlife-sightings-labels', 'wildlife-sightings-label:inat:123'); + + // Off the label, a click on the card selects and focuses the sighting. + fake.click(); + assert.equal(f.state.selectedId, row.stableId); + assert.equal(f.flights.length, 1); + + 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.flights.length, 1, 'the camera is not sent to the sighting'); +}); + test('a tap selects only a sighting exactly under it, not one the touch search found near it', () => { const f = fixture(); f.selection.install(); From 3cf230b8b3307adb629bdc7ab921bee9e782c45c Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:29:35 -0800 Subject: [PATCH 08/15] Give back the Satellites a person chose between two missions A saved Satellites state kept by a busy restore could still carry the mark of a Satellites switch the person made after it, which tells the restore to leave Satellites as it is. Space Missions turned on again kept that mark, so turning it off left Satellites on when it had been off. The next mission now saves Satellites as it is when it starts in that case. Co-authored-by: Manjunath Paparaju --- src/layers/launches/failedEntry.test.mjs | 38 ++++++++++++++++++++++++ src/layers/launches/ingestion.js | 12 ++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/layers/launches/failedEntry.test.mjs b/src/layers/launches/failedEntry.test.mjs index 1458da4670..19d6c7aaa2 100644 --- a/src/layers/launches/failedEntry.test.mjs +++ b/src/layers/launches/failedEntry.test.mjs @@ -670,6 +670,44 @@ test('Space Missions turned on again after a busy restore switches Satellites on assert.equal(f.manager.isEnabled('satellites'), false); }); +test('a Satellites switch made between missions is what the next mission gives back', async (t) => { + const f = await fixture(t); + f.upstream.status = 200; + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + f.state.satelliteSettleTimeoutMs = 50; + const satellites = f.manager.layers.get('satellites').module; + const enable = satellites.enable; + const stuck = Promise.withResolvers(); + satellites.enable = () => stuck.promise; + try { + await f.manager.setEnabled('satellites', false); + void f.manager.setEnabled('satellites', true); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + } finally { + satellites.enable = enable; + stuck.resolve(); + } + await f.settle(); + // The person switches Satellites on, then something else switches it off. + await f.manager.setEnabled('satellites', true, { origin: 'user' }); + await f.settle(); + await f.manager.setEnabled('satellites', false); + await f.settle(); + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + assert.equal(f.manager.isEnabled('satellites'), true); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + await f.settle(); + assert.equal(f.manager.isEnabled('satellites'), false); +}); + test('a failed Satellites restore still clears the selected mission panel', async (t) => { const f = await fixture(t); f.upstream.status = 200; diff --git a/src/layers/launches/ingestion.js b/src/layers/launches/ingestion.js index 58135ad991..9b7de0e633 100644 --- a/src/layers/launches/ingestion.js +++ b/src/layers/launches/ingestion.js @@ -129,8 +129,16 @@ export function createIngestion({ return; // A saved state kept by a restore that could not finish (Satellites was // busy) is still the one from before the mission: keep it, and switch - // Satellites on for the mission again. - if (!layerState._satelliteStateBeforeMission) + // Satellites on for the mission again. A Satellites switch the person + // made since (restoreVisibility false) settled its visibility, so it + // is taken as it is now; its params are still the saved ones. + const kept = layerState._satelliteStateBeforeMission; + if (kept?.restoreVisibility === false) + layerState._satelliteStateBeforeMission = { + enabled: manager.isEnabled('satellites'), + params: kept.params, + }; + else if (!kept) layerState._satelliteStateBeforeMission = { enabled: manager.isEnabled('satellites'), params: parts.policyHelpers.satelliteParamsAfterSpaceMissions( From ab01345c7d1efe74ad83929493fb871848d3fd8e Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:36:15 -0800 Subject: [PATCH 09/15] Keep a Satellites setting the person changes while Space Missions holds its saved state A setting such as "show orbits" changed by the person or by voice while Space Missions keeps the Satellites state from before it (while it runs, or after a restore that found Satellites busy) was overwritten when the mission ended. It is now kept in that saved state, as their visibility choice is. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 2 +- src/layers/launches/failedEntry.test.mjs | 35 ++++++++++++++++++++++++ src/layers/launches/satelliteIntents.js | 20 ++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 789c158529..6c31ba08c0 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7338,7 +7338,7 @@ silently demoting every later lookup for the session. - Context is set for reading in every theme: mode, standby and action labels are 10 px, and the panel draws no glow halo. The two modes form one segmented control, the standby guidance is plain left-aligned text rather than a dashed placeholder, and the panel's section titles share the side panels' dock-label colour. - The expanded desktop header omits the redundant `ON` label; the active mode button carries state. Expanded Contact results also omit the duplicate `GLOBAL CONTEXT` / `CONTEXT ONLY` status row and begin with the selected subject and its 250 km scope. Global Context does not fabricate a selected-entity model preview: the provisional hand-authored aircraft wireframe was removed because it was not geometry extracted from the selected entity's actual asset. - Dependency ownership is reversible: disabling Global Context releases only dependencies it enabled, while user-enabled layers remain on. This also removes the Military-layer suppression handoff when Global Context owned Military, allowing an already-enabled civilian Flights layer to resume its normal mixed rendering. If OpenSky is unavailable and has no last-good cache, Flights requests a capped 250 nm adsb.lol point snapshot around the current view anchor and labels that provenance explicitly; it never relabels military-feed rows as civilian data. If both inputs fail, Flights remains `UNKNOWN`. -- Space Missions is an ordinary layer, not a Context mode. It neither isolates the globe nor refuses other layers, opens no Context session, and runs beside Contacts. Turning it on enables its Satellites dependency in the temporary dense/hidden mode and turning it off restores Satellites' exact prior visibility and parameters; an explicit Satellites action taken while it runs (by the person or by voice) is kept through that restore, and such a Satellites OFF asked for after the newest Space Missions ON ends Space Missions (request order, not settle order, decides; `src/layers/launches/satelliteIntents.js`). A scene, story, preset or other programmatic Satellites change does neither (owner decision). Contacts leaves Satellites as it is. The first mission-index load is part of the enable: an HTTP error, timeout, network failure or malformed payload before any index has loaded fails the enable, the camera returns to its pre-entry view unless navigation took it, and a toast says the mission index could not load. A valid empty index still enables, and a refresh failure after an index loaded keeps its records. Turning the layer on by hand, choosing it at first run, asking for it by voice (`set_context_mode` still accepts `space-missions` and switches the layer), or picking a mission on the globe opens the Space Missions panel; on desktop, opening it closes Context and the other right-rail panels, and opening Context closes it. Voice `set_panel_open` refuses to open the panel while the layer is off and says to turn Space Missions on first. +- Space Missions is an ordinary layer, not a Context mode. It neither isolates the globe nor refuses other layers, opens no Context session, and runs beside Contacts. Turning it on enables its Satellites dependency in the temporary dense/hidden mode and turning it off restores Satellites' exact prior visibility and parameters; an explicit Satellites action taken while it runs (by the person or by voice), a visibility switch or a changed setting, is kept through that restore (also while a restore that found Satellites busy keeps the saved state, for the next Space Missions start, which switches Satellites on again), and such a Satellites OFF asked for after the newest Space Missions ON ends Space Missions (request order, not settle order, decides; `src/layers/launches/satelliteIntents.js`). A scene, story, preset or other programmatic Satellites change does neither (owner decision). Contacts leaves Satellites as it is. The first mission-index load is part of the enable: an HTTP error, timeout, network failure or malformed payload before any index has loaded fails the enable, the camera returns to its pre-entry view unless navigation took it, and a toast says the mission index could not load. A valid empty index still enables, and a refresh failure after an index loaded keeps its records. Turning the layer on by hand, choosing it at first run, asking for it by voice (`set_context_mode` still accepts `space-missions` and switches the layer), or picking a mission on the globe opens the Space Missions panel; on desktop, opening it closes Context and the other right-rail panels, and opening Context closes it. Voice `set_panel_open` refuses to open the panel while the layer is off and says to turn Space Missions on first. - Enabled Data Layer controls report normalized feed health on the button (`LOADING`, `DEGRADED`, `STALE`, `FALLBACK`, or `UNAVAILABLE`) while the metadata line retains the source and reason. A partial CelesTrak group failure keeps the usable catalog and reports `DEGRADED`; a total outage keeps last-good catalog data visible but reports `UNAVAILABLE`. - On activation it focuses the nearest currently observed aircraft across the civilian and military feeds, with military winning an exact distance tie; if none are available, it focuses an observed AIS vessel. The aircraft search is deliberately uncapped and one refresh-tick retry handles initially empty feeds. This is an attention-priority navigation shortcut, not a high-risk, affiliation, or threat classification. - A selected aircraft, AIS vessel, or mapped installation gets a 250 km **context window** with nearby cohort counts, nearest examples, source labels, and stale/unavailable reasons. It emits `NEARBY` or `UNKNOWN`; no detection, engagement, affiliation, or sensor-activity conclusion is calculated. diff --git a/src/layers/launches/failedEntry.test.mjs b/src/layers/launches/failedEntry.test.mjs index 19d6c7aaa2..71bdec3c5d 100644 --- a/src/layers/launches/failedEntry.test.mjs +++ b/src/layers/launches/failedEntry.test.mjs @@ -708,6 +708,41 @@ test('a Satellites switch made between missions is what the next mission gives b assert.equal(f.manager.isEnabled('satellites'), false); }); +test('a Satellites setting changed between missions survives the next one', async (t) => { + const f = await fixture(t); + f.upstream.status = 200; + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + f.state.satelliteSettleTimeoutMs = 50; + const satellites = f.manager.layers.get('satellites').module; + const enable = satellites.enable; + const stuck = Promise.withResolvers(); + satellites.enable = () => stuck.promise; + try { + await f.manager.setEnabled('satellites', false); + void f.manager.setEnabled('satellites', true); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + } finally { + satellites.enable = enable; + stuck.resolve(); + } + await f.settle(); + f.manager.setLayerParams( + 'satellites', + { showOrbits: false }, + { origin: 'user' }, + ); + await f.settle(); + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }); + await f.settle(); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + await f.settle(); + assert.equal(f.manager.getLayerParams('satellites').showOrbits, false); +}); + test('a failed Satellites restore still clears the selected mission panel', async (t) => { const f = await fixture(t); f.upstream.status = 200; diff --git a/src/layers/launches/satelliteIntents.js b/src/layers/launches/satelliteIntents.js index 7e646fb2fa..63290e22ce 100644 --- a/src/layers/launches/satelliteIntents.js +++ b/src/layers/launches/satelliteIntents.js @@ -93,6 +93,24 @@ export function createSatelliteIntents({ state: layerState }) { return stop; } + /** + * Keep a Satellites setting the person changed while Space Missions holds + * its saved state ("show orbits" off): it survives the mission teardown, + * as their visibility choice does. + */ + function handleParams(change) { + if ( + change?.type !== 'params' || + change.layerId !== 'satellites' || + !isExplicitOrigin(change.origin) + ) + return; + const previous = layerState._satelliteStateBeforeMission; + const requested = change.requestedParams; + if (!previous || !requested || typeof requested !== 'object') return; + previous.params = { ...previous.params, ...requested }; + } + /** Settle once a Satellites OFF has finished stopping Space Missions. */ function settled() { return pendingStop ?? Promise.resolve(false); @@ -108,6 +126,7 @@ export function createSatelliteIntents({ state: layerState }) { manager.subscribeVisibilityRequests?.(recordRequest) ?? null; const unsubscribeChanges = manager.subscribe?.((change) => { + handleParams(change); void handleVisibility(change); }) ?? null; unsubscribe = () => { @@ -120,6 +139,7 @@ export function createSatelliteIntents({ state: layerState }) { connect, settled, handleVisibility, + handleParams, recordRequest, offFollowsMissionsEntry, }; From 29d0fa6e0b39cece96dd1db761dd498d19ba9741 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:54:28 -0800 Subject: [PATCH 10/15] Keep satellite tracking stopped by a place search through the Space Missions restore A place search or fly-to stops satellite tracking with the tool origin, which the saved Satellites state did not take in, so a satellite tracked by voice during the mission was tracked again when Space Missions ended. The saved state now takes in every deliberate Satellites setting (person, voice or tool), as the layer state does. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 2 +- src/layers/launches/failedEntry.test.mjs | 29 ++++++++++++++++++++++++ src/layers/launches/satelliteIntents.js | 18 +++++++++++---- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 6c31ba08c0..f707354ef6 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7338,7 +7338,7 @@ silently demoting every later lookup for the session. - Context is set for reading in every theme: mode, standby and action labels are 10 px, and the panel draws no glow halo. The two modes form one segmented control, the standby guidance is plain left-aligned text rather than a dashed placeholder, and the panel's section titles share the side panels' dock-label colour. - The expanded desktop header omits the redundant `ON` label; the active mode button carries state. Expanded Contact results also omit the duplicate `GLOBAL CONTEXT` / `CONTEXT ONLY` status row and begin with the selected subject and its 250 km scope. Global Context does not fabricate a selected-entity model preview: the provisional hand-authored aircraft wireframe was removed because it was not geometry extracted from the selected entity's actual asset. - Dependency ownership is reversible: disabling Global Context releases only dependencies it enabled, while user-enabled layers remain on. This also removes the Military-layer suppression handoff when Global Context owned Military, allowing an already-enabled civilian Flights layer to resume its normal mixed rendering. If OpenSky is unavailable and has no last-good cache, Flights requests a capped 250 nm adsb.lol point snapshot around the current view anchor and labels that provenance explicitly; it never relabels military-feed rows as civilian data. If both inputs fail, Flights remains `UNKNOWN`. -- Space Missions is an ordinary layer, not a Context mode. It neither isolates the globe nor refuses other layers, opens no Context session, and runs beside Contacts. Turning it on enables its Satellites dependency in the temporary dense/hidden mode and turning it off restores Satellites' exact prior visibility and parameters; an explicit Satellites action taken while it runs (by the person or by voice), a visibility switch or a changed setting, is kept through that restore (also while a restore that found Satellites busy keeps the saved state, for the next Space Missions start, which switches Satellites on again), and such a Satellites OFF asked for after the newest Space Missions ON ends Space Missions (request order, not settle order, decides; `src/layers/launches/satelliteIntents.js`). A scene, story, preset or other programmatic Satellites change does neither (owner decision). Contacts leaves Satellites as it is. The first mission-index load is part of the enable: an HTTP error, timeout, network failure or malformed payload before any index has loaded fails the enable, the camera returns to its pre-entry view unless navigation took it, and a toast says the mission index could not load. A valid empty index still enables, and a refresh failure after an index loaded keeps its records. Turning the layer on by hand, choosing it at first run, asking for it by voice (`set_context_mode` still accepts `space-missions` and switches the layer), or picking a mission on the globe opens the Space Missions panel; on desktop, opening it closes Context and the other right-rail panels, and opening Context closes it. Voice `set_panel_open` refuses to open the panel while the layer is off and says to turn Space Missions on first. +- Space Missions is an ordinary layer, not a Context mode. It neither isolates the globe nor refuses other layers, opens no Context session, and runs beside Contacts. Turning it on enables its Satellites dependency in the temporary dense/hidden mode and turning it off restores Satellites' exact prior visibility and parameters; an explicit Satellites action taken while it runs (by the person or by voice), a visibility switch or a changed setting (also a place search that stops tracking a satellite), is kept through that restore (also while a restore that found Satellites busy keeps the saved state, for the next Space Missions start, which switches Satellites on again), and such a Satellites OFF asked for after the newest Space Missions ON ends Space Missions (request order, not settle order, decides; `src/layers/launches/satelliteIntents.js`). A scene, story, preset or other programmatic Satellites change does neither (owner decision). Contacts leaves Satellites as it is. The first mission-index load is part of the enable: an HTTP error, timeout, network failure or malformed payload before any index has loaded fails the enable, the camera returns to its pre-entry view unless navigation took it, and a toast says the mission index could not load. A valid empty index still enables, and a refresh failure after an index loaded keeps its records. Turning the layer on by hand, choosing it at first run, asking for it by voice (`set_context_mode` still accepts `space-missions` and switches the layer), or picking a mission on the globe opens the Space Missions panel; on desktop, opening it closes Context and the other right-rail panels, and opening Context closes it. Voice `set_panel_open` refuses to open the panel while the layer is off and says to turn Space Missions on first. - Enabled Data Layer controls report normalized feed health on the button (`LOADING`, `DEGRADED`, `STALE`, `FALLBACK`, or `UNAVAILABLE`) while the metadata line retains the source and reason. A partial CelesTrak group failure keeps the usable catalog and reports `DEGRADED`; a total outage keeps last-good catalog data visible but reports `UNAVAILABLE`. - On activation it focuses the nearest currently observed aircraft across the civilian and military feeds, with military winning an exact distance tie; if none are available, it focuses an observed AIS vessel. The aircraft search is deliberately uncapped and one refresh-tick retry handles initially empty feeds. This is an attention-priority navigation shortcut, not a high-risk, affiliation, or threat classification. - A selected aircraft, AIS vessel, or mapped installation gets a 250 km **context window** with nearby cohort counts, nearest examples, source labels, and stale/unavailable reasons. It emits `NEARBY` or `UNKNOWN`; no detection, engagement, affiliation, or sensor-activity conclusion is calculated. diff --git a/src/layers/launches/failedEntry.test.mjs b/src/layers/launches/failedEntry.test.mjs index 71bdec3c5d..40436d7a9e 100644 --- a/src/layers/launches/failedEntry.test.mjs +++ b/src/layers/launches/failedEntry.test.mjs @@ -743,6 +743,35 @@ test('a Satellites setting changed between missions survives the next one', asyn assert.equal(f.manager.getLayerParams('satellites').showOrbits, false); }); +test('tracking stopped by a place search during a mission stays stopped after it', async (t) => { + const f = await fixture(t); + f.upstream.status = 200; + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + f.manager.setLayerParams( + 'satellites', + { selectedSatTrackingId: 25544 }, + { origin: 'voice' }, + ); + await f.settle(); + // A place search stops tracking with the tool origin. + f.manager.setLayerParams( + 'satellites', + { selectedSatTrackingId: null }, + { origin: 'tool' }, + ); + await f.settle(); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + await f.settle(); + assert.equal( + f.manager.getLayerParams('satellites').selectedSatTrackingId ?? null, + null, + ); +}); + test('a failed Satellites restore still clears the selected mission panel', async (t) => { const f = await fixture(t); f.upstream.status = 200; diff --git a/src/layers/launches/satelliteIntents.js b/src/layers/launches/satelliteIntents.js index 63290e22ce..0870dc351b 100644 --- a/src/layers/launches/satelliteIntents.js +++ b/src/layers/launches/satelliteIntents.js @@ -16,6 +16,15 @@ function isExplicitOrigin(origin) { return origin === 'user' || origin === 'voice'; } +/** + * A setting changed on purpose: by the person, by voice, or by a tool such + * as a place search (the layer state's own rule, isExplicitLayerStateOrigin + * in src/data/layerState.js). + */ +function isDeliberateOrigin(origin) { + return isExplicitOrigin(origin) || origin === 'tool'; +} + export function createSatelliteIntents({ state: layerState }) { const requestOrder = new Map(); let sequence = 0; @@ -94,15 +103,16 @@ export function createSatelliteIntents({ state: layerState }) { } /** - * Keep a Satellites setting the person changed while Space Missions holds - * its saved state ("show orbits" off): it survives the mission teardown, - * as their visibility choice does. + * Keep a Satellites setting changed on purpose while Space Missions holds + * its saved state ("show orbits" off, tracking a satellite, or a place + * search that stops tracking): it survives the mission teardown, as a + * visibility choice does. */ function handleParams(change) { if ( change?.type !== 'params' || change.layerId !== 'satellites' || - !isExplicitOrigin(change.origin) + !isDeliberateOrigin(change.origin) ) return; const previous = layerState._satelliteStateBeforeMission; From a29efa12c4e9abc934ac67d95ca64b7f3fd082bf Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:24:16 -0800 Subject: [PATCH 11/15] Let a mission label select its mission in the cockpit, and say what the merged click rule does Under the card-on-top rule a mission label is the card on top for the cockpit too, so the label no longer steps aside there: it selects its mission without moving the camera the cockpit holds. Tests and docs no longer claim a covered click reaches what lies under the label, and the busy-restore note says an explicit Satellites action lets the saved state go. Co-authored-by: Manjunath Paparaju --- changelog.d/1829-space-missions-fixes.md | 14 ++++++++------ docs/CURRENT-STATE.md | 2 +- src/layers/launches/labelClick.test.mjs | 23 ++++++++++++++++------- src/layers/launches/lifecycle.js | 12 +++++++----- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/changelog.d/1829-space-missions-fixes.md b/changelog.d/1829-space-missions-fixes.md index 32dc56ed72..a68ca80360 100644 --- a/changelog.d/1829-space-missions-fixes.md +++ b/changelog.d/1829-space-missions-fixes.md @@ -1,6 +1,8 @@ -- Space Missions finishes switching off before anything else runs: a launch - hovered while the layer is going off shows no preview, and Satellites - keeps the state it was saved with when it is still busy. A click on a - mission label reaches every layer as a click on the label, the card on - top, so none of them selects, turns on, flies to or opens the link of - what lies under the label (manjunath22466, samehkhamis, #1829). +- Space Missions going off no longer acts on a launch hovered, selected or + replayed meanwhile, and Satellites keeps the state it was saved with when + it is still busy; a Satellites setting changed during a mission, such as + a place search ending tracking, is kept when the mission ends. A click on + a mission label is a click on the card on top, so no layer selects, turns + on, flies to or opens the link of what lies under it; in the cockpit the + label selects its mission without moving the camera (manjunath22466, + samehkhamis, #1829). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 90ae482469..0d40a87685 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7569,7 +7569,7 @@ silently demoting every later lookup for the session. protected-card path. Disable tears the tier down completely. Coverage/viewshed semantics unchanged. - **Satellites**: every point moves every frame. Each satellite's SGP4 sample (position, velocity, gravity and its rate of change; `src/layers/satellites/motion.js`) is reckoned forward or back to the world time and turned into the Earth-fixed frame, so points glide at any play speed instead of stepping once a second. Core satellites take a fresh sample every second, or as soon as the world time is 30 s from their sample (fast play, a seek), which keeps every point within about 10 m of SGP4; Starlink extras are sampled round-robin, more per frame the faster time plays, and a point more than two minutes from its sample waits for the next one. Hidden points are not moved until shown. Orbit rings rotate about Earth's Z by ΔGMST every ~1s (exact inertial→ECEF compensation; no SGP4 re-runs); the tracked satellite propagates per frame with one shared epoch for dot/label/camera. Verified: ISS holds <1km perpendicular to its ring while tracked. Pass prediction (`src/data/satellitePass.js`; `getNextSatellitePass`, `getNextIssPass`) scans at 20s, bisects rise/set to ~0.2s, fits the peak with a parabola, and marks a pass visible when the satellite is outside a cylindrical Earth shadow while the observer's Sun is at or below −6°. `next_iss_pass` preserves its geometric-pass ordering and appends visibility metadata. General `next_satellite_pass` accepts a loaded NORAD ID or unambiguous name, searches 24 hours and optionally requires estimated visibility. These estimates do not account for weather or satellite brightness. -- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot; what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name. The name is an interactive world-overlay label, so it is the card on top for every click handler (`clickCard`, `isUnderOtherCard` in `src/data/pickRegistry.js`): no other layer selects, turns on, focuses or opens the link of a contact, card or camera that lies under the name, and their selections stay. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. +- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot (in the cockpit, which holds the camera, it selects without moving); what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name. The name is an interactive world-overlay label, so it is the card on top for every click handler (`clickCard`, `isUnderOtherCard` in `src/data/pickRegistry.js`): no other layer selects, turns on, focuses or opens the link of a contact, card or camera that lies under the name, and their selections stay. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. When no mission is selected, the Space Missions panel presents a scrollable newest-first roster of every launch in the rolling window, including the smaller 5 px operator-colored marker, provider, and launch date. Hovering or keyboard-focusing a row shows four compact cyan corner brackets on both that roster row and its corresponding globe dot, rotates the globe at the current zoom to center it, and gives its label declutter priority without selecting it; the globe label remains unbracketed. Selecting a roster row invokes the same mission isolation and full-orbit framing as clicking its globe marker. The replay vehicle is one screen-space SVG/CSS HUD overlay rather than separate Cesium billboard, label, and reticle graphics. It is hidden during ordinary Focus and manual close views, where the standard selected launch-site label remains visible, and exists only while ascent replay is active. Its fixed pixel scale is shared by ascent and insertion, so camera range never resizes the rocket on screen before the phase boundary. Generic Launch Library pad names are reduced to their identifying suffix, and replay timestamps use a cyan state title over unprefixed white UTC date/time values. `REPLAY ASCENT` holds the unframed cyan/white rocket at the pad for a real-time `T−10` countdown, transitions through `LIFTOFF`, and attaches six tapered cyan/white ellipse waves directly below it from liftoff through insertion to convey thrust without adding scene geometry. While replay is active, the single start button is replaced by compact Play, Pause, and Cancel icon controls. Pause freezes countdown or mission time, vehicle/stage positions, camera target, labels, and thrust-wave animation; Play resumes from that exact frame, and Cancel releases replay camera ownership. The rocket and thrust group rotates from the path's live screen-space tangent, so its nose follows the visible ascent curve while the adjacent text remains upright. The camera begins as a close oblique launch chase, then smoothly widens between roughly 120 and 420 km vehicle altitude into a higher oblique context view that keeps the moving rocket targeted while exposing the ascent bend and orbit connection. At insertion the rocket/thrust glyph is replaced by the fixed-size cyan orbit dot, which the camera follows through the existing globe-scale orbit pullback. The chase camera limits per-frame yaw changes across heading wraps so it cannot abruptly cross in front of the vehicle and make ascent read in reverse; the replay-speed slider affects mission playback but not countdown duration. Mission world text has no native `LabelGraphics`: overview launch markers publish at most 48 ambient candidates for a 24-winner budget, while selecting a mission clears that overview source and publishes its launch-site callout, stage re-entry annotations, live/estimated payload-position readout, and orbit annotation as protected selected-lane entries. The source retains the exact former strings and colors. Static anchors reuse the Cartesian values used to build their mission geometry; the moving payload entry reads the layer's per-frame live-position cache; catalog-backed orbit annotation positions are cached in the same one-second matrix update that realigns the orbit primitive. Keyhole edge fade, horizon culling, final collision placement, and UI exclusion are owned by the shared host. Deselect restores the bounded overview, and refresh, disable, and destroy replace or clear both mission sources. A selected mission renders its orbit as four repeating tactical sectors, each containing one prominent cyan dot followed by one hundred thin translucent dashes. The bright dots act as orbit anchors while the subdued dash field remains depth-tested against the globe and is shown only for the selected mission. diff --git a/src/layers/launches/labelClick.test.mjs b/src/layers/launches/labelClick.test.mjs index 7c50f3fdb0..7ac92d5564 100644 --- a/src/layers/launches/labelClick.test.mjs +++ b/src/layers/launches/labelClick.test.mjs @@ -54,6 +54,7 @@ function rig(t, { overlayHit = null, geometryLaunchId = null } = {}) { }; const state = createState({ services }); const focused = []; + const moved = []; const restoreFailure = { error: null }; const parts = { panel: stub(), @@ -63,6 +64,7 @@ function rig(t, { overlayHit = null, geometryLaunchId = null } = {}) { orbitRendering: stub(), selection: stub({ setSelectedMission: (id) => focused.push(id), + focusMission: (launch) => moved.push(launch.id), }), satelliteIntents: stub(), ingestion: stub({ @@ -97,6 +99,7 @@ function rig(t, { overlayHit = null, geometryLaunchId = null } = {}) { }); return { focused, + moved, ambient, state, lifecycle, @@ -122,8 +125,9 @@ test('a mission label click focuses its launch and covers the geometry beneath', const r = rig(t, { overlayHit: label('launch:L2'), geometryLaunchId: 'L1' }); r.click(); assert.deepEqual(r.focused, ['L2'], 'the mission beneath is not picked'); - // Other layers still hear it, to close their cards or clear selection, - // as a click on the label rather than on the geometry beneath. + // Other layers still hear it, as a click on the label rather than on the + // geometry beneath; the label is the card on top, so they keep their + // selections. assert.equal(r.ambient.length, 1); assert.equal(r.ambient[0].overlay, true); assert.equal(r.ambient[0].drawHit, null); @@ -164,14 +168,16 @@ test('a throwing globe-pick listener does not stop the pick', (t) => { assert.equal(r.ambient[0].overlay, true); }); -test('a mission label for an unknown launch falls through to other layers', (t) => { +test('a mission label for an unknown launch selects nothing', (t) => { const r = rig(t, { overlayHit: label('launch:gone'), geometryLaunchId: 'L1', }); r.click(); assert.deepEqual(r.focused, [], 'nothing is focused'); - assert.equal(r.ambient.length, 1, 'other layers still get the click'); + // Other layers hear the click; the label is still the card on top for + // them (clickYield.test.mjs), so none acts under it. + assert.equal(r.ambient.length, 1); }); test("another layer's label keeps the click above mission geometry", (t) => { @@ -190,7 +196,7 @@ test("another layer's label keeps the click above mission geometry", (t) => { assert.deepEqual(r.focused, ['L1']); }); -test('a mission label leaves the click to the cockpit while it is on', (t) => { +test('in the cockpit a mission label selects its mission without moving the camera', (t) => { const r = rig(t, { overlayHit: label('launch:L2') }); const previous = Object.getOwnPropertyDescriptor(globalThis, 'document'); Object.defineProperty(globalThis, 'document', { @@ -205,8 +211,11 @@ test('a mission label leaves the click to the cockpit while it is on', (t) => { if (previous) Object.defineProperty(globalThis, 'document', previous); else delete globalThis.document; } - assert.deepEqual(r.focused, []); - assert.equal(r.ambient.length, 1, 'the cockpit click handler gets it'); + assert.deepEqual(r.focused, ['L2'], 'the mission is selected'); + assert.deepEqual(r.moved, [], 'the cockpit keeps the camera'); + // Out of the cockpit the same click moves there too. + r.click(); + assert.deepEqual(r.moved, ['L2']); }); test('destroy releases the click handlers when the Satellites restore fails', async (t) => { diff --git a/src/layers/launches/lifecycle.js b/src/layers/launches/lifecycle.js index 2e67cba364..a42e14047b 100644 --- a/src/layers/launches/lifecycle.js +++ b/src/layers/launches/lifecycle.js @@ -181,12 +181,12 @@ export function createLifecycle({ services.overlays?.hitTestWorldOverlay?.(position?.x, position?.y); const missionsShown = () => layerState._enabled && parts.rendering.missionsShown(); - const focusLaunch = (id) => { + const focusLaunch = (id, { move = true } = {}) => { if (!id) return false; const launch = layerState._launches.find((entry) => entry.id === id); if (!launch) return false; parts.selection.setSelectedMission(launch.id); - parts.selection.focusMission(launch); + if (move) parts.selection.focusMission(launch); for (const listener of [...layerState._globePickListeners]) { try { listener(launch.id); @@ -245,14 +245,16 @@ export function createLifecycle({ const input = inputFor(viewer); const overlayClicks = new WeakSet(); const unsubscribeLabelClick = input.onOverlayClick((event) => { - // The cockpit reads ambient clicks; a mission label must not take them. - if (!missionsShown() || cockpitActive()) return false; + if (!missionsShown()) return false; const hit = overlayAt(event.screenPosition); if (!hit) return false; // Capture the painted hit before other handlers can invalidate the // overlay. An unrelated label keeps the click above mission geometry. overlayClicks.add(event); - return focusLaunch(markerLaunchId(hit)); + // The label is the card on top, so every other layer and the cockpit + // leave its click alone. In the cockpit, which holds the camera, it + // selects the mission without moving there. + return focusLaunch(markerLaunchId(hit), { move: !cockpitActive() }); }); const unsubscribeClick = input.onClick((event) => { // Another layer's card or label on top is that layer's click, read From 813c6b23ea44a12c19597e49a8c05c5d026518f3 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:28:58 -0800 Subject: [PATCH 12/15] Say that an explicit Satellites action lets the saved state go after a busy restore Co-authored-by: Manjunath Paparaju --- changelog.d/1829-space-missions-fixes.md | 2 +- docs/CURRENT-STATE.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog.d/1829-space-missions-fixes.md b/changelog.d/1829-space-missions-fixes.md index a68ca80360..d025da36f0 100644 --- a/changelog.d/1829-space-missions-fixes.md +++ b/changelog.d/1829-space-missions-fixes.md @@ -1,6 +1,6 @@ - Space Missions going off no longer acts on a launch hovered, selected or replayed meanwhile, and Satellites keeps the state it was saved with when - it is still busy; a Satellites setting changed during a mission, such as + it is still busy (unless it was switched on or off by hand meanwhile); a Satellites setting changed during a mission, such as a place search ending tracking, is kept when the mission ends. A click on a mission label is a click on the card on top, so no layer selects, turns on, flies to or opens the link of what lies under it; in the cockpit the diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 0d40a87685..4a970779a1 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -5668,7 +5668,9 @@ activeCameraCardEnabled: true })` may publish it through the retained > taken while it ran is kept. Restored parameters never re-show primitives > while the Satellite layer is disabled. When Satellites is still busy after > the 30 s limit, the restore changes nothing and keeps the saved state, so -> switching Space Missions off again finishes it. While Space Missions goes +> switching Space Missions off again finishes it; after an explicit +> Satellites on/off action, which keeps its visibility, the parameters are +> restored all the same and the saved state is let go. While Space Missions goes > off, its panel's roster and controls select, focus, preview and replay > nothing, so no camera move starts that nothing would end. > - **Flights 3D/cockpit hardening:** the destination-direction cue is an From 6c960eb3c9db4acbc96651d0a1f6f7a7e6cc34a4 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:37:53 -0800 Subject: [PATCH 13/15] Keep the camera still in the cockpit when a mission's dot is clicked or its orbit arrives The cockpit holds the camera: the mission dot, like its label, selects the mission there without flying to it, and a mission picked in the cockpit is not flown to when the active satellite lookup returns. Co-authored-by: Manjunath Paparaju --- changelog.d/1829-space-missions-fixes.md | 13 +++++++------ docs/CURRENT-STATE.md | 2 +- src/layers/launches/ingestion.js | 10 ++++++++-- src/layers/launches/labelClick.test.mjs | 21 +++++++++++++++++++-- src/layers/launches/lifecycle.js | 13 ++++--------- src/layers/launches/policy.js | 7 +++++++ 6 files changed, 46 insertions(+), 20 deletions(-) diff --git a/changelog.d/1829-space-missions-fixes.md b/changelog.d/1829-space-missions-fixes.md index d025da36f0..4072ef89a0 100644 --- a/changelog.d/1829-space-missions-fixes.md +++ b/changelog.d/1829-space-missions-fixes.md @@ -1,8 +1,9 @@ - Space Missions going off no longer acts on a launch hovered, selected or replayed meanwhile, and Satellites keeps the state it was saved with when - it is still busy (unless it was switched on or off by hand meanwhile); a Satellites setting changed during a mission, such as - a place search ending tracking, is kept when the mission ends. A click on - a mission label is a click on the card on top, so no layer selects, turns - on, flies to or opens the link of what lies under it; in the cockpit the - label selects its mission without moving the camera (manjunath22466, - samehkhamis, #1829). + it is still busy (unless it was switched on or off by hand meanwhile); a + Satellites setting changed during a mission, such as a place search ending + tracking, is kept when the mission ends. A click on a mission label is a + click on the card on top, so no layer selects, turns on, flies to or opens + the link of what lies under it; in the cockpit the label and the dot select + their mission without moving the camera (manjunath22466, samehkhamis, + #1829). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 4a970779a1..c769f03d4d 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7571,7 +7571,7 @@ silently demoting every later lookup for the session. protected-card path. Disable tears the tier down completely. Coverage/viewshed semantics unchanged. - **Satellites**: every point moves every frame. Each satellite's SGP4 sample (position, velocity, gravity and its rate of change; `src/layers/satellites/motion.js`) is reckoned forward or back to the world time and turned into the Earth-fixed frame, so points glide at any play speed instead of stepping once a second. Core satellites take a fresh sample every second, or as soon as the world time is 30 s from their sample (fast play, a seek), which keeps every point within about 10 m of SGP4; Starlink extras are sampled round-robin, more per frame the faster time plays, and a point more than two minutes from its sample waits for the next one. Hidden points are not moved until shown. Orbit rings rotate about Earth's Z by ΔGMST every ~1s (exact inertial→ECEF compensation; no SGP4 re-runs); the tracked satellite propagates per frame with one shared epoch for dot/label/camera. Verified: ISS holds <1km perpendicular to its ring while tracked. Pass prediction (`src/data/satellitePass.js`; `getNextSatellitePass`, `getNextIssPass`) scans at 20s, bisects rise/set to ~0.2s, fits the peak with a parabola, and marks a pass visible when the satellite is outside a cylindrical Earth shadow while the observer's Sun is at or below −6°. `next_iss_pass` preserves its geometric-pass ordering and appends visibility metadata. General `next_satellite_pass` accepts a loaded NORAD ID or unambiguous name, searches 24 hours and optionally requires estimated visibility. These estimates do not account for weather or satellite brightness. -- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot (in the cockpit, which holds the camera, it selects without moving); what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name. The name is an interactive world-overlay label, so it is the card on top for every click handler (`clickCard`, `isUnderOtherCard` in `src/data/pickRegistry.js`): no other layer selects, turns on, focuses or opens the link of a contact, card or camera that lies under the name, and their selections stay. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. +- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot (in the cockpit, which holds the camera, the name and the dot select without moving, also once the mission's orbit arrives); what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name. The name is an interactive world-overlay label, so it is the card on top for every click handler (`clickCard`, `isUnderOtherCard` in `src/data/pickRegistry.js`): no other layer selects, turns on, focuses or opens the link of a contact, card or camera that lies under the name, and their selections stay. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. When no mission is selected, the Space Missions panel presents a scrollable newest-first roster of every launch in the rolling window, including the smaller 5 px operator-colored marker, provider, and launch date. Hovering or keyboard-focusing a row shows four compact cyan corner brackets on both that roster row and its corresponding globe dot, rotates the globe at the current zoom to center it, and gives its label declutter priority without selecting it; the globe label remains unbracketed. Selecting a roster row invokes the same mission isolation and full-orbit framing as clicking its globe marker. The replay vehicle is one screen-space SVG/CSS HUD overlay rather than separate Cesium billboard, label, and reticle graphics. It is hidden during ordinary Focus and manual close views, where the standard selected launch-site label remains visible, and exists only while ascent replay is active. Its fixed pixel scale is shared by ascent and insertion, so camera range never resizes the rocket on screen before the phase boundary. Generic Launch Library pad names are reduced to their identifying suffix, and replay timestamps use a cyan state title over unprefixed white UTC date/time values. `REPLAY ASCENT` holds the unframed cyan/white rocket at the pad for a real-time `T−10` countdown, transitions through `LIFTOFF`, and attaches six tapered cyan/white ellipse waves directly below it from liftoff through insertion to convey thrust without adding scene geometry. While replay is active, the single start button is replaced by compact Play, Pause, and Cancel icon controls. Pause freezes countdown or mission time, vehicle/stage positions, camera target, labels, and thrust-wave animation; Play resumes from that exact frame, and Cancel releases replay camera ownership. The rocket and thrust group rotates from the path's live screen-space tangent, so its nose follows the visible ascent curve while the adjacent text remains upright. The camera begins as a close oblique launch chase, then smoothly widens between roughly 120 and 420 km vehicle altitude into a higher oblique context view that keeps the moving rocket targeted while exposing the ascent bend and orbit connection. At insertion the rocket/thrust glyph is replaced by the fixed-size cyan orbit dot, which the camera follows through the existing globe-scale orbit pullback. The chase camera limits per-frame yaw changes across heading wraps so it cannot abruptly cross in front of the vehicle and make ascent read in reverse; the replay-speed slider affects mission playback but not countdown duration. Mission world text has no native `LabelGraphics`: overview launch markers publish at most 48 ambient candidates for a 24-winner budget, while selecting a mission clears that overview source and publishes its launch-site callout, stage re-entry annotations, live/estimated payload-position readout, and orbit annotation as protected selected-lane entries. The source retains the exact former strings and colors. Static anchors reuse the Cartesian values used to build their mission geometry; the moving payload entry reads the layer's per-frame live-position cache; catalog-backed orbit annotation positions are cached in the same one-second matrix update that realigns the orbit primitive. Keyhole edge fade, horizon culling, final collision placement, and UI exclusion are owned by the shared host. Deselect restores the bounded overview, and refresh, disable, and destroy replace or clear both mission sources. A selected mission renders its orbit as four repeating tactical sectors, each containing one prominent cyan dot followed by one hundred thin translucent dashes. The bright dots act as orbit anchors while the subdued dash field remains depth-tested against the globe and is shown only for the selected mission. diff --git a/src/layers/launches/ingestion.js b/src/layers/launches/ingestion.js index 9b7de0e633..d16bd398b4 100644 --- a/src/layers/launches/ingestion.js +++ b/src/layers/launches/ingestion.js @@ -1,4 +1,8 @@ -import { MAX_POST_TLE_RETRIES, POST_TLE_RETRY_DELAY_MS } from './policy.js'; +import { + MAX_POST_TLE_RETRIES, + POST_TLE_RETRY_DELAY_MS, + cockpitActive, +} from './policy.js'; /** * Let pending Satellites work finish, including requests that join it while @@ -264,7 +268,9 @@ export function createIngestion({ parts.selection.setSelectedMission(null, false); } else { parts.selection.setSelectedMission(layerState._selectedLaunchId, true); - if (layerState._focusAfterActiveLookup) { + // The cockpit holds the camera: a mission picked there is not flown + // to when its orbit arrives. + if (layerState._focusAfterActiveLookup && !cockpitActive()) { parts.selection.focusMission( launches.find( (launch) => launch.id === layerState._selectedLaunchId, diff --git a/src/layers/launches/labelClick.test.mjs b/src/layers/launches/labelClick.test.mjs index 7ac92d5564..bd44c62187 100644 --- a/src/layers/launches/labelClick.test.mjs +++ b/src/layers/launches/labelClick.test.mjs @@ -196,8 +196,8 @@ test("another layer's label keeps the click above mission geometry", (t) => { assert.deepEqual(r.focused, ['L1']); }); -test('in the cockpit a mission label selects its mission without moving the camera', (t) => { - const r = rig(t, { overlayHit: label('launch:L2') }); +test('in the cockpit a mission label or dot selects its mission without moving the camera', (t) => { + const r = rig(t, { overlayHit: label('launch:L2'), geometryLaunchId: 'L1' }); const previous = Object.getOwnPropertyDescriptor(globalThis, 'document'); Object.defineProperty(globalThis, 'document', { configurable: true, @@ -213,6 +213,23 @@ test('in the cockpit a mission label selects its mission without moving the came } assert.deepEqual(r.focused, ['L2'], 'the mission is selected'); assert.deepEqual(r.moved, [], 'the cockpit keeps the camera'); + // The dot, with no label over it, does the same. + r.setHit(null); + Object.defineProperty(globalThis, 'document', { + configurable: true, + value: { + body: { classList: { contains: (name) => name === 'cockpit-mode' } }, + }, + }); + try { + r.click(); + } finally { + if (previous) Object.defineProperty(globalThis, 'document', previous); + else delete globalThis.document; + } + assert.deepEqual(r.focused, ['L2', 'L1']); + assert.deepEqual(r.moved, []); + r.setHit(label('launch:L2')); // Out of the cockpit the same click moves there too. r.click(); assert.deepEqual(r.moved, ['L2']); diff --git a/src/layers/launches/lifecycle.js b/src/layers/launches/lifecycle.js index a42e14047b..947c4750d1 100644 --- a/src/layers/launches/lifecycle.js +++ b/src/layers/launches/lifecycle.js @@ -5,6 +5,7 @@ import { worldClock } from '../../time/worldClock.js'; import { ROCKET_MISSION_AMBIENT_OVERLAY_SOURCE_ID, ROCKET_MISSION_SELECTED_OVERLAY_SOURCE_ID, + cockpitActive, } from './policy.js'; const HOVER_PICK_INTERVAL_MS = 120; @@ -154,13 +155,6 @@ function restoreCameraView(viewer, view, landedView) { /** The longest name a timeline mark carries, as in the mission index. */ const MARK_LABEL_LENGTH = 27; -/** Whether the cockpit view is on. */ -function cockpitActive() { - return Boolean( - globalThis.document?.body?.classList?.contains?.('cockpit-mode'), - ); -} - function markerLaunchId(hit) { if ( hit?.sourceId !== ROCKET_MISSION_AMBIENT_OVERLAY_SOURCE_ID && @@ -252,8 +246,8 @@ export function createLifecycle({ // overlay. An unrelated label keeps the click above mission geometry. overlayClicks.add(event); // The label is the card on top, so every other layer and the cockpit - // leave its click alone. In the cockpit, which holds the camera, it - // selects the mission without moving there. + // leave its click alone. In the cockpit, which holds the camera, the + // label and the dot select the mission without moving there. return focusLaunch(markerLaunchId(hit), { move: !cockpitActive() }); }); const unsubscribeClick = input.onClick((event) => { @@ -269,6 +263,7 @@ export function createLifecycle({ parts.rendering.launchIdFromPicks( parts.rendering.missionHitsAt(event.position, 12), ), + { move: !cockpitActive() }, ); }); hover = createLaunchHover({ diff --git a/src/layers/launches/policy.js b/src/layers/launches/policy.js index 34dcaae5bb..07718c26f6 100644 --- a/src/layers/launches/policy.js +++ b/src/layers/launches/policy.js @@ -103,3 +103,10 @@ export const TRAJECTORY_STAGE_COLORS = [ '#ffd166', '#60a5fa', ]; + +/** Whether the cockpit view is on; it holds the camera while it is. */ +export function cockpitActive() { + return Boolean( + globalThis.document?.body?.classList?.contains?.('cockpit-mode'), + ); +} From cdde80f3ad9b146ce6a892faeea50b181d93b122 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:58:17 -0800 Subject: [PATCH 14/15] Never fly to a mission while the cockpit holds the camera Focusing a mission does nothing in the cockpit, so the layer row's arrows select the next mission without moving the camera, as its label and dot already do. Co-authored-by: Manjunath Paparaju --- changelog.d/1829-space-missions-fixes.md | 6 +++--- docs/CURRENT-STATE.md | 2 +- src/layers/launches/selection.js | 9 ++++++++- src/layers/launches/worldTime.test.mjs | 22 +++++++++++++++++++++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/changelog.d/1829-space-missions-fixes.md b/changelog.d/1829-space-missions-fixes.md index 4072ef89a0..626defeb94 100644 --- a/changelog.d/1829-space-missions-fixes.md +++ b/changelog.d/1829-space-missions-fixes.md @@ -4,6 +4,6 @@ Satellites setting changed during a mission, such as a place search ending tracking, is kept when the mission ends. A click on a mission label is a click on the card on top, so no layer selects, turns on, flies to or opens - the link of what lies under it; in the cockpit the label and the dot select - their mission without moving the camera (manjunath22466, samehkhamis, - #1829). + the link of what lies under it; in the cockpit a mission chosen by its + label, its dot or the row's arrows is selected without moving the camera + (manjunath22466, samehkhamis, #1829). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index c769f03d4d..fe0a23d384 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7571,7 +7571,7 @@ silently demoting every later lookup for the session. protected-card path. Disable tears the tier down completely. Coverage/viewshed semantics unchanged. - **Satellites**: every point moves every frame. Each satellite's SGP4 sample (position, velocity, gravity and its rate of change; `src/layers/satellites/motion.js`) is reckoned forward or back to the world time and turned into the Earth-fixed frame, so points glide at any play speed instead of stepping once a second. Core satellites take a fresh sample every second, or as soon as the world time is 30 s from their sample (fast play, a seek), which keeps every point within about 10 m of SGP4; Starlink extras are sampled round-robin, more per frame the faster time plays, and a point more than two minutes from its sample waits for the next one. Hidden points are not moved until shown. Orbit rings rotate about Earth's Z by ΔGMST every ~1s (exact inertial→ECEF compensation; no SGP4 re-runs); the tracked satellite propagates per frame with one shared epoch for dot/label/camera. Verified: ISS holds <1km perpendicular to its ring while tracked. Pass prediction (`src/data/satellitePass.js`; `getNextSatellitePass`, `getNextIssPass`) scans at 20s, bisects rise/set to ~0.2s, fits the peak with a parabola, and marks a pass visible when the satellite is outside a cylindrical Earth shadow while the observer's Sun is at or below −6°. `next_iss_pass` preserves its geometric-pass ordering and appends visibility metadata. General `next_satellite_pass` accepts a loaded NORAD ID or unambiguous name, searches 24 hours and optionally requires estimated visibility. These estimates do not account for weather or satellite brightness. -- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot (in the cockpit, which holds the camera, the name and the dot select without moving, also once the mission's orbit arrives); what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name. The name is an interactive world-overlay label, so it is the card on top for every click handler (`clickCard`, `isUnderOtherCard` in `src/data/pickRegistry.js`): no other layer selects, turns on, focuses or opens the link of a contact, card or camera that lies under the name, and their selections stay. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. +- **Space Missions (30d)**: recent launches render as bounded shared-host, horizon-occluded mission markers using Launch Library 2 v2.3 detailed records. Enabling the layer reveals its own right-rail button and roster and enables the required satellite layer; it does not touch Context. Before applying its temporary dense/hidden Satellite mode, Space Missions snapshots the complete standalone Satellite parameter set and exact enabled-layer set. Disabling Space Missions from Data Layers hides its rail button and panel and restores those parameters and the exact prior enabled state, so a Satellite layer that was already on stays on while a mode-owned dependency returns off; enabling Satellites by itself remains independent. An explicit user or voice Satellites OFF requested after Space Missions ON exits Space Missions, including after returning from Stories; scene, story, preset and other programmatic Satellites changes do not. The controls under the Space Missions row cycle through available launches. Selecting a mission isolates its launch-to-orbit transfer and dashed satellite orbit, fills the Space Missions panel with details, navigation, and replay controls, and animates a small phase-colored marker along the exact displayed Cartesian samples. Marker hit testing drill-picks through photorealistic tiles so the depth-test-free tactical dot remains reliably selectable. Clicking the launch name on the globe selects and focuses the same mission as its dot (in the cockpit, which holds the camera, a mission chosen by its name, its dot or the layer row's arrows is selected without flying to it, also once its orbit arrives); what is drawn beneath the name is not picked, and the other layers still hear the click as one on the name. The name is an interactive world-overlay label, so it is the card on top for every click handler (`clickCard`, `isUnderOtherCard` in `src/data/pickRegistry.js`): no other layer selects, turns on, focuses or opens the link of a contact, card or camera that lies under the name, and their selections stay. The selected pad is the camera's zoom pivot: the overview remains centered on its launch site, wheel zoom approaches that site instead of drifting elsewhere, and camera pitch progressively changes from global nadir to an oblique close 3D view. Its protected shared-host callout remains visible and expands to include both mission and launch-site names. `FOCUS` flies directly to a 12 km oblique frame around the selected launch site and retains the same anchored zoom/orbit behavior. `REPLAY ASCENT` resets the selected marker at the pad, frames it from an oblique third-person angle, and follows it through the mission-specific compressed ascent directly into one orbital lap at the default `1×` rate. A live `0.25×`–`4×` slider changes ascent and orbit playback speed; adjusting it mid-replay preserves the current path position and historical mission timestamp. Re-entry/recovery cannot be inserted into replay. At orbit insertion the camera smoothly pulls back over the first fifth of the orbital replay and pitches to a globe-scale nadir view while continuing to target the moving replay point. Replay Cancel, mission navigation, deselection, layer disable, and data refresh all release camera ownership. Reconstructed paths are one continuous 128-sample geodetic curve: horizontal departure begins near zero while altitude rises quickly, then the climb progressively bends toward insertion without the former hard 120 km corner. Unmatched orbit fallbacks are smooth planar inclined rings rather than longitude/latitude ground-track curves. The panel lists disclosed payload names, types, operators/manufacturers, mass, multiplicity, and destination when supplied; an empty LL2 payload collection is shown as `CLASSIFIED / MULTI-PAYLOAD`. Launcher, spacecraft, and recoverable payload stages appear in a compact stage table with serial/flight/reuse details, recovery outcome/type, destination, and final coordinates when those records exist; an empty recovery collection omits the section. Stage recoveries with confirmed coordinates use those coordinates; return-to-launch-site records use the pad; downrange-only records receive an explicitly labeled estimated endpoint along the ascent azimuth. Available endpoints render as static 2 px dashed descent/recovery paths with a fixed final-position dot and an estimated atmospheric-interface segment when applicable. The ascent is geodetically densified above the ellipsoid toward the orbit's nearest insertion point, then rendered with `ArcType.NONE`, so it neither cuts through Earth nor separates from the marker. Because LL2 does not normally supply continuous ascent telemetry, pad-to-insertion paths without upstream trajectory samples are labeled `RECONSTRUCTED ESTIMATE` / `ASCENT ESTIMATE`; only supplied trajectory samples receive the replay wording. Selected-orbit framing fits the complete ring, rear-side linework uses normal scene depth occlusion, and current distance, speed, and callout data come only from a launch-year-validated satellite match. Both the loaded-catalog and active-TLE lookups read the launch year from the TLE international designator through one parser (`src/sources/tle.js`); a blank or malformed designator is an unknown year, which skips the year check rather than rejecting the match. Speed is the magnitude of the SGP4 inertial velocity vector at the same propagation epoch as position, displayed in km/s with km/h available as hover detail. Unavailable operator, site, launch-time, orbit, current-altitude, and speed values omit their detail rows instead of reserving panel space with placeholders. Newly launched payloads absent from the core operational groups use CelesTrak's cached active TLE feed as a lookup-only fallback; weak constellation-name matches are rejected. The replay callout maps compressed animation progress onto Launch Library's mission-relative timeline, showing the historical UTC date/time at the marker's current path position; unavailable timelines remain explicit. Matched live satellite positions propagate at one-second cadence and use a distinct green dot/callout with the current UTC date/time. When no mission is selected, the Space Missions panel presents a scrollable newest-first roster of every launch in the rolling window, including the smaller 5 px operator-colored marker, provider, and launch date. Hovering or keyboard-focusing a row shows four compact cyan corner brackets on both that roster row and its corresponding globe dot, rotates the globe at the current zoom to center it, and gives its label declutter priority without selecting it; the globe label remains unbracketed. Selecting a roster row invokes the same mission isolation and full-orbit framing as clicking its globe marker. The replay vehicle is one screen-space SVG/CSS HUD overlay rather than separate Cesium billboard, label, and reticle graphics. It is hidden during ordinary Focus and manual close views, where the standard selected launch-site label remains visible, and exists only while ascent replay is active. Its fixed pixel scale is shared by ascent and insertion, so camera range never resizes the rocket on screen before the phase boundary. Generic Launch Library pad names are reduced to their identifying suffix, and replay timestamps use a cyan state title over unprefixed white UTC date/time values. `REPLAY ASCENT` holds the unframed cyan/white rocket at the pad for a real-time `T−10` countdown, transitions through `LIFTOFF`, and attaches six tapered cyan/white ellipse waves directly below it from liftoff through insertion to convey thrust without adding scene geometry. While replay is active, the single start button is replaced by compact Play, Pause, and Cancel icon controls. Pause freezes countdown or mission time, vehicle/stage positions, camera target, labels, and thrust-wave animation; Play resumes from that exact frame, and Cancel releases replay camera ownership. The rocket and thrust group rotates from the path's live screen-space tangent, so its nose follows the visible ascent curve while the adjacent text remains upright. The camera begins as a close oblique launch chase, then smoothly widens between roughly 120 and 420 km vehicle altitude into a higher oblique context view that keeps the moving rocket targeted while exposing the ascent bend and orbit connection. At insertion the rocket/thrust glyph is replaced by the fixed-size cyan orbit dot, which the camera follows through the existing globe-scale orbit pullback. The chase camera limits per-frame yaw changes across heading wraps so it cannot abruptly cross in front of the vehicle and make ascent read in reverse; the replay-speed slider affects mission playback but not countdown duration. Mission world text has no native `LabelGraphics`: overview launch markers publish at most 48 ambient candidates for a 24-winner budget, while selecting a mission clears that overview source and publishes its launch-site callout, stage re-entry annotations, live/estimated payload-position readout, and orbit annotation as protected selected-lane entries. The source retains the exact former strings and colors. Static anchors reuse the Cartesian values used to build their mission geometry; the moving payload entry reads the layer's per-frame live-position cache; catalog-backed orbit annotation positions are cached in the same one-second matrix update that realigns the orbit primitive. Keyhole edge fade, horizon culling, final collision placement, and UI exclusion are owned by the shared host. Deselect restores the bounded overview, and refresh, disable, and destroy replace or clear both mission sources. A selected mission renders its orbit as four repeating tactical sectors, each containing one prominent cyan dot followed by one hundred thin translucent dashes. The bright dots act as orbit anchors while the subdued dash field remains depth-tested against the globe and is shown only for the selected mission. diff --git a/src/layers/launches/selection.js b/src/layers/launches/selection.js index 0f35eb28dc..281d0ee85c 100644 --- a/src/layers/launches/selection.js +++ b/src/layers/launches/selection.js @@ -11,7 +11,11 @@ import { toRadians, vec, } from '../../geo/vector.js'; -import { MISSION_GLOBE_VIEW_RANGE_M, MISSION_FOCUS_RANGE_M } from './policy.js'; +import { + MISSION_GLOBE_VIEW_RANGE_M, + MISSION_FOCUS_RANGE_M, + cockpitActive, +} from './policy.js'; import { cameraOf, canvasOf, findCamera } from '../../render/rendererOf.js'; export function createSelection({ @@ -122,6 +126,9 @@ export function createSelection({ function focusMission(launch) { if (!layerState._viewer || !launch || !layerState._enabled) return; + // The cockpit holds the camera: a mission chosen there, by its label, + // its dot or the layer row's arrows, is selected without flying to it. + if (cockpitActive()) return; stopMissionZoomAnchor(); parts.rendering.selectLaunchEntity(launch.id); const camera = cameraOf(layerState._viewer); diff --git a/src/layers/launches/worldTime.test.mjs b/src/layers/launches/worldTime.test.mjs index 73eb0b16f3..f16cd1fdd1 100644 --- a/src/layers/launches/worldTime.test.mjs +++ b/src/layers/launches/worldTime.test.mjs @@ -36,10 +36,12 @@ function scene(t) { ], }; const viewer = { scene: {} }; + const flights = []; const { draw, unbind } = bindFakeDraw(viewer, { camera: { pose: () => ({ position: { x: 2e7, y: 0, z: 0 } }), on: () => () => {}, + flyTo: (...args) => flights.push(args), }, }); t.after(unbind); @@ -88,7 +90,7 @@ function scene(t) { path: item(`rocket-trajectory:${launch.id}:0`).show, }; }; - return { state, rendering, launch, syncs, shown, draw }; + return { state, rendering, launch, syncs, shown, draw, parts, flights }; } test('live shows every launch in the window, lifted off or not', (t) => { @@ -127,3 +129,21 @@ test('the live orbit rings turn at the frame time, not the wall clock', (t) => { ); assert.deepEqual(orbits.spec.motionClock, { kind: 'scene' }); }); + +test('in the cockpit a chosen mission is not flown to', (t) => { + const { launch, parts, flights } = scene(t); + const previous = Object.getOwnPropertyDescriptor(globalThis, 'document'); + Object.defineProperty(globalThis, 'document', { + configurable: true, + value: { + body: { classList: { contains: (name) => name === 'cockpit-mode' } }, + }, + }); + try { + parts.selection.focusMission(launch); + } finally { + if (previous) Object.defineProperty(globalThis, 'document', previous); + else delete globalThis.document; + } + assert.deepEqual(flights, [], 'the cockpit keeps the camera'); +}); From b5018b8cc289b0131f51bd6e901751f2c72ecddd Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 21:25:05 -0800 Subject: [PATCH 15/15] Let the cockpit focus test reach its check The test's camera and rendering doubles now carry what focusing a mission uses, so without the cockpit guard the test fails on the camera flight rather than on a missing double. Co-authored-by: Manjunath Paparaju --- src/layers/launches/worldTime.test.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/layers/launches/worldTime.test.mjs b/src/layers/launches/worldTime.test.mjs index f16cd1fdd1..76f1b02c4e 100644 --- a/src/layers/launches/worldTime.test.mjs +++ b/src/layers/launches/worldTime.test.mjs @@ -42,6 +42,8 @@ function scene(t) { pose: () => ({ position: { x: 2e7, y: 0, z: 0 } }), on: () => () => {}, flyTo: (...args) => flights.push(args), + lookAt: noop, + release: noop, }, }); t.after(unbind); @@ -71,6 +73,7 @@ function scene(t) { }; parts.selection = createSelection({ state, services, parts }); const rendering = createRendering({ state, services, parts }); + parts.rendering = rendering; rendering.attach(viewer); rendering.showMissions(true); rendering.addLaunchEntity(launch, null);