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 <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 17:12:39 -08:00
1 parent 91700f89f8
commit dc31774109
18 files changed
+172 -8

No files matched your search

+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+1
View File
@@ -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}",
+11
View File
@@ -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 = /(?<!(?:^|[\s.])\p{L})[.!。]+$/u;
line = line.replace(end, '');
// A verb typed twice ("hide hide everything") is one.
line = line.replace(
/^((?:turn|switch) (?:on|off)|show|hide|remove|enable|disable|clear|go to|fly to)\s+\1\b/i,
'$1',
);
// "please" is dropped only around a request: "Please Touch Museum",
// "Kindly Lane" and "Pretty Please" are names.
const polite = line
@@ -903,6 +909,11 @@ export function parseOmnibar(
const unasked = steps.length > 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.
+64 -1
View File
@@ -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,
],
+73
View File
@@ -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'));
});
+1 -5
View File
@@ -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;