From 57f9c03eaab1285c1f97db3d13dc1582aacf7313 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Mon, 16 Nov 2026 14:58:49 -0800 Subject: [PATCH] Keep Context's follow, clicks, Radio, Cockpit entry and credits right - Following comes only from the camera's own follow, never claimed ahead of it; vessels, which the camera does not follow, are flown to. - A drag or a long press never selects, and only a clean click on open map closes the card; a card painted on the overlay is not open map. - Closing the card lets go through its own layer only, as the person's action, leaving other layers' selections alone. - Radio's panel, with its local SDR tuner, shows whether or not the Radio layer is on; Contacts' Cockpit entry hides only while the card offers its own. - Expanded Context keeps the credits beside it right to left and with the minimal HUD. - Context counts as closed until its panel says it is open; closed, the card's refresh and the view reading pause, and opening reads the view. - The five-minute re-read fetches again past the caches, keeps what is shown meanwhile, and an empty brief is not kept. Co-authored-by: Manjunath Paparaju --- src/creditAttribution.test.mjs | 574 ++++++++++++++++++++----- src/ui/applicationShell.js | 1 + src/ui/composition.js | 2 + src/ui/entityContextBridge.js | 79 +++- src/ui/spotConditions.js | 48 ++- src/ui/stores/entityCard.js | 27 +- src/ui/styles/context-dock.css | 26 +- src/ui/styles/entity-card.css | 8 +- src/ui/views/ContextView.vue | 4 +- src/ui/views/panels/SpotConditions.vue | 18 +- 10 files changed, 599 insertions(+), 188 deletions(-) diff --git a/src/creditAttribution.test.mjs b/src/creditAttribution.test.mjs index 13e1af394..b69566610 100644 --- a/src/creditAttribution.test.mjs +++ b/src/creditAttribution.test.mjs @@ -95,7 +95,10 @@ function specificity(selector) { if (rest[i] === '(') depth += 1; else if (rest[i] === ')') { depth -= 1; - if (depth === 0) { end = i; break; } + if (depth === 0) { + end = i; + break; + } } } assert.ok(end > 0, `unbalanced functional pseudo-class in "${selector}"`); @@ -116,7 +119,9 @@ function specificity(selector) { classes += (rest.match(/\[[^\]]*\]/g) || []).length; types += (rest.match(/::[\w-]+/g) || []).length; classes += (rest.replace(/::[\w-]+/g, '').match(/:[\w-]+/g) || []).length; - types += (rest.replace(/\[[^\]]*\]/g, '').match(/(?:^|[\s>+~])[a-zA-Z][\w-]*/g) || []).length; + types += ( + rest.replace(/\[[^\]]*\]/g, '').match(/(?:^|[\s>+~])[a-zA-Z][\w-]*/g) || [] + ).length; return [ids, classes, types]; } @@ -165,7 +170,11 @@ function flattenRules(source) { rules.push({ order: rules.length, media: [...mediaStack], - parts: splitTopLevel(head, ',').map((part) => part.trim().replace(/\(\s+/g, '(').replace(/\s+\)/g, ')')).filter(Boolean), + parts: splitTopLevel(head, ',') + .map((part) => + part.trim().replace(/\(\s+/g, '(').replace(/\s+\)/g, ')'), + ) + .filter(Boolean), decls, }); index = close + 1; @@ -218,14 +227,36 @@ const RECOGNIZED = new Set([ ]); const DOCKED_RAIL = 'body.context-docked #right-context-rail'; -const ELEMENT_KEYS = ['#cesium-credits', '#command-dock', '#right-context-rail', '.dock-popover-content']; +const ELEMENT_KEYS = [ + '#cesium-credits', + '#command-dock', + '#right-context-rail', + '.dock-popover-content', +]; // Any of these on a modelled element's own box changes the geometry this pin // reasons about, so each occurrence must be recognized and vetted. const GUARDED_PROPS = new Set([ - 'bottom', 'top', 'inset', 'inset-block', 'inset-block-end', 'inset-inline', 'inset-inline-end', - 'margin', 'margin-bottom', 'margin-block', 'margin-block-end', 'all', - 'height', 'min-height', 'max-height', 'position', 'transform', 'translate', 'scale', 'zoom', + 'bottom', + 'top', + 'inset', + 'inset-block', + 'inset-block-end', + 'inset-inline', + 'inset-inline-end', + 'margin', + 'margin-bottom', + 'margin-block', + 'margin-block-end', + 'all', + 'height', + 'min-height', + 'max-height', + 'position', + 'transform', + 'translate', + 'scale', + 'zoom', ]); // Custom properties allowed inside a modelled offset. Each is a pinned-tray @@ -291,7 +322,10 @@ function parseMediaCondition(condition) { function appliesAt(rule, width, label) { return rule.media.every((condition) => { const maxWidth = parseMediaCondition(condition); - assert.ok(maxWidth !== null, `unmodelled media condition "${condition}" gates ${label}`); + assert.ok( + maxWidth !== null, + `unmodelled media condition "${condition}" gates ${label}`, + ); return width <= maxWidth; }); } @@ -306,13 +340,26 @@ function resolve(candidates, prop, width, label) { if (!candidates.includes(part)) continue; for (const decl of rule.decls) { if (decl.prop !== prop) continue; - const contender = { decl, part, order: rule.order, spec: specificity(part) }; - if (!winner) { winner = contender; continue; } - const byImportance = Number(contender.decl.important) - Number(winner.decl.important); + const contender = { + decl, + part, + order: rule.order, + spec: specificity(part), + }; + if (!winner) { + winner = contender; + continue; + } + const byImportance = + Number(contender.decl.important) - Number(winner.decl.important); const bySpecificity = compareSpecificity(contender.spec, winner.spec); - if (byImportance > 0 - || (byImportance === 0 && bySpecificity > 0) - || (byImportance === 0 && bySpecificity === 0 && contender.order > winner.order)) { + if ( + byImportance > 0 || + (byImportance === 0 && bySpecificity > 0) || + (byImportance === 0 && + bySpecificity === 0 && + contender.order > winner.order) + ) { winner = contender; } } @@ -326,10 +373,26 @@ function resolve(candidates, prop, width, label) { function toPx(value, viewportHeight, where) { const trimmed = value.trim(); const inner = /^calc\(/.test(trimmed) ? trimmed.slice(5, -1) : trimmed; - assert.doesNotMatch(inner, /\bcalc\(/, `nested calc() in ${where}: "${value}"`); - assert.doesNotMatch(inner, /\b(min|max|clamp|env|attr|round|mod)\(/, `unmodelled function in ${where}: "${value}"`); - assert.doesNotMatch(inner, /[*/]/, `unmodelled operator in ${where}: "${value}"`); - assert.doesNotMatch(inner, /\s-\s/, `unmodelled subtraction in ${where}: "${value}"`); + assert.doesNotMatch( + inner, + /\bcalc\(/, + `nested calc() in ${where}: "${value}"`, + ); + assert.doesNotMatch( + inner, + /\b(min|max|clamp|env|attr|round|mod)\(/, + `unmodelled function in ${where}: "${value}"`, + ); + assert.doesNotMatch( + inner, + /[*/]/, + `unmodelled operator in ${where}: "${value}"`, + ); + assert.doesNotMatch( + inner, + /\s-\s/, + `unmodelled subtraction in ${where}: "${value}"`, + ); let total = 0; for (const raw of splitTopLevel(inner, '+')) { const term = raw.trim(); @@ -337,40 +400,60 @@ function toPx(value, viewportHeight, where) { if (term === '100%') continue; // the tray's own panel height, added separately if (term.startsWith('var(')) { const name = term.slice(4, term.lastIndexOf(')')).split(',')[0].trim(); - assert.ok(VETTED_VARS.has(name), `unvetted custom property ${name} in ${where}: "${value}"`); + assert.ok( + VETTED_VARS.has(name), + `unvetted custom property ${name} in ${where}: "${value}"`, + ); if (name === '--world-timeline-lift') total += liftPx; continue; // proven non-negative; 0 is the conservative floor } - assert.match(term, /^-?[\d.]+(px|rem|vh)$/, `unmodelled length term "${term}" in ${where}: "${value}"`); + assert.match( + term, + /^-?[\d.]+(px|rem|vh)$/, + `unmodelled length term "${term}" in ${where}: "${value}"`, + ); const number = Number.parseFloat(term); if (term.endsWith('rem')) total += number * REM_PX; - else if (term.endsWith('vh')) total += number * viewportHeight / 100; + else if (term.endsWith('vh')) total += (number * viewportHeight) / 100; else total += number; } return total; } -const WIDTHS = [1440, 1024, 980, 900, 830, 800, 760, 721, 720, 700, 640, 600, 480, 375]; +const WIDTHS = [ + 1440, 1024, 980, 900, 830, 800, 760, 721, 720, 700, 640, 600, 480, 375, +]; const HEIGHTS = [500, 560, 640, 700, 800, 900, 1000, 1080, 1200, 1440, 1600]; -const CREDIT_SELECTORS = ['#cesium-credits', 'body:not(.ui-clean-view):not(.recording-mode) #cesium-credits']; -const MINIMAL_HUD_CREDIT = "body:not(.ui-clean-view):not(.recording-mode):has(#intel-hud[data-variant='minimal'].active) #cesium-credits"; -const TRAY_ORDINARY = ['#command-dock .dock-popover-content', '#command-dock #location-bar .dock-popover-content']; +const CREDIT_SELECTORS = [ + '#cesium-credits', + 'body:not(.ui-clean-view):not(.recording-mode) #cesium-credits', +]; +const MINIMAL_HUD_CREDIT = + "body:not(.ui-clean-view):not(.recording-mode):has(#intel-hud[data-variant='minimal'].active) #cesium-credits"; +const TRAY_ORDINARY = [ + '#command-dock .dock-popover-content', + '#command-dock #location-bar .dock-popover-content', +]; const TRAY_SCENARIOS = [ { name: 'ordinary tray', offset: TRAY_ORDINARY }, { name: 'one pinned tray', - offset: [...TRAY_ORDINARY, - '#command-dock.dock-has-pinned-tray #location-bar:not(.collapsed):not(.dock-pinned) .dock-popover-content'], + offset: [ + ...TRAY_ORDINARY, + '#command-dock.dock-has-pinned-tray #location-bar:not(.collapsed):not(.dock-pinned) .dock-popover-content', + ], stackVar: '--dock-pinned-stack-height', }, { name: 'two pinned trays (upper)', - offset: [...TRAY_ORDINARY, + offset: [ + ...TRAY_ORDINARY, // The stock form still governs above 900px; the ID form is what keeps it // ahead of the ordinary narrow rule below it. '#command-dock.dock-has-two-pinned-trays .dock-pinned-top.dock-pinned:not(.collapsed) .dock-popover-content', - '#command-dock.dock-has-two-pinned-trays #location-bar.dock-pinned-top.dock-pinned:not(.collapsed) .dock-popover-content'], + '#command-dock.dock-has-two-pinned-trays #location-bar.dock-pinned-top.dock-pinned:not(.collapsed) .dock-popover-content', + ], stackVar: '--dock-lower-pinned-height', }, ]; @@ -383,12 +466,18 @@ function creditTopPx(width, height) { function trayBottomPx(scenario, width, height) { const dock = resolve(['#command-dock'], 'bottom', width, 'command dock'); const offset = resolve(scenario.offset, 'bottom', width, scenario.name); - const margin = resolve(['#command-dock #location-bar:not(.collapsed) .dock-popover-content'], - 'margin-bottom', width, 'open tray margin'); - return toPx(dock.decl.value, height, 'dock bottom') - + COMPACT_DOCK_HEIGHT_PX - + toPx(offset.decl.value, height, `${scenario.name} offset`) - + toPx(margin.decl.value, height, 'tray margin'); + const margin = resolve( + ['#command-dock #location-bar:not(.collapsed) .dock-popover-content'], + 'margin-bottom', + width, + 'open tray margin', + ); + return ( + toPx(dock.decl.value, height, 'dock bottom') + + COMPACT_DOCK_HEIGHT_PX + + toPx(offset.decl.value, height, `${scenario.name} offset`) + + toPx(margin.decl.value, height, 'tray margin') + ); } // ── Fail-closed guards ────────────────────────────────────────────────────── @@ -396,15 +485,31 @@ function trayBottomPx(scenario, width, height) { test('the specificity calculator itself is pinned', () => { const cases = [ ['#cesium-credits', [1, 0, 0]], - ['body:not(.ui-clean-view):not(.recording-mode) #cesium-credits', [1, 2, 1]], + [ + 'body:not(.ui-clean-view):not(.recording-mode) #cesium-credits', + [1, 2, 1], + ], ['#command-dock #location-bar .dock-popover-content', [2, 1, 0]], - ['#command-dock.dock-has-pinned-tray #location-bar:not(.collapsed):not(.dock-pinned) .dock-popover-content', [2, 4, 0]], - ['#command-dock.dock-has-two-pinned-trays #location-bar.dock-pinned-top.dock-pinned:not(.collapsed) .dock-popover-content', [2, 5, 0]], - ['#command-dock.dock-has-two-pinned-trays .dock-pinned-top.dock-pinned:not(.collapsed) .dock-popover-content', [1, 5, 0]], + [ + '#command-dock.dock-has-pinned-tray #location-bar:not(.collapsed):not(.dock-pinned) .dock-popover-content', + [2, 4, 0], + ], + [ + '#command-dock.dock-has-two-pinned-trays #location-bar.dock-pinned-top.dock-pinned:not(.collapsed) .dock-popover-content', + [2, 5, 0], + ], + [ + '#command-dock.dock-has-two-pinned-trays .dock-pinned-top.dock-pinned:not(.collapsed) .dock-popover-content', + [1, 5, 0], + ], ['#command-dock .dock-popover-content::after', [1, 1, 1]], ]; for (const [selector, expected] of cases) { - assert.deepEqual(specificity(selector), expected, `specificity of "${selector}"`); + assert.deepEqual( + specificity(selector), + expected, + `specificity of "${selector}"`, + ); } }); @@ -417,27 +522,42 @@ test('the model refuses every cascade construct it cannot resolve', () => { // stops short of it instead (the docked-Context test below). if (part === DOCKED_RAIL) continue; if (!RECOGNIZED.has(part)) { - complaints.push(`unrecognized selector positions a modelled element: "${part}" (${guarded.map((d) => d.prop).join(', ')})`); + complaints.push( + `unrecognized selector positions a modelled element: "${part}" (${guarded.map((d) => d.prop).join(', ')})`, + ); continue; } for (const condition of rule.media) { if (parseMediaCondition(condition) === null) { - complaints.push(`unmodelled media condition "${condition}" on "${part}"`); + complaints.push( + `unmodelled media condition "${condition}" on "${part}"`, + ); } } if (rule.media.length > 1) { - complaints.push(`nested media queries on "${part}": ${rule.media.join(' && ')}`); + complaints.push( + `nested media queries on "${part}": ${rule.media.join(' && ')}`, + ); } for (const decl of guarded) { // Measurement is synchronous and restored before returning or painting. // Only these two exact declarations earn the exemption tested below. - const railMeasurement = part === '#right-context-rail[data-rail-measuring]' - && ((decl.prop === 'height' && decl.value === 'auto') - || (decl.prop === 'max-height' && decl.value === 'none')); - if (decl.important && !railMeasurement) complaints.push(`!important on ${decl.prop} of "${part}"`); - if (decl.prop === 'inset' || decl.prop === 'margin' || decl.prop === 'all' - || decl.prop.startsWith('inset-') || decl.prop.startsWith('margin-block')) { - complaints.push(`shorthand ${decl.prop} on "${part}" — the model reads longhands only`); + const railMeasurement = + part === '#right-context-rail[data-rail-measuring]' && + ((decl.prop === 'height' && decl.value === 'auto') || + (decl.prop === 'max-height' && decl.value === 'none')); + if (decl.important && !railMeasurement) + complaints.push(`!important on ${decl.prop} of "${part}"`); + if ( + decl.prop === 'inset' || + decl.prop === 'margin' || + decl.prop === 'all' || + decl.prop.startsWith('inset-') || + decl.prop.startsWith('margin-block') + ) { + complaints.push( + `shorthand ${decl.prop} on "${part}" — the model reads longhands only`, + ); } if (decl.prop === 'height' || decl.prop === 'max-height') { // A capped height can override `bottom` and invalidate the measured @@ -446,68 +566,159 @@ test('the model refuses every cascade construct it cannot resolve', () => { // modelled band by the rail clearance test) and `.layout-focus` // (proven inapplicable at <=720px by the mobile-mode test), plus // synchronous measurement, which is removed before any paint. - const railOwn = part === '#right-context-rail' && decl.prop === 'max-height'; + const railOwn = + part === '#right-context-rail' && decl.prop === 'max-height'; const railFocus = part === '#right-context-rail.layout-focus'; - if (!railOwn && !railFocus && !railMeasurement) complaints.push(`${decl.prop}: ${decl.value} on "${part}"`); + if (!railOwn && !railFocus && !railMeasurement) + complaints.push(`${decl.prop}: ${decl.value} on "${part}"`); } - if (decl.prop === 'transform' && /translateY|translate3d|matrix|scale\(/.test(decl.value)) { + if ( + decl.prop === 'transform' && + /translateY|translate3d|matrix|scale\(/.test(decl.value) + ) { const identity = decl.value === 'translateY(0) scale(1)'; - const closedTray = part === '#command-dock .dock-popover-content' - && decl.value === 'translateY(0.55rem) scale(0.985)'; - if (!identity && !closedTray) complaints.push(`vertical transform on "${part}": ${decl.value}`); + const closedTray = + part === '#command-dock .dock-popover-content' && + decl.value === 'translateY(0.55rem) scale(0.985)'; + if (!identity && !closedTray) + complaints.push(`vertical transform on "${part}": ${decl.value}`); } - if (decl.prop === 'translate' || decl.prop === 'scale' || decl.prop === 'zoom') { - complaints.push(`${decl.prop} on "${part}" moves the box outside the model`); + if ( + decl.prop === 'translate' || + decl.prop === 'scale' || + decl.prop === 'zoom' + ) { + complaints.push( + `${decl.prop} on "${part}" moves the box outside the model`, + ); } } } - assert.deepEqual(complaints, [], `the attribution model cannot resolve:\n ${complaints.join('\n ')}\n`); + assert.deepEqual( + complaints, + [], + `the attribution model cannot resolve:\n ${complaints.join('\n ')}\n`, + ); }); test('custom properties inside modelled offsets are provably non-negative', () => { // The model evaluates them at 0, which is only a conservative floor if they // can never go negative. Both writers are checked: CSS and the JS. - const declared = RULES.flatMap((rule) => rule.decls.filter((decl) => VETTED_VARS.has(decl.prop))); - assert.ok(declared.length >= VETTED_VARS.size, 'every vetted custom property needs a CSS default'); + const declared = RULES.flatMap((rule) => + rule.decls.filter((decl) => VETTED_VARS.has(decl.prop)), + ); + assert.ok( + declared.length >= VETTED_VARS.size, + 'every vetted custom property needs a CSS default', + ); for (const decl of declared) { - assert.doesNotMatch(decl.value, /-\s*\d/, `${decl.prop} has a negative CSS default: ${decl.value}`); - const shape = FIXED_LENGTH_VARS.has(decl.prop) ? /^(0|\d+px)$/ : /^(0|0px)$/; - assert.match(decl.value, shape, `${decl.prop} default is not a vetted shape: ${decl.value}`); + assert.doesNotMatch( + decl.value, + /-\s*\d/, + `${decl.prop} has a negative CSS default: ${decl.value}`, + ); + const shape = FIXED_LENGTH_VARS.has(decl.prop) + ? /^(0|\d+px)$/ + : /^(0|0px)$/; + assert.match( + decl.value, + shape, + `${decl.prop} default is not a vetted shape: ${decl.value}`, + ); } - const layout = fs.readFileSync(new URL('./ui/panelLayoutController.js', import.meta.url), 'utf8'); + const layout = fs.readFileSync( + new URL('./ui/panelLayoutController.js', import.meta.url), + 'utf8', + ); const start = layout.indexOf('_updateCommandDockTrayStack() {'); assert.ok(start > 0, '_updateCommandDockTrayStack is missing'); - const writer = layout.slice(start, layout.indexOf(' _scheduleAdaptivePanelLayout(', start)); + const writer = layout.slice( + start, + layout.indexOf(' _scheduleAdaptivePanelLayout(', start), + ); // Every value traces back to a rect height, floored at 0 and rounded up. - assert.match(writer, /const locationHeight =\s*[\s\S]{0,180}?getBoundingClientRect\(\)\.height\s*\|\| 0;/); - assert.match(writer, /const presetsHeight =\s*[\s\S]{0,180}?getBoundingClientRect\(\)\.height\s*\|\| 0;/); - assert.match(writer, /const lowerPinnedHeight =\s*[\s\S]{0,220}?getBoundingClientRect\(\)\.height\s*\|\| 0;/); - assert.match(writer, /const locationHeightPx = Math\.ceil\(locationHeight\);/); + assert.match( + writer, + /const locationHeight =\s*[\s\S]{0,180}?getBoundingClientRect\(\)\.height\s*\|\| 0;/, + ); + assert.match( + writer, + /const presetsHeight =\s*[\s\S]{0,180}?getBoundingClientRect\(\)\.height\s*\|\| 0;/, + ); + assert.match( + writer, + /const lowerPinnedHeight =\s*[\s\S]{0,220}?getBoundingClientRect\(\)\.height\s*\|\| 0;/, + ); + assert.match( + writer, + /const locationHeightPx = Math\.ceil\(locationHeight\);/, + ); assert.match(writer, /const presetsHeightPx = Math\.ceil\(presetsHeight\);/); - assert.match(writer, /'--dock-location-pinned-height',\s*`\$\{locationHeightPx\}px`/); - assert.match(writer, /'--dock-presets-pinned-height',\s*`\$\{presetsHeightPx\}px`/); - assert.match(writer, /'--dock-lower-pinned-height',\s*`\$\{Math\.ceil\(lowerPinnedHeight\)\}px`/); + assert.match( + writer, + /'--dock-location-pinned-height',\s*`\$\{locationHeightPx\}px`/, + ); + assert.match( + writer, + /'--dock-presets-pinned-height',\s*`\$\{presetsHeightPx\}px`/, + ); + assert.match( + writer, + /'--dock-lower-pinned-height',\s*`\$\{Math\.ceil\(lowerPinnedHeight\)\}px`/, + ); assert.match(writer, /'--dock-pinned-stack-height', stackHeight/); - assert.match(writer, /const stackHeight =\s*pinnedCount > 1[\s\S]{0,160}?`calc\(\$\{locationHeightPx\}px \+ \$\{presetsHeightPx\}px \+ 1\.2rem\)`/); + assert.match( + writer, + /const stackHeight =\s*pinnedCount > 1[\s\S]{0,160}?`calc\(\$\{locationHeightPx\}px \+ \$\{presetsHeightPx\}px \+ 1\.2rem\)`/, + ); }); test('the inputs behind the measured constants are unchanged', () => { // 28px credit / 62px dock are measured, not derived. Guard the CSS that // determines them so a change forces a re-measure instead of a silent drift. - const creditBase = RULES.find((rule) => rule.parts.length === 1 && rule.parts[0] === '#cesium-credits'); + const creditBase = RULES.find( + (rule) => rule.parts.length === 1 && rule.parts[0] === '#cesium-credits', + ); assert.ok(creditBase, '#cesium-credits base rule is missing'); - const declOf = (rule, prop) => rule.decls.find((decl) => decl.prop === prop)?.value; - assert.equal(declOf(creditBase, 'font-size'), '10px', 'credit font-size drives its measured 28px height'); - assert.equal(declOf(creditBase, 'white-space'), 'nowrap', 'a wrapping credit is taller than the measured 28px'); - for (const prop of ['height', 'min-height', 'max-height', 'line-height', 'padding']) { - assert.equal(declOf(creditBase, prop), undefined, `#cesium-credits gained ${prop}; re-measure CREDIT_HEIGHT_PX`); + const declOf = (rule, prop) => + rule.decls.find((decl) => decl.prop === prop)?.value; + assert.equal( + declOf(creditBase, 'font-size'), + '10px', + 'credit font-size drives its measured 28px height', + ); + assert.equal( + declOf(creditBase, 'white-space'), + 'nowrap', + 'a wrapping credit is taller than the measured 28px', + ); + for (const prop of [ + 'height', + 'min-height', + 'max-height', + 'line-height', + 'padding', + ]) { + assert.equal( + declOf(creditBase, prop), + undefined, + `#cesium-credits gained ${prop}; re-measure CREDIT_HEIGHT_PX`, + ); } // Only `min-height` may floor the dock — that direction only ADDS clearance. for (const { rule, part } of ownBoxEntries()) { if (part !== '#command-dock') continue; for (const decl of rule.decls) { - assert.notEqual(decl.prop, 'height', 'a fixed dock height invalidates COMPACT_DOCK_HEIGHT_PX'); - assert.notEqual(decl.prop, 'max-height', 'a capped dock height invalidates COMPACT_DOCK_HEIGHT_PX'); + assert.notEqual( + decl.prop, + 'height', + 'a fixed dock height invalidates COMPACT_DOCK_HEIGHT_PX', + ); + assert.notEqual( + decl.prop, + 'max-height', + 'a capped dock height invalidates COMPACT_DOCK_HEIGHT_PX', + ); } } }); @@ -518,23 +729,44 @@ test('the full-width rail cannot inherit a height that overrides its floor', () // over-constrained. It is safe only because the rail's layout pass switches // to a mobile mode at the SAME breakpoint and removes both the class and the // custom property. Pin that, or the exemption above is unearned. - const rail = fs.readFileSync(path.join(ROOT, 'src', 'ui', 'rightPanelRail.js'), 'utf8'); + const rail = fs.readFileSync( + path.join(ROOT, 'src', 'ui', 'rightPanelRail.js'), + 'utf8', + ); const gate = rail.indexOf("windowRef.matchMedia('(max-width: 720px)')"); - assert.ok(gate > 0, 'the rail layout pass no longer keys off (max-width: 720px)'); - const mobileBranch = rail.slice(gate, rail.indexOf("layoutMode = 'mobile'", gate) + 40); + assert.ok( + gate > 0, + 'the rail layout pass no longer keys off (max-width: 720px)', + ); + const mobileBranch = rail.slice( + gate, + rail.indexOf("layoutMode = 'mobile'", gate) + 40, + ); assert.match(mobileBranch, /stack\.classList\.remove\('layout-focus'\)/); - assert.match(mobileBranch, /stack\.style\.removeProperty\('--right-stack-max-height'\)/); + assert.match( + mobileBranch, + /stack\.style\.removeProperty\('--right-stack-max-height'\)/, + ); }); test('right rail measurement cannot persist into a painted attribution layout', () => { - const rail = fs.readFileSync(path.join(ROOT, 'src', 'ui', 'rightPanelRail.js'), 'utf8'); + const rail = fs.readFileSync( + path.join(ROOT, 'src', 'ui', 'rightPanelRail.js'), + 'utf8', + ); const start = rail.indexOf("stack.setAttribute('data-rail-measuring', '')"); - const end = rail.indexOf("stack.removeAttribute('data-rail-measuring')", start); + const end = rail.indexOf( + "stack.removeAttribute('data-rail-measuring')", + start, + ); assert.ok(start > rail.indexOf("layoutMode = 'mobile'")); assert.ok(end > start); const measurement = rail.slice(start, end); assert.match(measurement, /try \{[\s\S]*\} finally \{/); - assert.doesNotMatch(measurement, /\b(?:await|return|yield)\b|requestAnimationFrame|setTimeout/); + assert.doesNotMatch( + measurement, + /\b(?:await|return|yield)\b|requestAnimationFrame|setTimeout/, + ); }); // ── Clearance ─────────────────────────────────────────────────────────────── @@ -549,15 +781,22 @@ test('every open dock tray clears the required credit at every modelled viewport for (const scenario of TRAY_SCENARIOS) { for (const width of WIDTHS.filter((w) => w <= 900)) { for (const height of HEIGHTS) { - const clearance = trayBottomPx(scenario, width, height) - creditTopPx(width, height); + const clearance = + trayBottomPx(scenario, width, height) - creditTopPx(width, height); if (clearance < MIN_CLEARANCE_PX) { - failures.push(`${scenario.name} @ ${width}x${height} lift ${lift}: ${clearance.toFixed(1)}px`); + failures.push( + `${scenario.name} @ ${width}x${height} lift ${lift}: ${clearance.toFixed(1)}px`, + ); } } } } }); - assert.deepEqual(failures, [], `a dock tray re-enters the credit band:\n ${failures.join('\n ')}\n`); + assert.deepEqual( + failures, + [], + `a dock tray re-enters the credit band:\n ${failures.join('\n ')}\n`, + ); }); test('a pinned tray still stacks above its sibling at narrow widths', () => { @@ -584,33 +823,64 @@ test('the full-width context rail clears the required credit at every modelled v if (decl.prop === 'bottom') anchors.push({ rule, decl }); } } - assert.equal(anchors.length, 1, 'the rail has exactly one bottom anchor to reason about'); - assert.equal(parseMediaCondition(anchors[0].rule.media[0]), 720, 'the rail only goes full-width below 720px'); + assert.equal( + anchors.length, + 1, + 'the rail has exactly one bottom anchor to reason about', + ); + assert.equal( + parseMediaCondition(anchors[0].rule.media[0]), + 720, + 'the rail only goes full-width below 720px', + ); const failures = []; for (const width of WIDTHS.filter((w) => w <= 720)) { // `bottom` only governs the floor while the box is not height-capped: // top + bottom + a resolved height is over-constrained and drops `bottom`. assert.equal( - resolve(['#right-context-rail'], 'max-height', width, 'context rail').decl.value, + resolve(['#right-context-rail'], 'max-height', width, 'context rail').decl + .value, 'none', `at ${width}px the rail is height-capped, so its bottom anchor no longer decides its floor`, ); eachLift((lift) => { for (const height of HEIGHTS) { - const rail = resolve(['#right-context-rail'], 'bottom', width, 'context rail'); - const clearance = toPx(rail.decl.value, height, 'rail bottom') - creditTopPx(width, height); - if (clearance < MIN_CLEARANCE_PX) failures.push(`${width}x${height} lift ${lift}: ${clearance.toFixed(1)}px`); + const rail = resolve( + ['#right-context-rail'], + 'bottom', + width, + 'context rail', + ); + const clearance = + toPx(rail.decl.value, height, 'rail bottom') - + creditTopPx(width, height); + if (clearance < MIN_CLEARANCE_PX) + failures.push( + `${width}x${height} lift ${lift}: ${clearance.toFixed(1)}px`, + ); } }); } - assert.deepEqual(failures, [], `context rail re-enters the credit band at ${failures.join(', ')}`); + assert.deepEqual( + failures, + [], + `context rail re-enters the credit band at ${failures.join(', ')}`, + ); }); test('expanded Context and the credit row never overlap', () => { const docked = RULES.filter((rule) => rule.parts.includes(DOCKED_RAIL)); - assert.equal(docked.length, 1, 'expanded Context has exactly one rule for its column'); - assert.deepEqual(docked[0].media, [], 'the expanded column applies at every width'); + assert.equal( + docked.length, + 1, + 'expanded Context has exactly one rule for its column', + ); + assert.deepEqual( + docked[0].media, + [], + 'the expanded column applies at every width', + ); const decl = (prop) => docked[0].decls.find((d) => d.prop === prop)?.value; assert.equal(decl('right'), '0'); assert.equal(decl('width'), 'var(--context-dock-width)'); @@ -623,9 +893,13 @@ test('expanded Context and the credit row never overlap', () => { for (const width of WIDTHS) { const left = resolve([base], 'left', width, 'credit').decl.value; const rem = /^(\d*\.?\d+)rem$/.exec(left); - assert.ok(rem && Number(rem[1]) < 3, `at ${width}px the credit starts at ${left}`); + assert.ok( + rem && Number(rem[1]) < 3, + `at ${width}px the credit starts at ${left}`, + ); assert.equal( - resolve([base, selector], 'max-width', width, 'docked credit').decl.value, + resolve([base, selector], 'max-width', width, 'docked credit').decl + .value, 'calc(100vw - 3rem - var(--context-dock-width))', `at ${width}px the credit row can run under expanded Context`, ); @@ -635,8 +909,14 @@ test('expanded Context and the credit row never overlap', () => { test('the dock anchor changes at 720px — the 2vh cancellation is band-limited', () => { const lift = 'var(--world-timeline-lift, 0px)'; - assert.equal(resolve(['#command-dock'], 'bottom', 800, 'dock').decl.value, `calc(2vh + ${lift})`); - assert.equal(resolve(['#command-dock'], 'bottom', 720, 'dock').decl.value, `calc(8px + ${lift})`); + assert.equal( + resolve(['#command-dock'], 'bottom', 800, 'dock').decl.value, + `calc(2vh + ${lift})`, + ); + assert.equal( + resolve(['#command-dock'], 'bottom', 720, 'dock').decl.value, + `calc(8px + ${lift})`, + ); assert.equal( resolve(CREDIT_SELECTORS, 'bottom', 720, 'credit').decl.value, `calc(2vh + 5rem + ${lift})`, @@ -647,10 +927,16 @@ test('the dock anchor changes at 720px — the 2vh cancellation is band-limited' test('the minimal-HUD credit variant tracks the ordinary one', () => { // It is MORE specific, so if the two ever diverge the model reads the wrong // anchor while the browser paints the other. - assert.ok(compareSpecificity(specificity(MINIMAL_HUD_CREDIT), specificity(CREDIT_SELECTORS[1])) > 0); + assert.ok( + compareSpecificity( + specificity(MINIMAL_HUD_CREDIT), + specificity(CREDIT_SELECTORS[1]), + ) > 0, + ); for (const width of WIDTHS) { assert.equal( - resolve([MINIMAL_HUD_CREDIT], 'bottom', width, 'minimal-HUD credit').decl.value, + resolve([MINIMAL_HUD_CREDIT], 'bottom', width, 'minimal-HUD credit').decl + .value, resolve(CREDIT_SELECTORS, 'bottom', width, 'credit').decl.value, `the minimal-HUD credit anchor diverges at ${width}px`, ); @@ -658,25 +944,81 @@ test('the minimal-HUD credit variant tracks the ordinary one', () => { }); test('the tray only spans the credit corner at the widths the model covers', () => { - const widened = RULES.filter((rule) => rule.parts.includes('#command-dock .dock-popover-content') - && rule.decls.some((decl) => decl.prop === 'width' && decl.value.includes('--dock-popover-mobile-width'))); + const widened = RULES.filter( + (rule) => + rule.parts.includes('#command-dock .dock-popover-content') && + rule.decls.some( + (decl) => + decl.prop === 'width' && + decl.value.includes('--dock-popover-mobile-width'), + ), + ); assert.equal(widened.length, 1); assert.equal(parseMediaCondition(widened[0].media[0]), 900); }); test('the credit line is never suppressed to make room', () => { - const creditBlocks = [...css.matchAll(/#cesium-credits[^{]*\{([^}]*)\}/g)].map((m) => m[1]); + const creditBlocks = [ + ...css.matchAll(/#cesium-credits[^{]*\{([^}]*)\}/g), + ].map((m) => m[1]); assert.ok(creditBlocks.length > 0); for (const block of creditBlocks) { - assert.doesNotMatch(block, /display\s*:\s*none/, 'the credit must never be display:none'); - assert.doesNotMatch(block, /visibility\s*:\s*hidden/, 'the credit must never be hidden'); - assert.doesNotMatch(block, /opacity\s*:\s*0(\D|$)/, 'the credit must never be faded out'); + assert.doesNotMatch( + block, + /display\s*:\s*none/, + 'the credit must never be display:none', + ); + assert.doesNotMatch( + block, + /visibility\s*:\s*hidden/, + 'the credit must never be hidden', + ); + assert.doesNotMatch( + block, + /opacity\s*:\s*0(\D|$)/, + 'the credit must never be faded out', + ); } - assert.match(css, /body\.ui-clean-view #cesium-credits,\s*\n\s*body\.recording-mode #cesium-credits \{[^}]*bottom: 36px;/); + assert.match( + css, + /body\.ui-clean-view #cesium-credits,\s*\n\s*body\.recording-mode #cesium-credits \{[^}]*bottom: 36px;/, + ); }); - test('OSM-derived layers never force the desktop credit row into a stack', () => { assert.doesNotMatch(css, /body:has\([^)]*alpr-cameras[^}]*#cesium-credits/); - assert.doesNotMatch(css, /#cesium-credits\s+\.cesium-credit-expand-link\s*\{[^}]*display:\s*block/); + assert.doesNotMatch( + css, + /#cesium-credits\s+\.cesium-credit-expand-link\s*\{[^}]*display:\s*block/, + ); +}); + +test('expanded Context keeps the credits beside it right to left and with the minimal HUD', () => { + const css = fs + .readFileSync( + path.join(ROOT, 'src', 'ui', 'styles', 'context-dock.css'), + 'utf8', + ) + .replace(/\/\*[\s\S]*?\*\//g, '') + .replace(/\s+/g, ' '); + const rule = (selectorPart, decl) => + new RegExp( + `${selectorPart}[^{}]*:is\\(#cesium-credits, #gev-credits\\) \\{[^}]*${decl}`, + ).test(css); + // Right to left the column docks to the left edge, where the credits start. + assert.ok( + rule( + "html\\[dir='rtl'\\] body\\.context-docked", + 'left: calc\\(36px \\+ var\\(--context-dock-width\\)\\)', + ), + 'right to left, the credits start past the expanded column', + ); + // The minimal HUD puts the credits bottom right, where the column docks. + assert.ok( + rule( + "^.*body\\.context-docked:not\\(\\.ui-clean-view\\):not\\(\\.recording-mode\\):has\\( #intel-hud\\[data-variant='minimal'\\]\\.active \\)", + 'right: calc\\(36px \\+ var\\(--context-dock-width\\)\\)', + ), + 'with the minimal HUD, the credits end before the expanded column', + ); }); diff --git a/src/ui/applicationShell.js b/src/ui/applicationShell.js index 3577513e0..3546f3800 100644 --- a/src/ui/applicationShell.js +++ b/src/ui/applicationShell.js @@ -199,6 +199,7 @@ export class StyleManager extends ShellFacade { pinia: applicationPinia(), pickWorld: services.pickWorldFromScreen, regionalBrief: services.fetchRegionalBrief, + overlayHit: services.hitTestWorldOverlay, }); this.mapStackController = mapStackController; this.placeSearch = placeSearch; diff --git a/src/ui/composition.js b/src/ui/composition.js index 169e73e53..3a24fe464 100644 --- a/src/ui/composition.js +++ b/src/ui/composition.js @@ -29,6 +29,7 @@ import { import { activateWorldOverlayAction, destroyWorldOverlay, + hitTestWorldOverlay, initWorldOverlay, subscribeWorldOverlayActions, } from '../overlays/worldOverlay.js'; @@ -73,6 +74,7 @@ export class StyleManager extends ApplicationShell { super(viewer, { ...options, services: { + hitTestWorldOverlay, CITY_POIS, GLOBE_VIEW, flyToGlobeView, diff --git a/src/ui/entityContextBridge.js b/src/ui/entityContextBridge.js index d9a9b3549..6bfa6b24f 100644 --- a/src/ui/entityContextBridge.js +++ b/src/ui/entityContextBridge.js @@ -2,10 +2,15 @@ import { resolvePickedContext } from '../data/pickedContext.js'; import { followedOf, onFollowChanged } from '../data/followed.js'; import { fromDegreesInto } from '../geo/ellipsoid.js'; import { inputFor } from '../input/dispatcher.js'; +import { + isTrackingClickGesture, + isTrackingSelectionGesture, +} from '../data/trackingClickGesture.js'; import { findCamera } from '../render/rendererOf.js'; import { useCockpitStore } from './stores/cockpit.js'; import { useEntityCardStore } from './stores/entityCard.js'; import { useOmnibarStore } from './stores/omnibar.js'; +import { usePanelChromeStore } from './stores/panelChrome.js'; import { useVoiceStore } from './stores/voice.js'; /** Camera distance (m) that frames an item of each kind. */ @@ -19,13 +24,11 @@ const FRAME_RANGE = Object.freeze({ 'fire perimeter': 40_000, }); const DEFAULT_RANGE = 8_000; -/** Items the voice runtime can keep the camera on. */ -const FOLLOWABLE = new Set([ - 'flights', - 'military', - 'ais-live-vessels', - 'satellites', -]); +/** + * Items the camera can follow: their layers follow through the camera port + * with a key naming the item (src/data/followed.js). A vessel is flown to. + */ +const FOLLOWABLE = new Set(['flights', 'military', 'satellites']); /** * Connects the Context panel's entity card to the globe: a click on anything a @@ -41,6 +44,8 @@ const FOLLOWABLE = new Set([ * to the point under the camera without it. * @param {(lat: number, lon: number) => Promise} [options.regionalBrief] * The app's regional brief service, for the weather and news Context shows. + * @param {(x: number, y: number) => object|null} [options.overlayHit] + * The overlay card under a screen point, if any (a vessel's, a fire's). * @returns {() => void} disconnects */ export function installEntityContext({ @@ -49,11 +54,16 @@ export function installEntityContext({ pinia, pickWorld, regionalBrief, + overlayHit, }) { const store = useEntityCardStore(pinia); const omnibar = useOmnibarStore(pinia); const voice = useVoiceStore(pinia); const cockpitStore = useCockpitStore(pinia); + const chrome = usePanelChromeStore(pinia); + /** Whether Context is open; a closed panel reads nothing. */ + const isOpen = () => + chrome.panels['global-context-panel']?.collapsed === false; const doc = globalThis.document; let disposed = false; // The renderer's camera; looked up on use, as a renderer can be bound @@ -116,9 +126,15 @@ export function installEntityContext({ // Closing the card lets go of the camera, when the camera follows the // card's own item and nothing else took it over since. function letGo(card) { - const run = omnibar.runner; - if (!run || !followsCard(card)) return; - Promise.resolve(run('stop_tracking', {})).catch(() => {}); + if (!followsCard(card)) return; + // Only the card's own layer lets go, as the person's own action; other + // layers' selections stay as they are. + const layer = getDataManager()?.layers?.get?.(card.layerId); + try { + layer?.module?.stopTracking?.({ origin: 'user' }); + } catch { + // A layer going away meanwhile has nothing left to let go of. + } } // Aircraft can be flown from, and a satellite ridden in the orbital view: @@ -182,6 +198,7 @@ export function installEntityContext({ flyTo, follow, letGo, + isOpen, regionalBrief, ask, askText, @@ -203,7 +220,7 @@ export function installEntityContext({ // the height. Read when the camera settles, not every frame. const readView = () => { const port = camera(); - if (!port) return; + if (!port || !isOpen()) return; const pose = port.pose(); if (![pose.lat, pose.lon, pose.height].every(Number.isFinite)) return; const middle = pickWorld?.(viewer, 0.5, 0.5); @@ -252,14 +269,16 @@ export function installEntityContext({ listen(); readView(); }, 0); + // Opening the panel describes the view as it is now. + let wasOpen = isOpen(); + const offChrome = chrome.$subscribe(() => { + const open = isOpen(); + if (open && !wasOpen) readView(); + wasOpen = open; + }); /** Layers whose own map click already follows what was clicked. */ - const CLICK_FOLLOWS = new Set([ - 'flights', - 'military', - 'satellites', - 'ais-live-vessels', - ]); + const CLICK_FOLLOWS = new Set(['flights', 'military', 'satellites']); // Keep the card's "following" in step with the camera: it says Following // while the camera follows the card's own item (the follow's key names @@ -269,9 +288,16 @@ export function installEntityContext({ let followCheck = 0; const offFollow = onFollowChanged(viewer, () => { clearTimeout(followCheck); + const card = store.card; + // Taking hold of the card's item shows at once; letting go waits a + // moment, in case the layer is only switching follows. + if (followsCard(card)) { + store.following = card.key; + return; + } followCheck = setTimeout(() => { - const card = store.card; - store.following = followsCard(card) ? card.key : null; + const now = store.card; + store.following = followsCard(now) ? now.key : null; }, 250); }); @@ -279,8 +305,9 @@ export function installEntityContext({ // dispatcher hands every subscriber the same click, picked once before // any layer acts on it, and only while no tool holds the pointer. const offClick = inputFor(viewer).onClick((event) => { - // Cockpit has its own picks, and Context is hidden while it runs. - if (inCockpit()) return; + // Cockpit has its own picks, and Context is hidden while it runs. A + // camera drag never selects, even if it ends over something. + if (inCockpit() || !isTrackingSelectionGesture(event.gesture)) return; const identity = resolvePickedContext(event.hit, { dataManager: getDataManager(), }); @@ -294,7 +321,14 @@ export function installEntityContext({ // A click on open ground, sea or sky lets go of what was selected. A // click on something else Context cannot describe (a label, a trail) // leaves the card as it is. - if (event.surface) store.clear(); + // Only a clean click lets go, as the layers' own clicks do; a card + // painted on the overlay (a vessel's, a fire's) is not open map. + if ( + event.surface && + isTrackingClickGesture(event.gesture) && + !overlayHit?.(event.screenPosition?.x, event.screenPosition?.y) + ) + store.clear(); }); // Layers that select through the context store (GeoJSON sites, fires, @@ -318,6 +352,7 @@ export function installEntityContext({ for (const off of cameraOff) off?.(); clearTimeout(trailing); offFollow(); + offChrome(); clearTimeout(followCheck); globalThis.removeEventListener?.('gev:entity-selected', onSelected); store.connect(null); diff --git a/src/ui/spotConditions.js b/src/ui/spotConditions.js index 2e1185dcb..963b65cf2 100644 --- a/src/ui/spotConditions.js +++ b/src/ui/spotConditions.js @@ -23,37 +23,45 @@ const briefs = new Map(); * @param {number} lat * @param {number} lon * @param {(lat: number, lon: number) => Promise} load + * @param {{force?: boolean}} [options] `force` reads again whatever is kept. */ -export function regionalBrief(lat, lon, load) { +export function regionalBrief(lat, lon, load, { force = false } = {}) { const key = `${lat.toFixed(2)},${lon.toFixed(2)}`; const kept = briefs.get(key); - if (kept && Date.now() - kept.at < BRIEF_TTL_MS) return kept.promise; + if (!force && kept && Date.now() - kept.at < BRIEF_TTL_MS) + return kept.promise; + const forget = () => { + if (briefs.get(key)?.promise === promise) briefs.delete(key); + return null; + }; const promise = Promise.resolve() .then(() => load(lat, lon)) - .catch(() => { - if (briefs.get(key)?.promise === promise) briefs.delete(key); - return null; - }); + .then((brief) => brief ?? forget(), forget); briefs.set(key, { at: Date.now(), promise }); if (briefs.size > 40) briefs.delete(briefs.keys().next().value); return promise; } const feeds = new Map(); -function snapshot(name, load) { +function snapshot(name, load, force) { const kept = feeds.get(name); - if (kept && Date.now() - kept.at < FEED_TTL_MS) return kept.promise; + if (!force && kept && Date.now() - kept.at < FEED_TTL_MS) return kept.promise; const promise = load().catch(() => null); feeds.set(name, { at: Date.now(), promise }); return promise; } -const quakes = () => - snapshot('quakes', () => createUsgsEarthquakeSource().getSnapshot()); -const storms = () => - snapshot('storms', () => createCycloneSource().getSnapshot()); -const perimeters = () => - snapshot('perimeters', () => createWfigsPerimeterSource().getSnapshot()); -const fires = () => snapshot('fires', () => createFirmsSource().getSnapshot()); +const quakes = (force) => + snapshot('quakes', () => createUsgsEarthquakeSource().getSnapshot(), force); +const storms = (force) => + snapshot('storms', () => createCycloneSource().getSnapshot(), force); +const perimeters = (force) => + snapshot( + 'perimeters', + () => createWfigsPerimeterSource().getSnapshot(), + force, + ); +const fires = (force) => + snapshot('fires', () => createFirmsSource().getSnapshot(), force); // English compass points, which the UI shows through t(). const COMPASS = [ @@ -118,14 +126,14 @@ export async function hazardsNear( lat, lon, radiusKm = 250, - { fires: withFires = false } = {}, + { fires: withFires = false, force = false } = {}, ) { const here = { lat, lon }; const [quakeRows, stormSnap, perimeterRows, fireSnap] = await Promise.all([ - quakes(), - storms(), - perimeters(), - withFires ? fires() : null, + quakes(force), + storms(force), + perimeters(force), + withFires ? fires(force) : null, ]); const found = []; const add = (row) => { diff --git a/src/ui/stores/entityCard.js b/src/ui/stores/entityCard.js index f1b51b3ac..fa8a148ec 100644 --- a/src/ui/stores/entityCard.js +++ b/src/ui/stores/entityCard.js @@ -218,6 +218,8 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => { // A card does not outlive its layer: turning the layer off (or clearing // all layers) closes it and lets go of the camera. if (layerOff(current.layerId)) return clear(); + // A closed panel shows nothing, so it reads nothing until it opens. + if (shell.value?.isOpen && !shell.value.isOpen()) return; const next = describeEntity(dataManager(), current.identity); // Keep showing the last reading when the item drops out of its feed. if (!next || next.key !== current.key || next.basis !== 'record') { @@ -238,15 +240,14 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => { * @returns {boolean} Whether a card could be made. */ /** Things that move are followed as soon as they are picked. */ - const AUTO_FOLLOW = new Set([ - 'flights', - 'military', - 'local-adsb', - 'satellites', - 'ais-live-vessels', - ]); - /** The key of the item the camera is following, if any. */ + const AUTO_FOLLOW = new Set(['flights', 'military', 'satellites']); + /** + * The key of the item the camera follows, if any. The shell sets it from + * the camera's own follow, so it is never claimed before the camera does. + */ const following = ref(null); + /** The item a follow was last asked for, so it is asked once per item. */ + let asked = null; /** * @param {object} identity @@ -266,13 +267,12 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => { if (followNow) { // Tracking can announce the craft again; following what is already // followed would loop, so it only starts once per item. - if (following.value !== current.key) { - following.value = current.key; + if (following.value !== current.key && asked !== current.key) { + asked = current.key; shell.value?.follow?.(current); } } else { - if (following.value && following.value !== current?.key) - following.value = null; + asked = null; if (fly) shell.value?.flyTo?.(current); } requestRoute(current?.identity); @@ -282,6 +282,7 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => { function clear() { if (following.value) shell.value?.letGo?.(card.value); following.value = null; + asked = null; clearInterval(timer); timer = null; card.value = null; @@ -291,7 +292,7 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => { const flyTo = () => card.value && shell.value?.flyTo?.(card.value); const follow = () => { if (!card.value) return; - following.value = card.value.key; + asked = card.value.key; shell.value?.follow?.(card.value); }; const isFollowing = () => diff --git a/src/ui/styles/context-dock.css b/src/ui/styles/context-dock.css index dd2e745d3..e02ecd486 100644 --- a/src/ui/styles/context-dock.css +++ b/src/ui/styles/context-dock.css @@ -202,8 +202,32 @@ body.mobile-shell .context-dock-btn { display: none; } +/* With the minimal HUD the credits sit at the bottom right, where the + column is: they move out to its left. */ +body.context-docked:not(.ui-clean-view):not(.recording-mode):has( + #intel-hud[data-variant='minimal'].active + ) + :is(#cesium-credits, #gev-credits) { + right: calc(36px + var(--context-dock-width)); +} + /* Right to left, the rail sits on the left edge (rtl.css), and so does the - expanded column. */ + expanded column; the credits start past it. */ +html[dir='rtl'] + body.context-docked:not(.ui-clean-view):not(.recording-mode) + :is(#cesium-credits, #gev-credits) { + left: calc(36px + var(--context-dock-width)); +} + +html[dir='rtl'] + body.context-docked:not(.ui-clean-view):not(.recording-mode):has( + #intel-hud[data-variant='minimal'].active + ) + :is(#cesium-credits, #gev-credits) { + right: 36px; + left: auto; +} + html[dir='rtl'] body.context-docked #right-context-rail { right: auto !important; left: 0 !important; diff --git a/src/ui/styles/entity-card.css b/src/ui/styles/entity-card.css index 72bf72ab0..2f8f09840 100644 --- a/src/ui/styles/entity-card.css +++ b/src/ui/styles/entity-card.css @@ -325,13 +325,13 @@ } } -/* Radio can move between Context's two body hosts. Keep its visibility - tied to the Inspector and layer state in either location. */ +/* The Properties tab shows only the layers' settings. The idle hint gives + way to the view summary, and Contacts' Cockpit entry to the card's own + while the card offers one. */ #global-context-panel[data-context-tab='props'] :is(.global-context-modes, .context-mode-view, #radio-panel), -#global-context-panel #radio-panel:not(.radio-enabled), #global-context-panel #context-mode-standby, -#global-context-panel #cockpit-entry { +#global-context-panel:has([data-entity-cockpit-entry]) #cockpit-entry { display: none !important; } diff --git a/src/ui/views/ContextView.vue b/src/ui/views/ContextView.vue index 71070f866..461774c22 100644 --- a/src/ui/views/ContextView.vue +++ b/src/ui/views/ContextView.vue @@ -156,7 +156,7 @@ function setDocked(next) { } } // Only an open panel reads what is picked and in view; closed, it does no work. -const contextOpen = computed(() => chromePanels.value['global-context-panel']?.collapsed !== true); +const contextOpen = computed(() => chromePanels.value['global-context-panel']?.collapsed === false); watch( () => chromePanels.value['global-context-panel']?.collapsed, (collapsed) => { @@ -232,7 +232,7 @@ watch(
- diff --git a/src/ui/views/panels/SpotConditions.vue b/src/ui/views/panels/SpotConditions.vue index 08bde3659..225279625 100644 --- a/src/ui/views/panels/SpotConditions.vue +++ b/src/ui/views/panels/SpotConditions.vue @@ -53,18 +53,19 @@ const pickRadius = (index) => setContextRadiusKm(CONTEXT_RADIUS_STEPS[index]); const firesOn = () => Boolean((omnibar.controls?.layers() || []).find((layer) => layer.id === HAZARD_LAYER.hotspots)?.enabled); -async function read(lat, lon) { - if (readAt && distanceKm(readAt, { lat, lon }) <= props.settleKm) return; +async function read(lat, lon, { force = false } = {}) { + if (!force && readAt && distanceKm(readAt, { lat, lon }) <= props.settleKm) return; readAt = { lat, lon }; const mine = ++reading; const mineHazards = ++readingHazards; - loading.value = true; + // A forced re-read keeps what is shown until the new reading lands. + if (!force) loading.value = true; const [nextBrief, nextHazards] = await Promise.all([ - regionalBrief(lat, lon, store.readBrief), - hazardsNear(lat, lon, radiusKm.value, { fires: firesOn() }).catch(() => []), + regionalBrief(lat, lon, store.readBrief, { force }), + hazardsNear(lat, lon, radiusKm.value, { fires: firesOn(), force }).catch(() => []), ]); if (reading !== mine) return; - brief.value = nextBrief; + if (nextBrief || !force) brief.value = nextBrief; // A radius change meanwhile has its own, newer hazard read. if (readingHazards === mineHazards) hazards.value = nextHazards; loading.value = false; @@ -91,10 +92,7 @@ watch(radiusKm, (km) => void rereadHazards(km)); const REREAD_MS = 5 * 60_000; let rereadTimer = 0; onMounted(() => { - rereadTimer = setInterval(() => { - readAt = null; - void read(props.lat, props.lon); - }, REREAD_MS); + rereadTimer = setInterval(() => void read(props.lat, props.lon, { force: true }), REREAD_MS); }); onBeforeUnmount(() => clearInterval(rereadTimer)); // Hazard rows are worded as they are read, so a new language reads them again.