From 038915bc0b4925b8faaf8a1f0150a0e3a340c295 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:38:56 -0800 Subject: [PATCH] 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);