Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix(traffic): date the STALE row by the oldest cached tile; add zh-Hant string

Said Turksever69c5b3259823
diff --git a/changelog.d/1405-traffic-layer-stale.md b/changelog.d/1405-traffic-layer-stale.md
index b933e7c9b..dc564ac76 100644
--- a/changelog.d/1405-traffic-layer-stale.md
+++ b/changelog.d/1405-traffic-layer-stale.md
@@ -1,2 +1,3 @@
- The Traffic layer reads STALE instead of LIVE when the TomTom proxy serves
- cached flow tiles (budget spent or TomTom failing) (quanticsoul4772, #1405).
+ cached flow tiles (budget spent or TomTom failing), and the row dates them by
+ the oldest cached tile (quanticsoul4772, #1405).
diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md
index a5a1886c8..cfb5b85b7 100644
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@ -5760,7 +5760,8 @@ easier to meet (detection is now on more often), but does not create it.
shared loading batch as LOAD FAILED. Harnesses must gate on `!stats.error`,
never on `mode === 'live'` alone. When the drawn flow came from the proxy's
cached STALE-BUDGET / STALE-ERROR tiles, `getStats()` reports `stale: true`
- and `oldestTileAt`, the row reads STALE, and the sync chip reads
+ and `oldestTileAt`, the row reads STALE with the oldest tile's age, and the
+ sync chip reads
`STALE · Roads: <source> · Flow: cached TomTom tiles` instead of LIVE.
- Traffic runs in `sim` mode (white dots, hardcoded speeds) unless `TOMTOM_API_KEY`
is configured (env or Keychain `tomtom-api`/`api-key`), which enables `live` mode:
diff --git a/src/i18n/locales/zh-Hant.json b/src/i18n/locales/zh-Hant.json
index d95a18e39..f286da19e 100644
--- a/src/i18n/locales/zh-Hant.json
+++ b/src/i18n/locales/zh-Hant.json
@@ -1054,6 +1054,7 @@
"LIVE · Roads: {source} · No flow roads in view": "實時 · 道路:{source} · 視野內沒有帶路況數據的道路",
"LIVE · Roads: {source} · Flow {percent}%": "實時 · 道路:{source} · 路況 {percent}%",
"SIMULATED · Roads: {source} · Flow {percent}%": "模擬 · 道路:{source} · 路況 {percent}%",
+ "STALE · Roads: {source} · Flow: cached TomTom tiles": "過期 · 道路:{source} · 路況:TomTom 緩存瓦片",
"Syncing flow · Roads: OpenStreetMap · Flow: TomTom · Unmatched: simulated": "正在同步路況 · 道路:OpenStreetMap · 路況:TomTom · 未匹配:模擬",
"LIVE · Roads: OpenStreetMap · Flow: TomTom · {percent}% cov · Unmatched: simulated": "實時 · 道路:OpenStreetMap · 路況:TomTom · 覆蓋 {percent}% · 未匹配:模擬",
"LIVE · Roads: OpenStreetMap · Flow: TomTom · {percent}% cov": "實時 · 道路:OpenStreetMap · 路況:TomTom · 覆蓋 {percent}%",
diff --git a/src/ui/layerPanel.js b/src/ui/layerPanel.js
index 18b71dabf..24bcad6e6 100644
--- a/src/ui/layerPanel.js
+++ b/src/ui/layerPanel.js
@@ -714,18 +714,24 @@ export class LayerPanel {
});
}
if (feedState === 'stale') {
+ // A layer drawing cached upstream data (Traffic's proxy tiles) dates the
+ // row by the oldest of it, not by the load that re-served it.
+ const dataAgo =
+ Number(stats.oldestTileAt) > 0
+ ? this._timeAgo(stats.oldestTileAt)
+ : ago;
if (typeof stats.retryInSec === 'number' && stats.retryInSec > 0) {
return t('{state} · {source} · {ago} · retrying in {seconds}s', {
state: stateLabel,
source,
- ago,
+ ago: dataAgo,
seconds: stats.retryInSec,
});
}
return t('{state} · {source} · {ago}', {
state: stateLabel,
source,
- ago,
+ ago: dataAgo,
});
}
if (typeof stats.loadingLabel === 'string' && stats.loadingLabel.trim()) {
diff --git a/src/ui/layerPanel.test.mjs b/src/ui/layerPanel.test.mjs
index b4b771e1a..bd90f0777 100644
--- a/src/ui/layerPanel.test.mjs
+++ b/src/ui/layerPanel.test.mjs
@@ -93,6 +93,27 @@ test('partial feed controls distinguish incomplete records from stale data and o
assert.equal(button.textContent, 'OFF');
});
+test('a stale row dates cached data by its oldest tile, not the last load', async () => {
+ const { LayerPanel } = await import('./layerPanel.js');
+ const panel = LayerPanel.prototype;
+ const layer = {
+ id: 'traffic',
+ name: 'Street Traffic',
+ source: 'TomTom',
+ enabled: true,
+ stats: {
+ mode: 'live',
+ stale: true,
+ count: 4,
+ lastUpdate: Date.now(),
+ oldestTileAt: Date.now() - 3 * 3600_000,
+ },
+ };
+ assert.match(panel._buildMetaText(layer), /^STALE · TomTom · 3h ago$/);
+ delete layer.stats.oldestTileAt;
+ assert.match(panel._buildMetaText(layer), /^STALE · TomTom · just now$/);
+});
+
test('readout rows contain only toggles and metadata; ordinary rows retain controls', async () => {
const { LayerPanel } = await import('./layerPanel.js');
const { railFixture } = await import('./railTestFixture.mjs');