mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge main and switch Cesium and Navara in place through Vue
Preserve the camera, map source and layer selection across engine sessions. Restore the previous engine if startup fails and retain local history navigation.
This commit is contained in:
commit
b8f4d097c4
1691 files changed
+225876
-41594
No files matched your search
+486
-64
@@ -16,9 +16,29 @@
|
||||
*
|
||||
* Builders are small pure functions keyed by tool name. Tools without one are
|
||||
* returned unchanged.
|
||||
*
|
||||
* Only `display` and plan/progress labels are UI text (t()). `say`,
|
||||
* `identityLine`, spoken progress lines and the tool result stay English for
|
||||
* the model; the card shows them through the shown* helpers.
|
||||
*/
|
||||
|
||||
import { analystHeadline } from './resultDisplay.js';
|
||||
import {
|
||||
formatNumber,
|
||||
getLocale,
|
||||
msg,
|
||||
t,
|
||||
tn,
|
||||
translateKnown,
|
||||
} from '../i18n/index.js';
|
||||
import {
|
||||
layerNameForId,
|
||||
shownLayerName,
|
||||
sourceLabel,
|
||||
} from '../ui/layerNames.js';
|
||||
import { localizePlaceName } from '../ui/placeNames.js';
|
||||
import { CITY_POIS } from '../cityPois.js';
|
||||
import { formatQuantity } from '../ui/unitLabels.js';
|
||||
|
||||
const LAYER_NOUNS = Object.freeze({
|
||||
flights: 'aircraft',
|
||||
@@ -53,17 +73,180 @@ function listPhrase(items) {
|
||||
return `${list.slice(0, -1).join(', ')} and ${list.at(-1)}`;
|
||||
}
|
||||
|
||||
function feetRounded(meters) {
|
||||
// A missing altitude is unknown, not sea level: Number(null) is 0.
|
||||
return Number.isFinite(meters)
|
||||
? Math.round((meters * 3.28084) / 100) * 100
|
||||
: null;
|
||||
}
|
||||
|
||||
function feet(meters) {
|
||||
const value = Number(meters);
|
||||
if (!Number.isFinite(value)) return null;
|
||||
const rounded = Math.round((value * 3.28084) / 100) * 100;
|
||||
const rounded = feetRounded(meters);
|
||||
if (rounded === null) return null;
|
||||
return `${rounded.toLocaleString('en-US')} feet`;
|
||||
}
|
||||
|
||||
function kilometers(km) {
|
||||
/** The card's altitude, in the active language. */
|
||||
function shownFeet(meters) {
|
||||
const rounded = feetRounded(meters);
|
||||
if (rounded === null) return null;
|
||||
return t('{value} feet', { value: formatNumber(rounded) });
|
||||
}
|
||||
|
||||
function roundedKm(km) {
|
||||
const value = Number(km);
|
||||
if (!Number.isFinite(value)) return null;
|
||||
return `${value < 10 ? Number(value.toFixed(1)) : Math.round(value)} km`;
|
||||
return value < 10 ? Number(value.toFixed(1)) : Math.round(value);
|
||||
}
|
||||
|
||||
function kilometers(km) {
|
||||
const value = roundedKm(km);
|
||||
return value === null ? null : `${value} km`;
|
||||
}
|
||||
|
||||
/** The card's distance, in the active language: "2,5 км". */
|
||||
function shownKm(km) {
|
||||
const value = roundedKm(km);
|
||||
return value === null ? null : formatQuantity(value, 'km');
|
||||
}
|
||||
|
||||
/** Sources as the card lists them. */
|
||||
function shownSources(source) {
|
||||
return source ? [{ label: sourceLabel(source) }] : [];
|
||||
}
|
||||
|
||||
// Entity labels that layers register as English data (firms/, alpr/); keep in
|
||||
// step with the producers. Other names (callsigns, places) show as they came.
|
||||
const ENTITY_LABELS = new Set([msg('ALPR camera')]);
|
||||
const FIRE_LABEL = /^Fire · FRP (\S+) MW$/;
|
||||
|
||||
/** An entity label as the card shows it, in the active language. */
|
||||
export function shownEntityLabel(label) {
|
||||
if (ENTITY_LABELS.has(label)) return t(label);
|
||||
const fire = FIRE_LABEL.exec(label ?? '');
|
||||
return fire ? t('Fire · FRP {frp} MW', { frp: fire[1] }) : label;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tool errors stay English in the result (the model reads them). The card
|
||||
* translates the known ones; the English must match gevActions exactly.
|
||||
*/
|
||||
const KNOWN_ERRORS = new Map(
|
||||
[
|
||||
msg('The flights layer is not enabled'),
|
||||
msg('The military layer is not enabled'),
|
||||
msg('The satellites layer is not enabled'),
|
||||
msg('The ais-live-vessels layer is not enabled'),
|
||||
msg('Could not enable the requested layer'),
|
||||
msg('Could not disable the requested layer'),
|
||||
msg('Radio layer unavailable'),
|
||||
msg('Camera navigation is unavailable in the current view'),
|
||||
msg('Camera navigation policy unavailable'),
|
||||
msg('Nearest-aircraft selection supports Flights or Military Flights only'),
|
||||
msg(
|
||||
'Nearest-aircraft selection needs a preset, place name, or latitude and longitude',
|
||||
),
|
||||
msg('Could not arrive at the requested place'),
|
||||
msg('The nearest airborne aircraft could not be selected'),
|
||||
].map((text) => [text, text]),
|
||||
);
|
||||
|
||||
function noneWithinView(target, radius) {
|
||||
switch (target) {
|
||||
case 'flights':
|
||||
return t('No flights within {radius} of the current view', { radius });
|
||||
case 'military':
|
||||
return t('No military within {radius} of the current view', { radius });
|
||||
case 'satellites':
|
||||
return t('No satellites within {radius} of the current view', {
|
||||
radius,
|
||||
});
|
||||
case 'vessels':
|
||||
return t('No vessels within {radius} of the current view', { radius });
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const ERROR_PATTERNS = [
|
||||
[
|
||||
/^(.+) is enabled on the (.+) feed, but no airborne aircraft is loaded in the (.+) view yet$/,
|
||||
([, layer, source, place]) =>
|
||||
t(
|
||||
'{layer} is enabled on the {source} feed, but no airborne aircraft is loaded in the {place} view yet',
|
||||
{
|
||||
layer: shownLayerName(layer),
|
||||
source: sourceLabel(source),
|
||||
place: localizePlaceName(place),
|
||||
},
|
||||
),
|
||||
],
|
||||
[
|
||||
/^(.+) is enabled, but no airborne aircraft is loaded in the (.+) view yet$/,
|
||||
([, layer, place]) =>
|
||||
t(
|
||||
'{layer} is enabled, but no airborne aircraft is loaded in the {place} view yet',
|
||||
{ layer: shownLayerName(layer), place: localizePlaceName(place) },
|
||||
),
|
||||
],
|
||||
[
|
||||
/^(.+) is enabled, but its aircraft feed is unavailable$/,
|
||||
([, layer]) =>
|
||||
t('{layer} is enabled, but its aircraft feed is unavailable', {
|
||||
layer: shownLayerName(layer),
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^(.+) is enabled, but its destination refresh did not complete$/,
|
||||
([, layer]) =>
|
||||
t('{layer} is enabled, but its destination refresh did not complete', {
|
||||
layer: shownLayerName(layer),
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^(.+) is enabled, but (.+) is unavailable$/,
|
||||
([, layer, source]) =>
|
||||
t('{layer} is enabled, but {source} is unavailable', {
|
||||
layer: shownLayerName(layer),
|
||||
source: sourceLabel(source),
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^Could not arrive at (.+)$/,
|
||||
([, place]) =>
|
||||
t('Could not arrive at {place}', { place: localizePlaceName(place) }),
|
||||
],
|
||||
[
|
||||
/^(.+) is no longer loaded$/,
|
||||
([, name]) => t('{name} is no longer loaded', { name }),
|
||||
],
|
||||
[
|
||||
/^Unknown target layer: (.*)$/,
|
||||
([, target]) => t('Unknown target layer: {target}', { target }),
|
||||
],
|
||||
[
|
||||
/^No (\S+) within (\d+(?:\.\d+)?) km of the current view$/,
|
||||
([, target, km]) => noneWithinView(target, shownKm(km)),
|
||||
],
|
||||
];
|
||||
|
||||
/** A tool error as the card shows it. */
|
||||
function shownError(error) {
|
||||
if (typeof error !== 'string' || !error) return null;
|
||||
const known = KNOWN_ERRORS.get(error);
|
||||
if (known) return t(known);
|
||||
for (const [pattern, show] of ERROR_PATTERNS) {
|
||||
const match = pattern.exec(error);
|
||||
const shown = match ? show(match) : null;
|
||||
if (shown) return shown;
|
||||
}
|
||||
return translateKnown(error);
|
||||
}
|
||||
|
||||
// The card wraps a failed result's lines rather than cutting them: a
|
||||
// translated error runs longer than the English (voiceCardPresentation).
|
||||
function errorLines(result) {
|
||||
return [shownError(result?.error)].filter(Boolean);
|
||||
}
|
||||
|
||||
function sentence(text) {
|
||||
@@ -76,9 +259,110 @@ function feedTag(state) {
|
||||
return MATERIAL_FEED_TAGS[state] || null;
|
||||
}
|
||||
|
||||
/** Feed states as the card shows them; the state values stay English. */
|
||||
const FEED_STATE_LABELS = Object.freeze({
|
||||
nominal: msg('nominal'),
|
||||
loading: msg('loading'),
|
||||
degraded: msg('degraded'),
|
||||
stale: msg('stale'),
|
||||
partial: msg('partial'),
|
||||
fallback: msg('fallback'),
|
||||
unavailable: msg('unavailable'),
|
||||
});
|
||||
|
||||
function feedStateLabel(state) {
|
||||
const key = FEED_STATE_LABELS[state];
|
||||
return key ? t(key) : state;
|
||||
}
|
||||
|
||||
/** A feed chip only when the state is worth seeing; nominal is the default. */
|
||||
function feedChips(state) {
|
||||
return state && state !== 'nominal' ? [{ label: state }] : [];
|
||||
return state && state !== 'nominal' ? [{ label: feedStateLabel(state) }] : [];
|
||||
}
|
||||
|
||||
/** '{label} on' / '{label} off' as the card shows it. */
|
||||
function switchedTitle(label, on) {
|
||||
return on ? t('{label} on', { label }) : t('{label} off', { label });
|
||||
}
|
||||
|
||||
// Card titles name the layer's things in whole phrases, so each language can
|
||||
// inflect the noun; the English matches LAYER_NOUNS.
|
||||
function frameTitle(layerId) {
|
||||
switch (layerId) {
|
||||
case 'flights':
|
||||
return t('Frame aircraft');
|
||||
case 'military':
|
||||
return t('Frame military aircraft');
|
||||
case 'ais-live-vessels':
|
||||
return t('Frame ships');
|
||||
case 'satellites':
|
||||
return t('Frame satellites');
|
||||
default:
|
||||
return t('Frame contacts');
|
||||
}
|
||||
}
|
||||
|
||||
function inFrameTitle(layerId, count) {
|
||||
switch (layerId) {
|
||||
case 'flights':
|
||||
return tn(
|
||||
count,
|
||||
'{count} aircraft in frame',
|
||||
'{count} aircraft in frame',
|
||||
);
|
||||
case 'military':
|
||||
return tn(
|
||||
count,
|
||||
'{count} military aircraft in frame',
|
||||
'{count} military aircraft in frame',
|
||||
);
|
||||
case 'ais-live-vessels':
|
||||
return tn(count, '{count} ships in frame', '{count} ships in frame');
|
||||
case 'satellites':
|
||||
return tn(
|
||||
count,
|
||||
'{count} satellites in frame',
|
||||
'{count} satellites in frame',
|
||||
);
|
||||
default:
|
||||
return tn(
|
||||
count,
|
||||
'{count} contacts in frame',
|
||||
'{count} contacts in frame',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function nearestTitle(layerId) {
|
||||
switch (layerId) {
|
||||
case 'military':
|
||||
return t('Nearest military aircraft');
|
||||
case 'ais-live-vessels':
|
||||
return t('Nearest ships');
|
||||
case 'satellites':
|
||||
return t('Nearest satellites');
|
||||
default:
|
||||
return t('Nearest aircraft');
|
||||
}
|
||||
}
|
||||
|
||||
/** Two shown items joined, or the one item. */
|
||||
function shownPair(items) {
|
||||
return items.length === 2
|
||||
? t('{first} and {second}', { first: items[0], second: items[1] })
|
||||
: items[0] || '';
|
||||
}
|
||||
|
||||
/** A preset city id (`sf`, `nyc`) as its English name; any other value unchanged. */
|
||||
function presetPlaceName(value) {
|
||||
const id = typeof value === 'string' ? value.trim() : '';
|
||||
return Object.hasOwn(CITY_POIS, id) ? CITY_POIS[id].name : value;
|
||||
}
|
||||
|
||||
// A place as the card shows it: a preset city in the interface language,
|
||||
// whether the call named it ("Tokyo") or gave its id ("tokyo", "nyc").
|
||||
function shownPlace(value, max) {
|
||||
return localizePlaceName(displayName(presetPlaceName(value), max));
|
||||
}
|
||||
|
||||
/** Ids such as `austin` or `local-firms` read as names on screen. */
|
||||
@@ -96,6 +380,12 @@ function layerLabel(result) {
|
||||
return spokenLabel(result?.label || result?.layerId || 'Layer');
|
||||
}
|
||||
|
||||
/** The layer as the card names it, in the active language. */
|
||||
function shownLayerLabel(result) {
|
||||
const name = shownLayerName(result?.label, result?.layerId);
|
||||
return spokenLabel(name || t('Layer'));
|
||||
}
|
||||
|
||||
/* ---------------- per-tool builders ---------------- */
|
||||
|
||||
function setLayerVisibility(result, args = {}) {
|
||||
@@ -112,7 +402,7 @@ function setLayerVisibility(result, args = {}) {
|
||||
};
|
||||
return {
|
||||
say: `Couldn't turn ${wanted} ${label}.`,
|
||||
display: { title: label, lines: [result?.error].filter(Boolean) },
|
||||
display: { title: shownLayerLabel(result), lines: errorLines(result) },
|
||||
};
|
||||
}
|
||||
const on = result.enabled !== false;
|
||||
@@ -124,28 +414,35 @@ function setLayerVisibility(result, args = {}) {
|
||||
return {
|
||||
say,
|
||||
display: {
|
||||
title: `${label} ${on ? 'on' : 'off'}`,
|
||||
title: switchedTitle(shownLayerLabel(result), on),
|
||||
chips: on ? feedChips(result.feedState) : [],
|
||||
sources: result.source ? [{ label: result.source }] : [],
|
||||
sources: shownSources(result.source),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function flyToLocation(result) {
|
||||
const label = spokenLabel(result?.label || result?.query || 'there');
|
||||
const title =
|
||||
spokenLabel(localizePlaceName(result?.label || result?.query)) ||
|
||||
t('there');
|
||||
if (result?.cancelled) return null;
|
||||
if (!result?.ok) {
|
||||
return {
|
||||
say: sentence(`Couldn't find ${label}`),
|
||||
display: { title: label, lines: [result?.error].filter(Boolean) },
|
||||
display: { title, lines: errorLines(result) },
|
||||
};
|
||||
}
|
||||
return {
|
||||
say: sentence(result.arrived ? `Over ${label}` : `Flying to ${label}`),
|
||||
display: {
|
||||
title: label,
|
||||
title,
|
||||
lines: result.rangeM
|
||||
? [`Camera range ${kilometers(result.rangeM / 1000)}`]
|
||||
? [
|
||||
t('Camera range {range}', {
|
||||
range: shownKm(result.rangeM / 1000),
|
||||
}),
|
||||
]
|
||||
: [],
|
||||
},
|
||||
};
|
||||
@@ -169,8 +466,8 @@ function frameOverhead(result) {
|
||||
return {
|
||||
say,
|
||||
display: {
|
||||
title: `Frame ${noun}`,
|
||||
lines: [result?.error].filter(Boolean),
|
||||
title: frameTitle(result?.layerId),
|
||||
lines: errorLines(result),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -188,12 +485,15 @@ function frameOverhead(result) {
|
||||
return {
|
||||
say: sentence(`Framed ${countText} ${noun} within ${radius}`),
|
||||
display: {
|
||||
title: `${count} ${noun} in frame`,
|
||||
title: inFrameTitle(result.layerId, count),
|
||||
lines: [
|
||||
`Within ${radius} of the view`,
|
||||
result.detectionEnabled ? 'Labels on' : null,
|
||||
t('Within {radius} of the view', {
|
||||
radius: shownKm(result?.radiusKm),
|
||||
}),
|
||||
result.detectionEnabled ? t('Labels on') : null,
|
||||
].filter(Boolean),
|
||||
notes: count >= 80 ? ['Framing uses the nearest 80 loaded contacts'] : [],
|
||||
notes:
|
||||
count >= 80 ? [t('Framing uses the nearest 80 loaded contacts')] : [],
|
||||
},
|
||||
referents,
|
||||
};
|
||||
@@ -204,8 +504,12 @@ function selectNearestAircraft(result) {
|
||||
result?.location?.label || result?.location || 'there',
|
||||
);
|
||||
const noun = LAYER_NOUNS[result?.layerId] || 'aircraft';
|
||||
const shownLocation =
|
||||
spokenLabel(
|
||||
localizePlaceName(result?.location?.label || result?.location),
|
||||
) || t('there');
|
||||
const feed = result?.feed || {};
|
||||
const sources = feed.source ? [{ label: feed.source }] : [];
|
||||
const sources = shownSources(feed.source);
|
||||
if (result?.cancelled) return null;
|
||||
if (!result?.ok) {
|
||||
let say;
|
||||
@@ -219,8 +523,8 @@ function selectNearestAircraft(result) {
|
||||
return {
|
||||
say,
|
||||
display: {
|
||||
title: `Nearest ${noun}`,
|
||||
lines: [result?.error].filter(Boolean),
|
||||
title: nearestTitle(result?.layerId),
|
||||
lines: errorLines(result),
|
||||
chips: feedChips(feed.state),
|
||||
sources,
|
||||
},
|
||||
@@ -246,8 +550,17 @@ function selectNearestAircraft(result) {
|
||||
display: {
|
||||
title: name,
|
||||
lines: [
|
||||
distance ? `${distance} from ${location}` : null,
|
||||
altitude ? `Altitude ${altitude}` : null,
|
||||
distance
|
||||
? t('{distance} from {location}', {
|
||||
distance: shownKm(aircraft.distanceKm),
|
||||
location: shownLocation,
|
||||
})
|
||||
: null,
|
||||
altitude
|
||||
? t('Altitude {altitude}', {
|
||||
altitude: shownFeet(aircraft.altitudeM),
|
||||
})
|
||||
: null,
|
||||
].filter(Boolean),
|
||||
chips: feedChips(feed.state),
|
||||
sources,
|
||||
@@ -258,14 +571,30 @@ function selectNearestAircraft(result) {
|
||||
};
|
||||
}
|
||||
|
||||
function routeText(properties) {
|
||||
const SPOKEN_ROUTE = Object.freeze({
|
||||
between: (origin, destination) => `${origin} to ${destination}`,
|
||||
from: (origin) => `from ${origin}`,
|
||||
to: (destination) => `to ${destination}`,
|
||||
});
|
||||
|
||||
const SHOWN_ROUTE = Object.freeze({
|
||||
between: (origin, destination) =>
|
||||
t('{origin} to {destination}', { origin, destination }),
|
||||
from: (origin) => t('from {origin}', { origin }),
|
||||
to: (destination) => t('to {destination}', { destination }),
|
||||
});
|
||||
|
||||
function routeText(properties, words = SPOKEN_ROUTE) {
|
||||
const route = spokenLabel(properties.route || '', 40);
|
||||
if (route) return route.replace(/\s*(?:-|→|>)\s*/g, ' to ');
|
||||
if (route)
|
||||
return route
|
||||
.split(/\s*(?:-|→|>)\s*/)
|
||||
.reduce((origin, destination) => words.between(origin, destination));
|
||||
const origin = spokenLabel(properties.routeOrigin || '', 12);
|
||||
const destination = spokenLabel(properties.routeDestination || '', 12);
|
||||
if (origin && destination) return `${origin} to ${destination}`;
|
||||
if (origin) return `from ${origin}`;
|
||||
if (destination) return `to ${destination}`;
|
||||
if (origin && destination) return words.between(origin, destination);
|
||||
if (origin) return words.from(origin);
|
||||
if (destination) return words.to(destination);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -282,9 +611,13 @@ function getEntityContext(result) {
|
||||
return {
|
||||
say: null,
|
||||
display: {
|
||||
title,
|
||||
lines: [selected.layerName].filter(Boolean),
|
||||
sources: selected.source ? [{ label: selected.source }] : [],
|
||||
title: spokenLabel(shownEntityLabel(title)),
|
||||
lines: [
|
||||
selected.layerName
|
||||
? shownLayerName(selected.layerName, selected.layerId)
|
||||
: null,
|
||||
].filter(Boolean),
|
||||
sources: shownSources(selected.source),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -308,11 +641,15 @@ function getEntityContext(result) {
|
||||
title,
|
||||
lines: [
|
||||
properties.registration
|
||||
? `Registration ${spokenLabel(properties.registration, 16)}`
|
||||
? t('Registration {registration}', {
|
||||
registration: spokenLabel(properties.registration, 16),
|
||||
})
|
||||
: null,
|
||||
route
|
||||
? t('Route {route}', { route: routeText(properties, SHOWN_ROUTE) })
|
||||
: null,
|
||||
route ? `Route ${route}` : null,
|
||||
].filter(Boolean),
|
||||
sources: selected.source ? [{ label: selected.source }] : [],
|
||||
sources: shownSources(selected.source),
|
||||
},
|
||||
referents: [
|
||||
{
|
||||
@@ -357,10 +694,10 @@ function getCurrentViewState(result) {
|
||||
.map((part) => sentence(part[0].toUpperCase() + part.slice(1)))
|
||||
.join(' '),
|
||||
display: {
|
||||
title: 'View state',
|
||||
title: t('View state'),
|
||||
lines: enabled.map(
|
||||
(layer) =>
|
||||
`${spokenLabel(layer.name || layer.id, 32)} · ${layer.count ?? 0} · ${layer.feedState || 'nominal'}`,
|
||||
`${spokenLabel(shownLayerName(layer.name, layer.id), 32)} · ${layer.count ?? 0} · ${feedStateLabel(layer.feedState || 'nominal')}`,
|
||||
),
|
||||
},
|
||||
schedule: 'silent',
|
||||
@@ -394,13 +731,15 @@ function annotateMap(result) {
|
||||
say: parts.length ? parts.join(' ') : null,
|
||||
display: {
|
||||
title: result?.ok
|
||||
? `Marked ${drawn.length} ${drawn.length === 1 ? 'place' : 'places'}`
|
||||
: 'Nothing marked',
|
||||
? tn(drawn.length, 'Marked {count} place', 'Marked {count} places')
|
||||
: t('Nothing marked'),
|
||||
// The numbered referents list the marks; lines stay for extra facts.
|
||||
lines: [],
|
||||
notes: [
|
||||
...(failed.length ? [`Not found: ${failed.join(', ')}`] : []),
|
||||
...(result?.outlinePending ? ['Tracing outlines'] : []),
|
||||
...(failed.length
|
||||
? [t('Not found: {places}', { places: failed.join(', ') })]
|
||||
: []),
|
||||
...(result?.outlinePending ? [t('Tracing outlines')] : []),
|
||||
],
|
||||
},
|
||||
referents,
|
||||
@@ -494,29 +833,99 @@ function annotationTargets(args) {
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
// frame_overhead targets as the schema names them.
|
||||
function frameStepLabel(target) {
|
||||
switch (target) {
|
||||
case 'flights':
|
||||
return t('Frame flights');
|
||||
case 'military':
|
||||
return t('Frame military');
|
||||
case 'satellites':
|
||||
return t('Frame satellites');
|
||||
case 'vessels':
|
||||
return t('Frame vessels');
|
||||
default:
|
||||
return t('Frame {target}', { target });
|
||||
}
|
||||
}
|
||||
|
||||
// Plan-step labels for the other tools in actionSchemas. A tool missing here
|
||||
// shows its raw name in English only.
|
||||
const STEP_TITLES = Object.freeze({
|
||||
zoom_to_globe: msg('Zoom out to globe'),
|
||||
show_data_layers_menu: msg('Open data layers'),
|
||||
set_panel_open: msg('Open or close a panel'),
|
||||
set_voice_inactivity_timeout: msg('Voice inactivity timeout'),
|
||||
set_context_mode: msg('Change context mode'),
|
||||
control_cockpit: msg('Control cockpit'),
|
||||
set_visual_style: msg('Change visual style'),
|
||||
set_hud: msg('Adjust HUD'),
|
||||
set_cyber_sonar: msg('Adjust cyber sonar'),
|
||||
set_detection: msg('Adjust detection overlay'),
|
||||
set_map_stack: msg('Change map stack'),
|
||||
set_post_processing: msg('Adjust post-processing'),
|
||||
control_scene: msg('Control scene'),
|
||||
control_cctv: msg('Control CCTV'),
|
||||
control_radio: msg('Control radio'),
|
||||
track_entity: msg('Track contact'),
|
||||
stop_tracking: msg('Stop tracking'),
|
||||
clear_annotations: msg('Clear marks'),
|
||||
move_camera: msg('Move camera'),
|
||||
fly_route: msg('Fly route'),
|
||||
analyst_query: msg('Analyst query'),
|
||||
next_iss_pass: msg('Next ISS pass'),
|
||||
next_satellite_pass: msg('Next satellite pass'),
|
||||
});
|
||||
|
||||
/** A short on-screen label for one tool call in the voice card's plan. */
|
||||
export function planStepLabel(name, args = {}) {
|
||||
if (Object.hasOwn(STEP_TITLES, name)) return t(STEP_TITLES[name]);
|
||||
switch (name) {
|
||||
case 'annotate_map': {
|
||||
const targets = annotationTargets(args);
|
||||
return targets.length
|
||||
? `Mark ${listPhrase(targets.slice(0, 2))}${targets.length > 2 ? ` +${targets.length - 2}` : ''}`
|
||||
: 'Mark the map';
|
||||
if (!targets.length) return t('Mark the map');
|
||||
const shown = shownPair(targets.slice(0, 2));
|
||||
return targets.length > 2
|
||||
? t('Mark {targets} +{more}', {
|
||||
targets: shown,
|
||||
more: targets.length - 2,
|
||||
})
|
||||
: t('Mark {targets}', { targets: shown });
|
||||
}
|
||||
case 'fly_to_location':
|
||||
return `Fly to ${displayName(args.query || args.locationId || 'location', 40)}`;
|
||||
case 'select_nearest_aircraft':
|
||||
return `Nearest aircraft to ${displayName(args.locationQuery || args.locationId || 'here', 32)}`;
|
||||
case 'set_layer_visibility':
|
||||
return `${displayName(args.layerId || 'Layer', 32)} ${args.enabled === false ? 'off' : 'on'}`;
|
||||
case 'fly_to_location': {
|
||||
const place = args.query || args.locationId;
|
||||
return place
|
||||
? t('Fly to {place}', { place: shownPlace(place, 40) })
|
||||
: t('Fly to Location');
|
||||
}
|
||||
case 'select_nearest_aircraft': {
|
||||
const place = args.locationQuery || args.locationId;
|
||||
return place
|
||||
? t('Nearest aircraft to {place}', { place: shownPlace(place, 32) })
|
||||
: t('Nearest aircraft to Here');
|
||||
}
|
||||
case 'set_layer_visibility': {
|
||||
const on = args.enabled !== false;
|
||||
const label =
|
||||
layerNameForId(args.layerId) ||
|
||||
(args.layerId ? displayName(args.layerId, 32) : '');
|
||||
// "Layer" alone is a noun the languages inflect the state for.
|
||||
if (!label) return on ? t('Layer on') : t('Layer off');
|
||||
return switchedTitle(label, on);
|
||||
}
|
||||
case 'adjust_camera_zoom':
|
||||
return args.direction === 'out' ? t('Zoom out') : t('Zoom in');
|
||||
case 'get_entity_context':
|
||||
return 'Read the view';
|
||||
return t('Read the view');
|
||||
case 'get_current_view_state':
|
||||
return 'Check view state';
|
||||
return t('Check view state');
|
||||
case 'frame_overhead':
|
||||
return `Frame ${spokenLabel(args.target || 'flights', 24)}`;
|
||||
return frameStepLabel(spokenLabel(args.target || 'flights', 24));
|
||||
default:
|
||||
return spokenLabel(String(name || 'Action').replace(/_/g, ' '), 40);
|
||||
// A tool with no label: its name in English, "Action" elsewhere.
|
||||
return getLocale() === 'en'
|
||||
? spokenLabel(String(name || 'Action').replace(/_/g, ' '), 40)
|
||||
: t('Action');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,9 +938,15 @@ export function narrationLabel(name, args = {}) {
|
||||
case 'annotate_map':
|
||||
return annotationTargets(args)[0] || '';
|
||||
case 'fly_to_location':
|
||||
return displayName(args.query || args.locationId || '', 32);
|
||||
return displayName(
|
||||
presetPlaceName(args.query || args.locationId || ''),
|
||||
32,
|
||||
);
|
||||
case 'select_nearest_aircraft':
|
||||
return displayName(args.locationQuery || args.locationId || '', 32);
|
||||
return displayName(
|
||||
presetPlaceName(args.locationQuery || args.locationId || ''),
|
||||
32,
|
||||
);
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@@ -539,19 +954,26 @@ export function narrationLabel(name, args = {}) {
|
||||
|
||||
/** On-screen labels for progress steps. */
|
||||
const STEP_LABELS = Object.freeze({
|
||||
resolve: 'Finding places',
|
||||
outline: 'Tracing outline',
|
||||
search: 'Looking up place',
|
||||
fly: 'Flying',
|
||||
layer: 'Turning on layer',
|
||||
refresh: 'Loading aircraft',
|
||||
nearest: 'Picking nearest',
|
||||
resolve: msg('Finding places'),
|
||||
outline: msg('Tracing outline'),
|
||||
search: msg('Looking up place'),
|
||||
fly: msg('Flying'),
|
||||
layer: msg('Turning on layer'),
|
||||
refresh: msg('Loading aircraft'),
|
||||
nearest: msg('Picking nearest'),
|
||||
});
|
||||
|
||||
/** On-screen label for a progress step. */
|
||||
export function progressStepLabel(step, label) {
|
||||
const base = STEP_LABELS[step] || spokenLabel(step || 'Working', 24);
|
||||
return label ? `${base}: ${spokenLabel(label, 32)}` : base;
|
||||
const base = STEP_LABELS[step]
|
||||
? t(STEP_LABELS[step])
|
||||
: step
|
||||
? spokenLabel(step, 24)
|
||||
: t('Working');
|
||||
// The join is a catalog string so each language spaces its colon.
|
||||
return label
|
||||
? t('{name}: {state}', { name: base, state: spokenLabel(label, 32) })
|
||||
: base;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user