fix(hud): lead with the state tag, keep feedState in get_hud_caption

Review fixes for the HUD summary language change:

- The translated feed-state tag now leads the one-line summary and the
  fallback line, so the readout's ellipsis cannot hide it.
- get_hud_caption checks the reply's feedState, returns it and appends the
  state tag; a reply naming another state keeps only the place.
- The model gets the layer names the user sees (localizeLayerName).
- Japanese and Chinese summaries are capped at 20 characters; pt, zh-CN and
  zh-Hant get explicit language names.
- A partial view is narrated as incomplete coverage, not as not live.
- provenanceTag and hudSummaryMatchesProvenance move to layerSnapshot.js so
  the tools package can use them without browser globals.
- docs/CURRENT-STATE.md, changelog and comments updated; redundant tests
  trimmed.
This commit is contained in:
German Khokhlov committed 2026-10-30 13:06:53 +04:00
1 parent 54750a01e5
commit f967218a04
10 files changed
+232 -80

No files matched your search

+12 -10
View File
@@ -782,7 +782,8 @@ export class IntelHUD {
zone: localTag,
},
);
return provenance ? `${line} | ${provenance}` : line;
// The feed state leads: the one-line readout clips its end.
return provenance ? `${provenance} | ${line}` : line;
}
/** Stop a summary still typing out, leaving what it has typed so far. */
@@ -894,11 +895,12 @@ export class IntelHUD {
throw new Error(data?.error || `HTTP ${response.status}`);
}
if (hudSummaryMatchesProvenance(data, context.feedProvenance)) {
// The warning is the HUD's own translated tag, not the model's words.
// The warning is the HUD's own translated tag, not the model's
// words, and it leads so the one-line readout never clips it.
const tag = localizedProvenanceTag(
provenanceTag(context.feedProvenance),
);
this._lastSummaryText = tag ? `${data.summary} | ${tag}` : data.summary;
this._lastSummaryText = tag ? `${tag} | ${data.summary}` : data.summary;
}
this._setSummaryText(this._lastSummaryText || fallbackText, animate);
} catch (error) {
@@ -959,18 +961,18 @@ export class IntelHUD {
// A slower build for a view the camera has left must not replace the
// newer view's lookup.
if (revision === this._summaryRevision) this._placeLabels = labels;
const enabledLayers =
this._dataManager
?.getAll?.()
?.filter((layer) => layer.enabled)
.map((layer) => layer.name) || [];
const layerContext = hudSummaryLayerContext(
this._dataManager?.getAll?.() || [],
);
return {
locale: getLocale(),
placeLabels: labels.placeLabels,
streetLabels: labels.streetLabels,
nearbyPlaceLabels: labels.nearbyPlaceLabels,
enabledLayerLabels: enabledLayers,
...hudSummaryLayerContext(this._dataManager?.getAll?.() || []),
...layerContext,
// The names the user sees; feedProvenance keeps the English ids.
enabledLayerLabels:
layerContext.enabledLayerLabels.map(localizeLayerName),
};
}