mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Street Level: a landed link, a replaced photo and a retired lookup keep their state
- A link's photo step compares with the navigation token its own restore flight owned, so a navigation after the flight landed (while the layers still load) keeps the camera. - A request that switches the source keeps the open photo up until it is replaced (holdViewer), so EXPAND stays across sources. - A lookup given up while it looked leaves the open photo and the panel as they were, also when it found nothing or failed. - A failed replacement shows its error inside the expanded viewer. - A replacing lookup stops a playing Mapillary sequence before the found photo opens. - The action refuses coordinates outside the globe, keeps a name given with coordinates as its label, and fly: false keeps the camera only for coordinates (its test-only entity and query branches are gone). - Numbered entities carry their label; a view's street-level point is a pair. - Mapillary's nearest search always asks for 50 m and 100 images. - Tests: the lifecycle reproductions, PLAY on replacement, out-of-range coordinates, half a point, and the named label; three layer tests share enabledLayer; the second payload digest is gone. - Docs: the tool count, the panel freshness rule, armed: false, the photo replacement, the browser-gate comment and a shorter changelog fragment.
This commit is contained in:
1 parent
9c73939425
commit
f3996da0af
26 files changed
+470
-327
No files matched your search
@@ -58,32 +58,11 @@ test('the complete Realtime tool payload pins the manifest-generated layer relea
|
||||
// control_cockpit states the own-layer entry rule (Contacts not required).
|
||||
// move_camera tilt takes an optional pitchDeg angle, described as
|
||||
// absolute with its -45 default, with steps sent as a direction.
|
||||
// show_street_level (map, source, photo) is the only change on top of main.
|
||||
SHOW_STREET_LEVEL_PAYLOAD_DIGEST,
|
||||
);
|
||||
// Every shipped tool is byte-identical to the previous release: the new
|
||||
// tool is the whole difference, so a later edit cannot hide in a re-pin.
|
||||
const shipped = createHash('sha256')
|
||||
.update(
|
||||
JSON.stringify(
|
||||
stable(
|
||||
GEV_REALTIME_TOOLS.filter(
|
||||
(tool) =>
|
||||
!['set_cyber_sonar', 'show_street_level'].includes(tool.name),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.digest('hex');
|
||||
assert.equal(
|
||||
shipped,
|
||||
'6a0d154e68beb787c4e20f12d29a5c86577dc343f3e71d8b5651998ea45d8c3c',
|
||||
// show_street_level (map, source, photo) adds one tool.
|
||||
'0c27f62062001e6a07241cd301c3d357f55e9b74f66cd2904d16590510337468',
|
||||
);
|
||||
});
|
||||
|
||||
const SHOW_STREET_LEVEL_PAYLOAD_DIGEST =
|
||||
'0c27f62062001e6a07241cd301c3d357f55e9b74f66cd2904d16590510337468';
|
||||
|
||||
test('descriptions customize wording without changing immutable shared arguments', () => {
|
||||
const descriptions = {
|
||||
fly_to_location: {
|
||||
|
||||
@@ -143,6 +143,8 @@ function resolveFly(args, { pointer, referents }) {
|
||||
entity: {
|
||||
layerId: target.layerId,
|
||||
id: target.id,
|
||||
// The answer names it, not its id ("near cam-9").
|
||||
...(target.label ? { label: target.label } : {}),
|
||||
...(hasPosition(target) ? { lat: target.lat, lon: target.lon } : {}),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -104,7 +104,7 @@ test('referents: numbered items resolve for track, fly and context', () => {
|
||||
const last = resolveDeicticArgs('track_entity', { query: 'x', referent: -1 }, { referents });
|
||||
assert.equal(last.args.query, 'ccc333', '-1 is the last one');
|
||||
const fly = resolveDeicticArgs('fly_to_location', { referent: 1 }, { referents });
|
||||
assert.deepEqual(fly.args, { entity: { layerId: 'flights', id: 'aaa111' } }, 'moving contacts are located at run time');
|
||||
assert.deepEqual(fly.args, { entity: { layerId: 'flights', id: 'aaa111', label: 'SWA12' } }, 'moving contacts are located at run time');
|
||||
const context = resolveDeicticArgs('get_entity_context', { referent: 3 }, { referents });
|
||||
assert.equal(context.args.scope, 'target');
|
||||
assert.equal(context.args.target.label, 'AAL9');
|
||||
|
||||
+32
-40
@@ -3813,24 +3813,26 @@ function streetLevelPanelHidden() {
|
||||
}
|
||||
|
||||
/**
|
||||
* "Show me <place> on Street View / on Mapillary": fly to the place, make sure
|
||||
* the imagery source's map is up, light that source in Street Level, turn the
|
||||
* layer on and open the nearest image. One source at a time, as the panel
|
||||
* does; the choice persists like a chip click. The key is checked before
|
||||
* anything changes, and each stage reports its own failure so speech can say
|
||||
* which part did not happen. With no place at all, the view centre is used.
|
||||
* `autoOpen: false` (links, not the model) stops short of loading a photo
|
||||
* from a source that bills every load: the panel is armed and the OPEN
|
||||
* button is one click away.
|
||||
* "Show me <place> on Street View / on Mapillary": fly there, light the source
|
||||
* (and its map) and open the nearest image. Each stage reports its own
|
||||
* failure, so speech can say which part did not happen. `autoOpen: false`
|
||||
* (links) stops short of a billed load: the panel is armed for OPEN.
|
||||
*/
|
||||
export async function showStreetLevel(args, context) {
|
||||
// Every await can hand the request's moment to someone else: a newer turn,
|
||||
// a navigation or gesture that takes the camera, or a mode that hides the
|
||||
// panel. Each stage after the place is settled checks again.
|
||||
const owner = watchCameraOwner(context.viewer, context.styleManager);
|
||||
// A photo held up while the request switches its source is let go however
|
||||
// the request ends: replaced by then, or closed if its source stayed off.
|
||||
let releaseViewer = null;
|
||||
const holdViewer = (layerModule) => {
|
||||
releaseViewer ??= layerModule.holdViewer?.() ?? null;
|
||||
};
|
||||
try {
|
||||
return await requestStreetLevel(args, { ...context, owner });
|
||||
return await requestStreetLevel(args, { ...context, owner, holdViewer });
|
||||
} finally {
|
||||
releaseViewer?.();
|
||||
owner.stop();
|
||||
}
|
||||
}
|
||||
@@ -3840,9 +3842,9 @@ async function requestStreetLevel(
|
||||
{
|
||||
dataManager,
|
||||
styleManager,
|
||||
placeSearch,
|
||||
runGevAction,
|
||||
owner,
|
||||
holdViewer = () => {},
|
||||
runOptions = {},
|
||||
current = () => true,
|
||||
reportProgress = () => {},
|
||||
@@ -3868,11 +3870,14 @@ async function requestStreetLevel(
|
||||
const query = String(args.query || '').trim();
|
||||
const latitude = Number(args.latitude);
|
||||
const longitude = Number(args.longitude);
|
||||
const coordinatesGiven = args.latitude != null && args.longitude != null;
|
||||
const hasCoordinates =
|
||||
args.latitude != null &&
|
||||
args.longitude != null &&
|
||||
Number.isFinite(latitude) &&
|
||||
Number.isFinite(longitude);
|
||||
coordinatesGiven && Math.abs(latitude) <= 90 && Math.abs(longitude) <= 180;
|
||||
if (coordinatesGiven && !hasCoordinates)
|
||||
return fail(
|
||||
'location',
|
||||
'Latitude must be within ±90° and longitude within ±180°',
|
||||
);
|
||||
// A referent that is a layer entity (deixis): located when the flight starts.
|
||||
const entity =
|
||||
args.entity && typeof args.entity === 'object' && args.entity.id
|
||||
@@ -3952,29 +3957,11 @@ async function requestStreetLevel(
|
||||
atViewCentre = !query && !hasCoordinates && !entity;
|
||||
let point = null;
|
||||
let location = null;
|
||||
if (args.fly === false || atViewCentre) {
|
||||
// No place at all: the layer looks at the ground under the screen centre,
|
||||
// as the OPEN button does. `fly: false` (tests) keeps the camera for a
|
||||
// point given by its coordinates.
|
||||
if (atViewCentre || (args.fly === false && hasCoordinates)) {
|
||||
if (hasCoordinates) point = { lat: latitude, lon: longitude };
|
||||
else if (entity) {
|
||||
// Where it is now, as the flying path does: the coordinates a list
|
||||
// saved go stale as soon as the item moves or unloads.
|
||||
const located = locateLayerEntity(dataManager, entity);
|
||||
if (!located) return fail('location', `${label} is no longer loaded`);
|
||||
point = { lat: located.lat, lon: located.lon };
|
||||
} else if (query) {
|
||||
reportProgress('search', query);
|
||||
const outcome = await placeSearch.geocode(query, {
|
||||
signal: runOptions.signal,
|
||||
});
|
||||
const place = outcome?.place;
|
||||
if (!current())
|
||||
return fail('location', 'Street-level request was cancelled');
|
||||
if (!Number.isFinite(place?.lat) || !Number.isFinite(place?.lng))
|
||||
return fail('location', `Could not find ${query}`);
|
||||
point = { lat: place.lat, lon: place.lng };
|
||||
label = place.label || query;
|
||||
}
|
||||
// No place at all: the layer looks at the ground under the screen
|
||||
// centre, as the OPEN button does.
|
||||
} else {
|
||||
location = await runGevAction(
|
||||
'fly_to_location',
|
||||
@@ -3995,8 +3982,10 @@ async function requestStreetLevel(
|
||||
location?.error || `Could not arrive at ${location?.label || label}`,
|
||||
{ cancelled: !current() || Boolean(location?.cancelled), location },
|
||||
);
|
||||
// An item keeps its name: the flight to it reports only coordinates.
|
||||
label = entity ? label : location.label || label;
|
||||
// An item, or a named place flown to by its coordinates, keeps its name:
|
||||
// such a flight reports only coordinates.
|
||||
label =
|
||||
entity || (query && hasCoordinates) ? label : location.label || label;
|
||||
if (
|
||||
!Number.isFinite(location.latitude) ||
|
||||
!Number.isFinite(location.longitude)
|
||||
@@ -4037,7 +4026,10 @@ async function requestStreetLevel(
|
||||
if (stop) return stop;
|
||||
}
|
||||
|
||||
// Light the source the way a chip click does, so the choice is kept.
|
||||
// Light the source the way a chip click does, so the choice is kept. An
|
||||
// open photo of another source stays up until this request replaces it.
|
||||
if (layerModule.getUIState?.()?.street?.open === true)
|
||||
holdViewer(layerModule);
|
||||
const switches = Object.fromEntries(
|
||||
providerIds.map((id) => [id, id === provider]),
|
||||
);
|
||||
|
||||
@@ -6660,11 +6660,11 @@ function createStreetLevelHarness({
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Like the layer: a replacing lookup that opens nothing closes the photo.
|
||||
// Like the layer: a lookup its caller gave up leaves the panel alone,
|
||||
// and a replacing lookup that opens nothing closes the photo.
|
||||
if (options.proceed && options.proceed() !== true) return false;
|
||||
const closeReplaced = () => {
|
||||
if (!options.replace || !street.open) return;
|
||||
order.push('close');
|
||||
Object.assign(street, { open: false, imageId: null, error: null, nearestOutcome: null });
|
||||
if (options.replace && street.open) layer.closeViewer();
|
||||
};
|
||||
if (imageryError) {
|
||||
closeReplaced();
|
||||
@@ -6678,8 +6678,6 @@ function createStreetLevelHarness({
|
||||
street.error = `No street-level imagery within ${options.radiusM ?? 50} m of ${point ? 'that point' : 'the view centre'}`;
|
||||
return false;
|
||||
}
|
||||
// Found: it loads only if the request still wants it.
|
||||
if (options.proceed && options.proceed() !== true) return false;
|
||||
street.open = true;
|
||||
street.imageId = nearest;
|
||||
street.title = '10th St, Sacramento';
|
||||
@@ -6762,6 +6760,14 @@ test('show_street_level flies first, then switches the map, lights the source, t
|
||||
assert.equal(result.imageId, 'pano-a');
|
||||
assert.equal(result.title, '10th St, Sacramento');
|
||||
assert.equal(result.flew, true);
|
||||
// A name given with its coordinates is what the answer says.
|
||||
const named = createStreetLevelHarness();
|
||||
const naming = named.runner('show_street_level', {
|
||||
query: 'Capitol Mall', latitude: 38.5799, longitude: -121.4937, provider: 'google',
|
||||
});
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
named.finishFlight();
|
||||
assert.equal((await naming).label, 'Capitol Mall');
|
||||
});
|
||||
|
||||
test('show_street_level on Mapillary keeps the map, searches at the default radius and skips what is already on', async () => {
|
||||
@@ -6799,6 +6805,11 @@ test('show_street_level reports each stage it could not pass', async () => {
|
||||
assert.equal(none.label, 'the view centre');
|
||||
assert.deepEqual(centre.order, ['params:google:voice', 'open:google:250:false:view-centre']);
|
||||
|
||||
const offGlobe = createStreetLevelHarness({ enabled: true, activeStack: 'photoreal' });
|
||||
const outOfRange = await offGlobe.runner('show_street_level', { latitude: 95, longitude: 2, provider: 'google' });
|
||||
assert.deepEqual([outOfRange.ok, outOfRange.stage], [false, 'location']);
|
||||
assert.deepEqual(offGlobe.order, [], 'nothing flies, switches or looks up');
|
||||
|
||||
const unknown = await createStreetLevelHarness().runner('show_street_level', {
|
||||
latitude: 1, longitude: 2, provider: 'openstreetcam', fly: false,
|
||||
});
|
||||
@@ -6865,15 +6876,6 @@ test('show_street_level opens photos of a numbered item or a pointed spot throug
|
||||
assert.equal(result.ok, true, result.error);
|
||||
assert.equal(result.label, 'Camera 9');
|
||||
assert.deepEqual(order, ['fly', 'params:google:voice', 'open:google:250:false']);
|
||||
// Without a flight the entity's own position is used.
|
||||
const still = withCamera(createStreetLevelHarness({ enabled: true, activeStack: 'photoreal' }));
|
||||
const kept = await still.runner('show_street_level', {
|
||||
provider: 'google',
|
||||
fly: false,
|
||||
entity: { layerId: 'cctv', id: 'cam-9', lat: 38.58, lon: -121.5 },
|
||||
});
|
||||
assert.equal(kept.ok, true, kept.error);
|
||||
assert.deepEqual(still.order, ['params:google:voice', 'open:google:250:false']);
|
||||
});
|
||||
|
||||
test('show_street_level hands the point from a named place, a preset and a curated POI to the lookup', async () => {
|
||||
@@ -7003,43 +7005,9 @@ test('show_street_level tells a failed enable, a delisted source, a key refused
|
||||
assert.deepEqual(unconfigured.order, [], 'nothing changed');
|
||||
});
|
||||
|
||||
test('show_street_level without a flight geocodes a name, locates an item, and reports what it cannot place', async () => {
|
||||
test('show_street_level reports a flight that lands without a position', async () => {
|
||||
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
|
||||
const hit = createStreetLevelHarness({ enabled: true, activeStack: 'osm' });
|
||||
const points = [];
|
||||
const open = hit.layer.openNearest;
|
||||
hit.layer.openNearest = (point, options) => {
|
||||
points.push(point);
|
||||
return open(point, options);
|
||||
};
|
||||
const runner = createGevActionRunner({
|
||||
viewer: createVoiceNavigationHarness().viewer,
|
||||
styleManager: { mapStackController: { getActiveId: () => 'osm' }, setMapStack: async () => ({ ok: true }) },
|
||||
dataManager: hit.dataManager,
|
||||
placeSearch: {
|
||||
geocode: async (query) =>
|
||||
query === 'Capitol Mall'
|
||||
? { place: { lat: 38.5792, lng: -121.4958, label: 'Capitol Mall, Sacramento' } }
|
||||
: { place: null, answered: true },
|
||||
},
|
||||
});
|
||||
const found = await runner('show_street_level', { query: 'Capitol Mall', provider: 'mapillary', fly: false });
|
||||
assert.equal(found.ok, true, found.error);
|
||||
assert.equal(found.label, 'Capitol Mall, Sacramento');
|
||||
assert.deepEqual(points.at(-1), { lat: 38.5792, lon: -121.4958 });
|
||||
assert.equal(found.flew, false);
|
||||
|
||||
const miss = await runner('show_street_level', { query: 'Atlantis Boulevard', provider: 'mapillary', fly: false });
|
||||
assert.deepEqual([miss.ok, miss.stage], [false, 'location']);
|
||||
assert.equal(miss.say, "Couldn't find Atlantis Boulevard.");
|
||||
assert.equal(points.length, 1, 'a miss asks for no imagery');
|
||||
|
||||
const gone = await runner('show_street_level', {
|
||||
provider: 'mapillary', fly: false, entity: { layerId: 'cctv', id: 'cam-gone', label: 'Camera 7' },
|
||||
});
|
||||
assert.deepEqual([gone.ok, gone.stage], [false, 'location']);
|
||||
assert.equal(gone.say, "Couldn't find Camera 7.");
|
||||
|
||||
// A flight that reports no coordinates cannot be followed by a lookup.
|
||||
const noPoint = createGevActionRunner({
|
||||
viewer: createVoiceNavigationHarness().viewer,
|
||||
@@ -7105,20 +7073,6 @@ test('show_street_level says "refused its key" when Google already refused it, a
|
||||
assert.match(dark.error, /could not be switched on/);
|
||||
});
|
||||
|
||||
test('show_street_level without a flight needs the item where it is now, not where a list saw it', async () => {
|
||||
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
|
||||
const harness = createStreetLevelHarness({ enabled: true, activeStack: 'photoreal' });
|
||||
// The referent carries the coordinates the list saved, but it is no longer loaded.
|
||||
const stale = await harness.runner('show_street_level', {
|
||||
provider: 'google',
|
||||
fly: false,
|
||||
entity: { layerId: 'cctv', id: 'cam-gone', label: 'Camera 7', lat: 38.58, lon: -121.5 },
|
||||
});
|
||||
assert.deepEqual([stale.ok, stale.stage], [false, 'location']);
|
||||
assert.match(stale.error, /no longer loaded/);
|
||||
assert.ok(!harness.order.some((entry) => entry.startsWith('open:')), 'nothing looked up at the stale point');
|
||||
});
|
||||
|
||||
test('activeImageryFilter reports only the narrowing filters the lit source honours', async () => {
|
||||
const { activeImageryFilter } = await import('./gevActions.js');
|
||||
const both = { pano: true, since: true };
|
||||
@@ -7281,32 +7235,6 @@ test('a partial analyst card shows one partial chip', () => {
|
||||
assert.equal(new Set(labels).size, labels.length, JSON.stringify(labels));
|
||||
});
|
||||
|
||||
test('show_street_level superseded during its geocode changes nothing', async () => {
|
||||
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
|
||||
const h = createStreetLevelHarness({ enabled: true });
|
||||
let current = true;
|
||||
const runner = createGevActionRunner({
|
||||
viewer: createVoiceNavigationHarness().viewer,
|
||||
styleManager: {
|
||||
mapStackController: { getActiveId: () => 'osm' },
|
||||
setMapStack: async (id) => {
|
||||
h.order.push(`map:${id}`);
|
||||
return { ok: true };
|
||||
},
|
||||
},
|
||||
dataManager: h.dataManager,
|
||||
placeSearch: {
|
||||
geocode: async () => {
|
||||
current = false;
|
||||
return { place: { lat: 1, lng: 2, label: 'X' } };
|
||||
},
|
||||
},
|
||||
});
|
||||
const result = await runner('show_street_level', { query: 'X', provider: 'google', fly: false }, { isCurrent: () => current });
|
||||
assert.deepEqual(h.order.filter((step) => /^(map|params|open|arm)/.test(step)), [], 'the stale turn switched nothing');
|
||||
assert.deepEqual([result.ok, result.stage, result.cancelled], [false, 'location', true]);
|
||||
});
|
||||
|
||||
test('show_street_level superseded during its flight switches nothing', async () => {
|
||||
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
|
||||
const h = createStreetLevelHarness();
|
||||
|
||||
@@ -343,17 +343,9 @@ test('deixis prompt lint: one short rule, and every sentinel it names exists in
|
||||
tool('annotate_map').annotations.items.properties.target.description,
|
||||
/"pointer"/,
|
||||
);
|
||||
// Budget: the whole Realtime prompt (instructions + tools), measured in
|
||||
// characters. It was 56,308 after the area/imagery/OSM merge; stating each
|
||||
// policy once (WHERE precedence, AREAS routing, AFTER TOOLS speech) brought
|
||||
// it to 51,646. Voice geometry (resolve_area, find_imagery, osm_query and
|
||||
// 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, and the tilt pitchDeg argument (with its -45
|
||||
// default) and main's cockpit entry rule to 55,339. show_street_level (the
|
||||
// tool and its routing rule, ~940) raises it to 56,500. A new tool or rule
|
||||
// has to fit under this ceiling.
|
||||
// Budget: the whole Realtime prompt (instructions + every tool, osm_query
|
||||
// included), in characters. Every session pays for it in latency and cost,
|
||||
// so a new tool or rule has to fit under this ceiling or earn a raise.
|
||||
const size = instructions.length + JSON.stringify(GEV_REALTIME_TOOLS).length;
|
||||
assert.ok(size <= 56_500, `prompt size ${size}`);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user