fix(street-level): links keep the recipient's preferences; aim under the screen centre

Review fixes for gekh's #1113 round:
- a link runs show_street_level with origin 'programmatic', so its source
  switch and layer are not saved as the recipient's preferences;
- with no place named, the action looks under the screen centre
  (aim 'screen-centre', armed false), keeps the sky refusal and leaves a
  link's armed point alone;
- an armed OPEN aimed at the sky opens nothing instead of the far link point;
- an imagery-stage failure is spoken as an error, missing imagery as missing
  (street.nearestOutcome); the card says "the view centre" in the interface
  language;
- every photo the action opens reveals its panel, and revealPanel scrolls the
  panel into view in the phone sheet;
- embed: EXPAND survives embed's own clean view, the lifted photo hides in
  cockpit, recording and scene playback, and a failed photo step closes the
  earlier photo before the view flies;
- links pasted into an open tab run their street-level step after the
  restore settles; a superseded start link does not;
- Mapillary's nearest search gives up after 12 s, body included.
This commit is contained in:
Said Turksever committed 2026-11-05 18:25:21 +00:00
1 parent 3f55077c2c
commit 451f3e41cf
22 files changed
+716 -64

No files matched your search

+45 -5
View File
@@ -465,7 +465,7 @@ export function createGevActionRunner({
const pending = dataManager.getAll?.().find((l) => l.id === layerId);
reportProgress('layer', pending?.name || layerId);
}
const changeOptions = { origin: 'voice' };
const changeOptions = { origin: actionIntentOrigin(runOptions) };
if (runOptions.signal) changeOptions.signal = runOptions.signal;
let changed = false;
let changeError = null;
@@ -3446,6 +3446,18 @@ function normalizeStyle(value) {
return null;
}
/** The application panel that holds the street-level photo. */
const STREET_LEVEL_PANEL_ID = 'street-level-panel';
/**
* The layer-state origin of an action's changes. The assistant's are the
* user's own choices and persist; a link replays someone else's view
* (`origin: 'programmatic'`) and never writes the recipient's preferences.
*/
function actionIntentOrigin(runOptions) {
return runOptions?.origin === 'programmatic' ? 'programmatic' : 'voice';
}
/**
* "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
@@ -3482,8 +3494,10 @@ export async function showStreetLevel(
...(provider ? { provider } : {}),
...(providerName ? { providerName } : {}),
...(label ? { label } : {}),
...(atViewCentre ? { atViewCentre } : {}),
...extra,
});
let atViewCentre = false;
const query = String(args.query || '').trim();
const latitude = Number(args.latitude);
const longitude = Number(args.longitude);
@@ -3540,7 +3554,7 @@ export async function showStreetLevel(
(entity ? String(entity.label || entity.id) : '') ||
(hasCoordinates ? `${latitude.toFixed(4)}, ${longitude.toFixed(4)}` : '') ||
'the view centre';
const atViewCentre = !query && !hasCoordinates && !entity;
atViewCentre = !query && !hasCoordinates && !entity;
let point = null;
let location = null;
if (args.fly === false || atViewCentre) {
@@ -3564,7 +3578,8 @@ export async function showStreetLevel(
point = { lat: place.lat, lon: place.lng };
label = place.label || query;
}
// No place at all: the layer looks under the view centre.
// 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',
@@ -3646,7 +3661,7 @@ export async function showStreetLevel(
if (typeof dataManager.setLayerParams === 'function')
accepted =
dataManager.setLayerParams(STREET_LEVEL_LAYER_ID, switches, {
origin: 'voice',
origin: actionIntentOrigin(runOptions),
}) !== false;
else layerModule.setProviderEnabled?.(provider, true);
if (!accepted)
@@ -3712,6 +3727,9 @@ export async function showStreetLevel(
const opened = await layerModule.openNearest(point, {
providerIds: [provider],
frame: false,
// Under the screen centre, not the middle of a tilted view's footprint;
// this request is the user's own, not a link's armed one.
...(point ? {} : { aim: 'screen-centre', armed: false }),
...(runOptions.signal ? { signal: runOptions.signal } : {}),
...(snapshot.groundClick === true
? { radiusM: STREET_LEVEL_WIDE_RADIUS_M }
@@ -3744,6 +3762,19 @@ export async function showStreetLevel(
street.error || 'Street Level changed while it looked for imagery',
{ cancelled: true, location },
);
// The screen centre is sky: nothing was looked up.
if (street.nearestOutcome === 'sky')
return fail('imagery', street.error || 'Aim the view at a street', {
location,
aim: 'sky',
});
// The source or the viewer failed: an error, not missing coverage.
if (street.nearestOutcome !== 'empty')
return fail(
'imagery',
street.error || `${providerName} imagery could not be opened`,
{ location, imageryError: true },
);
// An imagery filter the source honours can hide every photo here; say
// so, or the answer reads as "no coverage" when one switch would do.
const filter = activeImageryFilter(layerModule.getUIState?.());
@@ -3751,9 +3782,17 @@ export async function showStreetLevel(
return fail(
'imagery',
filter ? `${reason} with the ${filter.label} on` : reason,
{ location, ...(filter ? { filter } : {}) },
{ location, noImagery: true, ...(filter ? { filter } : {}) },
);
}
// Every explicit request shows its photo, also one replacing a photo whose
// panel or phone sheet the user had closed. Embed mode lifts the photo.
if (!globalThis.document?.body?.classList?.contains('ui-embed')) {
styleManager?.setPanelCollapsed?.(STREET_LEVEL_PANEL_ID, false, {
persist: false,
});
styleManager?.revealPanel?.(STREET_LEVEL_PANEL_ID);
}
return {
ok: true,
action,
@@ -3767,6 +3806,7 @@ export async function showStreetLevel(
position: street.position ?? null,
externalUrl: street.externalUrl ?? null,
flew: location !== null,
...(atViewCentre ? { atViewCentre } : {}),
...(location ? { location: location.label } : {}),
};
}
+80 -2
View File
@@ -5715,8 +5715,13 @@ function createStreetLevelHarness({
duringLookup = null,
keyRejectedAtStart = false,
lightFails = false,
imageryError = null,
sky = false,
} = {}) {
const order = [];
const lookups = [];
const origins = [];
const revealed = [];
const { viewer, styleManager } = createVoiceNavigationHarness();
let completeFlight = null;
viewer.camera.lookAt = () => {};
@@ -5776,6 +5781,7 @@ function createStreetLevelHarness({
order.push(`arm:${options.providerIds.join('+')}:${options.radiusM ?? 'default'}:${point ? `${point.lat},${point.lon}` : 'view-centre'}`);
},
async openNearest(point, options) {
lookups.push({ point, ...options });
order.push(`open:${options.providerIds.join('+')}:${options.radiusM ?? 'default'}:${options.frame}${point ? '' : ':view-centre'}`);
if (options.signal?.aborted) return false;
if (duringLookup) {
@@ -5790,7 +5796,13 @@ function createStreetLevelHarness({
return false;
}
}
if (imageryError) {
street.error = imageryError;
street.nearestOutcome = null;
return false;
}
if (!nearest) {
street.nearestOutcome = options.aim === 'screen-centre' && sky ? 'sky' : 'empty';
street.error = `No street-level imagery within ${options.radiusM ?? 50} m of ${point ? 'that point' : 'the view centre'}`;
return false;
}
@@ -5805,12 +5817,14 @@ function createStreetLevelHarness({
isEnabled: () => enabled,
getLayerParams: () => ({ ...params }),
setLayerParams(id, next, { origin }) {
origins.push(origin);
order.push(`params:${Object.entries(next).filter(([, on]) => on).map(([k]) => k).join('+')}:${origin}`);
if (paramsAccepted === false) return false;
if (!lightFails) params = { ...params, ...next };
return true;
},
async setEnabled(id) {
async setEnabled(id, _on, options) {
origins.push(options?.origin);
order.push(`enable:${id}`);
if (enableResult === false) return false;
enabled = true;
@@ -5818,8 +5832,10 @@ function createStreetLevelHarness({
},
getAll: () => [{ id: 'street-level', name: 'Street Level', enabled }],
};
styleManager.setPanelCollapsed = (id, collapsed) => revealed.push(`collapse:${id}:${collapsed}`);
styleManager.revealPanel = (id) => revealed.push(`reveal:${id}`);
const runner = createGevActionRunner({ viewer, styleManager, dataManager });
return { runner, order, finishFlight: () => completeFlight?.(), layer, dataManager };
return { runner, order, finishFlight: () => completeFlight?.(), layer, dataManager, lookups, origins, revealed };
}
/** A loaded CCTV camera the entity branch can locate. */
@@ -6403,3 +6419,65 @@ test('show_street_level opens over the clean embedded globe but respects its oth
globalThis.document = saved;
}
});
test('show_street_level from a link keeps the recipient’s preferences: its switches are not the user’s', async () => {
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
const link = createStreetLevelHarness();
const linked = await link.runner(
'show_street_level',
{ latitude: 1, longitude: 2, provider: 'mapillary', fly: false },
{ origin: 'programmatic' },
);
assert.equal(linked.ok, true, linked.error);
assert.deepEqual(link.origins, ['programmatic', 'programmatic'], 'source switch and layer on');
const asked = createStreetLevelHarness();
await asked.runner('show_street_level', { latitude: 1, longitude: 2, provider: 'mapillary', fly: false });
assert.deepEqual(asked.origins, ['voice', 'voice'], 'the assistant’s request is the user’s choice');
});
test('show_street_level with no place looks under the screen centre, not a link’s armed point', async () => {
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
const here = createStreetLevelHarness({ enabled: true });
const result = await here.runner('show_street_level', { provider: 'mapillary' });
assert.equal(result.ok, true, result.error);
assert.equal(result.atViewCentre, true);
assert.equal(here.lookups[0].point, null);
assert.equal(here.lookups[0].aim, 'screen-centre');
assert.equal(here.lookups[0].armed, false);
const placed = createStreetLevelHarness({ enabled: true });
await placed.runner('show_street_level', { latitude: 1, longitude: 2, provider: 'mapillary', fly: false });
assert.equal(placed.lookups[0].aim, undefined, 'a place is looked up where it is');
const sky = createStreetLevelHarness({ enabled: true, nearest: null, sky: true });
const refused = await sky.runner('show_street_level', { provider: 'mapillary' });
assert.deepEqual([refused.ok, refused.stage, refused.aim], [false, 'imagery', 'sky']);
});
test('show_street_level tells missing imagery from a failing source', async () => {
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
const empty = await createStreetLevelHarness({ enabled: true, nearest: null }).runner('show_street_level', {
latitude: 1, longitude: 2, provider: 'mapillary', fly: false,
});
assert.deepEqual([empty.stage, empty.noImagery, empty.imageryError], ['imagery', true, undefined]);
const broken = await createStreetLevelHarness({ enabled: true, imageryError: 'Mapillary graph HTTP 500' }).runner(
'show_street_level',
{ latitude: 1, longitude: 2, provider: 'mapillary', fly: false },
);
assert.deepEqual([broken.stage, broken.noImagery, broken.imageryError], ['imagery', undefined, true]);
assert.equal(broken.error, 'Mapillary graph HTTP 500');
});
test('show_street_level shows every photo it opens, also over a panel the user had closed', async () => {
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
const harness = createStreetLevelHarness({ enabled: true });
await harness.runner('show_street_level', { latitude: 1, longitude: 2, provider: 'mapillary', fly: false });
await harness.runner('show_street_level', { latitude: 3, longitude: 4, provider: 'mapillary', fly: false });
assert.deepEqual(harness.revealed, [
'collapse:street-level-panel:false',
'reveal:street-level-panel',
'collapse:street-level-panel:false',
'reveal:street-level-panel',
]);
const missing = createStreetLevelHarness({ enabled: true, nearest: null });
await missing.runner('show_street_level', { latitude: 1, longitude: 2, provider: 'mapillary', fly: false });
assert.deepEqual(missing.revealed, [], 'nothing opened, nothing revealed');
});
+13 -4
View File
@@ -626,7 +626,11 @@ function showStreetLevel(result) {
const shownSource = result?.providerName
? spokenLabel(result.providerName)
: t('Street Level');
const shown = spokenLabel(localizePlaceName(result?.label || '')) || place;
// The view centre is a phrase, not a place name: the card says it in the
// interface language.
const shown = result?.atViewCentre
? t('the view centre')
: spokenLabel(localizePlaceName(result?.label || '')) || place;
if (result?.cancelled) return null;
if (!result?.ok) {
let say;
@@ -640,10 +644,15 @@ function showStreetLevel(result) {
else if (result?.stage === 'layer') say = "Couldn't turn on Street Level.";
else if (result?.stage === 'view')
say = 'Street-level photos are hidden in this view. Leave it first.';
else if (result?.stage === 'imagery' && result?.aim === 'sky')
say = 'Aim the middle of the view at a street first.';
else if (result?.stage === 'imagery' && result?.filter?.label)
say = `No ${source} imagery near ${place} with the ${result.filter.label} on.`;
else if (result?.stage === 'imagery' && result?.noImagery === true)
say = `No ${source} imagery near ${place}.`;
// A service or viewer failure is not missing coverage.
else if (result?.stage === 'imagery')
say = result?.filter?.label
? `No ${source} imagery near ${place} with the ${result.filter.label} on.`
: `No ${source} imagery near ${place}.`;
say = `${source} could not open imagery near ${place}.`;
else say = `Couldn't open ${source}.`;
return {
say,
+36 -1
View File
@@ -536,6 +536,22 @@ test('labels are bounded and cleaned before they are spoken', () => {
);
});
test('the street-level card says "the view centre" in the interface language', () => {
setLocale('de');
try {
const out = envelope('show_street_level', {
ok: true,
providerName: 'Mapillary',
label: 'the view centre',
atViewCentre: true,
});
assert.equal(out.display.lines[0], 'die Bildmitte');
assert.match(out.say, /the view centre/, 'speech stays English');
} finally {
setLocale('en');
}
});
test('street-level speech names the source and the place, and says which step failed', () => {
const ok = envelope('show_street_level', {
ok: true,
@@ -556,7 +572,8 @@ test('street-level speech names the source and the place, and says which step fa
map: "Google Street View needs the Google 3D map, which isn't available.",
key: 'Google Street View needs its key.',
layer: "Couldn't turn on Street Level.",
imagery: 'No Google Street View imagery near Nowhere.',
// A service or viewer failure, not missing coverage.
imagery: 'Google Street View could not open imagery near Nowhere.',
};
for (const [stage, say] of Object.entries(stages)) {
const out = envelope('show_street_level', {
@@ -570,6 +587,24 @@ test('street-level speech names the source and the place, and says which step fa
assertSpeakable(out.say);
assert.deepEqual(out.display.lines, ['detail']);
}
const empty = envelope('show_street_level', {
ok: false,
stage: 'imagery',
noImagery: true,
label: 'Nowhere',
providerName: 'Mapillary',
});
assert.equal(empty.say, 'No Mapillary imagery near Nowhere.');
const sky = envelope('show_street_level', {
ok: false,
stage: 'imagery',
aim: 'sky',
atViewCentre: true,
label: 'the view centre',
providerName: 'Mapillary',
});
assert.equal(sky.say, 'Aim the middle of the view at a street first.');
assertSpeakable(sky.say);
const armed = envelope('show_street_level', {
ok: true,
armed: true,