From a3f4af91f8cf84845035c1b9daf1fb5dd18e95ab Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Wed, 18 Nov 2026 13:00:41 -0800 Subject: [PATCH] Add the Omnibar: one field above the footer for places, layers and commands On desktop the dock becomes one search bar (Omnibar.vue) that shows the rows the line-reading pipeline makes: places with nearby suggestions, coordinates, map items, layers, commands, plans such as "go to Austin and show flights", guided walks through the real controls, and Ask GEV for questions. Enter runs only what the line asks for outright. The map credits move below the bar onto the Power Up row, the voice waveform shows in the bar while voice is on, and the dock's Location and Visual trays are hidden in this layout. The phone layout is unchanged. Long place names are kept out of automatic Ask GEV. Co-authored-by: Sameh Khamis --- docs/CURRENT-STATE.md | 284 ++++ src/creditAttribution.test.mjs | 259 +++- src/i18n/locales/ar.json | 31 +- src/i18n/locales/de.json | 23 +- src/i18n/locales/es.json | 25 +- src/i18n/locales/fr.json | 25 +- src/i18n/locales/he.json | 25 +- src/i18n/locales/it.json | 25 +- src/i18n/locales/ja.json | 21 +- src/i18n/locales/pt.json | 25 +- src/i18n/locales/ru.json | 27 +- src/i18n/locales/sv.json | 23 +- src/i18n/locales/uk.json | 27 +- src/i18n/locales/zh-CN.json | 21 +- src/i18n/locales/zh-Hant.json | 21 +- src/ui/applicationShell.js | 14 + src/ui/commandDock.test.mjs | 1596 +++++++++++++++++++++++ src/ui/entityContextBridge.js | 12 +- src/ui/leftPanelRail.js | 32 +- src/ui/locationControls.js | 38 +- src/ui/locationControls.test.mjs | 1 + src/ui/locationSearch.js | 2 + src/ui/omnibarIntent.js | 11 +- src/ui/omnibarIntent.test.mjs | 1 + src/ui/omnibarRows.test.mjs | 9 +- src/ui/panelRails.test.mjs | 32 + src/ui/stores/entityCard.js | 6 + src/ui/stores/globeActions.js | 3 + src/ui/stores/omnibar.js | 9 +- src/ui/styles/guide.css | 413 ++++++ src/ui/styles/omnibar-dock.css | 360 +++++ src/ui/views/CommandDockView.vue | 4 +- src/ui/views/SceneChromeView.vue | 2 + src/ui/views/panels/Omnibar.vue | 1341 +++++++++++++++++++ src/ui/views/panels/VoiceVisualizer.vue | 66 +- style.css | 2 + 36 files changed, 4741 insertions(+), 75 deletions(-) create mode 100644 src/ui/styles/guide.css create mode 100644 src/ui/styles/omnibar-dock.css create mode 100644 src/ui/views/panels/Omnibar.vue diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 7292252ac1..9c3a7804a9 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7814,6 +7814,290 @@ and unreachable upstream (502/504) separately from road geometry. - `partial` is a feed state of its own, ranked between `fallback` and `nominal`, so one partial layer, or partial plus nominal, reads partial, not off or nominal (HUD, voice view state, `analyst_query`, `brief`, the agent world packet). Its narration note says coverage is incomplete rather than not live. - A summary asked for before the camera starts moving never paints over the next view: `moveStart` marks the summary dirty and bumps its revision, as `moveEnd` does, aborts the request in flight and stops a reply still typing; neither a reply nor a fallback line (on an error, the 5 s timeout, the abort, or a failed context build) paints once the revision has moved. A dropped request forgets its signature and a timeout counts as a failure, so the next 15 s tick asks again even over the same place. An interrupted typewriter reply also forgets its signature; fully displayed answers remain reusable. +### Omnibar + +The desktop Omnibar sits above the footer with the existing mic and chat +buttons on either side. Suggestions open upward; the phone field stays at +the top and opens downward. While voice is on, the desktop field shows +three audio traces in place of the search text and icon. The thinking dots +sit on the field's top edge. World Time appears immediately above the dock +and hides while suggestions, chat, or voice settings are visible. `/` +focuses search from outside a text field, as do Cmd+K on macOS and Ctrl+K +elsewhere (Ctrl+K on macOS is left alone); none of them takes focus from an +open modal dialog or from inside a dialog such as the guide. While voice is +on, the suggestions give way to the waveform but an error stays shown. The map credits stay on the +Power Up row in the ordinary desktop layout, and the two lower tactical HUD +readouts start at the same height. + +Pending owner decision: in the desktop Omnibar layout +(`src/ui/styles/omnibar-dock.css`) the legacy Location and Visual trays of +the command dock are hidden (`#command-dock > :is(#location-bar, +#control-panel)`), as is the tactical and minimal HUD's mode readout +(`.hud-readout:has(> #hud-mode)`). Search moves to the Omnibar and presets to +the Visual rail; the phone shell and exclusive modes keep their layouts. + +The field offers places, latitude/longitude and grid coordinates, named map +entities, and layer controls. The strip can show cities and landmarks, +nearby small places from the bundled Wikidata packs, selected items and +drawing shapes. The cities of a state or country are those inside its +extent and in its country (by the ISO code Photon returns); with only one of +the two known, that one decides. Selecting a +guided result highlights the existing app controls. "Show me how", "how do +I …" and "how to …" find a walk by the words people use: a layer's name +("how to turn on flights"), or a feature's (`FEATURE_TOPICS` in +`src/ui/omnibarRows.js`): the style or look ("change the map style"), the +map underneath ("change the map", "switch to OpenStreetMap"), the HUD, +north or the compass, tilt, the globe or a reset ("get back to the globe"), +sharing, clearing all layers, and drawing and measuring ("how to measure +distance": open Utilities, press Draw, pick Line for a distance or Area for +its size). A leading `>` opens the +command menu; use it for exact layer commands such as `> show flights`. + +The rows come from one pure pipeline, `createOmnibar` in +`src/ui/omnibarRows.js`: the line is normalised once (`normalizeLine` in +`src/ui/omnibarIntent.js`, through `readLine` in `src/ui/omnibarRows.js`: +full-width forms folded, curly apostrophes made straight, a closing full +stop or "!" dropped (an initial's kept, as in "Washington D.C."), and a +"please" before or after a request dropped, never one in a name ("Please +Touch Museum", "Pretty Please")), read once (`parseOmnibar`), turned into +rows, and ordered by the Enter rule; the same reader decides what may go +to Photon and what is a count request. A whole line searched as a place is +searched as typed ("Paris, Texas.", "Yahoo!"). The +component (`Omnibar.vue`) supplies the layers, Photon's answers, the map's +items and the selection, and runs the chosen row; the strip of chips under +the field (landmarks, cities of a region, villages, recent places, draw +shapes) is built in the component from the same normalised line. What Enter does with no +row chosen follows one rule, in `src/ui/omnibarEnter.js` (`enterDefault`), +pinned by an input-to-outcome table in `src/ui/omnibarRows.test.mjs` and +by the mounted table in `src/ui/commandDock.test.mjs`. Only the first row can be the default; an +empty field and a bare `>` have none; the pointer never chooses a row +(hovering then pressing Enter runs the default, a click runs the row), and +the arrow keys choose any row. Enter performs an action (a plan, a layer +switch, a command, Ask GEV) only when the line asks for it outright: + +- the action's own clause starts with a verb from the one list + (`ACTION_VERB` in `src/ui/omnibarIntent.js`, read in any letter case by + `hasActionVerb`): show, hide, turn, switch, toggle, enable, disable, add, + remove, display (with something after it), play, start, open, close, + enter, listen, tune, mute, unmute, follow, track, draw, measure, share, + copy, reset, silence, pause, "nearest plane" and the like, or a clause + ending in "on" or "off" ("radio off"). A style, map, camera move, HUD or + layer followed by "on" or "off" reads as that switch ("noir off" and + "turn off noir" go back to the normal style, "orbit off" stops the camera, + "osm off" runs nothing), never as a place called "off"; words that also start names count + only alone or before what they act on ("clear the map", "zoom in", + "tilt", "orbit", "stop the radio", "kill the radio", "face north"). Verbs + are read per clause, so a verb inside a place's name asks for nothing + ("radio near Clear Lake", "radio in Show Low", "radio near Stop, + Arkansas" search the place). A layer is asked for only by a switch (show, + display, add, enable, turn or switch on, hide, remove, disable, turn or + switch off) right before its word: "Show Low radio" and "Kill Devil Hills + radio" name places, and a verb with a name left beside its keywords asks + for nothing else in its clause ("Show Low noir", "Start Point noir", + "Track Hill noir"). A clause joined to a "go to" + clause by "and" or "then" counts as asked ("go to Paris, Texas and + noir"); +- or it is a command's exact label, alone or after `>` ("North up", "Noir", + "> Clear all layers"). A command row runs on nothing else: a bare switch + verb ("hide", "turn off", "disable") only lists what it could switch; +- or a data layer's whole shown name or synonym alone, which names that + layer as a command's label does ("flights", "earthquakes", "Satellite"); +- or, for Ask GEV, it is a real question: it ends with "?" (full-width + "?" and Arabic "؟" too), has a word of two letters or more, and has a + question's form (below), or two words in a + non-Latin script; or five Han, Kana or Hangul characters ("what?", "??", + "N Y?", "New York?", "Truth or Consequences?" and "東京都?" are not: + Ask GEV is offered first and Enter runs nothing; small talk such as "what's up" or "how's it going" is never one); or, without "?", it + starts with + what/where/when/who/why/how/which followed by is, are, was, do, does, + did, can, could, should, would, will, 's, many, much, far, long or to, + then has a word about something ("what is here", "how far is paris"; not + "what is", "how to", "who is it"), and is not written as a name (three + words or more, each capitalised: "Where Is My Mind"). A line starting + with an auxiliary and a pronoun or determiner (is it, can you, do it…) + asks only with "?": without it, Ask GEV is offered first and Enter runs + nothing ("can you show me", "is it raining in tokyo"), and with a capital + after its first two words it is a name and searches the place ("Can You + Imagine", "Do it Best Hardware"). "Can Tho City" and "Is Kinabalu Park" + are places. A line + with a comma and no "?" is a place ("Why, Arizona"), never a question. + Any other line, small talk and question words included ("why", "help", + "what cheer", "List"), still offers the place row first, with Ask GEV + after it. + +A whole layer name with a place after near, in, around, over, across or +above ("flights near Tokyo", "earthquakes above m5 in japan") asks outright +too; after "of" or "at" the line may be a name and the whole line is +offered as a place first ("Planes of Fame Air Museum", "Boats at Sea"). Keywords without a +verb ask for nothing, however many clauses they fill ("New York City +noir", "Fire and Rain", "noir and cctv near austin, north up"): with a +place after near or in that place is searched, and otherwise the whole +line is offered as a place first ("Storm Lake and Spencer", "Thermal and +Indio"), the plan after it. Draw opens on Enter only for "draw" itself or a +draw verb with something to draw ("draw a line"; not "Draw Bridge"), and a +guided walk found by forgiving a typo, or on a line written as a title +("How To Train Your Dragon"), is offered, never run. A switch verb before +a capitalised name that names no layer is a place ("Remove Island", +"Toggle Inn"). A +layer row runs only when the line names that layer before any other, by a +whole word of its shown or English name (never its id, and not a word of +kind such as local, global, live, world, new, open, data, map, view or +level) or a synonym, with a plural "s" allowed from four letters +("flights" yes; "a", "display", "Local", "Global", "new" no). "show +flights" with Live Flights already on offers Live Flights, which then +switches nothing; Military Flights, which also has the word, is only +offered after it. Words about a layer after a switch are no place ("show radio +stations", "show flights here"); without the switch the line may be a name +("Train Station"). A line of more than six words left over as a +place (ten with a number in it), or of more than eight words that asks for +nothing outright, is a sentence (pasted text, a remark): it is never sent to +Photon, Ask GEV is offered, and so is a row that searches the whole line as a +place when picked ("San Miguel de las Piedras Primera Sección"); Enter runs +neither. A word that is +both a bundled place's name and, alone, a command, style or layer word +(`PLACE_WORDS` in `src/ui/omnibarEnter.js`: Bike, Hurricane, Normal, Rain, +Ski, Street, Thermal) searches the place first and offers the switch +second. The list comes from sweeping every bundled name (139,502), alone +and with " radio" and " noir" after it, through the mounted Omnibar; after +it, none defaults to anything but a place. A test samples about 2,000 of +them. Some actions need more: sound (the Radio layer and command), +clearing the map, closing panels and the cockpit need a verb or their exact +label ("turn on radio", "close all panels", "enter cockpit"; not "radio near +tokyo" or "Radio, Tokyo"), and the microphone, sharing the view, resetting +it and the globe view need their exact label ("Talk to GEV", "Share this +view", "Reset view", "Globe view"; not "mic", "share", "home" or "start +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 +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 +after it ("Goto" is a town). A row chosen with the arrow keys is kept by its key while rows +arrive above it, and the default comes back if it goes away. After a row +runs with Enter, the field empties and keeps focus for the next line on +desktop; a tapped or clicked row lets go of it, and on the phone shell any +row does (so the keyboard does not stay over the map), and so do Ask GEV, the mic, the cockpit, following, a guided +walk, and any row while drawing is on (the draw tool reads Enter, Backspace +and Esc). Escape closes the list, and on an empty, closed field lets go of +it, so the app's own keys work again. While voice +is on, the list is closed (not expanded) and Enter runs nothing. Text that +may be private is never looked up or searched while typed or on Enter: only +things already loaded on the map may match it, locally, and when only a +long run of digits makes it look private and it has words (an address can: +"Москва, ул. Тверская, д. 13, 125009") one row searches it as a place only +when picked (see below). + +After "go to" (or "fly to" and the like) the rest of the clause, and a +following part after a comma that has no verb, is the place, read before +any keyword in it: "go to Thermal, California" only searches there. A +request ending that clause is peeled off and offered as a plan after the +place: "in", "with" or "at" and a style, map or layer ("go to tokyo in +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 +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 +"Hamburg" goes to the city before the ship HAMBURG. An unrecognized explicit command +stays in search. Questions can be sent through Ask GEV, which uses the +existing typed chat. + +Han, Hangul and Kana names are looked up from two characters (東京), others +from three. + +Plans run step by step, and a layer step reads the layer's state when it +runs, not when the line was read. A step the app refuses (an action +answering `ok: false`, a layer switch answering `false`, a globe action no +connected owner answers, a panel to open with no rail button) stops the +plan and shows the same error under the field as a single action, with +the action's own short spoken reason (`say`) when it gives one and the +interface is in English (the runner speaks English, so other languages +get the translated message alone); a flight cancelled by a newer +one stops the plan quietly. A running plan is superseded, and none of its +later steps run, when the field's text changes, another row or chip is +chosen, Escape is pressed, the field is reset after a finished choice, or the +Omnibar unmounts. Focus leaving the field (a click on the map, the mic, the +search shortcut) does not cancel it. The guide's placement check pauses +while the tab is hidden. +A place search on its own runs through Location and shares its cancellation +and errors, keeping the separate Location draft intact. + +While typing, a short line (six words or fewer, no `?`, not a command, +coordinates, a hex code, a callsign such as UAL2110 or N123AB, and nothing +that may be private) is sent to +Photon for place suggestions: at most one request every 500 ms per tab, +and none for a minute after a refusal. Photon is the keyless geocoder the +place search already uses; a submitted search is not part of this spacing. +A line that may be one name ("Satellite Beach") is looked up whole. While +its suggestions show, or a recent-place chip that came from them, the +OpenStreetMap credit shows too; recent chips from the bundled packs credit +Wikidata. Private text, by `mayBePrivate` in +`src/search/placeSuggestions.js`, is never sent to Photon, offered as a +place, searched or sent to GEV; only things already loaded on the map may +match it, locally. The line is read after NFKC, so full-width letters, +digits and "@" count, and digits of any script count as digits. It is +any line with: an "@" with something right on both sides, ending a word, +starting a lowercase handle ("@jdoe"), or spaced before a domain ("john @ +gmail.com") (an email address or a handle, also while it is typed; spaced, as in "Nanjampeta @ +Chandambylu", it is part of a name); seven digits or more with nothing but spaces, +punctuation, symbols or format characters between them (a phone, card, +SSN or account number or its start: "+1 415 555", "4111 1111", "123 45 +6789", "123456789", "4111.1111.1111.1111", "123–45–6789"; a street address's house number +and its postcode are read apart: five digits, or between the street and +the city "00-950", "111 21", "125009", "1100-053", or four digits after a +comma ("Straße 120, 1070 Wien"); and so are a US ZIP+4 after a word, +a Brazilian CEP, a Japanese postcode after "〒" or before the address, and +digits on either side of "#", so "Hauptstrasse 12 10115 Berlin", "DC +20500-0003", "〒100-0001 東京都千代田区" and "Calle 100 # 19-61" are places, +while a seven-digit postcode alone such as "Tel Aviv 6100000" still reads +as private); a phone number written with dots; two letters, two +digits and ten more letters or digits (an IBAN's shape); "password", +"passcode", "passwd", "ssn", "pw", "pwd" or "bearer" followed by anything, +"token", "secret", "api key", "key" or "pass" followed by ":" or "=", a +door, access, gate, alarm, entry or security code followed by a digit, "api +key", "access token" or "secret key" followed by a word of six characters +or more, the word for "password" in the interface's languages +(contraseña, Passwort, mot de passe, пароль…) followed by anything, or "pin" +(also "pin code", "pin number", "pin is") followed by a digit; a word +starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_` or a Slack token's `xoxb-` and the like (any case) or +`AIza`, `eyJ` or `AKIA`; or a word that may be a password or key, with letters and digits mixed +within one run (a number beside a word, as in "Yanino-1", "2-chōme" or +"Route-66", is a name): eight characters or more, six or more with four +letters and a digit ("hunter22", "Area51"), or six or more with letters, +digits and a symbol ("Tr0ub4dor&3"). The password words match whole words +only ("Sachsenhausen" is a place). Over the bundled names (139,502), five +read as private: two with stray digits ("Maliga0N", "Jerónim67") and three +with number lists or codes. When the text may be private the field says +so ("Looks private, so nothing is searched or sent"), and a line whose +only private sign is an address-sized run of digits (no group over six +digits, nine at most in all, counted as they fold, and no word such as +card, code, key, phone or account beside them, in English and some other +European languages; compounds such as "Kreditkartennummer" and words in +other scripts are not read), with words beside it, gets a row +to search it as a place on purpose ("Search … as a place anyway"), which +runs the ordinary place search and its online services only when picked; a +bare number, an email or handle, a password, key, code or IBAN gets none. +A nine-digit number or a short phone number written with no such word +still gets the row: only picking it sends anything. One-time and verification codes, +OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, +recovery or seed phrases, "my secret is …" and an email spelled out ("john +at example dot com") are private too. Text that parses as coordinates or a +grid reference is not private. A place's name is six words at most, or ten +when it has a number in it (an address: "1600 Pennsylvania Ave NW +Washington DC 20500"). The places you go to from the Omnibar (the last 20: +name, position and where the name came from) are kept in this browser's +`localStorage` under `gev:omnibar:recent-places` for the strip; nothing +clears them but the browser's own site data. Setting `PHOTON_URL` +empty turns the suggestions off along with it. Small places come from the +bundled Wikidata packs and are never looked up online; a small place with +the name of a city within 3 km in the same country is that city, and only +the city is listed. At most 64 detail tiles are kept in memory, the least +recently used dropped first. + ### Place-search providers Coordinate input requires exactly two nonempty components; extra comma or semicolon separators decline to geocoding rather than silently choosing a location. diff --git a/src/creditAttribution.test.mjs b/src/creditAttribution.test.mjs index b695666103..879f58d64e 100644 --- a/src/creditAttribution.test.mjs +++ b/src/creditAttribution.test.mjs @@ -6,6 +6,12 @@ import test from 'node:test'; import { fileURLToPath } from 'node:url'; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +// The Omnibar's desktop footer (src/ui/styles/omnibar-dock.css) is part of +// the cascade below like every other stylesheet; its rules carry the +// Omnibar scope, so they are modelled as a layout of their own. +const omnibarCss = readStylesheet( + path.join(ROOT, 'src/ui/styles/omnibar-dock.css'), +); const css = readStylesheet(path.join(ROOT, 'style.css')); /* @@ -125,11 +131,56 @@ function specificity(selector) { return [ids, classes, types]; } -/** Flatten style.css into rules carrying their raw media stack. */ +/** Collapse whitespace and the padding inside brackets of a selector. */ +const tidySelector = (part) => + part + .replace(/\s+/g, ' ') + .trim() + .replace(/\(\s+/g, '(') + .replace(/\s+\)/g, ')'); + +/** + * A nested selector resolved against its parent rule's selectors, as CSS + * nesting does: `&` stands for the parent, and a selector without one is a + * descendant of it. + */ +function nestSelectors(parents, head) { + const own = splitTopLevel(head, ',').map(tidySelector).filter(Boolean); + if (!parents) return own; + return parents.flatMap((parent) => + own.map((part) => + part.includes('&') ? part.replaceAll('&', parent) : `${parent} ${part}`, + ), + ); +} + +/** + * Flatten style.css into rules carrying their raw media stack. Nested style + * rules (CSS nesting) and media queries nested in a rule are resolved to + * full selectors, so a nested rule is modelled like any other. + */ function flattenRules(source) { const src = source.replace(/\/\*[\s\S]*?\*\//g, ''); const rules = []; - const mediaStack = []; + // Open blocks, innermost last: media queries and style rules. + const stack = []; + const mediaStack = () => + stack.filter((frame) => frame.media).map((frame) => frame.media); + const parentRule = () => + [...stack].reverse().find((frame) => frame.rule)?.rule || null; + const declare = (text) => { + const rule = parentRule(); + const trimmed = text.trim(); + if (!rule || !trimmed) return; + const colon = trimmed.indexOf(':'); + if (colon < 0) return; + const value = trimmed.slice(colon + 1).trim(); + rule.decls.push({ + prop: trimmed.slice(0, colon).trim().toLowerCase(), + value: value.replace(/\s*!important$/i, '').trim(), + important: /!important\s*$/i.test(value), + }); + }; let index = 0; let prelude = ''; while (index < src.length) { @@ -137,14 +188,13 @@ function flattenRules(source) { if (char === '{') { const head = prelude.replace(/\s+/g, ' ').trim(); prelude = ''; + index += 1; if (head.startsWith('@media')) { - mediaStack.push(head.slice('@media'.length).trim()); - index += 1; + stack.push({ media: head.slice('@media'.length).trim() }); continue; } if (head.startsWith('@')) { let level = 1; - index += 1; while (index < src.length && level > 0) { if (src[index] === '{') level += 1; else if (src[index] === '}') level -= 1; @@ -152,43 +202,34 @@ function flattenRules(source) { } continue; } - const close = src.indexOf('}', index); - assert.ok(close > index, `unterminated rule block for "${head}"`); - const decls = []; - for (const raw of src.slice(index + 1, close).split(';')) { - const text = raw.trim(); - if (!text) continue; - const colon = text.indexOf(':'); - if (colon < 0) continue; - const value = text.slice(colon + 1).trim(); - decls.push({ - prop: text.slice(0, colon).trim().toLowerCase(), - value: value.replace(/\s*!important$/i, '').trim(), - important: /!important\s*$/i.test(value), - }); - } - rules.push({ + const rule = { order: rules.length, - media: [...mediaStack], - parts: splitTopLevel(head, ',') - .map((part) => - part.trim().replace(/\(\s+/g, '(').replace(/\s+\)/g, ')'), - ) - .filter(Boolean), - decls, - }); - index = close + 1; + media: mediaStack(), + parts: nestSelectors(parentRule()?.parts, head), + decls: [], + }; + rules.push(rule); + stack.push({ rule }); + continue; + } + if (char === ';') { + declare(prelude); + prelude = ''; + index += 1; continue; } if (char === '}') { - mediaStack.pop(); + // The last declaration of a block may omit its semicolon. + declare(prelude); prelude = ''; + stack.pop(); index += 1; continue; } prelude += char; index += 1; } + assert.equal(stack.length, 0, 'unbalanced braces in style.css'); return rules; } @@ -227,6 +268,29 @@ const RECOGNIZED = new Set([ ]); const DOCKED_RAIL = 'body.context-docked #right-context-rail'; + +// The desktop Omnibar layout: the scope its stylesheet nests every rule in. +// It applies on the desktop shell (above the 720px phone breakpoint) while +// the Omnibar and the voice control share the dock; outside it the legacy +// layout below governs. +const OMNIBAR_SCOPE = + 'body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(.ui-clean-view):not(.recording-mode):where(:has(#gev-omnibar):has(#command-dock > #gev-voice-control))'; +const OMNIBAR = Object.freeze({ + dock: `${OMNIBAR_SCOPE} #command-dock`, + credit: `${OMNIBAR_SCOPE} :is(#cesium-credits, #gev-credits)`, + minimalCredit: `${OMNIBAR_SCOPE}:has(#intel-hud[data-variant='minimal'].active) :is(#cesium-credits, #gev-credits)`, + minimalRail: `${OMNIBAR_SCOPE}:not(.context-docked):has(#intel-hud[data-variant='minimal'].active) #right-context-rail`, + trays: `${OMNIBAR_SCOPE} #command-dock > :is(#location-bar, #control-panel)`, +}); +// What each Omnibar-scope rule may set on a modelled box; the Omnibar +// clearance test resolves every one of them through the full cascade. +const OMNIBAR_RECOGNIZED = new Map([ + [OMNIBAR.dock, new Set(['top', 'bottom', 'height', 'min-height'])], + [OMNIBAR.credit, new Set(['bottom'])], + [OMNIBAR.minimalCredit, new Set(['bottom'])], + [OMNIBAR.minimalRail, new Set(['max-height'])], +]); +const OMNIBAR_MIN_WIDTH = 721; const ELEMENT_KEYS = [ '#cesium-credits', '#command-dock', @@ -300,8 +364,11 @@ function ownBoxEntries() { // So is Stories, with GEV's chrome stepped aside; storiesCredit.test.mjs // pins its attribution placement. if ( - /^body\.stories-mode:not\(#gs-a\):not\(#gs-b\) #(cesium|gev)-credits$/.test(part) - ) continue; + /^body\.stories-mode:not\(#gs-a\):not\(#gs-b\) #(cesium|gev)-credits$/.test( + part, + ) + ) + continue; entries.push({ rule, part }); } } @@ -521,6 +588,22 @@ test('the model refuses every cascade construct it cannot resolve', () => { // Expanded Context covers the right edge top to bottom; the credit row // stops short of it instead (the docked-Context test below). if (part === DOCKED_RAIL) continue; + if (part.startsWith(OMNIBAR_SCOPE)) { + const allowed = OMNIBAR_RECOGNIZED.get(part); + for (const decl of guarded) { + if (!allowed?.has(decl.prop)) + complaints.push( + `unrecognized Omnibar rule positions a modelled element: "${part}" (${decl.prop})`, + ); + if (decl.important) + complaints.push(`!important on ${decl.prop} of "${part}"`); + } + if (rule.media.length) + complaints.push( + `media query on Omnibar rule "${part}": ${rule.media.join(' && ')}`, + ); + continue; + } if (!RECOGNIZED.has(part)) { complaints.push( `unrecognized selector positions a modelled element: "${part}" (${guarded.map((d) => d.prop).join(', ')})`, @@ -771,6 +854,116 @@ test('right rail measurement cannot persist into a painted attribution layout', // ── Clearance ─────────────────────────────────────────────────────────────── +/** A custom property's value as the Omnibar scope declares it. */ +function omnibarVar(name) { + const decls = RULES.filter((rule) => rule.parts.includes(OMNIBAR_SCOPE)) + .flatMap((rule) => rule.decls) + .filter((decl) => decl.prop === name); + assert.equal(decls.length, 1, `${name} is declared once in the Omnibar scope`); + return decls[0].value; +} + +/** A length in the Omnibar layout, with its scope's own custom properties. */ +function omnibarPx(value, viewportHeight, where) { + const substituted = value.replace( + /var\((--omnibar-[\w-]+)\)/g, + (_, name) => omnibarVar(name), + ); + return toPx(substituted, viewportHeight, where); +} + +test('Omnibar reserves a non-overlapping desktop footer at native credit sizing', () => { + // The Omnibar layout resolves through the same cascade as the legacy one: + // every legacy rule that could still match competes with the scope's. + const trayOpen = [ + '#command-dock:has(#location-bar:not(.collapsed))', + '#command-dock:has(#control-panel:not(.collapsed))', + ]; + assert.equal( + omnibarVar('--world-timeline-lift'), + '0px', + 'the Omnibar layout holds the timeline lift at 0', + ); + for (const width of WIDTHS.filter((w) => w >= OMNIBAR_MIN_WIDTH)) { + for (const height of HEIGHTS) { + for (const minimal of [false, true]) { + const dock = resolve( + ['#command-dock', ...trayOpen, OMNIBAR.dock], + 'bottom', + width, + 'Omnibar dock', + ); + assert.equal(dock.part, OMNIBAR.dock, `the Omnibar owns the dock at ${width}px`); + // Its top and height too: a legacy top or height winning here would + // move or stretch the dock the clearance below is measured from. + for (const [prop, value] of [ + ['top', 'auto'], + ['height', '56px'], + ]) { + const own = resolve( + ['#command-dock', ...trayOpen, OMNIBAR.dock], + prop, + width, + `Omnibar dock ${prop}`, + ); + assert.equal(own.part, OMNIBAR.dock, `the Omnibar owns the dock ${prop} at ${width}px`); + assert.equal(own.decl.value, value, `Omnibar dock ${prop} at ${width}px`); + } + const credit = resolve( + [ + ...CREDIT_SELECTORS, + OMNIBAR.credit, + ...(minimal ? [MINIMAL_HUD_CREDIT, OMNIBAR.minimalCredit] : []), + ], + 'bottom', + width, + 'Omnibar credit', + ); + assert.ok( + credit.part.startsWith(OMNIBAR_SCOPE), + `the Omnibar owns the credit row at ${width}px`, + ); + const dockBottom = omnibarPx(dock.decl.value, height, 'Omnibar dock bottom'); + const creditTop = + omnibarPx(credit.decl.value, height, 'Omnibar credit bottom') + + CREDIT_HEIGHT_PX; + assert.ok( + dockBottom - creditTop >= MIN_CLEARANCE_PX, + `at ${width}x${height}${minimal ? ' (minimal HUD)' : ''} the Omnibar dock (${dockBottom}px) must clear the credit line (${creditTop}px)`, + ); + } + } + } + // No legacy tray opens over the credit: both are hidden in this layout, + // and no rule elsewhere forces them back. + const trays = RULES.find((rule) => rule.parts.includes(OMNIBAR.trays)); + assert.ok(trays, 'the Omnibar layout hides the legacy trays'); + assert.equal(trays.decls.find((decl) => decl.prop === 'display')?.value, 'none'); + for (const rule of RULES) { + for (const part of rule.parts) { + if (!/#(location-bar|control-panel)$/.test(lastCompound(part))) continue; + assert.ok( + !rule.decls.some((decl) => decl.prop === 'display' && decl.important), + `"${part}" forces a hidden tray back with !important`, + ); + } + } + // The minimal-HUD rail cap only shortens the rail, which is anchored at + // its top, so it can only add room above the credit. + const rail = RULES.find((rule) => rule.parts.includes(OMNIBAR.minimalRail)); + const cap = rail.decls.find((decl) => decl.prop === '--omnibar-minimal-rail-height'); + assert.match(cap?.value || '', /^min\(\s*var\(--right-stack-max-height, 70vh\),/); + assert.equal( + rail.decls.find((decl) => decl.prop === 'max-height')?.value, + 'var(--omnibar-minimal-rail-height)', + ); + assert.doesNotMatch( + omnibarCss, + /\.cesium-widget-credits|\.cesium-credit-logoContainer|\.cesium-credit-textContainer/, + 'the footer uses the original credit text and logo sizing', + ); +}); + test('every open dock tray clears the required credit at every modelled viewport', () => { // Below 900px the tray widens to nearly the viewport and lands on the // bottom-left corner where the credit lives. The clearance is NOT one fixed diff --git a/src/i18n/locales/ar.json b/src/i18n/locales/ar.json index a14abe67f5..1aa9457d77 100644 --- a/src/i18n/locales/ar.json +++ b/src/i18n/locales/ar.json @@ -4675,5 +4675,34 @@ "other": "عرض {what} في {place} ({count} عنصر)" }, "Go there": "انتقل إلى هناك", - "Open draw options": "فتح خيارات الرسم" + "Open draw options": "فتح خيارات الرسم", + "{what} in {place}: {count} items": { + "zero": "{what} في {place}: ‏{count} عنصر", + "one": "{what} في {place}: ‏{count} عنصر", + "two": "{what} في {place}: ‏{count} عنصران", + "few": "{what} في {place}: ‏{count} عناصر", + "many": "{what} في {place}: ‏{count} عنصرًا", + "other": "{what} في {place}: ‏{count} عنصر" + }, + "{count} items in view": { + "zero": "{count} عنصر في العرض", + "one": "{count} عنصر في العرض", + "two": "{count} عنصران في العرض", + "few": "{count} عناصر في العرض", + "many": "{count} عنصرًا في العرض", + "other": "{count} عنصر في العرض" + }, + "Selected · near {name}": "محدّد · قرب {name}", + "Near {name}": "بالقرب من {name}", + "Stop drawing": "إيقاف الرسم", + "{place} · landmarks": "{place} · معالم", + "In {place}": "داخل {place}", + "Near {place}": "بالقرب من {place}", + "Unable to complete this action: {reason}": "تعذر إكمال هذا الإجراء: ‏{reason}", + "Unable to complete this action. Please try again.": "تعذر إكمال هذا الإجراء. يرجى المحاولة مرة أخرى.", + "{layer} M{mag}+": "{layer} بقوة M{mag} فأكثر", + "Search places, layers and things on the map, or ask GEV": "ابحث عن أماكن وطبقات وعناصر على الخريطة، أو اسأل GEV", + "Search places, layers, flights… or ask GEV · > for commands": "ابحث عن أماكن وطبقات ورحلات جوية… أو اسأل GEV · > للأوامر", + "No matching command": "لا يوجد أمر مطابق", + "Looks private, so nothing is searched or sent": "يبدو خاصًا، لذا لا يُبحث عنه ولا يُرسل" } diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json index 786bfa741e..fc654eabb1 100644 --- a/src/i18n/locales/de.json +++ b/src/i18n/locales/de.json @@ -4259,5 +4259,26 @@ "other": "{what} in der Region {place} anzeigen ({count} Elemente)" }, "Go there": "Dorthin wechseln", - "Open draw options": "Zeichenoptionen öffnen" + "Open draw options": "Zeichenoptionen öffnen", + "{what} in {place}: {count} items": { + "one": "{what} in der Region {place}: {count} Element", + "other": "{what} in der Region {place}: {count} Elemente" + }, + "{count} items in view": { + "one": "{count} Element im Blick", + "other": "{count} Elemente im Blick" + }, + "Selected · near {name}": "Auswahl · nahe {name}", + "Near {name}": "Nahe {name}", + "Stop drawing": "Zeichnen beenden", + "{place} · landmarks": "{place} · Sehenswürdigkeiten", + "In {place}": "In der Region {place}", + "Near {place}": "Nahe {place}", + "Unable to complete this action: {reason}": "Diese Aktion konnte nicht abgeschlossen werden: {reason}", + "Unable to complete this action. Please try again.": "Diese Aktion konnte nicht abgeschlossen werden. Bitte versuche es erneut.", + "{layer} M{mag}+": "{layer} ab Magnitude {mag}", + "Search places, layers and things on the map, or ask GEV": "Suche Orte, Ebenen und Kartenelemente oder frage GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Orte, Ebenen, Flüge suchen… oder GEV fragen · > für Befehle", + "No matching command": "Kein passender Befehl", + "Looks private, so nothing is searched or sent": "Sieht privat aus, daher wird nichts gesucht oder gesendet" } diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 38c484b85f..1c4543818d 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -4363,5 +4363,28 @@ "other": "Mostrar {what} en {place} ({count} elementos)" }, "Go there": "Ir allí", - "Open draw options": "Abrir opciones de dibujo" + "Open draw options": "Abrir opciones de dibujo", + "{what} in {place}: {count} items": { + "one": "{what} en {place}: {count} elemento", + "many": "{what} en {place}: {count} de elementos", + "other": "{what} en {place}: {count} elementos" + }, + "{count} items in view": { + "one": "{count} elemento a la vista", + "many": "{count} de elementos a la vista", + "other": "{count} elementos a la vista" + }, + "Selected · near {name}": "Selección · cerca de {name}", + "Near {name}": "Cerca de {name}", + "Stop drawing": "Dejar de dibujar", + "{place} · landmarks": "{place} · lugares de interés", + "In {place}": "En {place}", + "Near {place}": "Cerca de {place}", + "Unable to complete this action: {reason}": "No se pudo completar esta acción: {reason}", + "Unable to complete this action. Please try again.": "No se pudo completar esta acción. Inténtalo de nuevo.", + "{layer} M{mag}+": "{layer} de M{mag} o más", + "Search places, layers and things on the map, or ask GEV": "Busca lugares, capas y elementos del mapa, o pregunta a GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Busca lugares, capas, vuelos… o pregunta a GEV · > para comandos", + "No matching command": "Ningún comando coincide", + "Looks private, so nothing is searched or sent": "Parece privado, así que no se busca ni se envía nada" } diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index 95725609fb..725b762065 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -4363,5 +4363,28 @@ "other": "Afficher {what} dans la zone de {place} ({count} éléments)" }, "Go there": "Y aller", - "Open draw options": "Ouvrir les options de dessin" + "Open draw options": "Ouvrir les options de dessin", + "{what} in {place}: {count} items": { + "one": "{what} dans la zone de {place} : {count} élément", + "many": "{what} dans la zone de {place} : {count} d’éléments", + "other": "{what} dans la zone de {place} : {count} éléments" + }, + "{count} items in view": { + "one": "{count} élément visible", + "many": "{count} d’éléments visibles", + "other": "{count} éléments visibles" + }, + "Selected · near {name}": "Sélection · près de {name}", + "Near {name}": "Près de {name}", + "Stop drawing": "Arrêter le dessin", + "{place} · landmarks": "{place} · points d’intérêt", + "In {place}": "Dans la zone de {place}", + "Near {place}": "Près de {place}", + "Unable to complete this action: {reason}": "Impossible de terminer cette action : {reason}", + "Unable to complete this action. Please try again.": "Impossible de terminer cette action. Veuillez réessayer.", + "{layer} M{mag}+": "{layer} de magnitude {mag} ou plus", + "Search places, layers and things on the map, or ask GEV": "Recherchez des lieux, des couches et des éléments sur la carte, ou interrogez GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Recherchez des lieux, des couches, des vols… ou interrogez GEV · > pour les commandes", + "No matching command": "Aucune commande correspondante", + "Looks private, so nothing is searched or sent": "Semble privé, donc rien n’est recherché ni envoyé" } diff --git a/src/i18n/locales/he.json b/src/i18n/locales/he.json index bda1806ab2..07d2cb56e7 100644 --- a/src/i18n/locales/he.json +++ b/src/i18n/locales/he.json @@ -4363,5 +4363,28 @@ "other": "הצגת {what} ב{place} ({count} פריטים)" }, "Go there": "מעבר למקום", - "Open draw options": "פתיחת אפשרויות הציור" + "Open draw options": "פתיחת אפשרויות הציור", + "{what} in {place}: {count} items": { + "one": "{what} ב{place}: ‏{count} פריט", + "two": "{what} ב{place}: ‏{count} פריטים", + "other": "{what} ב{place}: ‏{count} פריטים" + }, + "{count} items in view": { + "one": "{count} פריט בתצוגה", + "two": "{count} פריטים בתצוגה", + "other": "{count} פריטים בתצוגה" + }, + "Selected · near {name}": "נבחר · ליד {name}", + "Near {name}": "ליד {name}", + "Stop drawing": "הפסקת הציור", + "{place} · landmarks": "{place} · אתרים בולטים", + "In {place}": "בתוך {place}", + "Near {place}": "בסביבת {place}", + "Unable to complete this action: {reason}": "לא ניתן להשלים את הפעולה: ‏{reason}", + "Unable to complete this action. Please try again.": "לא ניתן להשלים את הפעולה. נסו שוב.", + "{layer} M{mag}+": "{layer} בעוצמה M{mag} ומעלה", + "Search places, layers and things on the map, or ask GEV": "חפשו מקומות, שכבות ופריטים במפה, או שאלו את GEV", + "Search places, layers, flights… or ask GEV · > for commands": "חיפוש מקומות, שכבות וטיסות… או שאלה ל‑GEV · > לפקודות", + "No matching command": "אין פקודה תואמת", + "Looks private, so nothing is searched or sent": "נראה פרטי, ולכן שום דבר לא מחופש או נשלח" } diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index 45b64e9c08..ba9c86cdb2 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -4363,5 +4363,28 @@ "other": "Mostra {what} a {place} ({count} elementi)" }, "Go there": "Vai lì", - "Open draw options": "Apri le opzioni di disegno" + "Open draw options": "Apri le opzioni di disegno", + "{what} in {place}: {count} items": { + "one": "{what} a {place}: {count} elemento", + "many": "{what} a {place}: {count} di elementi", + "other": "{what} a {place}: {count} elementi" + }, + "{count} items in view": { + "one": "{count} elemento in vista", + "many": "{count} di elementi in vista", + "other": "{count} elementi in vista" + }, + "Selected · near {name}": "Selezione · vicino a {name}", + "Near {name}": "Vicino a {name}", + "Stop drawing": "Interrompi il disegno", + "{place} · landmarks": "{place} · punti di interesse", + "In {place}": "A {place}", + "Near {place}": "Vicino a {place}", + "Unable to complete this action: {reason}": "Impossibile completare questa azione: {reason}", + "Unable to complete this action. Please try again.": "Impossibile completare questa azione. Riprova.", + "{layer} M{mag}+": "{layer} di magnitudo {mag} o superiore", + "Search places, layers and things on the map, or ask GEV": "Cerca luoghi, livelli ed elementi sulla mappa oppure chiedi a GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Cerca luoghi, livelli, voli… oppure chiedi a GEV · > per i comandi", + "No matching command": "Nessun comando corrispondente", + "Looks private, so nothing is searched or sent": "Sembra privato, quindi non viene cercato né inviato nulla" } diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 0fe1a3c597..cda461467b 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -4155,5 +4155,24 @@ "other": "{place}の{what}を表示({count}件)" }, "Go there": "その場所に移動", - "Open draw options": "描画オプションを開く" + "Open draw options": "描画オプションを開く", + "{what} in {place}: {count} items": { + "other": "{place}の{what}:{count}件" + }, + "{count} items in view": { + "other": "{count}件表示中" + }, + "Selected · near {name}": "選択中 · {name}の周辺", + "Near {name}": "{name}の周辺", + "Stop drawing": "描画を終了", + "{place} · landmarks": "{place} · 名所", + "In {place}": "{place}の範囲内", + "Near {place}": "{place}の周辺", + "Unable to complete this action: {reason}": "この操作を完了できませんでした:{reason}", + "Unable to complete this action. Please try again.": "この操作を完了できませんでした。もう一度お試しください。", + "{layer} M{mag}+": "{layer}(M{mag}以上)", + "Search places, layers and things on the map, or ask GEV": "場所、レイヤー、マップ上の対象を検索するか、GEVに質問", + "Search places, layers, flights… or ask GEV · > for commands": "場所、レイヤー、航空便を検索… またはGEVに質問 · > でコマンド", + "No matching command": "一致するコマンドがありません", + "Looks private, so nothing is searched or sent": "個人情報の可能性があるため、検索も送信もしません" } diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 5e75f06d6c..7505611ece 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -4363,5 +4363,28 @@ "other": "Mostrar {what} em {place} ({count} itens)" }, "Go there": "Ir até lá", - "Open draw options": "Abrir opções de desenho" + "Open draw options": "Abrir opções de desenho", + "{what} in {place}: {count} items": { + "one": "{what} em {place}: {count} item", + "many": "{what} em {place}: {count} de itens", + "other": "{what} em {place}: {count} itens" + }, + "{count} items in view": { + "one": "{count} item à vista", + "many": "{count} de itens à vista", + "other": "{count} itens à vista" + }, + "Selected · near {name}": "Seleção · perto de {name}", + "Near {name}": "Perto de {name}", + "Stop drawing": "Parar de desenhar", + "{place} · landmarks": "{place} · pontos de interesse", + "In {place}": "Em {place}", + "Near {place}": "Perto de {place}", + "Unable to complete this action: {reason}": "Não foi possível concluir esta ação: {reason}", + "Unable to complete this action. Please try again.": "Não foi possível concluir esta ação. Tente novamente.", + "{layer} M{mag}+": "{layer} de magnitude {mag} ou mais", + "Search places, layers and things on the map, or ask GEV": "Busque lugares, camadas e elementos no mapa ou pergunte ao GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Busque lugares, camadas, voos… ou pergunte ao GEV · > para comandos", + "No matching command": "Nenhum comando correspondente", + "Looks private, so nothing is searched or sent": "Parece privado, por isso nada é pesquisado nem enviado" } diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index 3f3f224cfd..03b46c3591 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -4467,5 +4467,30 @@ "other": "Показать {what} · {place} ({count} объекта)" }, "Go there": "Перейти туда", - "Open draw options": "Открыть параметры рисования" + "Open draw options": "Открыть параметры рисования", + "{what} in {place}: {count} items": { + "one": "{what} · {place}: {count} объект", + "few": "{what} · {place}: {count} объекта", + "many": "{what} · {place}: {count} объектов", + "other": "{what} · {place}: {count} объекта" + }, + "{count} items in view": { + "one": "{count} объект в поле зрения", + "few": "{count} объекта в поле зрения", + "many": "{count} объектов в поле зрения", + "other": "{count} объекта в поле зрения" + }, + "Selected · near {name}": "Выбрано · рядом с {name}", + "Near {name}": "Рядом с {name}", + "Stop drawing": "Завершить рисование", + "{place} · landmarks": "{place} · достопримечательности", + "In {place}": "Места в {place}", + "Near {place}": "Рядом с {place}", + "Unable to complete this action: {reason}": "Не удалось выполнить действие: {reason}", + "Unable to complete this action. Please try again.": "Не удалось выполнить действие. Попробуйте ещё раз.", + "{layer} M{mag}+": "{layer} с магнитудой от {mag}", + "Search places, layers and things on the map, or ask GEV": "Ищите места, слои и объекты на карте или спросите GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Ищите места, слои, рейсы… или спросите GEV · > для команд", + "No matching command": "Подходящая команда не найдена", + "Looks private, so nothing is searched or sent": "Похоже на личные данные, поэтому ничего не ищется и не отправляется" } diff --git a/src/i18n/locales/sv.json b/src/i18n/locales/sv.json index 14c8ed02ee..fd2cb35a42 100644 --- a/src/i18n/locales/sv.json +++ b/src/i18n/locales/sv.json @@ -4259,5 +4259,26 @@ "other": "Visa {what} i {place} ({count} objekt)" }, "Go there": "Gå dit", - "Open draw options": "Öppna ritalternativ" + "Open draw options": "Öppna ritalternativ", + "{what} in {place}: {count} items": { + "one": "{what} i {place}: {count} objekt", + "other": "{what} i {place}: {count} objekt" + }, + "{count} items in view": { + "one": "{count} objekt i vyn", + "other": "{count} objekt i vyn" + }, + "Selected · near {name}": "Valt objekt · nära {name}", + "Near {name}": "Nära {name}", + "Stop drawing": "Sluta rita", + "{place} · landmarks": "{place} · sevärdheter", + "In {place}": "I {place}", + "Near {place}": "Nära {place}", + "Unable to complete this action: {reason}": "Det gick inte att slutföra åtgärden: {reason}", + "Unable to complete this action. Please try again.": "Det gick inte att slutföra åtgärden. Försök igen.", + "{layer} M{mag}+": "{layer} med magnitud {mag} eller högre", + "Search places, layers and things on the map, or ask GEV": "Sök efter platser, lager och objekt på kartan eller fråga GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Sök efter platser, lager, flyg… eller fråga GEV · > för kommandon", + "No matching command": "Inget matchande kommando", + "Looks private, so nothing is searched or sent": "Ser privat ut, så inget söks eller skickas" } diff --git a/src/i18n/locales/uk.json b/src/i18n/locales/uk.json index d778b54801..ff34b3aaeb 100644 --- a/src/i18n/locales/uk.json +++ b/src/i18n/locales/uk.json @@ -4467,5 +4467,30 @@ "other": "Показати {what} · {place} ({count} об’єкта)" }, "Go there": "Перейти туди", - "Open draw options": "Відкрити параметри малювання" + "Open draw options": "Відкрити параметри малювання", + "{what} in {place}: {count} items": { + "one": "{what} · {place}: {count} об’єкт", + "few": "{what} · {place}: {count} об’єкти", + "many": "{what} · {place}: {count} об’єктів", + "other": "{what} · {place}: {count} об’єкта" + }, + "{count} items in view": { + "one": "{count} об’єкт у полі зору", + "few": "{count} об’єкти у полі зору", + "many": "{count} об’єктів у полі зору", + "other": "{count} об’єкта у полі зору" + }, + "Selected · near {name}": "Вибране · поблизу {name}", + "Near {name}": "Поблизу {name}", + "Stop drawing": "Припинити малювання", + "{place} · landmarks": "{place} · визначні місця", + "In {place}": "Місця в {place}", + "Near {place}": "Поблизу {place}", + "Unable to complete this action: {reason}": "Не вдалося виконати цю дію: {reason}", + "Unable to complete this action. Please try again.": "Не вдалося виконати цю дію. Спробуйте ще раз.", + "{layer} M{mag}+": "{layer} з магнітудою від {mag}", + "Search places, layers and things on the map, or ask GEV": "Шукайте місця, шари й об’єкти на карті або запитайте GEV", + "Search places, layers, flights… or ask GEV · > for commands": "Шукайте місця, шари, рейси… або запитайте GEV · > для команд", + "No matching command": "Відповідної команди не знайдено", + "Looks private, so nothing is searched or sent": "Схоже на особисті дані, тому нічого не шукається й не надсилається" } diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index c2d1f49e94..f4333ece82 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -4155,5 +4155,24 @@ "other": "显示{place}的{what}({count} 个)" }, "Go there": "前往该地点", - "Open draw options": "打开绘制选项" + "Open draw options": "打开绘制选项", + "{what} in {place}: {count} items": { + "other": "{place}的{what}:{count} 个" + }, + "{count} items in view": { + "other": "视野内 {count} 个" + }, + "Selected · near {name}": "已选中 · {name}附近", + "Near {name}": "{name}附近", + "Stop drawing": "停止绘制", + "{place} · landmarks": "{place} · 地标", + "In {place}": "{place}境内", + "Near {place}": "{place}附近", + "Unable to complete this action: {reason}": "无法完成此操作:{reason}", + "Unable to complete this action. Please try again.": "无法完成此操作。请重试。", + "{layer} M{mag}+": "{layer}(震级 M{mag} 及以上)", + "Search places, layers and things on the map, or ask GEV": "搜索地点、图层和地图上的对象,或向 GEV 提问", + "Search places, layers, flights… or ask GEV · > for commands": "搜索地点、图层、航班… 或问 GEV · > 输入命令", + "No matching command": "没有匹配的命令", + "Looks private, so nothing is searched or sent": "疑似隐私信息,因此不会搜索或发送" } diff --git a/src/i18n/locales/zh-Hant.json b/src/i18n/locales/zh-Hant.json index 640f5bb730..210a831dc9 100644 --- a/src/i18n/locales/zh-Hant.json +++ b/src/i18n/locales/zh-Hant.json @@ -4155,5 +4155,24 @@ "other": "顯示{place}的{what}({count} 個)" }, "Go there": "前往該地點", - "Open draw options": "打開繪製選項" + "Open draw options": "打開繪製選項", + "{what} in {place}: {count} items": { + "other": "{place}的{what}:{count} 個" + }, + "{count} items in view": { + "other": "視野內 {count} 個" + }, + "Selected · near {name}": "已選中 · {name}附近", + "Near {name}": "{name}附近", + "Stop drawing": "停止繪製", + "{place} · landmarks": "{place} · 地標", + "In {place}": "{place}境內", + "Near {place}": "{place}附近", + "Unable to complete this action: {reason}": "無法完成此操作:{reason}", + "Unable to complete this action. Please try again.": "無法完成此操作。請重試。", + "{layer} M{mag}+": "{layer}(震級 M{mag} 及以上)", + "Search places, layers and things on the map, or ask GEV": "搜索地點、圖層和地圖上的對象,或向 GEV 提問", + "Search places, layers, flights… or ask GEV · > for commands": "搜索地點、圖層、航班… 或問 GEV · > 輸入命令", + "No matching command": "沒有匹配的命令", + "Looks private, so nothing is searched or sent": "疑似隱私信息,因此不會搜索或發送" } diff --git a/src/ui/applicationShell.js b/src/ui/applicationShell.js index ed10b008f6..6b636f9b51 100644 --- a/src/ui/applicationShell.js +++ b/src/ui/applicationShell.js @@ -78,6 +78,12 @@ import { useCockpitStore } from './stores/cockpit.js'; import { useGlobeActionsStore } from './stores/globeActions.js'; import { useRecordingStore } from './stores/recording.js'; import { onPlacePacksLoadingChange } from '../data/placeBelow.js'; +import { + hideOsmCredit, + registerDynamicCredit, + showOsmCredit, + WIKIDATA_PLACES_CREDIT, +} from '../data/dataCredits.js'; import { withPlacePacks } from './placePacksLoading.js'; import { preloadOwnerFlags } from './ownerFlag.js'; @@ -182,6 +188,14 @@ export class StyleManager extends ShellFacade { layers: () => this._dataManager?.getAll?.() || [], setLayer: (id, enabled) => this._dataManager?.setEnabled(id, enabled, { origin: 'user' }), + // The Omnibar shows names from the bundled Wikidata packs. + creditPlaces: () => + registerDynamicCredit(this.viewer, WIKIDATA_PLACES_CREDIT), + // Photon's suggestions are OpenStreetMap data: credited while shown. + creditSuggestions: (shown) => + shown + ? showOsmCredit(this.viewer, 'omnibar') + : hideOsmCredit(this.viewer, 'omnibar'), }); // Scrolling at a screen edge steps through that side's rail panels. this._removeRailEdgeScroll = installRailEdgeScroll(); diff --git a/src/ui/commandDock.test.mjs b/src/ui/commandDock.test.mjs index 733c34425e..5f6d1bf2ab 100644 --- a/src/ui/commandDock.test.mjs +++ b/src/ui/commandDock.test.mjs @@ -8,7 +8,13 @@ import { createApp, h, nextTick } from 'vue'; import { setLocale } from '../i18n/index.js'; import { useDisplayStore } from './stores/display.js'; import { useLocationStore } from './stores/location.js'; +import { useOmnibarStore } from './stores/omnibar.js'; +import { useVoiceStore } from './stores/voice.js'; +import { useGlobeActionsStore } from './stores/globeActions.js'; import { LocationControls } from './locationControls.js'; +import { LocationSearch } from './locationSearch.js'; +import { LocationNavigation } from './locationNavigation.js'; +import { NavigationController } from './navigationController.js'; import { MOBILE_TABS, initMobileShell } from './mobileShell.js'; import CommandDockView from './views/CommandDockView.vue'; import SceneChromeView from './views/SceneChromeView.vue'; @@ -486,3 +492,1593 @@ test('the search toggle opens the field, and a lookup marks it', async (t) => { assert.equal(field.classList.contains('searching'), false); assert.equal(field.classList.contains('expanded'), false); }); + +function omnibarFixture(t, onSearch = () => {}) { + const mounted = fixture(t); + const { $, pinia } = mounted; + const location = useLocationStore(pinia); + const controls = new LocationControls({ + elements: { search: $('#location-search') }, + cities: {}, + getExpandedCity: () => null, + onCity() {}, + onPoi() {}, + onReset() {}, + onSearch: (query) => { + controls.setSearching(true); + return onSearch(query); + }, + onSearchEdit: () => controls.setSearchError(null), + publish: (view) => location.publish(view), + requestFrame() {}, + cancelFrame() {}, + }); + t.after(() => controls.destroy()); + location.connect(controls); + const mutations = []; + // Switching a layer changes its state, as the app's layers do. + const fixtureLayers = [ + { id: 'flights', name: 'Flights', enabled: false }, + { + id: 'scene-layer', + name: 'Scene Layer', + enabled: false, + showInTogglePanel: false, + }, + ]; + useOmnibarStore(pinia).connect({ + layers: () => fixtureLayers, + setLayer: (id, enabled) => { + mutations.push([id, enabled]); + const layer = fixtureLayers.find((each) => each.id === id); + if (layer) layer.enabled = enabled; + }, + }); + const voiceEvents = []; + useVoiceStore(pinia).connect({ emit: (...args) => voiceEvents.push(args) }); + const globeEvents = []; + useGlobeActionsStore(pinia).connect({ + northUp: () => globeEvents.push('northUp'), + }); + const input = $('#gev-omnibar-input'); + async function type(text) { + input.focus(); + input.value = text; + input.dispatchEvent(new Event('input', { bubbles: true })); + await nextTick(); + } + async function key(key, options = {}) { + input.dispatchEvent( + new KeyboardEvent('keydown', { key, bubbles: true, ...options }), + ); + await nextTick(); + } + function option(kind) { + return [ + ...document.querySelectorAll('#gev-omnibar-list [role="option"]'), + ].find((row) => + row.classList.contains(`omnibar-item--${kind.toLowerCase()}`), + ); + } + return { + ...mounted, + controls, + mutations, + voiceEvents, + globeEvents, + input, + type, + key, + option, + }; +} + +test('omnibar preserves ambiguous and disambiguated place queries, including IME input', async (t) => { + const searched = []; + const { type, key, mutations } = omnibarFixture(t, (query) => + searched.push(query), + ); + await type('Little Rock'); + await key('Enter', { isComposing: true }); + assert.deepEqual(searched, []); + await key('Enter'); + await type('Paris, Texas'); + await key('Enter'); + assert.deepEqual(searched, ['Little Rock', 'Paris, Texas']); + assert.deepEqual(mutations, []); +}); + +test('omnibar executes explicit commands and click selections, while guides and unknown commands do not mutate', async (t) => { + const { + $, + type, + key, + option, + mutations, + voiceEvents, + globeEvents, + pinia, + input, + } = omnibarFixture(t); + await type('> show flights'); + await key('Enter'); + await type('> hide flights'); + await key('Enter'); + assert.deepEqual(mutations, [ + ['flights', true], + ['flights', false], + ]); + await type('scene layer'); + assert.equal(option('Layer'), undefined); + assert.equal(option('Guide'), undefined); + await type('> show scene-layer'); + await key('Enter'); + assert.equal(mutations.length, 2); + await type('> not a command'); + await key('Enter'); + assert.deepEqual(voiceEvents, []); + await type('flights'); + const layer = option('Layer'); + layer.dispatchEvent(new Event('pointerdown', { bubbles: true })); + assert.equal( + mutations.length, + 2, + 'starting a touch scroll does not select a layer', + ); + layer.click(); + await nextTick(); + assert.deepEqual(mutations[2], ['flights', true]); + await type('how to see flights'); + option('Guide').click(); + await nextTick(); + assert.ok($('.gev-guide [role="dialog"]')); + $('.gev-guide-close').click(); + assert.deepEqual(globeEvents, []); + assert.equal(mutations.length, 3); + await type('> north up'); + for (const mode of ['scene-playback-mode', 'cockpit-mode']) { + document.body.classList.add(mode); + try { + const escape = new KeyboardEvent('keydown', { + key: 'Escape', + bubbles: true, + cancelable: true, + }); + input.dispatchEvent(escape); + assert.equal(escape.defaultPrevented, false); + await key('Enter'); + assert.deepEqual(globeEvents, []); + } finally { + document.body.classList.remove(mode); + } + } + await key('Enter'); + assert.deepEqual(globeEvents, ['northUp']); + let accepted = false; + useOmnibarStore(pinia).connect({ + layers: () => [{ id: 'flights', name: 'Flights', enabled: false }], + setLayer: () => accepted, + }); + await type('> show flights'); + await key('Enter'); + assert.ok($('#gev-omnibar [role="alert"]').textContent.trim()); + assert.equal(input.getAttribute('aria-expanded'), 'true'); + accepted = true; + await key('Enter'); + assert.equal($('#gev-omnibar [role="alert"]').textContent.trim(), ''); + assert.equal(input.getAttribute('aria-expanded'), 'false'); +}); + +test('omnibar uses the existing microphone and typed chat controls', async (t) => { + const { $, type, option, voiceEvents } = omnibarFixture(t); + await nextTick(); + $('#gev-omnibar button').click(); + await type('What is here?'); + option('Ask').click(); + await nextTick(); + assert.deepEqual(voiceEvents, [ + ['button'], + ['chat-restore'], + ['chat-prompt', 'What is here?'], + ['chat-submit'], + ]); +}); + +test('a replacement omnibar search keeps newer input and leaves the dock draft alone', async (t) => { + const pending = []; + const { $, type, key, input, option, mutations } = omnibarFixture( + t, + (query) => new Promise((resolve) => pending.push({ query, resolve })), + ); + $('#location-search').value = 'unfinished dock query'; + await type('Paris'); + await key('Enter'); + await type('Paris, Texas'); + await key('Enter'); + assert.deepEqual( + pending.map(({ query }) => query), + ['Paris', 'Paris, Texas'], + ); + pending[0].resolve(); + await nextTick(); + assert.equal(document.activeElement, input); + assert.equal(input.value, 'Paris, Texas'); + await type('flights'); + option('Layer').click(); + await nextTick(); + assert.deepEqual( + mutations, + [['flights', true]], + 'a pending place lookup does not block an explicit layer selection', + ); + pending[1].resolve(); + await nextTick(); + assert.equal($('#location-search').value, 'unfinished dock query'); +}); + +test('a superseded compound command does not run steps after its flight', async (t) => { + const { type, key, pinia, mutations, globeEvents } = omnibarFixture(t); + let finishFlight; + const calls = []; + useOmnibarStore(pinia).connectRunner((name) => { + calls.push(name); + return new Promise((resolve) => { + finishFlight = resolve; + }); + }); + + await type('go to Austin and show flights'); + await key('Enter'); + assert.deepEqual(calls, ['fly_to_location']); + await type('> north up'); + await key('Enter'); + assert.deepEqual(globeEvents, ['northUp']); + finishFlight({ ok: true }); + await nextTick(); + assert.deepEqual(mutations, []); +}); + +test('a cancelled flight stops the remaining steps in an omnibar command', async (t) => { + const { type, key, pinia, mutations } = omnibarFixture(t); + useOmnibarStore(pinia).connectRunner(async (name) => { + assert.equal(name, 'fly_to_location'); + return { ok: false, cancelled: true }; + }); + await type('go to Austin and show flights'); + await key('Enter'); + assert.deepEqual(mutations, []); +}); + +test('failed omnibar searches keep focus and clear their error on edit without changing the dock', async (t) => { + const { $, controls, input, type, key } = omnibarFixture(t, () => { + controls.setSearchError('No match'); + controls.settleSearch({ keepQuery: true }); + }); + $('#location-search').value = 'unfinished dock query'; + await type('missing place'); + const results = $('.omnibar-results'); + results.scrollTop = 20; + assert.equal(results.scrollTop, 20); + await key('Enter'); + assert.equal(document.activeElement, input); + assert.equal(results.scrollTop, 0); + assert.equal($('#location-search').value, 'unfinished dock query'); + assert.ok($('#gev-omnibar [role="alert"]')); + await type('corrected place'); + assert.equal($('#gev-omnibar [role="alert"]').textContent.trim(), ''); + await key('Escape'); + assert.equal(document.activeElement, input); + assert.equal(input.getAttribute('aria-expanded'), 'false'); +}); + +for (const firstOrigin of ['omnibar', 'dock']) { + test(`a pending ${firstOrigin} search yields to the other field without settling its draft`, async (t) => { + const requests = []; + let lookup; + const { $, controls, input, type, key } = omnibarFixture(t, (query) => + lookup.run(query), + ); + controls.onSearch = (query) => lookup.run(query); + const navigation = new NavigationController({ + viewer: {}, + tracking: { + flightsLayer: {}, + militaryFlightsLayer: {}, + satellitesLayer: {}, + }, + clearLocation() {}, + cancelShareSelection() {}, + getDataManager: () => null, + settleSearch: (options) => controls.settleSearch(options), + }); + const owner = { + _disposed: false, + get _activeLocationSearchGeneration() { + return navigation._activeLocationSearchGeneration; + }, + set _activeLocationSearchGeneration(value) { + navigation._activeLocationSearchGeneration = value; + }, + _locationControls: controls, + _setLocationSearchError: + LocationNavigation.prototype._setLocationSearchError, + _settleLocationSearchUi: + navigation._settleLocationSearchUi.bind(navigation), + }; + lookup = new LocationSearch({ + input: $('#location-search'), + begin: () => navigation._stampNavigation(), + isCurrent: (generation) => + generation === navigation._navigationGeneration, + setSearching: (value) => controls.setSearching(value), + search: (query, options) => + new Promise((resolve, reject) => + requests.push({ query, options, resolve, reject }), + ), + }); + lookup.subscribe(({ state, change }) => + LocationNavigation.prototype._handleLocationSearchState.call( + owner, + state, + change, + ), + ); + t.after(() => lookup.destroy()); + const dock = $('#location-search'); + async function submit(origin, text) { + if (origin === 'omnibar') { + await type(text); + await key('Enter'); + } else { + dock.value = text; + dock.focus(); + dock.dispatchEvent( + new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }), + ); + await nextTick(); + } + } + const lastOrigin = firstOrigin === 'omnibar' ? 'dock' : 'omnibar'; + await submit(firstOrigin, 'Old place'); + if (firstOrigin === 'omnibar') { + await submit('dock', ' '); + assert.equal(requests.length, 1); + assert.equal(controls.searchOrigin, 'omnibar'); + assert.equal(requests[0].options.signal.aborted, false); + } + await submit(lastOrigin, 'New place'); + assert.deepEqual( + requests.map(({ query }) => query), + ['Old place', 'New place'], + ); + assert.equal(requests[0].options.signal.aborted, true); + const latestInput = lastOrigin === 'dock' ? dock : input; + assert.equal(latestInput.value, 'New place'); + assert.equal(document.activeElement, latestInput); + requests[0].reject(new Error('obsolete provider failure')); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.equal(controls.searching, true); + assert.equal(controls.searchError, null); + assert.equal(latestInput.value, 'New place'); + assert.equal(document.activeElement, latestInput); + requests[1].resolve(null); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.equal(controls.searching, false); + assert.equal(controls.searchOrigin, lastOrigin); + assert.equal(latestInput.value, 'New place'); + assert.equal(document.activeElement, latestInput); + const omnibarError = $('#gev-omnibar [role="alert"]').textContent.trim(); + const dockError = $('#location-search-error').textContent.trim(); + assert.equal(Boolean(omnibarError), lastOrigin === 'omnibar'); + assert.equal(Boolean(dockError), lastOrigin === 'dock'); + }); +} + +/** The suggestion rows as `kind: label`, top first. */ +function omnibarRows() { + return [...document.querySelectorAll('#gev-omnibar-list .omnibar-item')].map( + (row) => + `${[...row.classList].find((name) => name.startsWith('omnibar-item--')).slice(14)}: ${row.querySelector('.omnibar-item-label').textContent.trim()}`, + ); +} + +test('a command leads only on its exact name, and never the mic or cockpit', async (t) => { + const { type, input } = omnibarFixture(t); + const first = () => omnibarRows()[0]; + const activeRow = () => + document.getElementById(input.getAttribute('aria-activedescendant')); + for (const text of ['Voi', 'mic', 'Fly', 'Pilot']) { + await type(text); + assert.match(first(), /^place: /, `${text}: ${omnibarRows().join(' | ')}`); + assert.ok( + !activeRow().classList.contains('omnibar-item--mic'), + `${text} must not default to the microphone`, + ); + assert.doesNotMatch(activeRow().textContent, /cockpit/i, text); + } + // Still offered, after the first row. + await type('mic'); + assert.ok(omnibarRows().includes('mic: Talk to GEV')); + await type('Fly'); + assert.ok(omnibarRows().includes('plan: Enter cockpit')); + // A search word alone only finds its command, after the first row. + await type('Globe'); + assert.equal(first(), 'place: Go to Globe'); + assert.ok(omnibarRows().includes('plan: Globe view')); + // "Home" reads as Reset view, a whole-view change, so it is no default. + await type('Home'); + assert.equal(first(), 'plan: Reset view'); + assert.equal(input.getAttribute('aria-activedescendant'), null); + // A general word is no command name: Enter on it clears nothing. + await type('everything'); + assert.notEqual(first(), 'plan: Clear all layers'); +}); + +test('an empty field has no default row, so a bare Enter asks nothing', async (t) => { + const { type, key, input, voiceEvents, option } = omnibarFixture(t); + await type(''); + assert.ok(option('view-ask'), 'the empty field still offers What’s here?'); + assert.equal(input.getAttribute('aria-activedescendant'), null); + await key('Enter'); + assert.deepEqual(voiceEvents, []); + await key('ArrowDown'); + assert.equal( + input.getAttribute('aria-activedescendant'), + 'gev-omnibar-item-0', + ); +}); + +test('short place names that start like questions keep a place row first', async (t) => { + const { type } = omnibarFixture(t); + for (const text of ['Can Tho', 'Tell City']) { + await type(text); + const rows = omnibarRows(); + assert.equal(rows[0], `place: Go to ${text}`, rows.join(' | ')); + assert.ok( + rows.indexOf(`place: Go to ${text}`) < + rows.findIndex((row) => row.startsWith('ask:')), + ); + } + await type('Can Tho?'); + assert.match(omnibarRows()[0], /^ask: /); +}); + +test('near-miss lines in the field: clears, turning off, and a place named like a verb', async (t) => { + const searched = []; + const { type, key } = omnibarFixture(t, (query) => searched.push(query)); + await type('hide everything'); + assert.equal(omnibarRows()[0], 'plan: Clear all layers'); + await type('remove everything'); + assert.equal(omnibarRows()[0], 'plan: Clear all layers'); + await type('How do I turn off flights'); + // Flights is off already: its row offers nothing to switch. + assert.ok( + [ + ...document.querySelectorAll( + '#gev-omnibar-list .omnibar-item--layer small', + ), + ].some((hint) => hint.textContent === 'Layer'), + omnibarRows().join(' | '), + ); + await type('Show Low, AZ'); + assert.equal(omnibarRows()[0], 'place: Go to Show Low, AZ'); + await key('Enter'); + assert.deepEqual(searched, ['Show Low, AZ']); +}); + +test('Escape while a plan waits on its flight leaves the layers alone', async (t) => { + const { type, key, pinia, mutations, input } = omnibarFixture(t); + let finishFlight; + useOmnibarStore(pinia).connectRunner( + () => + new Promise((resolve) => { + finishFlight = resolve; + }), + ); + await type('go to Austin and show flights'); + await key('Enter'); + assert.equal(input.getAttribute('aria-busy'), 'true'); + await key('Escape'); + assert.equal(input.getAttribute('aria-busy'), 'false'); + finishFlight({ ok: true }); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(mutations, []); +}); + +test('a plan step that fails stops the plan and shows the error', async (t) => { + const { $, type, key, pinia, mutations } = omnibarFixture(t); + const calls = []; + useOmnibarStore(pinia).connectRunner(async (name) => { + calls.push(name); + return name === 'fly_to_location' + ? { ok: false, error: 'no route' } + : { ok: true }; + }); + await type('go to Austin and show flights'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(calls, ['fly_to_location']); + assert.deepEqual(mutations, []); + assert.ok($('#gev-omnibar [role="alert"]').textContent.trim()); + + // A layer the shell refuses is an error too. + useOmnibarStore(pinia).connect({ + layers: () => [{ id: 'flights', name: 'Flights', enabled: false }], + setLayer: () => false, + }); + useOmnibarStore(pinia).connectRunner(async () => ({ ok: true })); + await type('show flights near tokyo'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.ok($('#gev-omnibar [role="alert"]').textContent.trim()); +}); + +test('radio off in a plan flies there first and turns the radio off', async (t) => { + const { type, key, pinia } = omnibarFixture(t); + const calls = []; + useOmnibarStore(pinia).connectRunner(async (name, args) => { + calls.push([name, args]); + return { ok: true }; + }); + await type('tokyo and turn off the radio'); + assert.equal(omnibarRows()[0], 'plan: Tokyo · Radio off'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(calls, [ + ['fly_to_location', { query: 'tokyo', waitForArrival: true }], + ['control_radio', { action: 'disable' }], + ]); +}); + +test('the field states what it controls and the mic its state', async (t) => { + const { $, type, input } = omnibarFixture(t); + input.blur(); + await nextTick(); + assert.equal(input.getAttribute('aria-controls'), null); + await type('flights'); + assert.equal(input.getAttribute('aria-controls'), 'gev-omnibar-list'); + assert.ok($('#gev-omnibar-list')); + const mic = $('.omnibar-mic'); + // Off until a voice session is in voice mode. + assert.equal(mic.getAttribute('aria-pressed'), 'false'); +}); + +test('the guide is a non-modal dialog that takes focus and only Escape', async (t) => { + const { $, type, option } = omnibarFixture(t); + await type('how to see flights'); + option('Guide').click(); + await nextTick(); + await nextTick(); + const dialog = $('.gev-guide [role="dialog"]'); + assert.equal(dialog.getAttribute('aria-modal'), 'false'); + // Steps are announced from a status line, not the whole dialog. + assert.equal(dialog.getAttribute('aria-live'), null); + assert.equal($('.gev-guide-status').getAttribute('role'), 'status'); + assert.equal(document.activeElement, dialog); + const other = new KeyboardEvent('keydown', { + key: 'a', + bubbles: true, + cancelable: true, + }); + document.dispatchEvent(other); + assert.equal(other.defaultPrevented, false); + assert.ok($('.gev-guide'), 'another key leaves the guide open'); + const escape = new KeyboardEvent('keydown', { + key: 'Escape', + bubbles: true, + cancelable: true, + }); + document.dispatchEvent(escape); + assert.equal(escape.defaultPrevented, true); + assert.equal($('.gev-guide'), null); +}); + +test('a bare ">" picks nothing, and whole-map commands need their name', async (t) => { + const { type, key, pinia, input, mutations } = omnibarFixture(t); + const acted = []; + useGlobeActionsStore(pinia).connect({ + clear: () => acted.push('clear'), + reset: () => acted.push('reset'), + northUp: () => acted.push('northUp'), + }); + for (const text of ['>', '> ', '> cl', '> clear']) { + await type(text); + assert.ok(omnibarRows().length, text); + assert.equal(input.getAttribute('aria-activedescendant'), null, text); + await key('Enter'); + } + assert.deepEqual(acted, []); + assert.deepEqual(mutations, []); + // Its exact name makes it the default. + await type('> Clear all layers'); + assert.equal( + input.getAttribute('aria-activedescendant'), + 'gev-omnibar-item-0', + ); + await key('Enter'); + assert.deepEqual(acted, ['clear']); + // A harmless command still leads on its name. + await type('> North up'); + await key('Enter'); + assert.deepEqual(acted, ['clear', 'northUp']); +}); + +test('place names holding a command word go to the place on Enter', async (t) => { + const searched = []; + const { type, key, input, pinia } = omnibarFixture(t, (query) => + searched.push(query), + ); + useOmnibarStore(pinia).connect({ + layers: () => [ + { id: 'flights', name: 'Flights', enabled: false }, + { id: 'rocket-launches', name: 'Rocket launches', enabled: false }, + { id: 'earthquakes', name: 'Earthquakes', enabled: false }, + { id: 'radio', name: 'Radio', enabled: false }, + ], + setLayer: () => {}, + }); + const activeRow = () => + document.getElementById(input.getAttribute('aria-activedescendant')); + for (const text of [ + 'Cockpit Country, Jamaica', + 'Radio City Music Hall', + 'Radio Free Europe', + 'Thermal, California', + 'Tilt Cove', + 'Hud Valley', + 'Rock and Roll Hall of Fame', + 'cockpit', + 'cockpit view', + ]) { + await type(text); + assert.match( + omnibarRows()[0], + /^place: Go to /, + `${text}: ${omnibarRows().join(' | ')}`, + ); + assert.ok(activeRow().classList.contains('omnibar-item--place'), text); + await key('Enter'); + assert.equal(searched.at(-1), text); + } + // The plan is still offered, second. + await type('Thermal, California'); + assert.equal(omnibarRows()[1], 'plan: California · Style: Thermal'); + // A word alone is no action default. + for (const text of ['music', 'link', 'heat', 'green', 'rotate', 'missions']) { + await type(text); + assert.ok( + !/^(plan|mic): /.test( + activeRow()?.classList.contains('omnibar-item--place') + ? '' + : omnibarRows()[0], + ), + `${text}: ${omnibarRows().join(' | ')}`, + ); + assert.ok(activeRow()?.classList.contains('omnibar-item--place'), text); + } + // "earth" offers the globe view before the earthquakes layer. + await type('earth'); + const rows = omnibarRows(); + const globe = rows.indexOf('plan: Globe view'); + assert.ok(globe > 0, rows.join(' | ')); + const quakes = rows.findIndex((row) => row.startsWith('layer: Earthquakes')); + assert.ok(quakes === -1 || globe < quakes, rows.join(' | ')); +}); + +test('several places and a magnitude floor in one line', async (t) => { + const { type, pinia } = omnibarFixture(t); + useOmnibarStore(pinia).connect({ + layers: () => [ + { id: 'flights', name: 'Flights', enabled: false }, + { id: 'earthquakes', name: 'Earthquakes', enabled: false }, + ], + setLayer: () => {}, + }); + await type('flights near New York and Paris'); + const rows = omnibarRows(); + assert.match(rows[0], /^plan: New York · /); + assert.ok(rows.includes('place: Go to Paris'), rows.join(' | ')); + await type('show me earthquakes above m5 in japan'); + assert.ok( + omnibarRows().includes('place: Go to Japan'), + omnibarRows().join(' | '), + ); +}); + +test('a refusal shows the action’s own short reason', async (t) => { + const { $, type, key, pinia } = omnibarFixture(t); + useOmnibarStore(pinia).connectRunner(async () => ({ + ok: false, + error: 'internal: no such entity', + say: 'I could not find that flight.', + })); + await type('follow ual123'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + const alert = $('#gev-omnibar [role="alert"]').textContent; + assert.match(alert, /I could not find that flight\./); + assert.doesNotMatch(alert, /internal/); +}); + +test('a plan whose flight does not land stops before its layers', async (t) => { + const { type, key, pinia, mutations } = omnibarFixture(t); + // A location search that was superseded answers neither true nor found. + useLocationStore(pinia).controls.search = async () => ({ cancelled: true }); + await type('go to Austin and show flights'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(mutations, []); +}); + +test('pressing the mic stops a plan still waiting on its flight', async (t) => { + const { type, key, pinia, mutations, voiceEvents, $ } = omnibarFixture(t); + let land; + useOmnibarStore(pinia).connectRunner((name) => + name === 'fly_to_location' + ? new Promise((resolve) => { + land = () => resolve({ ok: true }); + }) + : { ok: true }, + ); + await type('go to Austin and show flights'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + $('#gev-omnibar .omnibar-mic').click(); + assert.deepEqual(voiceEvents.at(-1), ['button']); + land(); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(mutations, []); +}); + +test('"how to measure distance" walks to Draw in Utilities', async (t) => { + const { type, key, $ } = omnibarFixture(t); + const rail = document.body.appendChild(document.createElement('div')); + rail.className = 'ui-rail--left'; + const utilities = rail.appendChild(document.createElement('button')); + utilities.className = 'ui-rail__item'; + utilities.dataset.railItem = 'utilities-panel'; + utilities.setAttribute('aria-pressed', 'true'); + const draw = document.body.appendChild(document.createElement('button')); + draw.id = 'draw-toggle'; + t.after(() => { + rail.remove(); + draw.remove(); + $('.gev-guide-close')?.click(); + }); + await type('how to measure distance'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + await nextTick(); + assert.match( + $('.gev-guide [role="dialog"]').textContent, + /Press Draw to start drawing on the map/, + ); +}); + +test('the field keeps focus after a command, a plan or a layer runs', async (t) => { + const { type, key, input } = recordingOmnibar(t, ['cctv']); + input.focus(); + for (const text of ['> North up', 'North up', 'show flights', 'noir']) { + await type(text); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + await nextTick(); + assert.equal(document.activeElement, input, text); + assert.equal(input.value, '', text); + } +}); + +test('a tapped or clicked row lets go of the field', async (t) => { + const { type, input } = recordingOmnibar(t); + input.focus(); + await type('North up'); + document.querySelector('#gev-omnibar-list .omnibar-item').click(); + await new Promise((resolve) => setTimeout(resolve, 0)); + await nextTick(); + assert.notEqual(document.activeElement, input); +}); + +test('while drawing, Enter leaves the keys to the draw tool', async (t) => { + const { type, key, input, pinia } = recordingOmnibar(t); + useDisplayStore(pinia).publishDraw({ active: true, shape: 'line' }); + input.focus(); + await type('North up'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + await nextTick(); + assert.notEqual(document.activeElement, input); +}); + +test("on the phone, the keyboard's Go key lets go of the field too", async (t) => { + const { type, key, input } = recordingOmnibar(t); + document.body.classList.add('mobile-shell'); + t.after(() => document.body.classList.remove('mobile-shell')); + input.focus(); + await type('North up'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + await nextTick(); + assert.notEqual(document.activeElement, input); +}); + +test('Escape closes the list, then lets go of the empty field', async (t) => { + const { key, input } = recordingOmnibar(t); + input.focus(); + await key('Escape'); + assert.equal(document.activeElement, input); + await key('Escape'); + assert.notEqual(document.activeElement, input); +}); + +test('asking GEV hands the keyboard to the chat', async (t) => { + const { type, key, input } = recordingOmnibar(t); + input.focus(); + await type('how far is paris'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.notEqual(document.activeElement, input); +}); + +test('text withheld as private says so', async (t) => { + const { type } = recordingOmnibar(t); + const note = () => + [...document.querySelectorAll('#gev-omnibar [role="status"]')].find( + (element) => /Looks private/.test(element.textContent), + ); + await type('4111 1111 1111 1111'); + assert.notEqual(note().style.display, 'none'); + await type('Tokyo'); + assert.equal(note().style.display, 'none'); +}); + +test('a panel with no rail button fails rather than passing for done', async (t) => { + const { enter, $ } = recordingOmnibar(t); + await enter('Open Utilities'); + assert.match( + $('#gev-omnibar [role="alert"]').textContent, + /Unable to complete this action/, + ); +}); + +test('outside English a refusal shows the translated message alone', async (t) => { + t.after(() => setLocale('en')); + setLocale('de'); + const { type, key, pinia, $ } = omnibarFixture(t); + useOmnibarStore(pinia).connectRunner(async () => ({ + ok: false, + say: 'I could not find that flight.', + })); + await type('follow ual123'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + const alert = $('#gev-omnibar [role="alert"]').textContent; + assert.ok(alert.trim()); + assert.doesNotMatch(alert, /could not find/); +}); + +test('a recent place that came from Photon shows the OpenStreetMap credit', async (t) => { + const store = globalThis.localStorage; + store.setItem( + 'gev:omnibar:recent-places', + JSON.stringify([ + { + name: 'Shibuya Crossing', + latitude: 35.6595, + longitude: 139.7005, + source: 'photon', + }, + ]), + ); + t.after(() => store.removeItem('gev:omnibar:recent-places')); + stubPhoton(t); + const { type, credits } = recordingOmnibar(t); + await type('Tokyo'); + assert.ok( + [...document.querySelectorAll('.omnibar-strip__chip')].some((chip) => + chip.textContent.includes('Shibuya Crossing'), + ), + ); + assert.equal(credits.at(-1), true); +}); + +/** The fixture with a recording runner and globe actions, as the shell has. */ +function recordingOmnibar( + t, + layers = [], + { acts: actNames = ['clear', 'reset', 'share', 'northUp', 'tilt'] } = {}, +) { + const searched = []; + const fixture = omnibarFixture(t, (query) => searched.push(query)); + const calls = []; + const acted = []; + const switched = []; + const credits = []; + // One list, so a test can change a layer's live state. + const layerList = [ + { id: 'flights', name: 'Flights', enabled: false }, + ...layers.map((id) => ({ + id, + name: id.replace(/-/g, ' '), + enabled: false, + })), + ]; + useOmnibarStore(fixture.pinia).connect({ + layers: () => layerList, + setLayer: (...args) => switched.push(args), + creditSuggestions: (shown) => credits.push(shown), + }); + useOmnibarStore(fixture.pinia).connectRunner(async (name, args) => { + calls.push([name, args]); + return { ok: true }; + }); + const acts = {}; + for (const act of actNames) acts[act] = () => acted.push(act); + useGlobeActionsStore(fixture.pinia).connect(acts); + async function enter(text) { + await fixture.type(text); + await fixture.key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + await nextTick(); + } + return { + ...fixture, + searched, + calls, + acted, + switched, + credits, + layerList, + enter, + }; +} + +test('the radio and sharing are never Enter defaults unless named in full', async (t) => { + const { enter, calls, acted, input, type, switched } = recordingOmnibar(t, [ + 'radio', + ]); + for (const text of [ + 'radio', + 'Radio', + '> radio', + 'share', + 'Share', + 'copy map', + ]) { + await enter(text); + assert.deepEqual(calls, [], text); + assert.deepEqual(acted, [], text); + } + await type('radio'); + // Not asked outright: the place row leads, the Radio layer follows. + assert.deepEqual(omnibarRows().slice(0, 2), [ + 'place: Go to Radio', + 'layer: Radio', + ]); + assert.equal( + input.getAttribute('aria-activedescendant'), + 'gev-omnibar-item-0', + ); + // The Radio layer plays sound too: a verb turns it on, its name alone not. + assert.deepEqual(switched, []); + await enter('turn on radio'); + assert.deepEqual(switched, [['radio', true]]); + await enter('Share this view'); + assert.deepEqual(acted, ['share']); + // Its full name runs the command where no Radio layer answers it first. + await enter('Enable Radio'); + assert.deepEqual(switched.at(-1), ['radio', true]); + assert.deepEqual(calls, []); +}); + +test('the radio command runs on its full name', async (t) => { + const { enter, calls } = recordingOmnibar(t); + await enter('radio'); + assert.deepEqual(calls, []); + await enter('Enable Radio'); + assert.deepEqual(calls, [['control_radio', { action: 'enable' }]]); +}); + +test('"go to" takes the rest of its clause as the place, keywords and all', async (t) => { + const { enter, calls, acted, switched, searched } = recordingOmnibar(t); + for (const [text, place] of [ + ['go to cockpit country', 'cockpit country'], + ['go to Thermal, California', 'Thermal, California'], + ['fly to Tilt Cove', 'Tilt Cove'], + ['go to Night Vision Way', 'Night Vision Way'], + ['go to Whole Earth Provision', 'Whole Earth Provision'], + ]) { + await enter(text); + // A place alone goes through the place search, with nothing else run. + assert.equal(searched.at(-1), place, text); + assert.deepEqual(calls, [], text); + } + assert.deepEqual(acted, []); + assert.deepEqual(switched, []); + calls.length = 0; + await enter('go to Austin and show flights'); + assert.deepEqual( + calls.map(([name]) => name), + ['fly_to_location'], + ); + assert.deepEqual(switched, [['flights', true]]); +}); + +test('a radio verb must apply to the radio', async (t) => { + const { enter, calls } = recordingOmnibar(t); + await enter('play radio in Kill Devil Hills'); + assert.deepEqual(calls, [ + ['control_radio', { action: 'enable', locationQuery: 'kill devil hills' }], + ]); +}); + +test('Ask GEV is no default for a word or two, and CJK names are places from two characters', async (t) => { + const { enter, voiceEvents, searched, input, type } = recordingOmnibar(t); + // Two letters are too few for a place or a question; "help" may be a + // place, so it searches rather than asking. + for (const text of ['NY', 'Uk', 'hi']) { + await type(text); + assert.equal(input.getAttribute('aria-activedescendant'), null, text); + await enter(text); + } + await enter('help'); + assert.deepEqual(voiceEvents, []); + assert.deepEqual(searched.splice(0), ['help']); + for (const text of ['東京', '北京', '서울']) { + await type(text); + assert.equal(omnibarRows()[0], `place: Go to ${text}`, text); + await enter(text); + } + assert.deepEqual(searched, ['東京', '北京', '서울']); + await enter('what is here?'); + assert.deepEqual(voiceEvents.at(-1), ['chat-submit']); +}); + +test('the place service is asked about whole names, never about callsigns', async (t) => { + const asked = []; + const realFetch = globalThis.fetch; + globalThis.fetch = async (url) => { + asked.push(new URL(String(url)).searchParams.get('q')); + return Response.json({ features: [] }); + }; + t.after(() => { + globalThis.fetch = realFetch; + }); + const { type } = recordingOmnibar(t, ['traffic']); + const settle = () => new Promise((resolve) => setTimeout(resolve, 800)); + for (const text of ['UAL2110', 'N123AB', 'BAW15K']) { + await type(text); + await settle(); + } + assert.deepEqual(asked, []); + for (const text of ['Tokyo traffic', 'Home, Washington', '東京']) { + await type(text); + await settle(); + } + assert.deepEqual(asked, ['Tokyo traffic', 'Home, Washington', '東京']); +}); + +test('the search shortcut leaves an open dialog its focus', async (t) => { + const { input } = recordingOmnibar(t); + const dialog = document.body.appendChild(document.createElement('div')); + dialog.setAttribute('role', 'dialog'); + dialog.setAttribute('aria-modal', 'true'); + const button = dialog.appendChild(document.createElement('button')); + button.focus(); + document.dispatchEvent( + new KeyboardEvent('keydown', { key: '/', bubbles: true, cancelable: true }), + ); + assert.notEqual(document.activeElement, input); + dialog.remove(); + button.blur(); + document.dispatchEvent( + new KeyboardEvent('keydown', { key: '/', bubbles: true, cancelable: true }), + ); + assert.equal(document.activeElement, input); +}); + +// ── Enter-safety table ───────────────────────────────────────────────── +// Every line below is typed into the mounted Omnibar and Enter pressed with +// no row chosen; the table says exactly what runs. See src/ui/omnibarEnter.js +// and the Omnibar section of docs/CURRENT-STATE.md for the rule. +// `search(q)` is the place search, `fly(q)` a plan's flight, `nothing` +// means Enter ran nothing at all. +const ENTER_TABLE = [ + // A switch after its subject, a closing full stop, "please", + // names that look like questions, words about a layer. + ['noir off', 'style(normal)'], + ['turn off noir', 'style(normal)'], + ['Show flights.', 'layer(flights,on)'], + ['please show flights', 'layer(flights,on)'], + ['North up.', 'globe(northUp)'], + ['Do it Best Hardware', 'search(Do it Best Hardware)'], + ['Can You Imagine', 'search(Can You Imagine)'], + ['Show radio stations', 'layer(radio,on)'], + ['I went to the store yesterday and it was really great', 'nothing'], + ['123 45 6789', 'nothing'], + ['hunter22', 'nothing'], + // A layer is asked for only by a switch right before its word. + ['Kill Devil Hills radio', 'search(Kill Devil Hills radio)'], + ['Show Low radio', 'search(Show Low radio)'], + ['show low radio', 'search(show low radio)'], + ['Show Low noir', 'search(Show Low noir)'], + ['See radio', 'search(See radio)'], + ['PIN code 1234', 'nothing'], + ['my bank pin is 1234', 'nothing'], + ['123-45-6789', 'nothing'], + ['pw hunter2', 'nothing'], + ['Bearer abcdef', 'nothing'], + // Verbs in any letter case. + ['Turn on the radio', 'layer(radio,on)'], + ['Turn On Radio', 'layer(radio,on)'], + ['Draw', 'open(utilities)'], + // A bundled place's name that is also a command or layer word. + ['Thermal', 'search(Thermal)'], + ['Normal', 'search(Normal)'], + ['Hurricane', 'search(Hurricane)'], + ['Ski', 'search(Ski)'], + ['Street', 'search(Street)'], + ['Bike', 'search(Bike)'], + ['Rain', 'search(Rain)'], + // A question's form alone asks nothing. + ['Is there', 'search(Is there)'], + ['Can I', 'search(Can I)'], + ['Do it', 'search(Do it)'], + ['what is', 'search(what is)'], + ['how to', 'search(how to)'], + ['Who is it', 'search(Who is it)'], + ['N Y?', 'nothing'], + ['how far is paris', 'ask(how far is paris)'], + ['東京はどこ?', 'ask(東京はどこ?)'], + ['وين القاهرة؟', 'ask(وين القاهرة؟)'], + ['what cheer', 'search(what cheer)'], + ['List', 'search(List)'], + ['Describe', 'search(Describe)'], + // Verbs are read per clause, never inside a place's name. + ['radio near Clear Lake', 'search(clear lake)'], + ['radio in Show Low', 'search(show low)'], + ['Clear Lake radio', 'search(Clear Lake radio)'], + ['radio near Race Track', 'search(race track)'], + ['radio near Zoom Hill', 'search(zoom hill)'], + ['radio near Stop, Arkansas', 'search(stop, arkansas)'], + ['radio near Mute', 'search(mute)'], + ['turn radio on', 'radio(enable)'], + ['start radio', 'radio(enable)'], + ['toggle radio', 'layer(radio,on)'], + ['Track Hill', 'search(Track Hill)'], + // A question mark alone is no question; names that start like one are places. + ['?', 'nothing'], + ['??', 'nothing'], + ['what?', 'nothing'], + ['Why?', 'nothing'], + ['who?', 'nothing'], + ['Can Tho City', 'search(Can Tho City)'], + ['Can Gio District', 'search(Can Gio District)'], + ['Is Kinabalu Park', 'search(Is Kinabalu Park)'], + // A bare switch verb only lists what it could switch. + ['hide', 'nothing'], + ['remove', 'nothing'], + ['disable', 'nothing'], + ['turn off', 'nothing'], + ['switch off', 'nothing'], + ['clear everything', 'globe(clear)'], + ['hide everything near tokyo', 'fly(tokyo) + globe(clear)'], + ['hide everything in tokyo', 'fly(tokyo) + globe(clear)'], + // Private text gets no rows and no search. + ['4111 1111 1111 1111', 'nothing'], + ['+1 (415) 555-0100', 'nothing'], + ['SSN 123-45-6789', 'nothing'], + ['GB29 NWBK 6016 1331 9268 19', 'nothing'], + ['sk_live_51Habcdef', 'nothing'], + ['pk_live_abc', 'nothing'], + ['password hunter2', 'nothing'], + ['me@example.com', 'nothing'], + ['>', 'nothing'], + ['> ', 'nothing'], + ['a', 'nothing'], + ['ny', 'nothing'], + ['Uk', 'nothing'], + ['hi', 'nothing'], + ['help', 'search(help)'], + ['Is', 'nothing'], + ['why', 'search(why)'], + ['how', 'search(how)'], + ['what', 'search(what)'], + ['who', 'search(who)'], + ['where', 'search(where)'], + ['explain', 'search(explain)'], + ['summarize', 'search(summarize)'], + ['Why, Arizona', 'search(Why, Arizona)'], + ['What Cheer', 'search(What Cheer)'], + ['What Cheer, Iowa', 'search(What Cheer, Iowa)'], + ['Tell City', 'search(Tell City)'], + ['Tell City, Indiana', 'search(Tell City, Indiana)'], + ['Can Tho', 'search(Can Tho)'], + ['Can Tho, Vietnam', 'search(Can Tho, Vietnam)'], + ['what is here', 'ask(what is here)'], + ['how far is tokyo', 'ask(how far is tokyo)'], + // An auxiliary's question without "?" offers GEV but runs nothing. + ['is it raining in tokyo', 'nothing'], + ['is it raining in tokyo?', 'ask(is it raining in tokyo?)'], + ['where is tokyo?', 'ask(where is tokyo?)'], + ['radio', 'search(radio)'], + ['> radio', 'nothing'], + ['radio near tokyo', 'search(tokyo)'], + ['Radio, Tokyo', 'search(Radio, Tokyo)'], + ['radio in Kill Devil Hills', 'search(kill devil hills)'], + ['play radio in Tokyo', 'radio(enable@tokyo)'], + ['turn on radio', 'layer(radio,on)'], + ['radio on', 'radio(enable)'], + ['Enable Radio', 'layer(radio,on)'], + ['Radio City Music Hall', 'search(Radio City Music Hall)'], + ['share', 'nothing'], + ['copy map', 'nothing'], + ['Share this view', 'globe(share)'], + ['home', 'nothing'], + ['start over', 'nothing'], + ['Reset view', 'globe(reset)'], + ['globe', 'search(globe)'], + ['Globe view', 'zoom_to_globe'], + ['clear', 'search(clear)'], + ['clear map', 'globe(clear)'], + ['hide everything', 'globe(clear)'], + ['Clear all layers', 'globe(clear)'], + ['> Clear all layers', 'globe(clear)'], + ['> cl', 'nothing'], + ['close all panels', 'close(left) + close(right)'], + ['Close left panel', 'close(left)'], + ['cockpit', 'search(cockpit)'], + ['Cockpit Country', 'search(Cockpit Country)'], + ['enter cockpit', 'control_cockpit'], + ['mic', 'search(mic)'], + ['Talk to GEV', 'mic'], + ['display', 'nothing'], + ['turn on', 'nothing'], + ['flights', 'layer(flights,on)'], + ['show flights', 'layer(flights,on)'], + ['earthquakes', 'layer(earthquakes,on)'], + ['Hurricane, Utah', 'search(Hurricane, Utah)'], + ['Thermal, California', 'search(Thermal, California)'], + ['Tilt Cove', 'search(Tilt Cove)'], + ['Satellite Beach', 'search(Satellite Beach)'], + ['tokyo traffic', 'search(tokyo traffic)'], + ['go to tokyo in noir', 'search(tokyo)'], + ['go to tokyo, noir', 'search(tokyo)'], + ['go to Tokyo, north up', 'search(tokyo)'], + ['take me to Austin in thermal', 'search(austin)'], + ['go to London with flights', 'search(london)'], + ['go to tokyo show flights', 'search(tokyo)'], + ['go to Thermal, California', 'search(Thermal, California)'], + ['fly to Tilt Cove', 'search(Tilt Cove)'], + ['go to Night Vision Way', 'search(Night Vision Way)'], + ['go to cockpit country', 'search(cockpit country)'], + ['go to Whole Earth Provision', 'search(Whole Earth Provision)'], + ['go to Austin and show flights', 'fly(austin) + layer(flights,on)'], + [ + 'go to Austin and show flights in noir', + 'fly(austin) + style(noir) + layer(flights,on)', + ], + ['show flights near Tokyo', 'fly(tokyo) + layer(flights,on)'], + ['flights near tokyo', 'fly(tokyo) + layer(flights,on)'], + ['earthquakes above m5 in japan', 'fly(japan) + layer(earthquakes,on)'], + ['go to Paris, Texas and noir', 'fly(paris, texas) + style(noir)'], + ['go to tokyo and follow UAL123', 'fly(tokyo) + follow(ual123)'], + // Keywords without a verb ask for nothing, however many clauses: the + // place after "near" is searched and the plan offered. + ['noir and cctv near austin, north up', 'search(austin)'], + [ + 'show noir and show cctv near austin, face north', + 'fly(austin) + style(noir) + layer(cctv,on) + globe(northUp)', + ], + ['noir', 'style(noir)'], + ['North up', 'globe(northUp)'], + ['> North up', 'globe(northUp)'], + ['zoom in', 'adjust_camera_zoom'], + ['orbit', 'move_camera'], + ['follow UAL123', 'follow(ual123)'], + ['nearest plane to heathrow', 'select_nearest_aircraft'], + ['東京', 'search(東京)'], + ['Show Low, AZ', 'search(Show Low, AZ)'], + ['Paris, Texas', 'search(Paris, Texas)'], +]; + +async function enterOutcome(t, text, { hover = false } = {}) { + const realFetch = globalThis.fetch; + globalThis.fetch = async () => Response.json({ features: [] }); + t.after(() => { + globalThis.fetch = realFetch; + }); + const m = recordingOmnibar(t, [ + 'earthquakes', + 'cctv', + 'radio', + 'traffic', + 'weather-cyclones', + 'ski-pistes', + 'bikeshare', + 'weather-radar', + ]); + // Open side panels whose rail buttons record a close. + const closed = []; + const opened = []; + for (const side of ['left', 'right']) { + const rail = document.body.appendChild(document.createElement('div')); + rail.className = `ui-rail--${side}`; + const button = rail.appendChild(document.createElement('button')); + button.className = 'ui-rail__item'; + button.setAttribute('aria-pressed', 'true'); + button.dataset.railItem = `${side}-panel`; + button.addEventListener('click', () => closed.push(side)); + } + // Utilities, closed, for "open draw options". + const utilities = document + .querySelector('.ui-rail--left') + .appendChild(document.createElement('button')); + utilities.className = 'ui-rail__item'; + utilities.setAttribute('aria-pressed', 'false'); + utilities.dataset.railItem = 'utilities-panel'; + utilities.addEventListener('click', () => opened.push('utilities')); + await m.type(text); + if (hover) { + const rows = [ + ...document.querySelectorAll('#gev-omnibar-list .omnibar-item'), + ]; + rows.at(-1)?.dispatchEvent(new MouseEvent('mousemove', { bubbles: true })); + await nextTick(); + } + await m.key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + await nextTick(); + const events = [ + ...m.searched.map((q) => `search(${q})`), + ...m.calls.map(([name, args]) => + name === 'fly_to_location' + ? `fly(${args.query})` + : name === 'set_visual_style' + ? `style(${args.style})` + : name === 'control_radio' + ? `radio(${args.action}${args.locationQuery ? `@${args.locationQuery}` : ''})` + : name === 'track_entity' + ? `follow(${args.query})` + : name, + ), + ...m.switched.map(([id, on]) => `layer(${id},${on ? 'on' : 'off'})`), + ...m.acted.map((act) => `globe(${act})`), + ...m.voiceEvents + .filter(([kind]) => kind === 'chat-prompt') + .map(([, q]) => `ask(${q})`), + ...m.voiceEvents.filter(([kind]) => kind === 'button').map(() => 'mic'), + ...closed.map((side) => `close(${side})`), + ...opened.map((panel) => `open(${panel})`), + ]; + return events.join(' + ') || 'nothing'; +} + +for (const [text, expected] of ENTER_TABLE) + test(`Enter on ${JSON.stringify(text)} runs ${expected}`, async (t) => { + assert.equal(await enterOutcome(t, text), expected); + }); + +// The pointer last on the Ask GEV row, or on a guarded plan, changes +// nothing: Enter still runs the default (or nothing). +for (const [text, expected] of [ + ['radio near tokyo', 'search(tokyo)'], + ['Share', 'nothing'], + ['hi', 'nothing'], +]) + test(`hovering a row of ${JSON.stringify(text)} never makes it what Enter runs`, async (t) => { + assert.equal(await enterOutcome(t, text, { hover: true }), expected); + }); + +/** Route Photon requests to a stub; return the queries it was sent. */ +function stubPhoton(t, features = () => []) { + const asked = []; + const realFetch = globalThis.fetch; + globalThis.fetch = async (url) => { + const q = new URL(String(url)).searchParams.get('q'); + asked.push(q); + return Response.json({ features: features(q) }); + }; + t.after(() => { + globalThis.fetch = realFetch; + }); + return asked; +} +const settle = (ms = 800) => new Promise((resolve) => setTimeout(resolve, ms)); + +for (const text of [ + '4111 1111 1111 1111', + '4111-1111-1111-1111', + '+1 (415) 555-0100', + '415.555.0100 x12', + 'SSN 123-45-6789', + 'GB29 NWBK 6016 1331 9268 19', + 'DE89370400440532013000', + 'sk_live_51Habcdef', + 'rk_live_51Habcdef', + 'pk_live_abc', + 'password hunter2', + 'my passcode is 4433', + 'pin 1234', + 'me@example.com', + 'PIN code 1234', + 'my bank pin is 1234', + '123-45-6789', + 'pw hunter2', + 'Bearer abcdef', +]) + test(`private text ${JSON.stringify(text)} is never looked up or searched`, async (t) => { + const asked = stubPhoton(t); + const { type, key, searched, calls } = recordingOmnibar(t); + await type(text); + await settle(); + // At most a row to search it as a place on purpose, which Enter skips. + assert.ok(omnibarRows().every((row) => row.includes('as a place anyway'))); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(asked, []); + assert.deepEqual(searched, []); + assert.deepEqual(calls, []); + }); + +test('a row chosen with the keys stays chosen when rows arrive above it', async (t) => { + stubPhoton(t, (q) => [ + { + geometry: { type: 'Point', coordinates: [2.35, 48.86] }, + properties: { + name: 'Paris', + country: 'France', + countrycode: 'fr', + osm_value: 'city', + }, + }, + { + geometry: { type: 'Point', coordinates: [-95.55, 33.66] }, + properties: { + name: `${q} Texas`, + country: 'United States', + countrycode: 'us', + osm_value: 'city', + }, + }, + ]); + const { type, key, voiceEvents, searched } = recordingOmnibar(t); + await type('Paris'); + // Choose Ask GEV, the second row, before the suggestions come in. + assert.deepEqual(omnibarRows(), [ + 'place: Go to Paris', + 'ask: Ask GEV: “Paris”', + ]); + await key('ArrowDown'); + await settle(); + assert.ok(omnibarRows().length > 2, omnibarRows().join(' | ')); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(searched, []); + assert.deepEqual( + voiceEvents.find(([kind]) => kind === 'chat-prompt'), + ['chat-prompt', 'Paris'], + ); +}); + +test('a plan switches a layer by its state when it runs, not when it was read', async (t) => { + const { type, key, switched, calls, layerList } = recordingOmnibar(t); + await type('go to Austin and show flights'); + // Flights came on elsewhere after the line was read. + layerList[0].enabled = true; + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual( + calls.map(([name]) => name), + ['fly_to_location'], + ); + assert.deepEqual(switched, []); +}); + +test('a globe action nobody answers fails the plan', async (t) => { + const { $, type, key, acted } = recordingOmnibar(t, [], { acts: ['clear'] }); + await type('go to Austin and tilt'); + await key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.deepEqual(acted, []); + assert.ok($('#gev-omnibar [role="alert"]').textContent.trim()); +}); + +test('the OpenStreetMap credit shows while Photon suggestions do', async (t) => { + stubPhoton(t, () => [ + { + geometry: { type: 'Point', coordinates: [139.69, 35.69] }, + properties: { + name: 'Tokyo', + country: 'Japan', + countrycode: 'jp', + osm_value: 'city', + }, + }, + ]); + const { type, key, credits } = recordingOmnibar(t); + await type('Tokyo'); + await settle(); + assert.deepEqual(credits, [true]); + await key('Escape'); + await nextTick(); + assert.deepEqual(credits, [true, false]); +}); + +test('ids name no layer: "Local" and "Global" search a place', async (t) => { + stubPhoton(t); + const searched = []; + const fixture = omnibarFixture(t, (query) => searched.push(query)); + const switched = []; + useOmnibarStore(fixture.pinia).connect({ + layers: () => [ + { id: 'local-firms', name: 'Active fires', enabled: false }, + { id: 'global-context', name: 'World context', enabled: false }, + // A shown name holding a word of kind names it only in full. + { id: 'local-adsb', name: 'Local ADS-B', enabled: false }, + ], + setLayer: (...args) => switched.push(args), + }); + for (const text of ['Local', 'Global']) { + await fixture.type(text); + await fixture.key('Enter'); + await new Promise((resolve) => setTimeout(resolve, 0)); + } + assert.deepEqual(switched, []); + assert.deepEqual(searched, ['Local', 'Global']); +}); + +// A deterministic sample of about 2,000 bundled place names, alone and with +// " radio" and " noir" after them: none may default to an action. Sweeping +// every name the same way takes minutes, so the suite samples them. +test('bundled place names never default to an action', async (t) => { + stubPhoton(t); + const { readFile, readdir } = await import('node:fs/promises'); + const names = new Set(); + const cities = JSON.parse( + await readFile( + new URL( + '../data/local_data/wikidata_cities/cities.json', + import.meta.url, + ), + 'utf8', + ), + ); + for (const row of cities.rows) names.add(row[0]); + const dir = new URL('../data/local_data/wikidata_places/', import.meta.url); + for (const file of (await readdir(dir)).sort()) + if (/^-?\d+_-?\d+\.json$/.test(file)) + for (const row of JSON.parse(await readFile(new URL(file, dir), 'utf8')) + .rows) + names.add(row[0]); + const all = [...names].sort(); + const step = Math.floor(all.length / 2000); + const sample = all.filter((_, index) => index % step === 0); + // The words of PLACE_WORDS are in the sample too. + sample.push( + 'Thermal', + 'Normal', + 'Hurricane', + 'Ski', + 'Street', + 'Bike', + 'Rain', + ); + const { type, input } = recordingOmnibar(t, [ + 'radio', + 'traffic', + 'earthquakes', + 'weather-cyclones', + 'news', + ]); + const wrong = []; + for (const name of sample) + for (const text of [name, `${name} radio`, `${name} noir`]) { + await type(text); + const id = input.getAttribute('aria-activedescendant'); + const row = id && document.getElementById(id); + if (row && !row.classList.contains('omnibar-item--place')) + wrong.push(`${text} => ${row.textContent.trim()}`); + } + assert.ok(sample.length > 1900, `${sample.length} names`); + assert.deepEqual(wrong, []); +}); diff --git a/src/ui/entityContextBridge.js b/src/ui/entityContextBridge.js index eea7e72c29..927532f496 100644 --- a/src/ui/entityContextBridge.js +++ b/src/ui/entityContextBridge.js @@ -62,7 +62,7 @@ export function installEntityContext({ const voice = useVoiceStore(pinia); const cockpitStore = useCockpitStore(pinia); const chrome = usePanelChromeStore(pinia); - /** Whether Context is open; a closed panel reads nothing. */ + /** Whether Context is open. (readView also reads while the Omnibar is focused.) */ const isOpen = () => chrome.panels['global-context-panel']?.collapsed === false; const doc = globalThis.document; @@ -223,7 +223,8 @@ export function installEntityContext({ // the height. Read when the camera settles, not every frame. const readView = () => { const port = camera(); - if (!port || !isOpen()) return; + if (!port || (!isOpen() && doc?.activeElement?.id !== 'gev-omnibar-input')) + return; const pose = port.pose(); if (![pose.lat, pose.lon, pose.height].every(Number.isFinite)) return; const middle = pickWorld?.(viewer, 0.5, 0.5); @@ -272,6 +273,12 @@ export function installEntityContext({ listen(); readView(); }, 0); + // The Omnibar's nearby suggestions also need a fresh center even with + // Context closed. Its focus event requests one camera read. + const onSearchFocus = (event) => { + if (event.target?.id === 'gev-omnibar-input') readView(); + }; + doc?.addEventListener('focusin', onSearchFocus); // Opening the panel describes the view as it is now. let wasOpen = isOpen(); const offChrome = chrome.$subscribe(() => { @@ -356,6 +363,7 @@ export function installEntityContext({ clearTimeout(trailing); offFollow(); offChrome(); + doc?.removeEventListener('focusin', onSearchFocus); clearTimeout(followCheck); globalThis.removeEventListener?.('gev:entity-selected', onSelected); store.connect(null); diff --git a/src/ui/leftPanelRail.js b/src/ui/leftPanelRail.js index c5c65378b3..44eef21fd5 100644 --- a/src/ui/leftPanelRail.js +++ b/src/ui/leftPanelRail.js @@ -115,8 +115,15 @@ export function layoutLeftPanelRail({ if (hiddenByAncestor) continue; const rect = obstacle.getBoundingClientRect(); if (rect.width <= 0 || rect.height <= 0) continue; - const overlapsHorizontally = - rect.right > stackRect.left && rect.left < stackRect.right; + // The centered controls can enter the stack's transparent outer gutter. + // Only constrain the lane if they reach an expanded panel itself, whose + // actual bounds also include the edge-rail offset. + const lanes = ['world-timeline', 'gev-voice-control'].includes(obstacle.id) + ? laidOutPanels.map((panel) => panel.getBoundingClientRect()) + : [stackRect]; + const overlapsHorizontally = lanes.some( + (lane) => rect.right > lane.left && rect.left < lane.right, + ); if (!overlapsHorizontally) continue; if (rect.top < baseTop && rect.bottom <= viewportHeight * 0.5) { @@ -220,11 +227,20 @@ export function layoutLeftPanelRail({ const tailLayoutBottom = tailLayoutTop + tailRequiredHeight; const tailAvailableHeight = Math.max(0, obstacleSafeBottom - obstacleSafeTop); const tailTolerance = wasTail ? stabilityBand : -stabilityBand; + // Data Layers has a scrollable list and a fixed footer. Give it the full + // desktop lane while short control panels keep their natural height. + const fillDataLayers = + exclusive && + expandedPanels.length === 1 && + expandedPanels[0].id === 'data-panel' && + Boolean(documentRef?.getElementById?.('gev-omnibar')); const shouldTail = + !fillDataLayers && expandedPanels.length > 0 && tailLayoutTop >= obstacleSafeTop - tailTolerance && tailLayoutBottom <= obstacleSafeBottom + tailTolerance; - const shouldFocus = exceedsCenteredCorridor && !shouldTail; + const shouldFocus = + fillDataLayers || (exceedsCenteredCorridor && !shouldTail); // Focus mode owns the lane, so let every expanded panel share the full // obstacle-safe corridor. Tail/normal layouts keep the balanced // viewport centering used for compact accordion stacks. @@ -250,10 +266,12 @@ export function layoutLeftPanelRail({ rowGap * Math.max(0, expandedPanels.length - 1), ) : naturalExpandedHeight; - const allocatedExpandedHeights = allocatePanelStackHeights({ - naturalHeights: naturalExpandedHeights, - availableHeight: expandedAvailableHeight, - }); + const allocatedExpandedHeights = fillDataLayers + ? [expandedAvailableHeight] + : allocatePanelStackHeights({ + naturalHeights: naturalExpandedHeights, + availableHeight: expandedAvailableHeight, + }); const autoCollapseIndices = hud.visible ? panelStackAutoCollapseIndices({ naturalHeights: naturalExpandedHeights, diff --git a/src/ui/locationControls.js b/src/ui/locationControls.js index 388fb51e14..80d189e5e1 100644 --- a/src/ui/locationControls.js +++ b/src/ui/locationControls.js @@ -46,6 +46,7 @@ export class LocationControls { onCity, onPoi, onSearch, + onSearchEdit, onReset, publish, doc, @@ -74,6 +75,7 @@ export class LocationControls { poi: t('Landmark: --'), }; this.searchError = null; + this.searchOrigin = 'dock'; // The search field: whether it is open, and whether a lookup runs. this.searchExpanded = Boolean(searchExpanded); this.searching = false; @@ -96,12 +98,16 @@ export class LocationControls { onPoi(cityId, index); }); this.bind(elements.search, 'keydown', (event) => { - if (event.key === 'Enter') void onSearch(elements.search.value); + if (event.key === 'Enter') + void this.search(elements.search.value, { origin: 'dock' }); }); // Typing corrects a failed query; closing the field (which empties it) drops its error. - this.bind(elements.search, 'input', () => onSearchEdit?.()); + this.bind(elements.search, 'input', () => { + if (this.searchOrigin === 'dock') onSearchEdit?.(); + }); this.bind(elements.search, 'blur', () => { - if (!elements.search.value) onSearchEdit?.(); + if (this.searchOrigin === 'dock' && !elements.search.value) + onSearchEdit?.(); }); this.present(); } @@ -138,9 +144,29 @@ export class LocationControls { searchError: this.searchError, searchExpanded: this.searchExpanded, searching: this.searching, + searchOrigin: this.searchOrigin, orbit: this.orbit && { ...this.orbit }, }; } + /** Search through the same lifecycle as the location field. */ + search(query, { origin = 'omnibar' } = {}) { + if (this.destroyed || !String(query || '').trim()) return false; + this._requestedSearchOrigin = origin; + // Beginning navigation synchronously settles the previous lookup. That + // handoff must not clear or blur the draft just submitted by either field. + this._startingSearch = true; + try { + return this.onSearch(query); + } finally { + this._startingSearch = false; + this._requestedSearchOrigin = null; + } + } + /** Editing an external query clears its prior lookup error. */ + editSearch() { + if (!this.destroyed && this.searchOrigin === 'omnibar') + this.onSearchEdit?.(); + } /** A city pill was clicked. */ chooseCity(id) { if (!this.destroyed) this.onCity(id); @@ -233,6 +259,8 @@ export class LocationControls { /** Mark the search field while a lookup runs. */ setSearching(active) { if (this.destroyed) return; + if (active && this._requestedSearchOrigin) + this.searchOrigin = this._requestedSearchOrigin; this.searching = Boolean(active); this.present(); } @@ -243,6 +271,10 @@ export class LocationControls { settleSearch({ keepQuery = false } = {}) { if (this.destroyed) return; this.searching = false; + if (this._startingSearch || this.searchOrigin === 'omnibar') { + this.present(); + return; + } if (!keepQuery) { this.closeSearch(); return; diff --git a/src/ui/locationControls.test.mjs b/src/ui/locationControls.test.mjs index 2863564c8f..555536b65a 100644 --- a/src/ui/locationControls.test.mjs +++ b/src/ui/locationControls.test.mjs @@ -108,6 +108,7 @@ test('the tray presents its cities, empty status and no landmarks at first', () searchError: null, searchExpanded: false, searching: false, + searchOrigin: 'dock', orbit: null, }); f.controls.highlightCity('b'); diff --git a/src/ui/locationSearch.js b/src/ui/locationSearch.js index aeed9320ef..689a3a3795 100644 --- a/src/ui/locationSearch.js +++ b/src/ui/locationSearch.js @@ -101,6 +101,8 @@ export class LocationSearch { destination: { ...destination }, }; this.channel.publish(change('found')); + // Found and still the current search: a plan may go on. + return current() && !controller.signal.aborted; } else { this.onMissing?.(); if (!current() || controller.signal.aborted) return; diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index aefaa07df0..03ea30938a 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -185,8 +185,8 @@ const AUX_FORM = /** * Whether a line is a real question, which Ask GEV may answer on Enter (a * billed call): - * - one ending with "?" that has two words and two letters or more (or - * three Han, Kana or Hangul characters); + * - one ending with "?" that has a question form or two non-Latin words + * with a word of two letters or more, or five Han, Kana or Hangul characters; * - without "?", only a question word's form ("what is here", "how far is * paris") with a word about something after it, and not written as a * name ("Where Is My Mind"). @@ -209,13 +209,12 @@ export function isRealQuestion(text) { const words = line.replace(/\?+$/, '').split(/\s+/).filter(Boolean); if (line.endsWith('?')) // A name with "?" ("New York?", "Truth or Consequences?", "東京都?") is - // offered to GEV, not sent: a question's form, or four words or more - // (five Han, Kana or Hangul characters, written without spaces; two - // words in other non-Latin scripts). + // offered to GEV, not sent: a question's form, or five Han, Kana or + // Hangul characters written without spaces, or two words in other + // non-Latin scripts. return ( ((WH_FORM.test(line) || AUX_FORM.test(line) || - words.length >= 4 || // Question words in other scripts are not read: two words do. (words.length >= 2 && !/\p{Script=Latin}/u.test(line))) && words.some((word) => (word.match(/\p{L}/gu) || []).length >= 2)) || diff --git a/src/ui/omnibarIntent.test.mjs b/src/ui/omnibarIntent.test.mjs index 08a6df10e7..5ceb9e578f 100644 --- a/src/ui/omnibarIntent.test.mjs +++ b/src/ui/omnibarIntent.test.mjs @@ -252,6 +252,7 @@ test('ar and he mark every Omnibar string alike with a right-to-left mark', asyn // U+200F, so the punctuation stays with the right-to-left text before it. const sources = await Promise.all( [ + './views/panels/Omnibar.vue', './views/panels/VoiceVisualizer.vue', './omnibarIntent.js', './omnibarRows.js', diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index 3d6533275c..a62cdde11c 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -148,16 +148,15 @@ const OUTCOMES = [ ['remove island', 'nothing'], ['show noir and show cctv', 'style(noir) + layer(cctv,on)'], // a name with "?" is offered to GEV, - // never sent; a question's form or four words are. + // never sent; a question's form is. ['New York?', 'nothing'], ['Truth or Consequences?', 'nothing'], + ['Ho Chi Minh City?', 'nothing'], + ['Santa Cruz de la Sierra?', 'nothing'], ['東京都?', 'nothing'], ['東京はどこ?', 'ask(東京はどこ?)'], ['is it far?', 'ask(is it far?)'], - [ - 'how about the weather in paris today?', - 'ask(how about the weather in paris today?)', - ], + ['how about the weather in paris today?', 'nothing'], ['123–45–6789', 'nothing'], ['what is 4111–1111–1111–1111?', 'nothing'], // a switch with its place after "in" asks; diff --git a/src/ui/panelRails.test.mjs b/src/ui/panelRails.test.mjs index ce1c824466..cf5a534451 100644 --- a/src/ui/panelRails.test.mjs +++ b/src/ui/panelRails.test.mjs @@ -232,6 +232,38 @@ test('left corridor respects a lower obstacle but ignores an obstacle hidden by assert.equal(Number(f.stack.dataset.safeBottomPct), 65.47); }); +test('a centered timeline only shortens the corridor when it reaches the visible panel', () => { + const f = fixture('left'); + f.stack.rect.width = 360; + f.stack.rect.right = f.stack.rect.left + 360; + f.expand(f.first, 850); + const timeline = element('world-timeline', { top: 650, left: 320 }); + f.options.obstacles = [timeline]; + f.run(); + const clear = Number(f.stack.dataset.safeBottomPct); + timeline.rect.left = 280; + f.run(); + assert(clear > 85); + assert(Number(f.stack.dataset.safeBottomPct) < 73); +}); + +test('Data Layers extends to the HUD even if its list is currently short', () => { + const f = fixture('left'); + f.first.id = 'data-panel'; + f.options.documentRef.getElementById = (id) => + id === 'gev-omnibar' ? {} : null; + f.expand(f.first, 250); + f.options.obstacles = [element('hud', { top: 760, height: 45 })]; + f.run(); + assert.equal(f.stack.dataset.layoutMode, 'focus'); + assert(Number(f.stack.dataset.safeBottomPct) > 80); + assert( + parseFloat( + f.first.style.getPropertyValue('--left-panel-allocated-height'), + ) > 500, + ); +}); + for (const side of ['left', 'right']) { test(`${side} mobile layout releases desktop height/position styles and labels`, () => { const f = fixture(side, { mobile: true }); diff --git a/src/ui/stores/entityCard.js b/src/ui/stores/entityCard.js index 611065ac2d..a0186fea2c 100644 --- a/src/ui/stores/entityCard.js +++ b/src/ui/stores/entityCard.js @@ -6,6 +6,7 @@ import { describeEntity, layerBreakdown, nearbyByKind, + nearbyEntities, layerMatches, searchEntities, viewSummary, @@ -204,6 +205,10 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => { return nearbyByKind(shell.value?.dataManager?.(), { lat, lon }, options); } + function nearbySelected() { + return nearbyEntities(dataManager(), card.value); + } + /** Whether a card's layer is known to the layer manager and switched off. */ function layerOff(layerId) { const dm = dataManager(); @@ -333,6 +338,7 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => { following, search, nearbyGroups, + nearbySelected, alertsAt, liveLayers, breakdown, diff --git a/src/ui/stores/globeActions.js b/src/ui/stores/globeActions.js index 58247604ff..74243e1452 100644 --- a/src/ui/stores/globeActions.js +++ b/src/ui/stores/globeActions.js @@ -79,6 +79,8 @@ export const useGlobeActionsStore = defineStore('gev-globe-actions', () => { } const { act, owns } = owners; + /** Whether a connected owner answers this action at all. */ + const answers = (name) => Boolean(owners.ownerOf(name)); return { clearBusy, @@ -91,5 +93,6 @@ export const useGlobeActionsStore = defineStore('gev-globe-actions', () => { detach, act, owns, + answers, }; }); diff --git a/src/ui/stores/omnibar.js b/src/ui/stores/omnibar.js index 68c2e4e259..a4210b75fa 100644 --- a/src/ui/stores/omnibar.js +++ b/src/ui/stores/omnibar.js @@ -5,11 +5,14 @@ import { markRaw, shallowRef } from 'vue'; * The top-bar omnibar's link to the shell. The shell connects the actions * the omnibar offers: `layers()` lists the data layers as `{id, name, * enabled}`, and `setLayer(id, enabled)` turns one on or off as a user click - * would. Place search runs through the location controls and Ask GEV through - * the voice controls, so neither is repeated here. + * would. `creditPlaces()`, optional, credits the bundled Wikidata place + * packs once a name from them is shown, and `creditSuggestions(shown)`, + * optional, shows the OpenStreetMap credit while Photon's suggestions are. Place search runs through the + * location controls and Ask GEV through the voice controls, so neither is + * repeated here. */ export const useOmnibarStore = defineStore('gev-omnibar', () => { - /** `{layers(), setLayer(id, enabled)}`, or null while disconnected. */ + /** `{layers(), setLayer(id, enabled), creditPlaces?()}`, or null while disconnected. */ const controls = shallowRef(null); /** @param {?object} next The shell's omnibar actions, or null. */ diff --git a/src/ui/styles/guide.css b/src/ui/styles/guide.css new file mode 100644 index 0000000000..d19da7a3a4 --- /dev/null +++ b/src/ui/styles/guide.css @@ -0,0 +1,413 @@ +/* ── "Show me how" guide ─────────────────────────────────────────────── + A spotlight dims everything but the control to press and frames it with + tactical corner brackets; a second frame marks a part of it (a layer's + switch). A glass callout beside it, with an arrow to the target, says + what to do and how far along the walk is. Clicks pass through to the + app: the guide only points. */ +.gev-guide { + --gev-guide-accent: #ff9f43; + --gev-guide-accent-soft: rgba(255, 159, 67, 0.5); + position: fixed; + z-index: 400; + inset: 0; + pointer-events: none; +} + +/* ── Spotlight ── */ +.gev-guide-ring { + position: fixed; + border: 1px solid rgba(255, 159, 67, 0.28); + border-radius: 8px; + box-shadow: 0 0 0 200vmax rgba(3, 8, 14, 0.55); + opacity: 0; + transition: + left 280ms cubic-bezier(0.2, 0.8, 0.2, 1), + top 280ms cubic-bezier(0.2, 0.8, 0.2, 1), + width 280ms cubic-bezier(0.2, 0.8, 0.2, 1), + height 280ms cubic-bezier(0.2, 0.8, 0.2, 1), + opacity 160ms ease; +} + +/* Corner brackets, drawn as eight short gradient strokes. */ +.gev-guide-ring::before { + position: absolute; + inset: -3px; + background: + linear-gradient(var(--gev-guide-accent) 0 0) top left / 12px 2px, + linear-gradient(var(--gev-guide-accent) 0 0) top left / 2px 12px, + linear-gradient(var(--gev-guide-accent) 0 0) top right / 12px 2px, + linear-gradient(var(--gev-guide-accent) 0 0) top right / 2px 12px, + linear-gradient(var(--gev-guide-accent) 0 0) bottom left / 12px 2px, + linear-gradient(var(--gev-guide-accent) 0 0) bottom left / 2px 12px, + linear-gradient(var(--gev-guide-accent) 0 0) bottom right / 12px 2px, + linear-gradient(var(--gev-guide-accent) 0 0) bottom right / 2px 12px; + background-repeat: no-repeat; + content: ''; + filter: drop-shadow(0 0 4px rgba(255, 159, 67, 0.6)); +} + +/* A soft ping that grows out of the frame: "press here". */ +.gev-guide-ring > i { + position: absolute; + inset: 0; + border: 1px solid var(--gev-guide-accent-soft); + border-radius: inherit; + animation: gev-guide-ping 1.8s cubic-bezier(0.2, 0.7, 0.3, 1) infinite; +} + +/* A second frame inside the spotlight does not dim the screen again. */ +.gev-guide-ring--sub { + border-color: rgba(255, 159, 67, 0.4); + border-radius: 6px; + box-shadow: none; +} + +.gev-guide-ring--sub::before { + inset: -2px; + background-size: + 8px 2px, + 2px 8px, + 8px 2px, + 2px 8px, + 8px 2px, + 2px 8px, + 8px 2px, + 2px 8px; +} + +/* ── Callout ── */ +.gev-guide-callout { + position: fixed; + width: 280px; + padding: 0.7rem 0.8rem 0.65rem; + color: rgba(232, 238, 242, 0.95); + background: rgba(40, 44, 52, 0.9); + border: 1px solid rgba(255, 255, 255, 0.12); + border-radius: 12px; + box-shadow: + 0 16px 40px rgba(0, 0, 0, 0.55), + inset 0 1px 0 rgba(255, 255, 255, 0.06); + backdrop-filter: blur(22px) saturate(1.3); + -webkit-backdrop-filter: blur(22px) saturate(1.3); + opacity: 0; + transform: translateY(4px); + transition: + left 280ms cubic-bezier(0.2, 0.8, 0.2, 1), + top 280ms cubic-bezier(0.2, 0.8, 0.2, 1), + opacity 180ms ease, + transform 180ms ease; + pointer-events: auto; +} + +.gev-guide.visible .gev-guide-callout { + opacity: 1; + transform: none; +} + +/* A leader line from the callout to the target's frame, ending in a dot. */ +.gev-guide-callout::before, +.gev-guide-callout::after { + position: absolute; + top: var(--gev-guide-arrow-y, 50%); + content: ''; + transition: top 280ms cubic-bezier(0.2, 0.8, 0.2, 1); +} + +.gev-guide-callout::before { + width: 18px; + height: 1px; + background: var(--gev-guide-accent); + box-shadow: 0 0 6px rgba(255, 159, 67, 0.7); +} + +.gev-guide-callout::after { + width: 5px; + height: 5px; + margin-top: -2px; + background: var(--gev-guide-accent); + border-radius: 50%; + box-shadow: 0 0 6px rgba(255, 159, 67, 0.9); +} + +.gev-guide-callout[data-side='right']::before { + right: 100%; +} + +.gev-guide-callout[data-side='right']::after { + right: calc(100% + 15px); +} + +.gev-guide-callout[data-side='left']::before { + left: 100%; +} + +.gev-guide-callout[data-side='left']::after { + left: calc(100% + 15px); +} + +.gev-guide-callout[data-side='none']::before, +.gev-guide-callout[data-side='none']::after { + display: none; +} + +/* The edge the line leaves from picks up the accent. */ +.gev-guide-callout[data-side='right'] { + border-left-color: rgba(255, 159, 67, 0.55); +} + +.gev-guide-callout[data-side='left'] { + border-right-color: rgba(255, 159, 67, 0.55); +} + +/* Header: what this walk is about, how far along, and a close. */ +.gev-guide-head { + display: flex; + align-items: center; + gap: 0.5rem; +} + +.gev-guide-title, +.gev-guide-count { + margin: 0; + font-family: var(--font-mono); + font-size: 0.56rem; + letter-spacing: 0.12rem; + text-transform: uppercase; +} + +.gev-guide-title { + flex: 1; + min-width: 0; + overflow: hidden; + color: var(--gev-guide-accent); + text-overflow: ellipsis; + white-space: nowrap; +} + +.gev-guide-count { + color: rgba(214, 220, 226, 0.55); + font-variant-numeric: tabular-nums; + letter-spacing: 0.06rem; +} + +.gev-guide-close { + display: grid; + place-items: center; + width: 20px; + height: 20px; + margin: -2px -4px 0 0; + padding: 0; + color: rgba(214, 220, 226, 0.55); + font-size: 0.95rem; + line-height: 1; + background: none; + border: 0; + border-radius: 5px; + cursor: pointer; +} + +.gev-guide-close:hover, +.gev-guide-close:focus-visible { + color: #fff; + background: rgba(255, 255, 255, 0.08); +} + +/* Progress: one segment per step. */ +.gev-guide-progress { + display: flex; + gap: 3px; + margin: 0.45rem 0 0.6rem; + padding: 0; + list-style: none; +} + +.gev-guide-progress li { + flex: 1; + height: 2px; + background: rgba(214, 220, 226, 0.16); + border-radius: 2px; + transition: background 220ms ease; +} + +.gev-guide-progress li.done { + background: rgba(255, 159, 67, 0.55); +} + +.gev-guide-progress li.current { + background: var(--gev-guide-accent); + box-shadow: 0 0 6px rgba(255, 159, 67, 0.6); +} + +.gev-guide-callout.swap .gev-guide-body { + animation: gev-guide-swap 260ms ease both; +} + +.gev-guide-text { + margin: 0; + font-size: 0.84rem; + line-height: 1.45; +} + +/* "Press the highlighted control", with a live dot. */ +.gev-guide-hint { + display: flex; + align-items: center; + gap: 0.45rem; + margin: 0.4rem 0 0; + color: rgba(214, 220, 226, 0.6); + font-size: 0.68rem; +} + +.gev-guide-hint[hidden] { + display: none; +} + +.gev-guide-hint-dot { + width: 6px; + height: 6px; + flex: none; + background: var(--gev-guide-accent); + border-radius: 50%; + animation: gev-guide-blink 1.4s ease-in-out infinite; +} + +/* Footer: the Esc hint on the left, the buttons on the right. */ +.gev-guide-actions { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.4rem; + margin-top: 0.7rem; + padding-top: 0.55rem; + border-top: 1px solid rgba(255, 255, 255, 0.07); +} + +.gev-guide-actions > span { + display: flex; + gap: 0.4rem; +} + +.gev-guide-keys { + display: flex; + align-items: center; + gap: 0.35rem; + margin: 0; + color: rgba(214, 220, 226, 0.45); + font-size: 0.62rem; +} + +.gev-guide-keys[hidden] { + display: none; +} + +/* With the Esc hint gone, the offer's buttons sit on the right. */ +.gev-guide-actions > span:only-of-type { + margin-left: auto; +} + +.gev-guide-keys kbd { + padding: 0.05rem 0.3rem; + font-family: var(--font-mono); + font-size: 0.54rem; + border: 1px solid rgba(214, 220, 226, 0.22); + border-radius: 4px; +} + +.gev-guide-actions button { + padding: 0.28rem 0.6rem; + color: #1a1206; + font-family: var(--font-mono); + font-size: 0.58rem; + font-weight: 600; + letter-spacing: 0.1rem; + text-transform: uppercase; + white-space: nowrap; + background: var(--gev-guide-accent); + border: 1px solid var(--gev-guide-accent); + border-radius: 6px; + cursor: pointer; + transition: + background 140ms ease, + color 140ms ease, + border-color 140ms ease; +} + +.gev-guide-actions button[hidden] { + display: none; +} + +.gev-guide-actions button:hover, +.gev-guide-actions button:focus-visible { + background: #ffb36b; + border-color: #ffb36b; +} + +/* Secondary buttons: skip a step that waits, or decline the offer. */ +.gev-guide-actions button.quiet, +.gev-guide-actions .gev-guide-skip { + color: rgba(214, 220, 226, 0.75); + font-weight: 400; + background: none; + border-color: rgba(214, 220, 226, 0.2); +} + +.gev-guide-actions button.quiet:hover, +.gev-guide-actions button.quiet:focus-visible, +.gev-guide-actions .gev-guide-skip:hover, +.gev-guide-actions .gev-guide-skip:focus-visible { + color: #fff; + background: rgba(255, 255, 255, 0.06); + border-color: rgba(255, 159, 67, 0.6); +} + +@keyframes gev-guide-ping { + 0% { + opacity: 0.9; + transform: scale(1); + } + + 100% { + opacity: 0; + transform: scale(1.12); + } +} + +@keyframes gev-guide-blink { + 50% { + opacity: 0.3; + } +} + +@keyframes gev-guide-swap { + from { + opacity: 0; + transform: translateY(3px); + } +} + +@media (prefers-reduced-motion: reduce) { + .gev-guide-ring, + .gev-guide-callout, + .gev-guide-callout::before { + transition: none; + } + + .gev-guide-ring > i, + .gev-guide-hint-dot, + .gev-guide-callout.swap .gev-guide-body { + animation: none; + } +} + +/* The guide's live status: read by screen readers, not shown. */ +.gev-guide-status { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; +} diff --git a/src/ui/styles/omnibar-dock.css b/src/ui/styles/omnibar-dock.css new file mode 100644 index 0000000000..362a48920b --- /dev/null +++ b/src/ui/styles/omnibar-dock.css @@ -0,0 +1,360 @@ +/* Shared desktop command surface. Mobile and exclusive owners keep their layout. */ +body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not( + .ui-clean-view + ):not(.recording-mode):where( + :has(#gev-omnibar):has(#command-dock > #gev-voice-control) + ) { + --omnibar-dock-width: clamp(400px, 32vw, 460px); + --omnibar-dock-bottom: 74px; + --omnibar-coordinates-bottom: 4.25rem; + --world-timeline-lift: 0px; + + #intel-hud:is([data-variant='tactical'], [data-variant='minimal']) + :is(.hud-top-left, .hud-top-right) { + top: clamp(92px, 10vh, 112px); + } + + #intel-hud:is([data-variant='tactical'], [data-variant='minimal']) + .hud-top-left + .hud-readout:has(> #hud-mode) { + display: none; + } + #top-center-actions { + top: clamp(86px, 9.55vh, 108px); + } + #left-panel-stack.layout-focus { + bottom: var(--left-stack-safe-bottom, 4vh); + } + + #world-timeline { + bottom: calc(var(--omnibar-dock-bottom) + 66px); + width: var(--omnibar-dock-width); + } + + &:has(#gev-chat-panel:not([hidden]), #gev-voice-panel:not([hidden])) + #world-timeline, + &:has(#gev-omnibar.has-results):not( + :has(#gev-voice-control[data-assistant-mode='voice']) + ) + #world-timeline { + visibility: hidden; + } + + #command-dock { + --dock-voice-width: var(--omnibar-dock-width); + top: auto; + bottom: var(--omnibar-dock-bottom); + z-index: 149; + width: var(--omnibar-dock-width); + max-width: none; + height: 56px; + min-height: 0; + overflow: visible; + align-items: center; + padding: 0; + } + #command-dock > #gev-voice-control { + box-sizing: border-box; + flex: none; + width: 100%; + min-width: 0; + max-width: none; + height: 56px; + margin: 0; + padding: 0 8px; + gap: 0; + align-items: center; + justify-content: space-between; + border: 1px solid rgba(120, 220, 255, 0.16); + border-radius: 18px; + background: linear-gradient( + 180deg, + rgba(16, 28, 36, 0.9), + rgba(6, 14, 20, 0.94) + ); + box-shadow: + inset 0 1px 0 rgba(200, 245, 255, 0.07), + 0 12px 32px rgba(0, 0, 0, 0.45); + backdrop-filter: none; + } + &:has(#gev-omnibar:focus-within) #command-dock > #gev-voice-control { + border-color: rgba(54, 220, 255, 0.5); + box-shadow: + 0 12px 32px rgba(0, 0, 0, 0.45), + 0 0 0 3px rgba(54, 220, 255, 0.1); + } + #command-dock > #gev-voice-control::before, + #command-dock > #gev-voice-control::after { + content: ''; + position: absolute; + top: 16px; + bottom: 16px; + width: 1px; + height: auto; + transform: none; + background: rgba(120, 220, 255, 0.12); + pointer-events: none; + } + #command-dock > #gev-voice-control::before { + inset-inline-start: 54px; + inset-inline-end: auto; + } + #command-dock > #gev-voice-control::after { + inset-inline-start: auto; + inset-inline-end: 54px; + } + #gev-voice-control > :is(#gev-voice-button, #gev-chat-button):focus-visible { + outline: 2px solid #7bd3ef; + outline-offset: 2px; + } + #gev-voice-control > :is(#gev-voice-button, #gev-chat-button) { + display: grid; + place-items: center; + flex: none; + width: 40px; + height: 40px; + min-width: 0; + margin: 0; + padding: 0; + border: 1px solid rgba(120, 220, 255, 0.18); + border-radius: 50%; + background: rgba(5, 17, 24, 0.48); + box-shadow: + inset 0 2px 4px rgba(0, 0, 0, 0.58), + inset 0 -1px 0 rgba(169, 226, 245, 0.12), + 0 1px 0 rgba(169, 226, 245, 0.1); + transform: none; + } + #gev-voice-control + > :is(#gev-voice-button, #gev-chat-button):is( + :hover, + [aria-pressed='true'], + [aria-expanded='true'] + ) { + background: rgba(54, 220, 255, 0.14); + border-color: rgba(54, 220, 255, 0.6); + } + #command-dock #gev-voice-control .gev-mic-orbit, + #command-dock #gev-chat-button > svg { + box-sizing: border-box; + width: 19px; + height: 19px; + padding: 0; + background: none; + border: 0; + box-shadow: none; + } + #gev-voice-button .gev-mic-orbit img { + width: 19px; + height: 19px; + filter: saturate(0.35) brightness(1.25); + } + #gev-voice-button .gev-mic-orbit::before, + #gev-voice-button .gev-mic-orbit::after { + display: none; + } + #gev-voice-control :is(.gev-mic-label, .gev-chat-label) { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + } + /* Status remains readable while live; idle meter is decorative. */ + #command-dock + #gev-voice-control:not([data-assistant-mode='voice']) + > .gev-voice-visualizer, + #command-dock + #gev-voice-control:not([data-chat-busy='true']) + > .gev-chat-thinking { + display: none; + } + #command-dock #gev-voice-control[data-chat-busy='true'] > .gev-chat-thinking { + position: absolute; + top: 10px; + left: 50%; + height: 0; + transform: translateX(-50%); + pointer-events: none; + z-index: 151; + } + #gev-voice-control > .gev-voice-readout { + position: absolute; + inset-inline: 0; + top: auto; + bottom: calc(100% + 8px); + pointer-events: none; + } + #gev-voice-control[data-assistant-mode='idle'] > .gev-voice-readout { + visibility: hidden; + } + + #gev-omnibar { + top: auto; + bottom: calc(var(--omnibar-dock-bottom) + 11px); + left: 50%; + width: calc(var(--omnibar-dock-width) - 120px); + transform: translateX(-50%); + } + #gev-omnibar .omnibar-field { + height: 34px; + padding-inline: 9px 6px; + border: 1px solid rgba(151, 213, 231, 0.27); + border-radius: 9px; + background: rgba(172, 219, 239, 0.07); + box-shadow: none; + backdrop-filter: none; + } + #gev-omnibar-input { + font-size: 0.86rem; + text-overflow: ellipsis; + } + #gev-omnibar-input::placeholder { + color: #b6cbd4; + } + #gev-omnibar .omnibar-field:focus-within { + border-color: rgba(95, 230, 255, 0.66); + background: rgba(109, 206, 232, 0.1); + } + #gev-omnibar .omnibar-search-icon { + color: #a9cfda; + } + #gev-omnibar :is(.omnibar-mic, .omnibar-edge) { + display: none; + } + #gev-omnibar .omnibar-results { + position: absolute; + inset-inline: -60px; + top: auto; + bottom: calc(100% + 11px); + max-height: min( + 360px, + max(0px, calc(100dvh - var(--omnibar-dock-bottom) - 144px)) + ); + overflow: auto; + border-radius: 18px 18px 0 0; + border: 1px solid rgba(255, 255, 255, 0.1); + background: rgba(50, 54, 62, 0.86); + backdrop-filter: blur(26px) saturate(1.2); + -webkit-backdrop-filter: blur(26px) saturate(1.2); + box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45); + } + &:has(#gev-omnibar.has-results):not( + :has(#gev-voice-control[data-assistant-mode='voice']) + ) + #command-dock + > #gev-voice-control { + border-start-start-radius: 0; + border-start-end-radius: 0; + } + #command-dock + #gev-voice-control[data-assistant-mode='voice'] + > .gev-voice-visualizer { + position: absolute; + display: block; + inset: auto 64px 10px; + width: auto; + height: 28px; + opacity: 1; + transform: none; + pointer-events: none; + } + #gev-voice-control > .gev-voice-visualizer > span { + display: none; + } + #gev-voice-control > .gev-voice-visualizer > .gev-voice-wave { + display: block; + width: 100%; + height: 100%; + overflow: visible; + mask-image: linear-gradient( + 90deg, + transparent, + #000 16%, + #000 84%, + transparent + ); + } + .gev-voice-wave path { + fill: none; + stroke-linecap: round; + stroke-linejoin: round; + } + .gev-voice-wave__main { + stroke: #5fe6ff; + stroke-width: 2; + filter: drop-shadow(0 0 4px rgba(54, 220, 255, 0.55)); + } + .gev-voice-wave__echo { + stroke: #36dcff; + stroke-width: 1.2; + opacity: 0.35; + } + .gev-voice-wave__soft { + stroke: #9ff1ff; + stroke-width: 1; + opacity: 0.6; + } + &:has(#gev-voice-control[data-assistant-mode='voice']) #gev-omnibar { + .omnibar-field { + background: transparent; + } + :is(input, .omnibar-kbd, .omnibar-search-icon) { + visibility: hidden; + } + /* Suggestions give way to the waveform; an error stays in view. */ + .omnibar-results:not(.has-feedback), + .omnibar-results .omnibar-list { + display: none; + } + } + @media (prefers-reduced-motion: no-preference) { + #command-dock #gev-voice-control[data-assistant-mode='voice'] { + animation: omnibar-listening 2.4s ease-in-out infinite; + } + } + + /* Desktop uses Omnibar for search and the Visual rail for presets. */ + #command-dock > :is(#location-bar, #control-panel) { + display: none; + } + + /* Align the plain credits with Power Up. */ + :is(#cesium-credits, #gev-credits), + &:has(#intel-hud[data-variant='minimal'].active) + :is(#cesium-credits, #gev-credits) { + bottom: 1rem; + } + #intel-hud[data-variant='tactical'] .hud-bottom-right { + bottom: calc(4.2rem - 26px); + } + #intel-hud:is([data-variant='tactical'], [data-variant='minimal']) + .hud-bottom-left { + bottom: var(--omnibar-coordinates-bottom); + } + &:not(.context-docked):has(#intel-hud[data-variant='minimal'].active) + #right-context-rail { + --omnibar-minimal-rail-height: min( + var(--right-stack-max-height, 70vh), + calc( + 100dvh - var(--right-stack-safe-top, 26vh) - + var(--omnibar-coordinates-bottom) - 3.1rem - 1.2vh + ) + ); + max-height: var(--omnibar-minimal-rail-height); + > [data-panel-id]:not(.collapsed) { + max-height: var(--omnibar-minimal-rail-height); + } + } +} + +@keyframes omnibar-listening { + 0%, + 100% { + border-color: rgba(54, 220, 255, 0.35); + } + 50% { + border-color: rgba(54, 220, 255, 0.75); + } +} diff --git a/src/ui/views/CommandDockView.vue b/src/ui/views/CommandDockView.vue index ed2db21964..e3f827fd34 100644 --- a/src/ui/views/CommandDockView.vue +++ b/src/ui/views/CommandDockView.vue @@ -153,10 +153,10 @@ function selectMapSource(chip) { - + - + diff --git a/src/ui/views/SceneChromeView.vue b/src/ui/views/SceneChromeView.vue index b742ec0269..106850fec4 100644 --- a/src/ui/views/SceneChromeView.vue +++ b/src/ui/views/SceneChromeView.vue @@ -19,6 +19,7 @@ import AwarenessDirection from './panels/AwarenessDirection.vue'; import UiButton from '../kit/UiButton.vue'; import GlobeActions from './panels/GlobeActions.vue'; import { useGlobeActionsStore } from '../stores/globeActions.js'; +import Omnibar from './panels/Omnibar.vue'; import RenderFailure from './panels/RenderFailure.vue'; import WorldTimeline from './panels/WorldTimeline.vue'; @@ -90,6 +91,7 @@ const vToastText = { +
{{ loading ? loading.detail : '' }} diff --git a/src/ui/views/panels/Omnibar.vue b/src/ui/views/panels/Omnibar.vue new file mode 100644 index 0000000000..1b4479a6c9 --- /dev/null +++ b/src/ui/views/panels/Omnibar.vue @@ -0,0 +1,1341 @@ + + + + + diff --git a/src/ui/views/panels/VoiceVisualizer.vue b/src/ui/views/panels/VoiceVisualizer.vue index b29a7e7dac..8067698e1b 100644 --- a/src/ui/views/panels/VoiceVisualizer.vue +++ b/src/ui/views/panels/VoiceVisualizer.vue @@ -1,11 +1,12 @@ + + diff --git a/style.css b/style.css index b8136340c4..1a79c9aeba 100644 --- a/style.css +++ b/style.css @@ -61,4 +61,6 @@ @import './src/ui/styles/ai-chat.css'; @import './src/ui/styles/scope-off-shadows.css'; @import './src/ui/styles/stories-entry.css'; +@import './src/ui/styles/omnibar-dock.css'; +@import './src/ui/styles/guide.css'; @import './src/ui/styles/cyber.css';