From 91700f89f8c858374f00b9bb5c214864098214ff Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 16:55:00 -0800 Subject: [PATCH 01/12] Keep a country named with "and" whole, and show places as they were typed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "flights near Trinidad and Tobago" flew to Trinidad and offered Tobago on its own; places whose own name holds "and" or "&" (Trinidad and Tobago, Bosnia and Herzegovina, Antigua and Barbuda and the like) now stay one place, while "Austin and Dallas" is still two. "İstanbul" was searched with a stray combining dot, and labels title-cased what was typed with capitals ("IPhone Store"); a place is searched in plain lower case and labelled as it was typed. Co-authored-by: Manjunath Paparaju --- src/ui/omnibarIntent.js | 80 +++++++++++++++++++++++++++++++++++-- src/ui/omnibarRows.js | 31 +++++++++----- src/ui/omnibarRows.test.mjs | 24 +++++++++++ 3 files changed, 121 insertions(+), 14 deletions(-) diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index a96accb592..b5b222ccd6 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -367,6 +367,66 @@ const GO_TAIL = const SEPARATORS = /(\s*(?:,|;(?!\s*[-+]?\d)|\+(?!\d)|&|\band then\b|\bthen\b|\band\b|\balso\b)\s*)/; +/** + * Places whose own name holds "and" (or "&"), kept whole after "near" or + * "in" instead of read as two places: "flights near Trinidad and Tobago". + */ +const COMPOUND_PLACES = new Set([ + 'trinidad and tobago', + 'antigua and barbuda', + 'bosnia and herzegovina', + 'saint kitts and nevis', + 'st kitts and nevis', + 'st. kitts and nevis', + 'saint vincent and the grenadines', + 'st vincent and the grenadines', + 'st. vincent and the grenadines', + 'sao tome and principe', + 'são tomé and príncipe', + 'turks and caicos', + 'turks and caicos islands', + 'wallis and futuna', + 'saint pierre and miquelon', + 'heard island and mcdonald islands', + 'svalbard and jan mayen', + 'south georgia and the south sandwich islands', + 'newfoundland and labrador', + 'jammu and kashmir', + 'andaman and nicobar islands', + 'dadra and nagar haveli', + 'brighton and hove', +]); +const isCompoundPlace = (first, second) => + COMPOUND_PLACES.has(`${first} and ${second}`.toLowerCase()); + +/** + * Lower case one character at a time, so the line keeps its length and + * "İstanbul" reads "istanbul" (not "i̇stanbul" with a combining dot). + */ +function lowerEach(text) { + return Array.from(text, (char) => + char === 'İ' ? 'i' : char.toLowerCase().normalize('NFC'), + ).join(''); +} + +/** + * A place as it was typed: "İstanbul", "iPhone store", "McAllen" are kept, + * where the line read them in lower case. A place the line put together + * ("Trinidad and Tobago" from "Trinidad & Tobago") stays as read. + */ +export function asTypedIn(raw, place) { + const lowered = lowerEach(raw).replace(/\s+/g, ' '); + const spaced = raw.replace(/\s+/g, ' '); + if (lowered.length !== spaced.length) return place; + const at = lowered.indexOf(place); + if (at < 0) return place; + const before = lowered[at - 1]; + const after = lowered[at + place.length]; + if (/[\p{L}\p{N}]/u.test(before || '') || /[\p{L}\p{N}]/u.test(after || '')) + return place; + return spaced.slice(at, at + place.length); +} + function tidy(text) { return text.replace(/\s+/g, ' ').trim(); } @@ -415,7 +475,7 @@ export function parseOmnibar( { isEntity = () => false } = {}, ) { const raw = String(text || '').trim(); - const line = tidy(raw.toLowerCase()).replace( + const line = tidy(lowerEach(raw)).replace( /\b(black[- ]and[- ]white|b ?& ?w)\b/g, 'noir', ); @@ -483,6 +543,7 @@ export function parseOmnibar( for (let i = 0; i < clauses.length; i += 2) { let clause = tidy(clauses[i]); const separator = clauses[i - 1]?.trim(); + const afterPlace = previousHadPlace; const afterPlaceComma = previousHadPlace && separator === ','; // "trinidad and tobago": a bare place joined to a bare place by "and". const afterBarePlaceAnd = previousBarePlace && separator === 'and'; @@ -526,7 +587,14 @@ export function parseOmnibar( const addPlace = (value, { bare = false, leftover = false } = {}) => { if (!value) return; if (leftover) placeClauses.add(i); - if (place && bare && afterBarePlaceAnd) place += ` and ${value}`; + // "near Trinidad and Tobago", "in Bosnia & Herzegovina": one place. + const joinsName = + place && + afterPlace && + (separator === 'and' || separator === '&') && + isCompoundPlace(place.split(', ').at(-1), value); + if (joinsName) place += ` and ${value}`; + else if (place && bare && afterBarePlaceAnd) place += ` and ${value}`; else if (place && !afterPlaceComma) { if (separator === 'and') extraPlaces.push(value); return; @@ -834,7 +902,13 @@ export function parseOmnibar( // Thermal"): no plan runs on Enter; the line may still be a name. const unasked = steps.length > 0 && steps.every((step) => !asked.has(step)); if (place && !placeFrom) placeFrom = placeBare ? 'bare' : 'near'; - if (place) steps.unshift({ kind: 'place', place }); + if (place) { + const step = { kind: 'place', place }; + // How the place was typed, for its label only ("İstanbul", "iPhone + // store"); kept off the step's fields, which plans compare. + Object.defineProperty(step, 'shown', { value: asTypedIn(raw, place) }); + steps.unshift(step); + } steps.verb = LAYER_OFF.test(line) || LAYER_ON.test(line) || GO.test(line); // Following happens once the camera has settled on the new view. steps.sort((a, b) => (a.kind === 'follow') - (b.kind === 'follow')); diff --git a/src/ui/omnibarRows.js b/src/ui/omnibarRows.js index 5185c2268a..0103cf137e 100644 --- a/src/ui/omnibarRows.js +++ b/src/ui/omnibarRows.js @@ -22,6 +22,7 @@ import { hasActionVerb, isPanelText, isRealQuestion, + asTypedIn, isWholeMapClear, magnitudeFloor, normalizeLine, @@ -393,12 +394,19 @@ const SMALL_WORDS = new Set([ 'da', 'des', ]); +/** + * A place's name for a row: as typed when it has a capital ("iPhone store", + * "McAllen", "İstanbul"), else each word capitalised but the small joining + * ones ("santa fe de bogotá" reads "Santa Fe de Bogotá"). + */ export const titleCase = (text) => - text.replace(/\S+/g, (word, at) => - at > 0 && SMALL_WORDS.has(word) - ? word - : word[0].toUpperCase() + word.slice(1), - ); + /\p{Lu}/u.test(text) + ? text + : text.replace(/\S+/g, (word, at) => + at > 0 && SMALL_WORDS.has(word) + ? word + : word[0].toUpperCase() + word.slice(1), + ); const STYLE_LABELS = { noir: msg('Style: Noir'), @@ -707,7 +715,7 @@ export function matchCommands(text) { export function stepLabel(step) { switch (step.kind) { case 'place': - return titleCase(step.place); + return titleCase(step.shown ?? step.place); case 'layer': return step.enabled ? t('{layer} on', { layer: step.layer.shown }) @@ -819,12 +827,13 @@ const askRow = (text) => ({ label: t('Ask GEV: “{query}”', { query: text }), hint: t('Opens chat'), }); -const placeRow = (place) => ({ +/** `shown`: the place as typed, for the label ("İstanbul", "iPhone store"). */ +const placeRow = (place, shown = place) => ({ key: `place:${place}`, kind: 'place', icon: 'location_on', place, - label: t('Go to {place}', { place: titleCase(place) }), + label: t('Go to {place}', { place: titleCase(shown) }), hint: t('Place or coordinates'), }); /** @@ -1049,7 +1058,7 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { realPlaces.length ? realPlaces : place.trim().length >= minPlaceChars(place) - ? [placeRow(place)] + ? [placeRow(place, asTypedIn(text, place))] : []; const titled = writtenAsName(text.split(/\s+/)); @@ -1260,7 +1269,7 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { ...(placeStep ? placeRows(placeStep.place).slice(0, 2) : []), // "near New York and Paris": the plan goes to the first; the others // are offered rather than dropped. - ...extraPlaces.map((extra) => placeRow(extra)), + ...extraPlaces.map((extra) => placeRow(extra, asTypedIn(text, extra))), ...steps .filter((step) => step.kind === 'layer') .map((step) => layerRow(step.layer, step.enabled)), @@ -1272,7 +1281,7 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { if (ambiguous) return withEntities( [ - placeRow(peeled ? placeStep.place : text), + peeled ? placeRow(placeStep.place, placeStep.shown) : placeRow(text), plan, ...alternatives.filter((row) => row.kind !== 'place'), ask, diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index a62cdde11c..648d3b4479 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -646,3 +646,27 @@ test('several switches in one line are one plan', () => { assert.equal(rows[defaultIndex].kind, 'plan', text); } }); + +test('a place named with "and" stays whole, and a place keeps how it was typed', () => { + const omnibar = createOmnibar({ + layers: [{ id: 'flights', name: 'Live Flights', enabled: false }], + }); + const first = (text) => omnibar.rows(text, { places: [] }).rows[0]; + const plan = first('flights near Trinidad and Tobago'); + assert.equal(plan.kind, 'plan'); + assert.equal(plan.steps[0].place, 'trinidad and tobago'); + assert.equal( + first('flights near Bosnia & Herzegovina').steps[0].place, + 'bosnia and herzegovina', + ); + // Two places joined by "and" are still two. + assert.equal( + first('flights near Austin and Dallas').steps[0].place, + 'austin', + ); + // "İstanbul" is searched without a stray combining dot, and labelled as typed. + const istanbul = first('show flights in İstanbul'); + assert.equal(istanbul.steps[0].place, 'istanbul'); + assert.match(istanbul.label, /^İstanbul /); + assert.equal(first('iPhone store').label, 'Go to iPhone store'); +}); From dc317741092ffd3c81de2a95ff8e2da0448fe2d1 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:12:39 -0800 Subject: [PATCH 02/12] Read "everything except", "from the map", a doubled verb and a grid reference after "near" "hide everything except flights" (or "all but", "other than") switches off every layer that is on but the ones named, or says no other layers are on. "remove flights from the map" is "remove flights", "hide hide everything" reads the verb once, and "flights near 14R PU 2090 4906" flies to the grid reference. A keyword that begins a name ("Fire Island", "Radio City Music Hall") no longer offers a plan to the rest of the name. The arrow keys drop a check for a list that opens upward, which it never does. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 12 +++++- src/i18n/locales/ar.json | 1 + src/i18n/locales/de.json | 1 + src/i18n/locales/es.json | 1 + src/i18n/locales/fr.json | 1 + src/i18n/locales/he.json | 1 + src/i18n/locales/it.json | 1 + src/i18n/locales/ja.json | 1 + src/i18n/locales/pt.json | 1 + src/i18n/locales/ru.json | 1 + src/i18n/locales/sv.json | 1 + src/i18n/locales/uk.json | 1 + src/i18n/locales/zh-CN.json | 1 + src/i18n/locales/zh-Hant.json | 1 + src/ui/omnibarIntent.js | 11 +++++ src/ui/omnibarRows.js | 65 ++++++++++++++++++++++++++++- src/ui/omnibarRows.test.mjs | 73 +++++++++++++++++++++++++++++++++ src/ui/views/panels/Omnibar.vue | 6 +-- 18 files changed, 172 insertions(+), 8 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 64207f325a..32be325a74 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7970,7 +7970,12 @@ over"). Otherwise the place row is the default and moves first ("Thermal, California", "radio near tokyo" searches Tokyo), and any plan or command is offered after it; a line with neither ("hi", "NY", "?") runs nothing. "hide everything near tokyo" clears the layers and flies to -Tokyo. Following needs a callsign or ICAO address (letters and a digit), a +Tokyo. "hide everything except flights" (or "all but", "other than", with +"turn off", "clear" or "remove") switches off every layer that is on but +the ones named, or says no other layers are on. "remove flights from the +map" is "remove flights", a doubled verb ("hide hide everything") is read +once, and a grid reference after "near" is the place ("flights near 14R PU +2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a nine-digit MMSI or the name of something loaded on the map, so "Track Hill" and "Track 29" are places; "nearest plane" counts alone or before a place ("Nearest Plane Crash Site" is a name), and "goto" only with a place @@ -7998,7 +8003,10 @@ noir", "go to London with flights"), a switch and a layer ("go to tokyo show flights"), or a comma part that is exactly a style, map, camera move or layer ("go to Tokyo, north up"). A line with one keyword and no verb beside the rest of a name ("Tilt Cove", "tokyo traffic", "Hurricane, Utah") offers -the whole line as a place first and the plan second. Further places joined +the whole line as a place first and the plan second. When that keyword +starts the line with no comma after it ("Fire Island", "Radio City Music +Hall"), it begins the name: the place and the layer are offered, and no +plan goes to the rest of the name. Further places joined with "and" are offered as their own rows. Things loaded on the map that match the line are offered too: a callsign, tail number or transponder code puts them first, and otherwise the place row keeps the top, so diff --git a/src/i18n/locales/ar.json b/src/i18n/locales/ar.json index 66e47080a5..438338cdc7 100644 --- a/src/i18n/locales/ar.json +++ b/src/i18n/locales/ar.json @@ -4648,6 +4648,7 @@ "Turn off": "إيقاف", "Command": "أمر", "No layers are on": "لا توجد طبقات مفعّلة", + "No other layers are on": "لا توجد طبقات أخرى مفعّلة", "No matching layers": "لا توجد طبقات مطابقة", "Show me {thing} settings": "عرض إعدادات {thing}", "Show me how: {thing}": "طريقة الاستخدام: ‏{thing}", diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json index cfec5e6e84..d47cbf6324 100644 --- a/src/i18n/locales/de.json +++ b/src/i18n/locales/de.json @@ -4236,6 +4236,7 @@ "Turn off": "Ausschalten", "Command": "Befehl", "No layers are on": "Keine Ebenen aktiv", + "No other layers are on": "Keine anderen Ebenen aktiv", "No matching layers": "Keine passenden Ebenen", "Show me {thing} settings": "Einstellungen für {thing} zeigen", "Show me how: {thing}": "Anleitung anzeigen: {thing}", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 37e4a2dc4e..489fd34eba 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -4339,6 +4339,7 @@ "Turn off": "Desactivar", "Command": "Comando", "No layers are on": "No hay capas activas", + "No other layers are on": "No hay otras capas activas", "No matching layers": "No se encontraron capas", "Show me {thing} settings": "Muéstrame los ajustes de {thing}", "Show me how: {thing}": "Muéstrame cómo: {thing}", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index 0f6c0ae519..aec90d6fd9 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -4339,6 +4339,7 @@ "Turn off": "Désactiver", "Command": "Commande", "No layers are on": "Aucune couche active", + "No other layers are on": "Aucune autre couche active", "No matching layers": "Aucune couche correspondante", "Show me {thing} settings": "Montrez-moi les réglages de {thing}", "Show me how: {thing}": "Montrez-moi comment faire : {thing}", diff --git a/src/i18n/locales/he.json b/src/i18n/locales/he.json index 5332a9a18f..0dcb7f001d 100644 --- a/src/i18n/locales/he.json +++ b/src/i18n/locales/he.json @@ -4339,6 +4339,7 @@ "Turn off": "כיבוי", "Command": "פקודה", "No layers are on": "אין שכבות פעילות", + "No other layers are on": "אין שכבות אחרות פעילות", "No matching layers": "אין שכבות תואמות", "Show me {thing} settings": "הצגת ההגדרות של {thing}", "Show me how: {thing}": "איך עושים זאת: ‏{thing}", diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index dd71b4270b..f517b67208 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -4339,6 +4339,7 @@ "Turn off": "Disattiva", "Command": "Comando", "No layers are on": "Nessun livello attivo", + "No other layers are on": "Nessun altro livello attivo", "No matching layers": "Nessun livello corrispondente", "Show me {thing} settings": "Mostrami le impostazioni di {thing}", "Show me how: {thing}": "Mostrami come: {thing}", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 6146800f19..2bebb3bcc9 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -4133,6 +4133,7 @@ "Turn off": "オフにする", "Command": "コマンド", "No layers are on": "オンになっているレイヤーはありません", + "No other layers are on": "他にオンになっているレイヤーはありません", "No matching layers": "該当するレイヤーはありません", "Show me {thing} settings": "{thing}の設定を表示", "Show me how: {thing}": "使い方を見る:{thing}", diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 7511af4391..950f139a4b 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -4339,6 +4339,7 @@ "Turn off": "Desativar", "Command": "Comando", "No layers are on": "Nenhuma camada ativa", + "No other layers are on": "Não há outras camadas ativas", "No matching layers": "Nenhuma camada encontrada", "Show me {thing} settings": "Mostre as configurações de {thing}", "Show me how: {thing}": "Mostre como fazer: {thing}", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index 4c65538e23..0cf2d61122 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -4442,6 +4442,7 @@ "Turn off": "Выключить", "Command": "Команда", "No layers are on": "Нет включённых слоёв", + "No other layers are on": "Других включённых слоёв нет", "No matching layers": "Подходящие слои не найдены", "Show me {thing} settings": "Показать настройки для {thing}", "Show me how: {thing}": "Показать как: {thing}", diff --git a/src/i18n/locales/sv.json b/src/i18n/locales/sv.json index ea3c8b277b..25b5f37976 100644 --- a/src/i18n/locales/sv.json +++ b/src/i18n/locales/sv.json @@ -4236,6 +4236,7 @@ "Turn off": "Slå av", "Command": "Kommando", "No layers are on": "Inga lager är på", + "No other layers are on": "Inga andra lager är på", "No matching layers": "Inga matchande lager", "Show me {thing} settings": "Visa inställningarna för {thing}", "Show me how: {thing}": "Visa hur: {thing}", diff --git a/src/i18n/locales/uk.json b/src/i18n/locales/uk.json index caf2a0aa7f..4293477add 100644 --- a/src/i18n/locales/uk.json +++ b/src/i18n/locales/uk.json @@ -4442,6 +4442,7 @@ "Turn off": "Вимкнути", "Command": "Команда", "No layers are on": "Немає увімкнених шарів", + "No other layers are on": "Інших увімкнених шарів немає", "No matching layers": "Відповідних шарів не знайдено", "Show me {thing} settings": "Показати налаштування для {thing}", "Show me how: {thing}": "Показати як: {thing}", diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index 94bcbce7e4..a7e5f73b91 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -4133,6 +4133,7 @@ "Turn off": "关闭", "Command": "命令", "No layers are on": "没有已启用的图层", + "No other layers are on": "没有其他已启用的图层", "No matching layers": "没有匹配的图层", "Show me {thing} settings": "显示{thing}的设置", "Show me how: {thing}": "查看操作方法:{thing}", diff --git a/src/i18n/locales/zh-Hant.json b/src/i18n/locales/zh-Hant.json index e4ae873337..9af1d69dfe 100644 --- a/src/i18n/locales/zh-Hant.json +++ b/src/i18n/locales/zh-Hant.json @@ -4133,6 +4133,7 @@ "Turn off": "關閉", "Command": "命令", "No layers are on": "沒有已啟用的圖層", + "No other layers are on": "沒有其他已啟用的圖層", "No matching layers": "沒有匹配的圖層", "Show me {thing} settings": "顯示{thing}的設置", "Show me how: {thing}": "查看操作方法:{thing}", diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index b5b222ccd6..9f0f3c59f5 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -9,6 +9,7 @@ // entity comes last. import { msg } from '../i18n/index.js'; +import { parseCoordinateQuery } from '../search/coordinateParser.js'; /** Visual styles, by the words people use for them. */ const STYLES = [ @@ -286,6 +287,11 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { .trim(); const end = /(? 0 && steps.every((step) => !asked.has(step)); if (place && !placeFrom) placeFrom = placeBare ? 'bare' : 'near'; if (place) { + // A grid reference is read only as typed ("14R PU 2090 4906"; in lower + // case it may be words), so the plan keeps it so. + const typed = asTypedIn(raw, place); + if (!parseCoordinateQuery(place) && parseCoordinateQuery(typed)) + place = typed; const step = { kind: 'place', place }; // How the place was typed, for its label only ("İstanbul", "iPhone // store"); kept off the step's fields, which plans compare. diff --git a/src/ui/omnibarRows.js b/src/ui/omnibarRows.js index 0103cf137e..fb37c346f6 100644 --- a/src/ui/omnibarRows.js +++ b/src/ui/omnibarRows.js @@ -153,6 +153,9 @@ const SETTINGS_FOR = const SWITCH = /^(turn on|switch on|enable|show|display|add|turn off|switch off|disable|hide|remove|toggle)(?:\s+(.*))?$/; const SWITCH_OFF = /^(turn off|switch off|disable|hide|remove)\b/; +/** "hide everything except …", "turn off all layers but …". */ +const EXCEPT = + /^(?:turn off|switch off|disable|hide|remove|clear)\s+(?:everything|all(?: the)?(?: other)?(?: layers?)?|every layer)\s+(?:except(?: for)?|but(?: for)?|other than|apart from|besides|save for)\s+(.+)$/; // Layers people reach for first, so "turn on" offers these before the rest. export const POPULAR_LAYERS = [ 'flights', @@ -929,7 +932,55 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { * line is not such a switch, or names nothing to switch and may be a place * ("Show Low, AZ"). */ + /** + * "hide everything except flights", "turn off all but ships": a plan that + * switches off every layer that is on but the ones named. Null when the + * line is not that, or names no layer to keep. + */ + function exceptRows(line, ask) { + const match = EXCEPT.exec(line.toLowerCase()); + if (!match) return null; + const kept = match[1] + .split(/\s*(?:,|\band\b|&)\s*/) + .map((term) => matchLayers(term)[0]) + .filter(named); + if (!kept.length) return null; + const keptIds = new Set(kept.map((layer) => layer.id)); + const steps = all() + .filter((layer) => layer.enabled && !keptIds.has(layer.id)) + .map((layer) => ({ kind: 'layer', layer, enabled: false })); + if (!steps.length) + return [ + { + key: 'none', + kind: 'none', + icon: 'layers', + label: t('No other layers are on'), + hint: '', + }, + ask, + ]; + return [ + { + key: `plan:${JSON.stringify(steps)}`, + kind: 'plan', + icon: 'bolt', + steps, + label: steps.map(stepLabel).join(' · '), + hint: t('Do all'), + }, + ask, + ]; + } + function switchRows(line, ask) { + const excepted = exceptRows(line, ask); + if (excepted) return excepted; + // "remove flights from the map": the map is where every layer is. + line = line.replace( + /\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, + '', + ); const switching = line.toLowerCase().match(SWITCH); if ( !switching || @@ -1278,11 +1329,23 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { // without a verb may be part of the place's name, so the whole line as a // place comes first and the plan second. After "go to …" with a request // peeled off, the place is the one read ("go to London with flights"). + // A keyword ahead of the rest of a name ("Fire Island", "Ship Bottom", + // "Radio City Music Hall") begins that name: the leftover is a fragment, + // not a place, so no plan goes there. "tokyo traffic" and "Thermal, + // California" (a comma parts them) keep their plans. + const lower = text.toLowerCase(); + const fragment = + ambiguous && + !peeled && + placeStep && + !/[,;]/.test(text) && + lower.endsWith(placeStep.place.toLowerCase()) && + !lower.startsWith(placeStep.place.toLowerCase()); if (ambiguous) return withEntities( [ peeled ? placeRow(placeStep.place, placeStep.shown) : placeRow(text), - plan, + ...(fragment ? [] : [plan]), ...alternatives.filter((row) => row.kind !== 'place'), ask, ], diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index 648d3b4479..8cdc302250 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -670,3 +670,76 @@ test('a place named with "and" stays whole, and a place keeps how it was typed', assert.match(istanbul.label, /^İstanbul /); assert.equal(first('iPhone store').label, 'Go to iPhone store'); }); + +test('"everything except" keeps the layers named and switches off the rest', () => { + const omnibar = createOmnibar({ + layers: layers(['flights', 'radio', 'cctv']), + }); + const first = (text) => omnibar.rows(text, { places: [] }).rows[0]; + for (const text of [ + 'hide everything except flights', + 'turn off all but live flights', + 'clear everything other than flights', + ]) { + const plan = first(text); + assert.equal(plan.kind, 'plan', text); + assert.deepEqual( + plan.steps.map(stepOutcome), + ['layer(radio,off)', 'layer(cctv,off)'], + text, + ); + } + assert.deepEqual( + first('hide everything except flights and cctv').steps.map(stepOutcome), + ['layer(radio,off)'], + ); + const alone = createOmnibar({ layers: layers(['flights']) }); + assert.equal( + alone.rows('hide everything except flights').rows[0].kind, + 'none', + ); + // Naming no layer to keep is not this reading. + assert.notEqual(first('hide everything except the coast').kind, 'plan'); +}); + +test('"from the map" and a doubled verb do not change the request', () => { + assert.equal( + outcome('remove flights from the map', { on: ['flights'] }), + 'layer(flights,off)', + ); + assert.equal( + outcome('hide flights off the globe', { on: ['flights'] }), + 'layer(flights,off)', + ); + assert.equal(normalizeLine('show show flights'), 'show flights'); + assert.equal(normalizeLine('turn off turn off flights'), 'turn off flights'); +}); + +test('a grid reference after "near" is the place', () => { + const omnibar = createOmnibar({ layers: layers() }); + const plan = omnibar.rows('flights near 14R PU 2090 4906', { places: [] }) + .rows[0]; + assert.equal(plan.kind, 'plan'); + assert.equal(plan.steps[0].kind, 'place'); + assert.match(plan.steps[0].place, /^14R PU 2090 4906$/i); +}); + +test('a keyword that begins a name offers no plan to the rest of it', () => { + const omnibar = createOmnibar({ layers: layers() }); + for (const text of [ + 'Radio City Music Hall', + 'Traffic Island', + 'radio island', + ]) { + const { rows } = omnibar.rows(text, { places: [] }); + assert.equal(rows[0].kind, 'place', text); + assert.ok(!rows.some((row) => row.kind === 'plan'), text); + assert.ok( + rows.some((row) => row.kind === 'layer'), + text, + ); + } + // A keyword after the place still offers its plan. + const { rows } = omnibar.rows('tokyo traffic', { places: [] }); + assert.ok(rows.some((row) => row.kind === 'plan')); +}); diff --git a/src/ui/views/panels/Omnibar.vue b/src/ui/views/panels/Omnibar.vue index 20a4327b92..7962cb346b 100644 --- a/src/ui/views/panels/Omnibar.vue +++ b/src/ui/views/panels/Omnibar.vue @@ -935,11 +935,7 @@ function onKeydown(event) { if (!items.value.length && !chips.length) return; event.preventDefault(); dismissed.value = false; - // When the list opens upward (read bottom-up) the keys follow the - // screen: Up moves away from the field. - const list = document.getElementById('gev-omnibar-list'); - const upward = list && getComputedStyle(list).flexDirection === 'column-reverse'; - const down = (event.key === 'ArrowDown') !== upward; + const down = event.key === 'ArrowDown'; if (inStrip.value) { inStrip.value = false; active.value = down ? 0 : items.value.length - 1; From 84d79f5c7662502ad5d43f34758346d3304b324f Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:14:37 -0800 Subject: [PATCH 03/12] Add the changelog entry for the Omnibar readings Co-authored-by: Manjunath Paparaju --- changelog.d/1831-omnibar-readings.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog.d/1831-omnibar-readings.md diff --git a/changelog.d/1831-omnibar-readings.md b/changelog.d/1831-omnibar-readings.md new file mode 100644 index 0000000000..fe73f2b5d9 --- /dev/null +++ b/changelog.d/1831-omnibar-readings.md @@ -0,0 +1,7 @@ +- The Omnibar reads more lines the way they are meant: a country named with + "and" stays whole ("flights near Trinidad and Tobago"), places show as they + were typed, "hide everything except flights" switches off every other + layer that is on, "remove flights from the map" and a doubled verb are + understood, a grid reference after "near" is the place, and a layer word + that begins a name ("Fire Island") no longer offers a plan to the rest of + it (manjunath22466, samehkhamis, #1831). From 25d33a2e6f449b9102552b2b2161469a6641e8ed Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:35:10 -0800 Subject: [PATCH 04/12] Run "everything except" on Enter, keep every layer it names, and keep plans for places "hide everything except flights" runs on Enter, as asked in so many words. A layer to keep written with "the" is read ("except flights and the radio"), and one that is not read switches nothing off: only Ask GEV is offered. A keyword before the rest of a name only drops its plan when that rest starts with a word for a kind of place ("Fire Island"), so "earthquakes japan" and "flights London" keep theirs. "Saint Vincent and the Grenadines" stays one place with its "the". Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 10 ++++++---- src/ui/omnibarEnter.js | 3 +++ src/ui/omnibarIntent.js | 16 ++++++++++++---- src/ui/omnibarRows.js | 21 ++++++++++++++++----- src/ui/omnibarRows.test.mjs | 32 ++++++++++++++++++++++++++++---- 5 files changed, 65 insertions(+), 17 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 32be325a74..ff5ff4eece 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7972,7 +7972,8 @@ California", "radio near tokyo" searches Tokyo), and any plan or command is offered after it; a line with neither ("hi", "NY", "?") runs nothing. "hide everything near tokyo" clears the layers and flies to Tokyo. "hide everything except flights" (or "all but", "other than", with "turn off", "clear" or "remove") switches off every layer that is on but -the ones named, or says no other layers are on. "remove flights from the +the ones named, on Enter, or says no other layers are on; with a layer to +keep that is not read, nothing is switched off and only Ask GEV is offered. "remove flights from the map" is "remove flights", a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a @@ -8004,9 +8005,10 @@ flights"), or a comma part that is exactly a style, map, camera move or layer ("go to Tokyo, north up"). A line with one keyword and no verb beside the rest of a name ("Tilt Cove", "tokyo traffic", "Hurricane, Utah") offers the whole line as a place first and the plan second. When that keyword -starts the line with no comma after it ("Fire Island", "Radio City Music -Hall"), it begins the name: the place and the layer are offered, and no -plan goes to the rest of the name. Further places joined +starts the line with no comma after it and the rest starts with a word for +a kind of place ("Fire Island", "Radio City Music Hall"), it begins the +name: the place and the layer are offered, and no plan goes to the rest +("earthquakes japan" keeps its plan). Further places joined with "and" are offered as their own rows. Things loaded on the map that match the line are offered too: a callsign, tail number or transponder code puts them first, and otherwise the place row keeps the top, so diff --git a/src/ui/omnibarEnter.js b/src/ui/omnibarEnter.js index 861f243d3b..0b817fca4e 100644 --- a/src/ui/omnibarEnter.js +++ b/src/ui/omnibarEnter.js @@ -140,6 +140,9 @@ export function mayRunOnEnter(item, text, parsed, context) { case 'open-draw': return verb; case 'plan': + // A plan the whole line asked for in so many words ("hide everything + // except flights") runs. + if (item.asked) return true; // A command row runs on its exact label only; a verb that merely // lists it ("hide", "turn off") offers it. if (item.command) return Boolean(item.named); diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index 9f0f3c59f5..7386afa5e7 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -402,8 +402,16 @@ const COMPOUND_PLACES = new Set([ 'dadra and nagar haveli', 'brighton and hove', ]); -const isCompoundPlace = (first, second) => - COMPOUND_PLACES.has(`${first} and ${second}`.toLowerCase()); +/** + * The joining words of a compound place ("and", or "and the" when "the" was + * read off the second part: "Saint Vincent and the Grenadines"), or null. + */ +const compoundJoin = (first, second) => + COMPOUND_PLACES.has(`${first} and ${second}`.toLowerCase()) + ? ' and ' + : COMPOUND_PLACES.has(`${first} and the ${second}`.toLowerCase()) + ? ' and the ' + : null; /** * Lower case one character at a time, so the line keeps its length and @@ -598,8 +606,8 @@ export function parseOmnibar( place && afterPlace && (separator === 'and' || separator === '&') && - isCompoundPlace(place.split(', ').at(-1), value); - if (joinsName) place += ` and ${value}`; + compoundJoin(place.split(', ').at(-1), value); + if (joinsName) place += `${joinsName}${value}`; else if (place && bare && afterBarePlaceAnd) place += ` and ${value}`; else if (place && !afterPlaceComma) { if (separator === 'and') extraPlaces.push(value); diff --git a/src/ui/omnibarRows.js b/src/ui/omnibarRows.js index fb37c346f6..3adeab6a11 100644 --- a/src/ui/omnibarRows.js +++ b/src/ui/omnibarRows.js @@ -154,6 +154,10 @@ const SWITCH = /^(turn on|switch on|enable|show|display|add|turn off|switch off|disable|hide|remove|toggle)(?:\s+(.*))?$/; const SWITCH_OFF = /^(turn off|switch off|disable|hide|remove)\b/; /** "hide everything except …", "turn off all layers but …". */ +/** A word for a kind of place, which a name goes on with ("Fire Island"). */ +const NAME_TAIL = + /^(?:islands?|isle|city|hall|bottom|lake|river|bay|beach|point|station|park|street|road|mountains?|mount|hills?|valley|falls|springs?|creek|county|town|village|harbou?r|cove|canyon|center|centre|square|tower|bridge|pass|ridge|peak)\b/i; + const EXCEPT = /^(?:turn off|switch off|disable|hide|remove|clear)\s+(?:everything|all(?: the)?(?: other)?(?: layers?)?|every layer)\s+(?:except(?: for)?|but(?: for)?|other than|apart from|besides|save for)\s+(.+)$/; // Layers people reach for first, so "turn on" offers these before the rest. @@ -940,11 +944,14 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { function exceptRows(line, ask) { const match = EXCEPT.exec(line.toLowerCase()); if (!match) return null; + // Every layer to keep must be one: with a name not read ("flights and + // the fog") nothing is switched off, and only GEV is offered. const kept = match[1] .split(/\s*(?:,|\band\b|&)\s*/) - .map((term) => matchLayers(term)[0]) - .filter(named); + .filter(Boolean) + .map((term) => matchLayers(term.replace(/^(?:the|my)\s+/, ''))[0]); if (!kept.length) return null; + if (!kept.every(named)) return [ask]; const keptIds = new Set(kept.map((layer) => layer.id)); const steps = all() .filter((layer) => layer.enabled && !keptIds.has(layer.id)) @@ -966,6 +973,8 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { kind: 'plan', icon: 'bolt', steps, + // Asked for in so many words: Enter runs it. + asked: true, label: steps.map(stepLabel).join(' · '), hint: t('Do all'), }, @@ -1330,8 +1339,9 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { // place comes first and the plan second. After "go to …" with a request // peeled off, the place is the one read ("go to London with flights"). // A keyword ahead of the rest of a name ("Fire Island", "Ship Bottom", - // "Radio City Music Hall") begins that name: the leftover is a fragment, - // not a place, so no plan goes there. "tokyo traffic" and "Thermal, + // "Radio City Music Hall") begins that name when what is left starts + // with a word for a kind of place: a fragment, not a place, so no plan + // goes there. "earthquakes japan", "tokyo traffic" and "Thermal, // California" (a comma parts them) keep their plans. const lower = text.toLowerCase(); const fragment = @@ -1340,7 +1350,8 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { placeStep && !/[,;]/.test(text) && lower.endsWith(placeStep.place.toLowerCase()) && - !lower.startsWith(placeStep.place.toLowerCase()); + !lower.startsWith(placeStep.place.toLowerCase()) && + NAME_TAIL.test(placeStep.place); if (ambiguous) return withEntities( [ diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index 8cdc302250..b084a6dc50 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -659,6 +659,10 @@ test('a place named with "and" stays whole, and a place keeps how it was typed', first('flights near Bosnia & Herzegovina').steps[0].place, 'bosnia and herzegovina', ); + assert.equal( + first('flights near Saint Vincent and the Grenadines').steps[0].place, + 'saint vincent and the grenadines', + ); // Two places joined by "and" are still two. assert.equal( first('flights near Austin and Dallas').steps[0].place, @@ -690,9 +694,23 @@ test('"everything except" keeps the layers named and switches off the rest', () ); } assert.deepEqual( - first('hide everything except flights and cctv').steps.map(stepOutcome), + first('hide everything except flights and the cctv').steps.map(stepOutcome), ['layer(radio,off)'], ); + // Enter runs it: the line asked for it in so many words. + assert.equal( + outcome('hide everything except flights', { on: ['flights', 'radio'] }), + 'layer(radio,off)', + ); + // A layer to keep that is not read switches nothing off. + const unread = omnibar.rows('hide everything except flights and the fog', { + places: [], + }); + assert.deepEqual( + unread.rows.map((row) => row.kind), + ['ask'], + ); + assert.equal(unread.defaultIndex, -1); const alone = createOmnibar({ layers: layers(['flights']) }); assert.equal( alone.rows('hide everything except flights').rows[0].kind, @@ -739,7 +757,13 @@ test('a keyword that begins a name offers no plan to the rest of it', () => { text, ); } - // A keyword after the place still offers its plan. - const { rows } = omnibar.rows('tokyo traffic', { places: [] }); - assert.ok(rows.some((row) => row.kind === 'plan')); + // A keyword after the place, or before a place that is no name's + // fragment, still offers its plan. + for (const text of ['tokyo traffic', 'earthquakes japan', 'radio London']) { + const { rows } = omnibar.rows(text, { places: [] }); + assert.ok( + rows.some((row) => row.kind === 'plan'), + text, + ); + } }); From 859aa172e7c13b91e5ee04e4ba0aa491726e7940 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 18:11:18 -0800 Subject: [PATCH 05/12] Keep Space Missions with Satellites in "except", leave "turn off the screen" alone, and part places after a compound country "hide everything except space missions" (or "satellites") keeps both, as switching either off takes the other. "turn off the screen" is no longer read as a switch with "off the screen" taken off it, which left a place search. A place joined after a compound country is another place ("near Trinidad and Tobago and Barbados"), and a compound country after another place stays whole ("near Paris and Trinidad and Tobago"). Only a word for a kind of place written after a name ("Island", "City") drops a plan, so "earthquakes lake tahoe" and "traffic tower bridge" keep theirs. Two doc comments are back above their code. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 7 +++-- src/ui/omnibarIntent.js | 30 ++++++++++++++++++-- src/ui/omnibarRows.js | 42 ++++++++++++++++++++-------- src/ui/omnibarRows.test.mjs | 56 +++++++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 16 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index ff5ff4eece..7a2850e17f 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7973,7 +7973,9 @@ offered after it; a line with neither ("hi", "NY", "?") runs nothing. "hide ever Tokyo. "hide everything except flights" (or "all but", "other than", with "turn off", "clear" or "remove") switches off every layer that is on but the ones named, on Enter, or says no other layers are on; with a layer to -keep that is not read, nothing is switched off and only Ask GEV is offered. "remove flights from the +keep that is not read, nothing is switched off and only Ask GEV is offered. +Space Missions and Satellites are kept together, since Space Missions draws +through Satellites. "remove flights from the map" is "remove flights", a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a @@ -8006,7 +8008,8 @@ layer ("go to Tokyo, north up"). A line with one keyword and no verb beside the rest of a name ("Tilt Cove", "tokyo traffic", "Hurricane, Utah") offers the whole line as a place first and the plan second. When that keyword starts the line with no comma after it and the rest starts with a word for -a kind of place ("Fire Island", "Radio City Music Hall"), it begins the +a kind of place written after a name ("Fire Island", "Radio City Music +Hall"; not "Lake Tahoe" or "Mount Fuji"), it begins the name: the place and the layer are offered, and no plan goes to the rest ("earthquakes japan" keeps its plan). Further places joined with "and" are offered as their own rows. Things loaded on the map that diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index 7386afa5e7..e9a2ebfd7b 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -522,6 +522,9 @@ export function parseOmnibar( const extraPlaces = []; let previousHadPlace = false; let previousBarePlace = false; + // Whether the clause before was a further place ("near Paris and + // Trinidad"), which a compound name may go on ("and Tobago"). + let previousExtraPlace = false; let previousGo = false; // Whether a request was peeled off a "go to" clause, and how the place // was named: after "go to", after "near"/"in", or bare. @@ -561,6 +564,8 @@ export function parseOmnibar( const afterPlaceComma = previousHadPlace && separator === ','; // "trinidad and tobago": a bare place joined to a bare place by "and". const afterBarePlaceAnd = previousBarePlace && separator === 'and'; + const afterExtraPlace = previousExtraPlace; + previousExtraPlace = false; const continuedLayer = previousLayerEnabled; const afterGo = previousGo; previousGo = false; @@ -607,10 +612,29 @@ export function parseOmnibar( afterPlace && (separator === 'and' || separator === '&') && compoundJoin(place.split(', ').at(-1), value); - if (joinsName) place += `${joinsName}${value}`; - else if (place && bare && afterBarePlaceAnd) place += ` and ${value}`; + if (joinsName) { + // The name is whole: a further "and" names another place ("near + // Trinidad and Tobago and Barbados"). + place += `${joinsName}${value}`; + previousHadPlace = true; + previousBarePlace = false; + return; + } + // "near Paris and Trinidad and Tobago": the further place is whole too. + const joinsExtra = + afterExtraPlace && + (separator === 'and' || separator === '&') && + compoundJoin(extraPlaces.at(-1), value); + if (joinsExtra) { + extraPlaces[extraPlaces.length - 1] += `${joinsExtra}${value}`; + return; + } + if (place && bare && afterBarePlaceAnd) place += ` and ${value}`; else if (place && !afterPlaceComma) { - if (separator === 'and') extraPlaces.push(value); + if (separator === 'and') { + extraPlaces.push(value); + previousExtraPlace = true; + } return; } else if (!place) { place = value; diff --git a/src/ui/omnibarRows.js b/src/ui/omnibarRows.js index 3adeab6a11..8c3839c3a5 100644 --- a/src/ui/omnibarRows.js +++ b/src/ui/omnibarRows.js @@ -153,11 +153,22 @@ const SETTINGS_FOR = const SWITCH = /^(turn on|switch on|enable|show|display|add|turn off|switch off|disable|hide|remove|toggle)(?:\s+(.*))?$/; const SWITCH_OFF = /^(turn off|switch off|disable|hide|remove)\b/; -/** "hide everything except …", "turn off all layers but …". */ -/** A word for a kind of place, which a name goes on with ("Fire Island"). */ +/** + * A word for a kind of place written after the name it ends ("Fire + * Island", "Ship Bottom", "Radio City"), not one written before it ("Lake + * Tahoe", "Mount Fuji", "Tower Bridge", "Park City"). + */ const NAME_TAIL = - /^(?:islands?|isle|city|hall|bottom|lake|river|bay|beach|point|station|park|street|road|mountains?|mount|hills?|valley|falls|springs?|creek|county|town|village|harbou?r|cove|canyon|center|centre|square|tower|bridge|pass|ridge|peak)\b/i; + /^(?:islands?|isle|city|hall|bottom|beach|station|street|road|hills?|valley|falls|springs?|creek|county|town|village|harbou?r|cove|canyon|center|centre|square|bridge|ridge|peak)\b(?!\s+of\b)/i; +/** + * A layer that shows itself through another, which must stay on with it: + * Space Missions draws its missions with Satellites, and switching it off + * puts Satellites back as it was before. + */ +const SHOWN_THROUGH = new Map([['rocket-launches', ['satellites']]]); + +/** "hide everything except …", "turn off all layers but …". */ const EXCEPT = /^(?:turn off|switch off|disable|hide|remove|clear)\s+(?:everything|all(?: the)?(?: other)?(?: layers?)?|every layer)\s+(?:except(?: for)?|but(?: for)?|other than|apart from|besides|save for)\s+(.+)$/; // Layers people reach for first, so "turn on" offers these before the rest. @@ -930,12 +941,6 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { return cache.get(line); } - /** - * "turn on …", "hide …", "toggle …", alone or with a few letters: the - * layers and features that switch that way, never places. Null when the - * line is not such a switch, or names nothing to switch and may be a place - * ("Show Low, AZ"). - */ /** * "hide everything except flights", "turn off all but ships": a plan that * switches off every layer that is on but the ones named. Null when the @@ -953,6 +958,13 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { if (!kept.length) return null; if (!kept.every(named)) return [ask]; const keptIds = new Set(kept.map((layer) => layer.id)); + // Keeping either of a pair keeps both: switching one off would take the + // other with it ("except space missions", "except satellites"). + for (const [layer, through] of SHOWN_THROUGH) { + const on = all().find((entry) => entry.id === layer)?.enabled; + if (keptIds.has(layer) || (on && through.some((id) => keptIds.has(id)))) + for (const id of [layer, ...through]) keptIds.add(id); + } const steps = all() .filter((layer) => layer.enabled && !keptIds.has(layer.id)) .map((layer) => ({ kind: 'layer', layer, enabled: false })); @@ -982,14 +994,22 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { ]; } + /** + * "turn on …", "hide …", "toggle …", alone or with a few letters: the + * layers and features that switch that way, never places. Null when the + * line is not such a switch, or names nothing to switch and may be a place + * ("Show Low, AZ"). + */ function switchRows(line, ask) { const excepted = exceptRows(line, ask); if (excepted) return excepted; - // "remove flights from the map": the map is where every layer is. - line = line.replace( + // "remove flights from the map": the map is where every layer is. Not + // the verb's own "off" ("turn off the screen" is no layer switch). + const bare = line.replace( /\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, '', ); + if (bare !== line && SWITCH.test(bare.toLowerCase())) line = bare; const switching = line.toLowerCase().match(SWITCH); if ( !switching || diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index b084a6dc50..e4a8f46d78 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -767,3 +767,59 @@ test('a keyword that begins a name offers no plan to the rest of it', () => { ); } }); + +test('"except" keeps a layer and the one it shows through together', () => { + const omnibar = createOmnibar({ + layers: [ + { id: 'flights', name: 'Live Flights', enabled: true }, + { id: 'satellites', name: 'Satellites', enabled: true }, + { id: 'rocket-launches', name: 'Space Missions', enabled: true }, + ], + }); + for (const text of [ + 'hide everything except space missions', + 'hide everything except satellites', + ]) + assert.deepEqual( + omnibar.rows(text, { places: [] }).rows[0].steps.map(stepOutcome), + ['layer(flights,off)'], + text, + ); +}); + +test('"turn off the screen" is no layer switch and no place', () => { + for (const text of ['turn off the screen', 'switch off the map']) + assert.equal(outcome(text, { on: ['flights'] }), 'nothing', text); +}); + +test('a place after a compound country is another place', () => { + const omnibar = createOmnibar({ layers: layers() }); + const places = (text) => + omnibar + .rows(text, { places: [] }) + .rows.filter((row) => row.kind === 'place') + .map((row) => row.place.toLowerCase()); + assert.deepEqual(places('flights near trinidad and tobago and barbados'), [ + 'trinidad and tobago', + 'barbados', + ]); + assert.deepEqual(places('flights near Paris and Trinidad and Tobago'), [ + 'paris', + 'trinidad and tobago', + ]); +}); + +test('a kind of place written before its name keeps the plan', () => { + const omnibar = createOmnibar({ layers: layers() }); + for (const text of [ + 'earthquakes lake tahoe', + 'earthquakes mount fuji', + 'traffic tower bridge', + ]) { + const { rows } = omnibar.rows(text, { places: [] }); + assert.ok( + rows.some((row) => row.kind === 'plan'), + text, + ); + } +}); From 81192cfa509dec24e855ad5d3f38ca65b4b40b0e Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 18:36:26 -0800 Subject: [PATCH 06/12] Keep plans for places that begin with a kind of place, and keep Satellites with Space Missions only while missions are on A keyword is read as the start of a name only when what follows is one word for a kind of place alone ("Radio City", "Traffic Island"), so "traffic city hall" and "earthquakes valley forge" keep their plans. "except space missions" keeps Satellites only while Space Missions is on, and "from the map" is read before "except". Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 13 ++++++------- src/ui/omnibarRows.js | 29 ++++++++++++++-------------- src/ui/omnibarRows.test.mjs | 38 +++++++++++++++++++++++++++++++------ 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 7a2850e17f..531fc1c8ea 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7974,8 +7974,8 @@ Tokyo. "hide everything except flights" (or "all but", "other than", with "turn off", "clear" or "remove") switches off every layer that is on but the ones named, on Enter, or says no other layers are on; with a layer to keep that is not read, nothing is switched off and only Ask GEV is offered. -Space Missions and Satellites are kept together, since Space Missions draws -through Satellites. "remove flights from the +While Space Missions is on, keeping either it or Satellites keeps both, +since Space Missions draws through Satellites. "remove flights from the map" is "remove flights", a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a @@ -8007,11 +8007,10 @@ flights"), or a comma part that is exactly a style, map, camera move or layer ("go to Tokyo, north up"). A line with one keyword and no verb beside the rest of a name ("Tilt Cove", "tokyo traffic", "Hurricane, Utah") offers the whole line as a place first and the plan second. When that keyword -starts the line with no comma after it and the rest starts with a word for -a kind of place written after a name ("Fire Island", "Radio City Music -Hall"; not "Lake Tahoe" or "Mount Fuji"), it begins the -name: the place and the layer are offered, and no plan goes to the rest -("earthquakes japan" keeps its plan). Further places joined +starts the line with no comma after it and the rest is only a word for a +kind of place ("Fire Island", "Radio City"), it begins the name: the place +and the layer are offered, and no plan goes to the rest ("earthquakes +japan" and "traffic city hall" keep their plans). Further places joined with "and" are offered as their own rows. Things loaded on the map that match the line are offered too: a callsign, tail number or transponder code puts them first, and otherwise the place row keeps the top, so diff --git a/src/ui/omnibarRows.js b/src/ui/omnibarRows.js index 8c3839c3a5..51f50211f7 100644 --- a/src/ui/omnibarRows.js +++ b/src/ui/omnibarRows.js @@ -154,12 +154,12 @@ const SWITCH = /^(turn on|switch on|enable|show|display|add|turn off|switch off|disable|hide|remove|toggle)(?:\s+(.*))?$/; const SWITCH_OFF = /^(turn off|switch off|disable|hide|remove)\b/; /** - * A word for a kind of place written after the name it ends ("Fire - * Island", "Ship Bottom", "Radio City"), not one written before it ("Lake - * Tahoe", "Mount Fuji", "Tower Bridge", "Park City"). + * A word for a kind of place, alone: after a keyword it ends a name ("Fire + * Island", "Ship Bottom", "Radio City"), and is no place to go to by itself. + * Followed by more words it may begin one ("City Hall", "Peak District"). */ const NAME_TAIL = - /^(?:islands?|isle|city|hall|bottom|beach|station|street|road|hills?|valley|falls|springs?|creek|county|town|village|harbou?r|cove|canyon|center|centre|square|bridge|ridge|peak)\b(?!\s+of\b)/i; + /^(?:islands?|isle|city|hall|bottom|beach|station|street|road|hills?|valley|falls|springs?|creek|county|town|village|harbou?r|cove|canyon|center|centre|square|bridge|ridge|peak)$/i; /** * A layer that shows itself through another, which must stay on with it: @@ -958,11 +958,12 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { if (!kept.length) return null; if (!kept.every(named)) return [ask]; const keptIds = new Set(kept.map((layer) => layer.id)); - // Keeping either of a pair keeps both: switching one off would take the - // other with it ("except space missions", "except satellites"). + // Keeping either of a pair keeps both while the first is on: switching + // one off would take the other with it ("except space missions", + // "except satellites"). for (const [layer, through] of SHOWN_THROUGH) { const on = all().find((entry) => entry.id === layer)?.enabled; - if (keptIds.has(layer) || (on && through.some((id) => keptIds.has(id)))) + if (on && (keptIds.has(layer) || through.some((id) => keptIds.has(id)))) for (const id of [layer, ...through]) keptIds.add(id); } const steps = all() @@ -1001,8 +1002,6 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { * ("Show Low, AZ"). */ function switchRows(line, ask) { - const excepted = exceptRows(line, ask); - if (excepted) return excepted; // "remove flights from the map": the map is where every layer is. Not // the verb's own "off" ("turn off the screen" is no layer switch). const bare = line.replace( @@ -1010,6 +1009,8 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { '', ); if (bare !== line && SWITCH.test(bare.toLowerCase())) line = bare; + const excepted = exceptRows(line, ask); + if (excepted) return excepted; const switching = line.toLowerCase().match(SWITCH); if ( !switching || @@ -1358,11 +1359,11 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { // without a verb may be part of the place's name, so the whole line as a // place comes first and the plan second. After "go to …" with a request // peeled off, the place is the one read ("go to London with flights"). - // A keyword ahead of the rest of a name ("Fire Island", "Ship Bottom", - // "Radio City Music Hall") begins that name when what is left starts - // with a word for a kind of place: a fragment, not a place, so no plan - // goes there. "earthquakes japan", "tokyo traffic" and "Thermal, - // California" (a comma parts them) keep their plans. + // A keyword ahead of the rest of a name ("Fire Island", "Ship Bottom") + // begins that name when what is left is only a word for a kind of + // place: a fragment, not a place, so no plan goes there. "earthquakes + // japan", "traffic city hall", "tokyo traffic" and "Thermal, California" + // (a comma parts them) keep their plans. const lower = text.toLowerCase(); const fragment = ambiguous && diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index e4a8f46d78..4333363bbe 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -744,11 +744,7 @@ test('a grid reference after "near" is the place', () => { test('a keyword that begins a name offers no plan to the rest of it', () => { const omnibar = createOmnibar({ layers: layers() }); - for (const text of [ - 'Radio City Music Hall', - 'Traffic Island', - 'radio island', - ]) { + for (const text of ['Radio City', 'Traffic Island', 'radio island']) { const { rows } = omnibar.rows(text, { places: [] }); assert.equal(rows[0].kind, 'place', text); assert.ok(!rows.some((row) => row.kind === 'plan'), text); @@ -759,7 +755,15 @@ test('a keyword that begins a name offers no plan to the rest of it', () => { } // A keyword after the place, or before a place that is no name's // fragment, still offers its plan. - for (const text of ['tokyo traffic', 'earthquakes japan', 'radio London']) { + for (const text of [ + 'tokyo traffic', + 'earthquakes japan', + 'radio London', + 'traffic city hall', + 'traffic county cork', + 'earthquakes valley forge', + 'traffic road to hana', + ]) { const { rows } = omnibar.rows(text, { places: [] }); assert.ok( rows.some((row) => row.kind === 'plan'), @@ -787,6 +791,28 @@ test('"except" keeps a layer and the one it shows through together', () => { ); }); +test('"except" leaves Satellites to switch off with Space Missions off', () => { + const omnibar = createOmnibar({ + layers: [ + { id: 'flights', name: 'Live Flights', enabled: true }, + { id: 'satellites', name: 'Satellites', enabled: true }, + { id: 'rocket-launches', name: 'Space Missions', enabled: false }, + ], + }); + assert.deepEqual( + omnibar + .rows('hide everything except space missions', { places: [] }) + .rows[0].steps.map(stepOutcome), + ['layer(flights,off)', 'layer(satellites,off)'], + ); + assert.deepEqual( + omnibar + .rows('hide everything except flights from the map', { places: [] }) + .rows[0].steps.map(stepOutcome), + ['layer(satellites,off)'], + ); +}); + test('"turn off the screen" is no layer switch and no place', () => { for (const text of ['turn off the screen', 'switch off the map']) assert.equal(outcome(text, { on: ['flights'] }), 'nothing', text); From cd5a4443a2587e1080583bfc1234c8f42a9a7310 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 19:10:54 -0800 Subject: [PATCH 07/12] Read "from the map" after any switch or clear verb, before anything else "clear everything except flights from the map" and "hide everything from the map" now read as they do without the ending, instead of only offering Ask GEV or a place search. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 3 ++- src/ui/omnibarIntent.js | 7 +++++++ src/ui/omnibarRows.js | 7 ------- src/ui/omnibarRows.test.mjs | 24 ++++++++++++++++++------ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 531fc1c8ea..810afb174c 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7976,7 +7976,8 @@ the ones named, on Enter, or says no other layers are on; with a layer to keep that is not read, nothing is switched off and only Ask GEV is offered. While Space Missions is on, keeping either it or Satellites keeps both, since Space Missions draws through Satellites. "remove flights from the -map" is "remove flights", a doubled verb ("hide hide everything") is read +map" is "remove flights", after any switch or clear verb ("clear everything +except flights from the map", "hide everything from the map"), a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a nine-digit MMSI or the name of something loaded on the map, so "Track diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index e9a2ebfd7b..e912330a32 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -292,6 +292,13 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { /^((?:turn|switch) (?:on|off)|show|hide|remove|enable|disable|clear|go to|fly to)\s+\1\b/i, '$1', ); + // "remove flights from the map", "clear everything except ships from the + // map": the map is where every layer is. Not the verb's own "off" ("turn + // off the screen" is no layer switch). + line = line.replace( + /^((?:turn|switch) (?:on|off)|show|display|add|hide|remove|enable|disable|clear|toggle)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, + '$1 $2', + ); // "please" is dropped only around a request: "Please Touch Museum", // "Kindly Lane" and "Pretty Please" are names. const polite = line diff --git a/src/ui/omnibarRows.js b/src/ui/omnibarRows.js index 51f50211f7..dd300fda51 100644 --- a/src/ui/omnibarRows.js +++ b/src/ui/omnibarRows.js @@ -1002,13 +1002,6 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { * ("Show Low, AZ"). */ function switchRows(line, ask) { - // "remove flights from the map": the map is where every layer is. Not - // the verb's own "off" ("turn off the screen" is no layer switch). - const bare = line.replace( - /\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, - '', - ); - if (bare !== line && SWITCH.test(bare.toLowerCase())) line = bare; const excepted = exceptRows(line, ask); if (excepted) return excepted; const switching = line.toLowerCase().match(SWITCH); diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index 4333363bbe..d6a7bb6323 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -805,12 +805,24 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { .rows[0].steps.map(stepOutcome), ['layer(flights,off)', 'layer(satellites,off)'], ); - assert.deepEqual( - omnibar - .rows('hide everything except flights from the map', { places: [] }) - .rows[0].steps.map(stepOutcome), - ['layer(satellites,off)'], - ); + for (const text of [ + 'hide everything except flights from the map', + 'clear everything except flights from the map', + ]) + assert.deepEqual( + omnibar.rows(text, { places: [] }).rows[0].steps.map(stepOutcome), + ['layer(satellites,off)'], + text, + ); + // The whole map cleared "from the map" is the same plan, not a place. + for (const text of [ + 'hide everything from the map', + 'remove all layers from the map', + ]) { + const { rows } = omnibar.rows(text, { places: [] }); + assert.equal(rows[0].kind, 'plan', text); + assert.ok(!rows.some((row) => row.kind === 'place'), text); + } }); test('"turn off the screen" is no layer switch and no place', () => { From 06eb60faab4c703a8773ad16f8715dc509467d60 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 19:33:50 -0800 Subject: [PATCH 08/12] Read "from the map" after "please" is dropped "hide flights from the map please" and "please clear everything except flights from the map" read as they do without "please". Co-authored-by: Manjunath Paparaju --- src/ui/omnibarIntent.js | 16 ++++++++-------- src/ui/omnibarRows.test.mjs | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index e912330a32..2186d59bae 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -292,13 +292,6 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { /^((?:turn|switch) (?:on|off)|show|hide|remove|enable|disable|clear|go to|fly to)\s+\1\b/i, '$1', ); - // "remove flights from the map", "clear everything except ships from the - // map": the map is where every layer is. Not the verb's own "off" ("turn - // off the screen" is no layer switch). - line = line.replace( - /^((?:turn|switch) (?:on|off)|show|display|add|hide|remove|enable|disable|clear|toggle)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, - '$1 $2', - ); // "please" is dropped only around a request: "Please Touch Museum", // "Kindly Lane" and "Pretty Please" are names. const polite = line @@ -306,7 +299,14 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { .replace(/(?:\s*,\s*|\s+)(?:please|pls|plz)$/i, '') .replace(end, '') .trim(); - return polite !== line && polite && isRequest(polite) ? polite : line; + const read = polite !== line && polite && isRequest(polite) ? polite : line; + // "remove flights from the map", "clear everything except ships from the + // map": the map is where every layer is. Not the verb's own "off" ("turn + // off the screen" is no layer switch). + return read.replace( + /^((?:turn|switch) (?:on|off)|show|display|add|hide|remove|enable|disable|clear|toggle)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, + '$1 $2', + ); } /** A request by its own words: a verb starting it, or a real question. */ diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index d6a7bb6323..b023516182 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -808,6 +808,8 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { for (const text of [ 'hide everything except flights from the map', 'clear everything except flights from the map', + 'please clear everything except flights from the map', + 'hide everything except flights from the map, please', ]) assert.deepEqual( omnibar.rows(text, { places: [] }).rows[0].steps.map(stepOutcome), From 3d31126c72cf220062c79973b5fa89b45ba24a15 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 19:45:38 -0800 Subject: [PATCH 09/12] Read "from the map" only after hide, remove, turn off or clear "show me the view from the map" is a question again, not a place search. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 5 +++-- src/ui/omnibarIntent.js | 7 ++++--- src/ui/omnibarRows.test.mjs | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 810afb174c..50958b0bca 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7976,8 +7976,9 @@ the ones named, on Enter, or says no other layers are on; with a layer to keep that is not read, nothing is switched off and only Ask GEV is offered. While Space Missions is on, keeping either it or Satellites keeps both, since Space Missions draws through Satellites. "remove flights from the -map" is "remove flights", after any switch or clear verb ("clear everything -except flights from the map", "hide everything from the map"), a doubled verb ("hide hide everything") is read +map" is "remove flights", after hide, remove, turn off or clear ("clear +everything except flights from the map", "hide everything from the map"; +"show me the view from the map" is a question), a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a nine-digit MMSI or the name of something loaded on the map, so "Track diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index 2186d59bae..041650c0d3 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -301,10 +301,11 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { .trim(); const read = polite !== line && polite && isRequest(polite) ? polite : line; // "remove flights from the map", "clear everything except ships from the - // map": the map is where every layer is. Not the verb's own "off" ("turn - // off the screen" is no layer switch). + // map": the map is where every layer is taken from. Not the verb's own + // "off" ("turn off the screen" is no layer switch), and not after "show" + // ("show me the view from the map" is a question). return read.replace( - /^((?:turn|switch) (?:on|off)|show|display|add|hide|remove|enable|disable|clear|toggle)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, + /^((?:turn|switch) off|hide|remove|disable|clear)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, '$1 $2', ); } diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index b023516182..542c1975b5 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -816,6 +816,11 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { ['layer(satellites,off)'], text, ); + // After "show" the ending is part of what is asked. + assert.equal( + omnibar.rows('show me the view from the map', { places: [] }).defaultIndex, + -1, + ); // The whole map cleared "from the map" is the same plan, not a place. for (const text of [ 'hide everything from the map', From 3a5b10a1f6a29729cbfd213c06668d441686e7c5 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:07:18 -0800 Subject: [PATCH 10/12] Take "from the map" off after "clear" only for the whole map "clear flights from the map" no longer offers to turn Flights on. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 5 +++-- src/ui/omnibarIntent.js | 7 ++++--- src/ui/omnibarRows.test.mjs | 9 +++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 50958b0bca..bc5ba14fe7 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7976,8 +7976,9 @@ the ones named, on Enter, or says no other layers are on; with a layer to keep that is not read, nothing is switched off and only Ask GEV is offered. While Space Missions is on, keeping either it or Satellites keeps both, since Space Missions draws through Satellites. "remove flights from the -map" is "remove flights", after hide, remove, turn off or clear ("clear -everything except flights from the map", "hide everything from the map"; +map" is "remove flights", after hide, remove or turn off, and after clear for the whole map +("clear everything except flights from the map", "hide everything from the +map"; "show me the view from the map" is a question), a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index 041650c0d3..b70a3034f7 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -302,10 +302,11 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { const read = polite !== line && polite && isRequest(polite) ? polite : line; // "remove flights from the map", "clear everything except ships from the // map": the map is where every layer is taken from. Not the verb's own - // "off" ("turn off the screen" is no layer switch), and not after "show" - // ("show me the view from the map" is a question). + // "off" ("turn off the screen" is no layer switch), not after "show" + // ("show me the view from the map" is a question), and after "clear" + // only for the whole map. return read.replace( - /^((?:turn|switch) off|hide|remove|disable|clear)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, + /^((?:turn|switch) off|hide|remove|disable|clear(?= (?:everything|all|every)\b))\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, '$1 $2', ); } diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index 542c1975b5..dfd62bec65 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -816,6 +816,15 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { ['layer(satellites,off)'], text, ); + // "clear" takes the ending off only for the whole map: "clear flights + // from the map" never offers to turn Flights on. + assert.ok( + !omnibar + .rows('clear flights from the map', { places: [] }) + .rows.some((row) => + (row.steps || []).some((step) => step.kind === 'layer' && step.enabled), + ), + ); // After "show" the ending is part of what is asked. assert.equal( omnibar.rows('show me the view from the map', { places: [] }).defaultIndex, From 038915bc0b4925b8faaf8a1f0150a0e3a340c295 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:38:56 -0800 Subject: [PATCH 11/12] Take "from the map" off after "clear" only when what is left clears the whole map "clear all flights from the map" no longer offers to turn Flights on, and "clear the layers from the map" clears the layers. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 8 ++++---- src/ui/omnibarIntent.js | 15 ++++++++++++--- src/ui/omnibarRows.test.mjs | 21 ++++++++++++++------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index bc5ba14fe7..6f9231fba5 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7976,10 +7976,10 @@ the ones named, on Enter, or says no other layers are on; with a layer to keep that is not read, nothing is switched off and only Ask GEV is offered. While Space Missions is on, keeping either it or Satellites keeps both, since Space Missions draws through Satellites. "remove flights from the -map" is "remove flights", after hide, remove or turn off, and after clear for the whole map -("clear everything except flights from the map", "hide everything from the -map"; -"show me the view from the map" is a question), a doubled verb ("hide hide everything") is read +map" is "remove flights", after hide, remove, +turn off, switch off or disable, and after clear only for the whole map +("clear everything except flights from the map", "clear the layers from +the map"; "show me the view from the map" is a question), a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a nine-digit MMSI or the name of something loaded on the map, so "Track diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index b70a3034f7..9692cec338 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -304,11 +304,20 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { // map": the map is where every layer is taken from. Not the verb's own // "off" ("turn off the screen" is no layer switch), not after "show" // ("show me the view from the map" is a question), and after "clear" - // only for the whole map. - return read.replace( - /^((?:turn|switch) off|hide|remove|disable|clear(?= (?:everything|all|every)\b))\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, + // only for the whole map ("clear all flights" would read as a place). + const bare = read.replace( + /^((?:turn|switch) off|hide|remove|disable|clear)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, '$1 $2', ); + if (bare === read || !/^clear\b/i.test(bare)) return bare; + // "clear" takes the whole map: "clear flights" would read as a place. + const lower = bare.toLowerCase(); + return CLEAR_ALL.test(lower) || + /^clear (?:everything|all|every)\b.*\b(?:except|but|other than|apart from|besides|save for)\b/.test( + lower, + ) + ? bare + : read; } /** A request by its own words: a verb starting it, or a real question. */ diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index dfd62bec65..ab786aaa1b 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -818,13 +818,19 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { ); // "clear" takes the ending off only for the whole map: "clear flights // from the map" never offers to turn Flights on. - assert.ok( - !omnibar - .rows('clear flights from the map', { places: [] }) - .rows.some((row) => - (row.steps || []).some((step) => step.kind === 'layer' && step.enabled), - ), - ); + for (const text of [ + 'clear flights from the map', + 'clear all flights from the map', + ]) + assert.ok( + !omnibar + .rows(text, { places: [] }) + .rows.some((row) => + (row.steps || []).some( + (step) => step.kind === 'layer' && step.enabled, + ), + ), + ); // After "show" the ending is part of what is asked. assert.equal( omnibar.rows('show me the view from the map', { places: [] }).defaultIndex, @@ -834,6 +840,7 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { for (const text of [ 'hide everything from the map', 'remove all layers from the map', + 'clear the layers from the map', ]) { const { rows } = omnibar.rows(text, { places: [] }); assert.equal(rows[0].kind, 'plan', text); From 6f959fc3cc7c7305f4cac2dee151da3a7c2aa91f Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:58:18 -0800 Subject: [PATCH 12/12] =?UTF-8?q?Read=20"clear=20=E2=80=A6=20except"=20fro?= =?UTF-8?q?m=20the=20map=20only=20when=20it=20clears=20every=20other=20lay?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "clear all flights except ships from the map" no longer offers to turn Ships on. Co-authored-by: Manjunath Paparaju --- src/ui/omnibarIntent.js | 2 +- src/ui/omnibarRows.test.mjs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index 9692cec338..e081d5aa29 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -313,7 +313,7 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { // "clear" takes the whole map: "clear flights" would read as a place. const lower = bare.toLowerCase(); return CLEAR_ALL.test(lower) || - /^clear (?:everything|all|every)\b.*\b(?:except|but|other than|apart from|besides|save for)\b/.test( + /^clear (?:everything|all(?: the)?(?: other)?(?: layers?)?|every layer) (?:except|but|other than|apart from|besides|save for)\b/.test( lower, ) ? bare diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index ab786aaa1b..247b177578 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -821,6 +821,7 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { for (const text of [ 'clear flights from the map', 'clear all flights from the map', + 'clear all flights except ships from the map', ]) assert.ok( !omnibar