A voice or chat selection shows its card in the Context panel (#1890)

* fix(voice): a selection steps a docked assistant panel down so Context shows; the panel keeps the last reply

A voice or chat action that selects an entity (select_nearest_aircraft,
track_entity) now minimizes a voice or chat panel docked in the right rail's
lane, so the rail and its Context panel show as after a click. The voice
card inside the panel no longer hides 14 s after its last update: the reply
stays until the next turn, Stop or a dismissal. The floating card keeps its
idle deadline.

* fix(voice): a voice or chat selection opens its card in the Context panel

A successful select_nearest_aircraft or track_entity now selects the entity
in the Context panel's entity card store the same way a click does, so the
panel opens on its details; the docked assistant panel then steps down so it
shows. track_entity reports the id it tracked. Nothing opens in Cockpit,
where Context is hidden.

* fix(voice): a slow selection never replaces a card picked since; Cockpit is read from its own state

The entity card store counts selections and clears. A voice or chat
selection notes that count when it is asked and opens its card only if no
other card was picked or cleared before it finished. Whether Cockpit is
running is read from the style manager's Cockpit state when it has one.

* Add the changelog entry

* fix(voice): the app hands voice its Context card opener

The voice package no longer imports the entity card store. The app builds
the opener (createContextCardOpener) and passes it to the voice commands as
contextCard, which keeps the voice package inside its own boundary.
This commit is contained in:
Sameh Khamis authored and GitHub committed 2026-11-20 22:19:16 -08:00
1 parent fbbe6cd91f
commit 918435ddc7
10 files changed
+419 -14

No files matched your search

+40
View File
@@ -357,6 +357,13 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
* @param {boolean} [options.fly] Also fly the camera to it.
* @returns {boolean} Whether a card could be made.
*/
/**
* Counts card selections and clears, so a selection that was asked for
* before a newer one can tell it came too late.
*/
let generation = 0;
const selectionGeneration = () => generation;
/** Things that move are followed as soon as they are picked. */
const AUTO_FOLLOW = new Set(['flights', 'military', 'satellites']);
/**
@@ -374,6 +381,7 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
*/
function select(identity, { fly = false, follow: autoFollow = true } = {}) {
if (!read(identity)) return false;
generation++;
stopLocating();
away.value = false;
reference =
@@ -403,6 +411,7 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
}
function clear() {
generation++;
if (following.value) shell.value?.letGo?.(card.value);
following.value = null;
asked = null;
@@ -451,6 +460,7 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
locate,
connect,
select,
selectionGeneration,
clear,
refresh,
flyTo,
@@ -477,3 +487,33 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
askAboutView,
};
});
/**
* Opens what a voice or chat action selected in the Context panel, as a click
* on it does (`src/ui/entityContextBridge.js` selects the same way): its card
* opens, and the panel with it. The app hands it to voice, which reads
* `generation()` when a selection is asked and passes it back as `since`.
* The action has already selected or followed the item in its own layer, so
* the card does not follow it again (a click on a flight does not either). A
* card picked or cleared since the action was asked stays, and nothing opens
* in Cockpit, where Context is hidden.
* @param {import('pinia').Pinia} pinia
* @returns {{generation: () => number, show: (identity: {layerId: string, id: string|number, label?: string, lat?: number, lon?: number}, options?: {since?: number|null, cockpitActive?: boolean}) => boolean}}
*/
export function createContextCardOpener(pinia) {
const store = () => useEntityCardStore(pinia);
return {
generation: () => store().selectionGeneration(),
show(identity, { since = null, cockpitActive = false } = {}) {
if (!identity?.layerId || identity.id == null || identity.id === '')
return false;
if (cockpitActive) return false;
if (since !== null && store().selectionGeneration() !== since)
return false;
return store().select(
{ ...identity, id: String(identity.id) },
{ follow: false },
);
},
};
}