fix(voice): localize the area, imagery and OSM cards and tidy OSM Places

From review:
- Card lines the actions write in English (area basis, part counts, merged
  duplicates, OSM caveats, the imagery window) are shown in the UI
  language through the analyst card's note path; the model still gets the
  English. One OSM place reads "1 hospital".
- Same-named clarification choices show their region code (WA, DC).
- OSM Places shows as unavailable once the server says no Overpass is
  configured, and its points are depth-tested past 2.5 km so they never
  show through the globe.
- find_imagery puts the operator's sources and mode back when a box is
  refused, and a voice search cancelled mid-flight leaves "Search
  cancelled" instead of an empty strip.
- The README lists OSM Places with the other Utilities.
This commit is contained in:
Manjunath committed 2026-11-03 19:36:48 +05:30
1 parent 34647758fc
commit 40d8839589
22 files changed
+535 -27

No files matched your search

@@ -280,3 +280,66 @@ test('every locationId the voice tools accept is a preset city', () => {
assert.ok(ids.size > 0, 'found the locationId enums');
for (const id of ids) assert.ok(Object.hasOwn(CITY_POIS, id), id);
});
test('area, imagery and OSM card lines are shown in the UI language', () => {
const area = {
ok: true,
name: 'Ferry Building',
approximate: true,
display: {
basis: '250 m around the landmark',
parts: '3 parts',
drawnParts: '2 of 3 parts drawn',
source: 'approximate outline',
},
notDrawn: 'the map was cleared while looking it up',
};
const areaLines = inLocale('de', () => presentResult('resolve_area', area).display.lines);
assert.ok(areaLines.includes('250 m um das Wahrzeichen'), areaLines.join(' | '));
assert.ok(areaLines.includes('Teile: 3'));
assert.ok(areaLines.includes('Gezeichnete Teile: 2 von 3'));
assert.ok(areaLines.some((line) => line.includes('die Karte wurde während der Suche geleert')));
const osm = {
ok: true,
kind: 'hospitals',
kindSingular: 'hospital',
count: 1,
complete: false,
area: 'Kathmandu',
display: {
source: 'OpenStreetMap',
merged: '2 duplicate mappings merged',
caveat: 'listed the first 500; there are more',
},
};
const osmCard = inLocale('de', () => presentResult('osm_query', osm).display);
assert.match(osmCard.title, /\bhospital\b/);
assert.doesNotMatch(osmCard.title, /hospitals/, 'one place takes the singular');
assert.equal(presentResult('osm_query', { ...osm, complete: true }).display.title, '1 hospital');
assert.ok(osmCard.lines.includes('Zusammengeführte Doppelkartierungen: 2'));
assert.deepEqual(osmCard.notes, ['die ersten 500 aufgelistet', 'es gibt weitere']);
const imagery = {
ok: true,
total: 4,
count: 0,
display: { window: 'the catalog covers the last 30 days' },
};
const imageryLines = inLocale('de', () => presentResult('find_imagery', imagery).display.lines);
assert.ok(imageryLines.includes('Der Katalog umfasst die letzten 30 Tage'), imageryLines.join(' | '));
});
test('same-named clarification choices show their region code', () => {
const asked = {
ok: false,
needsClarification: true,
code: 'AMBIGUOUS_AREA',
candidates: [
{ candidateId: 'ne:state:united-states-of-america-washington-wa', name: 'Washington', level: 'admin1', region: 'WA', country: 'United States of America' },
{ candidateId: 'ne:state:united-states-of-america-washington-dc', name: 'Washington', level: 'admin1', region: 'DC', country: 'United States of America' },
],
};
const lines = presentResult('resolve_area', asked, { query: 'Washington' }).display.lines;
assert.match(lines[0], /\bWA\b/);
assert.match(lines[1], /\bDC\b/);
assert.notEqual(lines[0], lines[1]);
});