fix: resolve review findings and refresh PR #881 against main

This commit is contained in:
Said Turksever committed 2026-11-03 16:17:31 +00:00
commit 379574bf11
1718 files changed
+159455 -40799

No files matched your search

+12 -2
View File
@@ -3,7 +3,12 @@
* day's readout. The model (`model.js`) stays English and i18n-free because AI
* tool services import it outside the browser; this module is page-only.
*/
import { formatDate, formatRelativeTime, t } from '../../i18n/index.js';
import {
formatDate,
formatRelativeTime,
getLocale,
t,
} from '../../i18n/index.js';
import { formatQuantity } from '../../ui/unitLabels.js';
import { dayTime } from './model.js';
@@ -26,7 +31,12 @@ export const displayMetres = (value) => formatQuantity(value, 'm');
/** The readout's words in the page's language; the model keeps them English. */
export const READOUT_WORDS = Object.freeze({
date: (day) => displayDay(day, LONG_DAY),
daysAgo: (delta) => formatRelativeTime(delta > 0 ? -delta : 0, 'day'),
daysAgo: (delta) => {
const text = formatRelativeTime(delta > 0 ? -delta : 0, 'day');
return getLocale().startsWith('zh-')
? text.replace(/(\d)(?=天)/g, '$1 ')
: text;
},
// "Sentinel-2" never breaks at its hyphen: a word joiner follows it
// (JetBrains Mono has no U+2011 non-breaking hyphen).
sensor: (sensor) =>
+1 -1
View File
@@ -300,7 +300,7 @@ export function hhmm(iso) {
}
/** Candidate key: `PRODUCT:YYYY-MM-DD`. */
export function candidateKey(product, day) {
function candidateKey(product, day) {
return `${product}:${day}`;
}
+14
View File
@@ -168,6 +168,20 @@ export function createThumbnailLoader({
const existing = entries.get(key);
if (existing) {
touch(existing);
if (existing.loading && existing.controller?.signal.aborted) {
// A known-present re-fetch keeps its metadata when cancelled. If
// that day is wanted again before cancellation settles, give the
// new request its own entry so the old run cannot discard it.
const renewed = {
...existing,
priority,
loading: false,
controller: null,
};
entries.set(key, renewed);
enqueue(renewed);
return;
}
if (existing.loading) return;
if (existing.status === 'unknown') {
existing.priority = priority;
@@ -400,3 +400,38 @@ test('repeat retain counts an aborted known-present re-fetch once', async () =>
await settle();
assert.equal(loader.get(stale.key).status, 'present');
});
for (const cancelRenewed of [false, true]) {
test(`a known-present day requested during abort settlement ${cancelRenewed ? 'can be cancelled again' : 'restarts without another intent change'}`, async (t) => {
const { loader, fetch } = fixture({ maxInFlight: 1, maxDecoded: 1 });
t.after(() => loader.destroy());
const day = candidate('S30', '2026-09-10');
const other = candidate('S30', '2026-09-11');
loader.request(day, BOX);
fetch.respond(0);
await settle();
const acquisitionTime = loader.get(day.key).acquisitionTime;
loader.request(other, BOX);
fetch.respond(1);
await settle();
assert.equal(loader.get(day.key).objectUrl, null);
loader.request(day, BOX);
loader.retain([]);
assert.equal(fetch.calls[2].signal.aborted, true);
// Deliberately do not await: the old run still owns its in-flight slot.
loader.request(day, BOX);
loader.retain(cancelRenewed ? [] : [day.key]);
assert.equal(fetch.calls.length, 3, 'renewal respects the concurrency cap');
await settle();
assert.equal(loader.get(day.key).acquisitionTime, acquisitionTime);
assert.equal(fetch.calls.length, cancelRenewed ? 3 : 4);
if (!cancelRenewed) {
assert.equal(fetch.calls[3].signal.aborted, false);
fetch.respond(3);
await settle();
assert.ok(loader.get(day.key).objectUrl);
assert.equal(loader.get(day.key).loading, false);
}
});
}