Merge branch 'main' into denis/gev-news-layer

Wildlife Sightings (#1591) published share token 9, so News takes the
next free token, 00. The token tests read the ledger before both where
they were written against it, and the README counts both layers.
This commit is contained in:
Denis Groshev committed 2026-11-06 12:33:13 +01:00
commit 2e87dd87eb
144 files changed
+26748 -489

No files matched your search

+1
View File
@@ -753,6 +753,7 @@ const schemas = [
type: 'string',
enum: ['once', 'continuous'],
},
pitchDeg: { type: 'number' },
},
required: ['motion'],
},
+17 -1
View File
@@ -56,7 +56,9 @@ test('the complete Realtime tool payload pins the manifest-generated layer relea
// area scopes and the osm-places layer; natural-region candidates and the
// tightened area tool wording follow review.
// control_cockpit states the own-layer entry rule (Contacts not required).
'9522ff6f6d640bede81c51cea6b9601439b08becc5bc20b7355aec24feb17e8d',
// move_camera tilt takes an optional pitchDeg angle, described as
// absolute with its -45 default, with steps sent as a direction.
'6a0d154e68beb787c4e20f12d29a5c86577dc343f3e71d8b5651998ea45d8c3c',
);
});
@@ -175,6 +177,8 @@ test('all legacy action arguments are byte-identical after removing the delibera
'stop',
]);
motion.enum = motion.enum.filter((value) => value !== 'rotate_globe');
// Tilt to an angle is additive.
delete property('move_camera').pitchDeg;
const panels = property('set_panel_open').panelId;
panels.enum = panels.enum.filter(
(id) =>
@@ -320,3 +324,15 @@ test('direct voice timeout schema accepts None and exact integers, rejects malfo
for (const minutes of [-1, 61, 1.5, '5'])
assert.ok(validateArgs(tool.parameters, { minutes }).length > 0);
});
test('tilt accepts an angle with no direction', () => {
const schema = GEV_ACTION_SCHEMAS.find(
(tool) => tool.name === 'move_camera',
).parameters;
assert.deepEqual(validateArgs(schema, { motion: 'tilt', pitchDeg: -45 }), []);
assert.deepEqual(validateArgs(schema, { motion: 'tilt' }), []);
// No range in the schema (prompt budget): the runner clamps to -89..-5.
assert.ok(
validateArgs(schema, { motion: 'tilt', pitchDeg: 'steep' }).length > 0,
);
});
+9
View File
@@ -184,6 +184,9 @@ export class GeminiSessionController {
this.model = null;
this.epoch = 0;
this.turn = 0;
// Identifies one turn's tool calls to the runner as one reply; a new
// object each turn, so no two sessions or turns share it.
this.turnReply = {};
this.globeToolsBlocked = false;
this.globeResetFailed = false;
this.inputGeneration = 0;
@@ -971,6 +974,7 @@ export class GeminiSessionController {
const tools = [...this.tools.values()];
this.turnAbort = new AbortController();
this.turn++;
this.turnReply = {};
this.typedIntent = null;
this.radioStrongerCommit = null;
this.pruneControls();
@@ -1544,6 +1548,7 @@ export class GeminiSessionController {
)
throw new Error(msg('Gemini requested too many simultaneous actions'));
const turn = this.turn;
const reply = this.turnReply;
this.userTurnPending = false;
this.modelComplete = false;
// Admit each valid native call ID once per connection.
@@ -1565,6 +1570,7 @@ export class GeminiSessionController {
const action = new AbortController();
action.call = { id: call.id, name: call.name };
action.sequence = ++this.toolSequence;
action.reply = reply;
this.tools.set(call.id, action);
const priorTools = this.toolQueue;
const args =
@@ -1674,6 +1680,9 @@ export class GeminiSessionController {
this.runAction(call.name, args, {
signal: toolSignal,
callId: call.id,
// Calls run one by one, so a motion can follow a fly-to of the
// same reply that already found nothing.
reply: action.reply,
progress: (update) => {
if (actionCurrent()) this.narration.progress(call.id, update);
},
+28
View File
@@ -1241,6 +1241,34 @@ test('successful stronger Radio stop still invalidates the prepared group', asyn
h.c.stop();
});
test('Gemini tools of one turn share a reply identity, and a new turn gets another', async () => {
const replies = [];
const h = harness({
runAction: (name, _args, next) => {
replies.push([name, next.reply]);
return { ok: true, action: name };
},
});
await h.c.start({ pushToTalk: true });
h.c.sendTextCommand('Fly to Xyzzyville and pan left');
const ws = h.sockets[0];
requestTool(ws, 'fly', 'fly_to_location', { query: 'Xyzzyville' });
requestTool(ws, 'pan', 'move_camera', { motion: 'pan', direction: 'left' });
await h.c.toolQueue;
assert.equal(replies.length, 2);
assert.ok(replies[0][1], 'a sequentially run call carries its reply');
assert.equal(replies[1][1], replies[0][1]);
drainRadioReply(h);
await tick();
assert.equal(h.c.sendTextCommand('Pan left'), true);
requestTool(ws, 'pan-2', 'move_camera', { motion: 'pan', direction: 'left' });
await h.c.toolQueue;
assert.equal(replies.length, 3);
assert.ok(replies[2][1]);
assert.notEqual(replies[2][1], replies[0][1]);
h.c.stop();
});
test('slow Gemini tools reuse shared progress timing without injecting a conversation turn', async () => {
const pending = deferred();
let options;
+328 -17
View File
@@ -47,6 +47,9 @@ import {
flyRoute,
interruptCameraMotion,
adjustOrbitRange,
manualCameraInputCount,
moveCameraArgsError,
getActiveCameraMotion,
} from '../cameraVerbs.js';
import * as defaultFloorServices from '../data/groundFloor.js';
import { isPickedWorldPosition } from '../data/scenePick.js';
@@ -286,6 +289,28 @@ export function createGevActionRunner({
? { ...SPEECH_BUILDERS, ...speechBuilders }
: SPEECH_BUILDERS;
const _layerEnabledAt = new Map();
// The latest voice flight. A tilt, orbit, pan or rotate in the same reply
// as "fly to X" waits for it to land: run at once, its navigation
// cancelled the flight, or the flight (still geocoding) then replaced the
// motion. The wait follows later fly-tos (voiceFlightTarget).
let voiceFlight = null;
// Waiters to tell when a newer voice flight begins.
const voiceFlightWatchers = new Set();
// Camera handoffs (navigation stamps) seen, and how many of them voice
// fly-tos made. A search, share link or import that stamps during a flight
// leaves it flying; the motion queued behind it then yields to that one.
// The voice fly-tos of the latest reply that sent one: whether any moved
// the camera, and whether one found nothing. A motion of that reply run
// after its fly-to found nothing (Gemini runs a reply's calls one by one)
// has no flight to wait on, and must not move the old view instead.
let replyFlights = null;
let cameraHandoffs = 0;
let voiceFlightHandoffs = 0;
const otherHandoffs = () => cameraHandoffs - voiceFlightHandoffs;
const unsubscribeCameraHandoff =
styleManager?.subscribeCameraHandoff?.(() => {
cameraHandoffs += 1;
}) ?? null;
let analystEngine;
// Area handles live for this runner (the page): resolve_area, the
// analyst's region/area/drawn scopes, find_imagery and osm_query all read
@@ -427,13 +452,30 @@ export function createGevActionRunner({
const zoomOut = String(args.direction || '').toLowerCase() === 'out';
const amt = String(args.amount || 'medium').toLowerCase();
const factor = { little: 1.25, medium: 1.6, lot: 2.4 }[amt] || 1.6;
if (adjustOrbitRange(zoomOut ? factor : 1 / factor)) {
const held = adjustOrbitRange(zoomOut ? factor : 1 / factor);
if (held) {
const direction = zoomOut ? 'out' : 'in';
if (!held.changed) {
return {
ok: false,
action: 'adjust_camera_zoom',
direction,
amount: amt,
error: `Not zoomed: the ${held.kind} is already at its ${zoomOut ? 'farthest' : 'closest'} range.`,
};
}
return {
ok: true,
action: 'adjust_camera_zoom',
direction: zoomOut ? 'out' : 'in',
direction,
amount: amt,
orbitRadiusAdjusted: true,
[held.kind === 'tilt' ? 'tiltRangeAdjusted' : 'orbitRadiusAdjusted']:
true,
// A tilt to an angle names the angle the new range now ends it at.
...(held.pitchDeg !== undefined && {
pitchDeg: held.pitchDeg,
note: held.note,
}),
};
}
}
@@ -1125,34 +1167,104 @@ export function createGevActionRunner({
runOptions,
);
}
return flyToRequestedLocation(viewer, args, {
// Chained fly-tos: a grab during an earlier one still flying counts.
// The flight replaced is the last one that moved, past lookups that
// found nothing.
const prior = voiceFlightTarget(voiceFlight);
const flight = trackVoiceFlight(
prior && !prior.done ? prior.inputCount : undefined,
prior,
);
// Navigation by anything but a voice fly-to since this one began.
flight.handoffs = otherHandoffs();
voiceFlight = flight;
const reply = voiceReplyOf(runOptions);
if (reply !== null && replyFlights?.reply !== reply)
replyFlights = { reply, moved: false, foundNothing: false };
const replyRecord = reply !== null ? replyFlights : null;
for (const notify of [...voiceFlightWatchers]) notify();
// A motion already running (one the model sent before this fly-to) is
// stopped when the flight takes navigation; the result says so.
let stoppedMotion = null;
const noteStop =
(hook) =>
(...hookArgs) => {
const before = getActiveCameraMotion();
const handoffsBefore = cameraHandoffs;
try {
return hook(...hookArgs);
} finally {
// A voice fly-to's own stamps are not another navigation, even
// for the flight it replaces (a later lookup may find nothing).
voiceFlightHandoffs += cameraHandoffs - handoffsBefore;
if (
before &&
!stoppedMotion &&
getActiveCameraMotion()?.motionId !== before.motionId
)
stoppedMotion = before.kind;
}
};
const flown = flyToRequestedLocation(viewer, args, {
onFlightEnd: flight.settle,
onProgress: reportProgress,
placeSearch,
searchNavigation,
signal: runOptions.signal,
runImmediate:
typeof styleManager?.runImmediateLocationNavigation === 'function'
? (navigate) =>
styleManager.runImmediateLocationNavigation(navigate)
? noteStop((navigate) =>
styleManager.runImmediateLocationNavigation(navigate),
)
: null,
beginDeferred:
typeof styleManager?.beginDeferredLocationNavigation === 'function'
? () => styleManager.beginDeferredLocationNavigation()
? noteStop(() => styleManager.beginDeferredLocationNavigation())
: null,
reassertDeferred:
typeof styleManager?.reassertDeferredLocationNavigation === 'function'
? (generation) =>
styleManager.reassertDeferredLocationNavigation(generation)
? noteStop((generation) =>
styleManager.reassertDeferredLocationNavigation(generation),
)
: null,
onStart: () => {
onStart: noteStop(() => {
if (typeof styleManager?.beginLocationNavigation === 'function') {
styleManager.beginLocationNavigation();
return;
}
interruptCameraMotion('nav:fly_to_location');
if (viewer.trackedEntity) stopAllTracking(viewer, dataManager);
},
}),
});
// No flight started: nothing to wait for. A lookup that was not found,
// threw, or was cancelled once a newer voice fly-to had begun (which
// takes navigation from it) moved nothing, so a queued motion looks
// past it to the flight it replaced. One cancelled while still the
// latest voice flight lost navigation to something else (a search, a
// share link, Cockpit): the motion then refuses. A flight its own hooks
// already settled (cancelled mid-air) keeps its status.
const notStarted = () => {
if (!flight.done) flight.movedNothing = true;
flight.settle('failed');
};
flown.then((result) => {
if (result?.ok === true) return;
if (result?.cancelled && voiceFlight === flight)
flight.settle('failed');
else notStarted();
}, notStarted);
// After the outcome above, which marks a lookup that moved nothing.
const noteReply = (result) => {
if (!replyRecord) return;
if (result?.ok === true) replyRecord.moved = true;
else if (flight.movedNothing) replyRecord.foundNothing = true;
};
flown.then(noteReply, () => noteReply(null));
return flown.then((result) =>
stoppedMotion && result && typeof result === 'object'
? { ...result, stoppedMotion }
: result,
);
}
if (name === 'adjust_camera_zoom') {
@@ -1254,6 +1366,85 @@ export function createGevActionRunner({
}
if (name === 'move_camera') {
const motion = String(args.motion || '').toLowerCase();
// A lookup that already found nothing does not hide the last flight
// that moved: running now would cancel that flight mid-air.
const pending = voiceFlightTarget(voiceFlight);
const reply = voiceReplyOf(runOptions);
if (
VOICE_FLIGHT_WAITING_MOTIONS.has(motion) &&
!(pending && !pending.done) &&
reply !== null &&
replyFlights?.reply === reply &&
replyFlights.foundNothing &&
!replyFlights.moved
)
return {
ok: false,
action: 'move_camera',
motion,
error: `Not run: the fly-to in this reply found nothing, so the ${motion} was not run at the old view.`,
};
if (
VOICE_FLIGHT_WAITING_MOTIONS.has(motion) &&
pending &&
!pending.done
) {
// Bad arguments are refused now, not after waiting on the flight.
const argsError = moveCameraArgsError(args);
if (argsError) return argsError;
const deadline = Date.now() + VOICE_FLIGHT_WAIT_MS;
const start = pending;
// Act on where the camera lands. Whatever a flight reports, a later
// fly-to replaces it, and the wait moves to that one as soon as it
// begins (a stalled geocode must not hold the motion past a newer
// flight that landed). A geocode that loses navigation reports
// failed, and a flight left flying while the next place is looked up
// can still land; running there would take navigation and cancel the
// newer one. A later lookup that found nothing moved nothing, so the
// motion looks past it to the last flight that did move the camera.
let flight = start;
let status;
for (;;) {
status = await waitForVoiceFlight(
flight,
runOptions.signal,
deadline,
voiceFlightWatchers,
);
if (status === 'aborted' || status === 'timeout' || !current()) break;
const target = voiceFlightTarget(voiceFlight, start);
if (!target || (target === flight && status !== 'newer')) break;
flight = target;
}
if (!current())
return { ok: false, action: 'move_camera', cancelled: true };
if (status !== 'arrived' || flight.movedNothing)
return {
ok: false,
action: 'move_camera',
motion,
error: `Not run: the flight this ${motion} was waiting for did not arrive.`,
};
// The flight lands even when the user grabs the globe mid-flight;
// the queued motion must not take the camera back from them.
if (manualCameraInputCount() !== flight.inputCount)
return {
ok: false,
action: 'move_camera',
motion,
error: `Not run: the user moved the camera during the flight, so the ${motion} was dropped.`,
};
// A search, share link or import that took navigation during the
// flight leaves it flying; running now would cancel that navigation.
if (otherHandoffs() !== flight.handoffs)
return {
ok: false,
action: 'move_camera',
motion,
error: `Not run: another navigation took the camera during the flight, so the ${motion} was dropped.`,
};
}
return moveCamera(args, (navigate, releaseOptions) =>
runManagedVoiceNavigation(
styleManager,
@@ -1569,6 +1760,7 @@ export function createGevActionRunner({
* forget the analyst's "last answer". Area handles stay (page lifetime).
*/
runVoiceAction.resetConversation = () => {
replyFlights = null;
conversationAbort.abort();
conversationAbort = new AbortController();
conversation++;
@@ -1582,6 +1774,7 @@ export function createGevActionRunner({
if (disposed) return;
runVoiceAction.resetConversation();
disposed = true;
unsubscribeCameraHandoff?.();
voiceAreas.dispose();
};
return runVoiceAction;
@@ -2854,6 +3047,116 @@ async function frameOverhead(viewer, dataManager, styleManager, args = {}) {
);
}
let voiceFlightCount = 0;
/**
* The model reply a voice call belongs to: Gemini's turn (`reply`), or the
* OpenAI response its sibling calls share (`authorityGroup`). Null when the
* caller names none.
*/
function voiceReplyOf(options) {
return options?.reply ?? options?.authorityGroup ?? null;
}
/**
* A voice flight's end: 'arrived', 'cancelled' or 'failed', settled once.
* `replaced` is the last flight that moved when this one began (past lookups
* that found nothing), landed or not. It is kept only while this one may turn
* out to have moved nothing (a lookup that found no place), so a queued
* motion can look past it to that flight and its outcome.
*/
function trackVoiceFlight(
inputCount = manualCameraInputCount(),
replaced = null,
) {
const flight = {
done: false,
seq: (voiceFlightCount += 1),
replaced,
movedNothing: false,
// Manual input after this means the user took the camera mid-flight.
inputCount,
status: null,
// Waiters to tell when this flight ends.
watchers: new Set(),
settle: (status) => {
if (flight.done) return;
flight.done = true;
flight.status = status;
// Kept only past a lookup that found nothing, and then straight to the
// flight that moved, so a run of such lookups holds no chain.
flight.replaced = flight.movedNothing
? voiceFlightTarget(flight.replaced)
: null;
for (const notify of [...flight.watchers]) notify(status);
flight.watchers.clear();
},
};
return flight;
}
/**
* The flight a motion queued since `start` acts on: the latest one that
* actually started. A lookup that found nothing moved nothing, so look past
* it to the flight it replaced, but never to one older than `start` (a flight
* from an earlier reply). Null when every later lookup found nothing. With
* no `start`, the latest flight that started, back through lookups that
* found nothing.
*/
function voiceFlightTarget(latest, start = null) {
let flight = latest;
while (flight?.movedNothing) flight = flight.replaced;
return flight && (!start || flight.seq >= start.seq) ? flight : null;
}
/**
* Longest a motion waits for its flight (geocode plus flight, which is about
* 2 s) before giving up. The wait also holds the tool output, and on Gemini
* the later tools in the turn.
*/
const VOICE_FLIGHT_WAIT_MS = 15_000;
/**
* Motions that act on the place the camera ends up at, so one sent beside a
* fly-to waits for it. Stop is not one, and rotate_globe turns the
* whole Earth from Globe View rather than at a place.
*/
const VOICE_FLIGHT_WAITING_MOTIONS = new Set([
'tilt',
'orbit',
'pan',
'rotate',
]);
/**
* Wait for a voice flight to end, or for a newer one to begin ('newer'):
* 'timeout' or 'aborted' if neither happens. A flight that has ended answers
* at once. Every listener is removed when the wait ends, so a flight that
* never settles holds nothing.
*/
function waitForVoiceFlight(flight, signal, deadline, newerWatchers) {
if (signal?.aborted) return Promise.resolve('aborted');
if (flight.done) return Promise.resolve(flight.status);
return new Promise((resolve) => {
const finish = (status) => {
clearTimeout(timer);
signal?.removeEventListener?.('abort', onAbort);
flight.watchers.delete(finish);
newerWatchers?.delete(onNewer);
resolve(status);
};
const onAbort = () => finish('aborted');
const onNewer = () => finish('newer');
const timer = setTimeout(
() => finish('timeout'),
Math.max(0, deadline - Date.now()),
);
signal?.addEventListener?.('abort', onAbort, { once: true });
flight.watchers.add(finish);
newerWatchers?.add(onNewer);
});
}
/** Run one validated voice camera mutation through the UI-owned authority seam. */
function runManagedVoiceNavigation(
styleManager,
@@ -3417,6 +3720,7 @@ async function flyToRequestedLocation(
runImmediate = null,
beginDeferred = null,
reassertDeferred = null,
onFlightEnd = null,
} = {},
) {
const requestedRangeM = Number(args.rangeM);
@@ -3440,12 +3744,19 @@ async function flyToRequestedLocation(
settleArrival = resolve;
})
: null;
const arrivalHooks = arrival
? {
onComplete: () => settleArrival?.('arrived'),
onCancel: () => settleArrival?.('cancelled'),
}
: {};
const arrivalHooks =
arrival || onFlightEnd
? {
onComplete: () => {
settleArrival?.('arrived');
onFlightEnd?.('arrived');
},
onCancel: () => {
settleArrival?.('cancelled');
onFlightEnd?.('cancelled');
},
}
: {};
const afterArrival = async (result, label) => {
if (!arrival || result?.ok !== true) return result;
onProgress('fly', label);
+853 -5
View File
@@ -143,6 +143,14 @@ test('track_entity runner narrates a callsign-less aircraft by its registration'
function createVoiceNavigationHarness({ cockpitActive = false } = {}) {
const order = [];
let generation = 0;
// Camera handoffs, published on every navigation stamp as the shell does.
const handoffListeners = new Set();
const stamp = (noun) => {
generation += 1;
order.push(`stamp:${noun}`);
for (const listener of [...handoffListeners]) listener({ generation });
return generation;
};
const position = Cesium.Cartesian3.fromDegrees(-97.74, 30.26, 500);
const viewer = {
trackedEntity: { id: 'prior-aircraft' },
@@ -179,11 +187,7 @@ function createVoiceNavigationHarness({ cockpitActive = false } = {}) {
return runExplicitNavigation({
cockpitActive,
noun,
stamp: () => {
generation += 1;
order.push(`stamp:${noun}`);
return generation;
},
stamp: () => stamp(noun),
release: () => {
order.push('release');
viewer.trackedEntity = undefined;
@@ -195,12 +199,21 @@ function createVoiceNavigationHarness({ cockpitActive = false } = {}) {
});
},
getDetectionState: () => ({ detectionMode: 'DENSE' }),
subscribeCameraHandoff(listener) {
handoffListeners.add(listener);
return () => handoffListeners.delete(listener);
},
// A voice lookup stamps when it begins and leaves any flight flying.
beginDeferredLocationNavigation: () => stamp('location-lookup'),
reassertDeferredLocationNavigation: (stamped) => stamped === generation,
};
return {
order,
viewer,
styleManager,
currentGeneration: () => generation,
// A location-panel search: a deferred stamp that leaves a flight flying.
panelSearch: () => stamp('panel-search'),
};
}
@@ -276,6 +289,841 @@ test('dependent voice navigation waits for the destination viewport to arrive',
assert.equal(result.arrived, true);
});
// "fly to London and tilt the camera" arrives as two sibling calls.
// Run at once, the tilt's navigation cancelled the flight; with a geocoded
// place, the late flight replaced the tilt.
function tiltAfterFlightHarness() {
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
const harness = createVoiceNavigationHarness();
const { viewer, styleManager } = harness;
const flights = [];
viewer.camera.flyTo = (options) => {
harness.order.push('fly');
flights.push(options);
};
styleManager.runImmediateLocationNavigation = (navigate) => (
styleManager.runImmediateNavigation('location', navigate)
);
return { ...harness, flights };
}
const settledYet = (promise) => {
let settled = false;
promise.then(() => { settled = true; });
return () => settled;
};
test('a tilt in the same reply as a fly-to waits for the flight to land', async () => {
const { viewer, styleManager, order, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
const fly = await runner('fly_to_location', { locationId: 'austin' });
assert.equal(fly.ok, true);
const tilt = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
const tiltDone = settledYet(tilt);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(tiltDone(), false, 'the tilt must wait while the camera flies');
assert.equal(
order.slice(order.indexOf('fly')).includes('cancel'),
false,
'the tilt must not cancel the flight',
);
flights[0].complete();
const result = await tilt;
assert.equal(result.ok, true);
assert.equal(result.motion, 'tilt');
});
test('a tilt waits through a geocoded fly-to search, then for its flight', async () => {
const { viewer, styleManager } = tiltAfterFlightHarness();
let finishSearch;
let landFlight;
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
finishSearch = () => {
landFlight = options.onComplete;
resolve({ label: query, navigationMode: 'city-overview' });
};
}),
});
const fly = runner('fly_to_location', { query: 'Somewhere Far' });
const tilt = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
const tiltDone = settledYet(tilt);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(tiltDone(), false, 'the tilt must wait for the place lookup');
finishSearch();
assert.equal((await fly).ok, true);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(tiltDone(), false, 'the tilt must wait for the flight too');
landFlight();
assert.equal((await tilt).ok, true);
});
test('a tilt waiting on a flight that never lands is not run', async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
await runner('fly_to_location', { locationId: 'austin' });
const tilt = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
flights[0].cancel();
const result = await tilt;
assert.equal(result.ok, false);
assert.match(result.error, /did not arrive/);
});
test('a tilt beside a fly-to that found nothing is not run', async () => {
const { viewer, styleManager } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: async () => null,
});
const fly = runner('fly_to_location', { query: 'Nowhere' });
const tilt = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
assert.equal((await fly).ok, false);
// Nothing flew: the tilt answers at once and honestly, never at the old view.
const result = await tilt;
assert.equal(result.ok, false);
assert.match(result.error, /did not arrive/);
// A later, separate tilt is not held by the failed lookup.
assert.equal((await runner('move_camera', { motion: 'tilt', pitchDeg: -45 })).ok, true);
});
test('a tilt with no voice flight pending runs at once', async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
await runner('fly_to_location', { locationId: 'austin' });
flights[0].complete();
const result = await runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
assert.equal(result.ok, true);
});
// Orbit, pan and rotate also act at the place the camera ends up, so "fly to
// Paris and orbit it" holds the orbit the same way.
for (const motion of [
{ motion: 'orbit' },
{ motion: 'pan', direction: 'left' },
{ motion: 'rotate', direction: 'right' },
]) {
test(`${motion.motion} in the same reply as a fly-to waits for the flight to land`, async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, order, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', motion);
const movedDone = settledYet(moved);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, `the ${motion.motion} must wait while the camera flies`);
assert.equal(
order.slice(order.indexOf('fly')).includes('cancel'),
false,
`the ${motion.motion} must not cancel the flight`,
);
flights[0].complete();
const result = await moved;
assert.equal(result.ok, true);
assert.equal(result.motion, motion.motion);
});
test(`${motion.motion} waits through a geocoded fly-to search, then for its flight`, async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager } = tiltAfterFlightHarness();
let finishSearch;
let landFlight;
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
finishSearch = () => {
landFlight = options.onComplete;
resolve({ label: query, navigationMode: 'city-overview' });
};
}),
});
const fly = runner('fly_to_location', { query: 'Somewhere Far' });
const moved = runner('move_camera', motion);
const movedDone = settledYet(moved);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, `the ${motion.motion} must wait for the place lookup`);
assert.equal(getActiveCameraMotion(), null, 'nothing moves before the flight');
finishSearch();
assert.equal((await fly).ok, true);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, `the ${motion.motion} must wait for the flight too`);
landFlight();
assert.equal((await moved).ok, true);
assert.equal(getActiveCameraMotion()?.kind, motion.motion);
});
test(`${motion.motion} waiting on a flight that never lands is not run`, async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
await runner('fly_to_location', { locationId: 'austin' });
const moved = runner('move_camera', motion);
flights[0].cancel();
const result = await moved;
assert.equal(result.ok, false);
assert.equal(result.motion, motion.motion);
assert.match(result.error, new RegExp(`this ${motion.motion} was waiting for did not arrive`));
assert.equal(getActiveCameraMotion(), null);
});
}
// Cesium lands a flight even when the user grabs the globe mid-flight, so the
// motion queued behind it must not then take the camera back.
for (const motion of [
{ motion: 'orbit' },
{ motion: 'tilt', pitchDeg: -45 },
]) {
test(`${motion.motion} queued behind a fly-to is dropped when the user drags mid-flight`, async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const canvasListeners = new Map();
viewer.scene.canvas.addEventListener = (type, listener) => {
canvasListeners.set(type, listener);
};
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', motion);
canvasListeners.get('pointerdown')();
flights[0].complete();
const result = await moved;
assert.equal(result.ok, false);
assert.equal(result.motion, motion.motion);
assert.match(result.error, /moved the camera during the flight/);
assert.equal(getActiveCameraMotion(), null);
});
}
test('a drag during the first of two chained fly-tos still drops the queued motion', async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const canvasListeners = new Map();
viewer.scene.canvas.addEventListener = (type, listener) => {
canvasListeners.set(type, listener);
};
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
canvasListeners.get('touchstart')();
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'orbit' });
flights.at(-1).complete();
const result = await moved;
assert.equal(result.ok, false);
assert.match(result.error, /moved the camera during the flight/);
});
test('input before a fly-to does not drop the motion queued behind it', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const canvasListeners = new Map();
viewer.scene.canvas.addEventListener = (type, listener) => {
canvasListeners.set(type, listener);
};
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
canvasListeners.get('wheel')();
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'orbit' });
flights[0].complete();
assert.equal((await moved).ok, true);
});
test('a motion follows a later fly-to in the same reply that cancels its flight', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'orbit' });
const movedDone = settledYet(moved);
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
// The second flight supersedes the first, as Cesium's flyTo does.
flights[0].cancel();
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, 'the orbit must wait for the second flight');
flights[1].complete();
const result = await moved;
assert.equal(result.ok, true);
assert.equal(result.motion, 'orbit');
});
test('a motion follows a later fly-to whose start cancels its geocode', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
const flyA = runner('fly_to_location', { query: 'Place A' });
const moved = runner('move_camera', { motion: 'orbit' });
const movedDone = settledYet(moved);
const flyB = runner('fly_to_location', { query: 'Place B' });
await new Promise((resolve) => setTimeout(resolve, 0));
// B takes navigation authority, so A's lookup comes back cancelled.
searches[0].resolve({ cancelled: true });
assert.equal((await flyA).cancelled, true);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, 'the orbit must follow B, not drop');
searches[1].resolve({ label: 'Place B', navigationMode: 'city-overview' });
assert.equal((await flyB).ok, true);
searches[1].options.onComplete();
const result = await moved;
assert.equal(result.ok, true);
assert.equal(result.motion, 'orbit');
});
test('a motion does not run at a flight that lands while the next place is looked up', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, order, flights } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
const movedDone = settledYet(moved);
const flyB = runner('fly_to_location', { query: 'Place B' });
await new Promise((resolve) => setTimeout(resolve, 0));
// Deferred navigation leaves A flying while B is looked up, and A lands.
const before = order.length;
flights[0].complete();
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, 'the tilt must wait for B');
assert.equal(
order.slice(before).includes('cancel'),
false,
'the tilt must not take navigation and cancel B',
);
searches[0].resolve({ label: 'Place B', navigationMode: 'city-overview' });
assert.equal((await flyB).ok, true);
searches[0].options.onComplete();
const result = await moved;
assert.equal(result.ok, true);
assert.equal(result.motion, 'tilt');
});
// A later fly-to that finds nothing moves nothing: the motion still runs where
// the earlier flight lands, whether the lookup fails before or after that.
for (const order of ['lands first', 'not found first']) {
test(`a motion runs at its flight when a later fly-to finds nothing (${order})`, async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const harness = tiltAfterFlightHarness();
const { viewer, styleManager, flights } = harness;
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
const flyB = runner('fly_to_location', { query: 'Nowhere' });
await new Promise((resolve) => setTimeout(resolve, 0));
if (order === 'lands first') flights[0].complete();
searches[0].resolve(null);
assert.equal((await flyB).ok, false);
if (order !== 'lands first') flights[0].complete();
const result = await moved;
assert.equal(result.ok, true, result.error);
assert.equal(result.motion, 'tilt');
});
}
test('a motion beside a fly-to that finds nothing never acts at an earlier reply\'s flight', async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
// Reply 1: "fly to Austin", still flying.
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
// Reply 2: "fly to Nowhere and tilt".
const flyB = runner('fly_to_location', { query: 'Nowhere' });
const moved = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
await new Promise((resolve) => setTimeout(resolve, 0));
searches[0].resolve(null);
assert.equal((await flyB).ok, false);
flights[0].complete();
const result = await moved;
assert.equal(result.ok, false);
assert.match(result.error, /did not arrive/);
});
// Two later lookups that both find nothing, in either order, leave the motion
// acting where the first flight landed.
for (const first of [0, 1]) {
test(`a motion looks past two lookups that found nothing (lookup ${first + 1} fails first)`, async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'orbit' });
const flyB = runner('fly_to_location', { query: 'Nowhere B' });
const flyC = runner('fly_to_location', { query: 'Nowhere C' });
await new Promise((resolve) => setTimeout(resolve, 0));
searches[first].resolve(null);
searches[1 - first].resolve(null);
assert.equal((await flyB).ok, false);
assert.equal((await flyC).ok, false);
flights[0].complete();
const result = await moved;
assert.equal(result.ok, true, result.error);
});
}
test('a lookup cancelled by a newer one that finds nothing does not hide the flight that landed', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
const flyB = runner('fly_to_location', { query: 'Place B' });
const flyC = runner('fly_to_location', { query: 'Nowhere C' });
await new Promise((resolve) => setTimeout(resolve, 0));
flights[0].complete();
// C's start takes navigation from B's lookup; C then finds nothing.
searches[0].resolve({ cancelled: true });
searches[1].resolve(null);
assert.equal((await flyB).cancelled, true);
assert.equal((await flyC).ok, false);
const result = await moved;
assert.equal(result.ok, true, result.error);
});
test('a motion sent after a fly-to that found nothing still waits for the flight before it', async (t) => {
// Serial dispatch: "fly to Austin, fly to Nowhere, tilt", one call at a time.
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, order, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: async () => null,
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
assert.equal((await runner('fly_to_location', { query: 'Nowhere' })).ok, false);
const before = order.length;
const moved = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
const movedDone = settledYet(moved);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, 'the tilt must wait for the Austin flight');
assert.equal(order.slice(before).includes('cancel'), false);
flights[0].complete();
assert.equal((await moved).ok, true);
});
test('two lookups that found nothing in a row still leave the motion waiting for the flight', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, order, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: async () => null,
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
assert.equal((await runner('fly_to_location', { query: 'Nowhere' })).ok, false);
assert.equal((await runner('fly_to_location', { query: 'Nowhere 2' })).ok, false);
const before = order.length;
const moved = runner('move_camera', { motion: 'orbit' });
const movedDone = settledYet(moved);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), false, 'the orbit must wait for the Austin flight');
assert.equal(order.slice(before).includes('cancel'), false);
flights[0].complete();
assert.equal((await moved).ok, true);
});
// A flight that already settled is still what a later failed lookup replaced.
test('a motion acts at a landed flight that a later failed lookup replaced', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
const flyA = runner('fly_to_location', { query: 'Slow A' });
const moved = runner('move_camera', { motion: 'orbit' });
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
flights[0].complete();
const flyC = runner('fly_to_location', { query: 'Nowhere C' });
await new Promise((resolve) => setTimeout(resolve, 0));
// B's start made A's lookup stale; C then finds nothing.
searches[0].resolve({ cancelled: true });
searches[1].resolve(null);
assert.equal((await flyA).cancelled, true);
assert.equal((await flyC).ok, false);
const result = await moved;
assert.equal(result.ok, true, result.error);
});
test('a motion refuses when the flight a later failed lookup replaced was cancelled', async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'orbit' });
const flyA = runner('fly_to_location', { query: 'Slow A' });
await new Promise((resolve) => setTimeout(resolve, 0));
// The motion sees Austin land, then follows A's lookup.
flights[0].complete();
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
flights[1].cancel();
const flyC = runner('fly_to_location', { query: 'Nowhere C' });
await new Promise((resolve) => setTimeout(resolve, 0));
searches[0].resolve({ cancelled: true });
searches[1].resolve(null);
assert.equal((await flyA).cancelled, true);
assert.equal((await flyC).ok, false);
const result = await moved;
assert.equal(result.ok, false);
assert.match(result.error, /did not arrive/);
});
test('a stale motion does not follow a newer reply\'s fly-to', async () => {
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
let live = true;
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'orbit' }, { isCurrent: () => live });
// A newer reply takes over and flies elsewhere; this reply is stale.
live = false;
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
flights[0].cancel();
// The newer flight never lands here: following it would hold this answer.
const result = await Promise.race([
moved,
new Promise((resolve) => setTimeout(() => resolve('still waiting'), 50)),
]);
assert.notEqual(result, 'still waiting');
assert.equal(result.ok, false);
assert.equal(result.cancelled, true);
});
test('a motion gives up on a flight that has not landed in 15 s', async (t) => {
const { viewer, styleManager } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
t.mock.timers.enable({ apis: ['setTimeout', 'Date'] });
const moved = runner('move_camera', { motion: 'orbit' });
const movedDone = settledYet(moved);
await Promise.resolve();
t.mock.timers.tick(14_999);
await Promise.resolve();
assert.equal(movedDone(), false);
t.mock.timers.tick(1);
const result = await moved;
assert.equal(result.ok, false);
assert.match(result.error, /did not arrive/);
});
test('a motion follows a newer fly-to that lands while its own lookup stalls', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
// Place A's lookup never answers.
searchNavigation: () => new Promise(() => {}),
});
t.mock.timers.enable({ apis: ['setTimeout', 'Date'] });
runner('fly_to_location', { query: 'Place A' });
const moved = runner('move_camera', { motion: 'orbit' });
const movedDone = settledYet(moved);
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
t.mock.timers.tick(2_000);
await Promise.resolve();
assert.equal(movedDone(), false, 'the orbit must wait for the newer flight to land');
flights[0].complete();
for (let i = 0; i < 5 && !movedDone(); i += 1) await Promise.resolve();
assert.equal(movedDone(), true, 'the orbit must not wait out A');
const result = await moved;
assert.equal(result.ok, true);
assert.equal(result.motion, 'orbit');
});
// "Fly to Paris and orbit it", then a location-panel search while the camera
// flies: the search stamps a deferred navigation without stopping the flight.
// Run where the flight landed, the orbit took navigation and the search's
// reassert failed, so the search was silently dropped.
// Gemini runs one reply's calls one after another: by the time "pan left"
// runs, "fly to Xyzzyville" has already found nothing, so there is no flight
// to wait on, and the pan moved the old view with ok: true.
test('a motion run after its reply\'s fly-to found nothing is not run', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: async () => null,
});
const reply = { turn: 1 };
const fly = await runner('fly_to_location', { query: 'Xyzzyville' }, { reply });
assert.equal(fly.ok, false);
const pan = await runner(
'move_camera',
{ motion: 'pan', direction: 'left' },
{ reply },
);
assert.equal(pan.ok, false);
assert.match(pan.error, /Not run: the fly-to in this reply found nothing/);
assert.equal(getActiveCameraMotion(), null);
// The same holds for OpenAI's reply identity.
const group = 'response-1';
await runner('fly_to_location', { query: 'Xyzzyville' }, { authorityGroup: group });
const tilt = await runner(
'move_camera',
{ motion: 'tilt', pitchDeg: -45 },
{ authorityGroup: group },
);
assert.equal(tilt.ok, false);
assert.match(tilt.error, /found nothing/);
});
test('a motion in a later reply runs after a fly-to that found nothing', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: async () => null,
});
await runner('fly_to_location', { query: 'Xyzzyville' }, { reply: { turn: 1 } });
const pan = await runner(
'move_camera',
{ motion: 'pan', direction: 'left' },
{ reply: { turn: 2 } },
);
assert.equal(pan.ok, true, pan.error);
});
test('a motion runs at a flight of its reply that landed after another lookup found nothing', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: async () => null,
});
const reply = { turn: 1 };
await runner('fly_to_location', { query: 'Xyzzyville' }, { reply });
assert.equal((await runner('fly_to_location', { locationId: 'austin' }, { reply })).ok, true);
flights[0].complete();
const pan = await runner(
'move_camera',
{ motion: 'pan', direction: 'left' },
{ reply },
);
assert.equal(pan.ok, true, pan.error);
});
test('a motion queued behind a fly-to yields to a search started during the flight', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights, panelSearch, currentGeneration } =
tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'orbit' });
await new Promise((resolve) => setTimeout(resolve, 0));
const search = panelSearch();
flights[0].complete();
const result = await moved;
assert.equal(result.ok, false);
assert.match(result.error, /Not run: another navigation took the camera/);
assert.equal(getActiveCameraMotion(), null);
assert.equal(currentGeneration(), search, 'the search still owns navigation');
});
test('a motion behind a geocoded fly-to yields to a search started while it flies', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, panelSearch } = tiltAfterFlightHarness();
const searches = [];
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
searchNavigation: (_viewer, query, options) => new Promise((resolve) => {
searches.push({ query, options, resolve });
}),
});
const fly = runner('fly_to_location', { query: 'Place A' });
const moved = runner('move_camera', { motion: 'orbit' });
await new Promise((resolve) => setTimeout(resolve, 0));
searches[0].resolve({ label: 'Place A', navigationMode: 'city-overview' });
assert.equal((await fly).ok, true);
panelSearch();
searches[0].options.onComplete();
const result = await moved;
assert.equal(result.ok, false);
assert.match(result.error, /another navigation took the camera/);
assert.equal(getActiveCameraMotion(), null);
});
test('a search before the fly-to does not drop the motion queued behind it', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager, flights, panelSearch } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
panelSearch();
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'tilt', pitchDeg: -45 });
await new Promise((resolve) => setTimeout(resolve, 0));
flights[0].complete();
const result = await moved;
assert.equal(result.ok, true);
assert.equal(result.motion, 'tilt');
});
test('a fly-to that stops a running motion says so', async (t) => {
t.after(() => interruptCameraMotion('test-cleanup'));
const { viewer, styleManager } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
// The model sent the orbit first, so it ran at once.
const orbit = await runner('move_camera', { motion: 'orbit', mode: 'continuous' });
assert.equal(orbit.ok, true);
const fly = await runner('fly_to_location', { locationId: 'austin' });
assert.equal(fly.ok, true);
assert.equal(fly.stoppedMotion, 'orbit');
const again = await runner('fly_to_location', { locationId: 'austin' });
assert.equal('stoppedMotion' in again, false);
});
test('bad move_camera arguments are refused without waiting for a flight', async () => {
const { viewer, styleManager } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
const moved = runner('move_camera', { motion: 'pan' });
const movedDone = settledYet(moved);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(movedDone(), true, 'the refusal must not wait on the flight');
const result = await moved;
assert.equal(result.ok, false);
assert.match(result.error, /needs a direction/);
});
test('stop does not wait for a voice flight', async () => {
const { viewer, styleManager } = tiltAfterFlightHarness();
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
});
await runner('fly_to_location', { locationId: 'austin' });
const result = await runner('move_camera', { motion: 'stop' });
assert.equal(result.ok, true);
assert.equal(result.motion, 'stop');
});
test('nearest-aircraft voice action serializes layer enable, arrival, refresh, airborne query, and selection', async () => {
globalThis.window = globalThis.window || {
clearTimeout,
+3 -1
View File
@@ -453,11 +453,13 @@ const layers = [
export const VOICE_OFF_LAYERS = Object.freeze({
'bhote-koshi-2026': 'scene-driven event layer (control_scene)',
'bhote-koshi-locator': 'scene-driven event layer (control_scene)',
// The Realtime prompt is at its 52,000-character budget; voice toggle and
// The Realtime prompt is at its 55,500-character budget; voice toggle and
// query for this layer wait until there is room.
'drone-airspace':
'informational airspace layer; no room in the prompt budget',
news: 'browsed in the News panel; voice tools are a later step',
'wildlife-sightings':
'community observation layer; no room in the prompt budget',
});
const TYPE_NAMES = Object.freeze({
+11 -5
View File
@@ -309,7 +309,10 @@ test('markup: the chip sits under the user caption with a screen-reader separato
assert.equal(pointer.hidden, true);
const separator = pointer.querySelector('.gev-voice-card-sr');
assert.equal(separator.textContent, ': ');
assert.equal(separator.previousElementSibling.id, 'gev-voice-card-pointer-kind');
assert.equal(
separator.previousElementSibling.id,
'gev-voice-card-pointer-kind',
);
});
test('deixis prompt lint: one short rule, and every sentinel it names exists in the schema', () => {
@@ -347,15 +350,18 @@ test('deixis prompt lint: one short rule, and every sentinel it names exists in
// the analyst area scopes) raised the ceiling to 55,500; tightening the
// AREAS rule and the area tool descriptions left it at 55,103 as measured
// below (every tool, osm_query included); main's Sea Marks and Ski Pistes
// layers bring it to 55,210, ~290 under. A new tool or rule has to fit
// under this ceiling.
// layers bring it to 55,210, and the tilt pitchDeg argument (with its -45
// default) and main's cockpit entry rule to 55,339. integrationContract's
// Overpass prompt is the tightest, at 55,499 (1 under). A new tool or rule
// has to fit under this ceiling.
const size = instructions.length + JSON.stringify(GEV_REALTIME_TOOLS).length;
assert.ok(size <= 55_500, `prompt size ${size}`);
});
test('after-tool speech allows returned items to answer requested lists and rankings', () => {
const rule = realtimeInstructions().split('\n').find(line => line.startsWith('AFTER TOOLS:'));
const rule = realtimeInstructions()
.split('\n')
.find((line) => line.startsWith('AFTER TOOLS:'));
assert.match(rule, /requested analyst list or ranking/);
assert.match(rule, /returned items.*returned values/);
assert.match(rule, /keep their order/);