Follow-up from #191 (issue #190 fix 2).
Context
tryEnterPointModeIfNeeded() (introduced in #191) short-circuits when currentRes !== 8 && loading === true:
async function tryEnterPointModeIfNeeded() {
if (mode === 'point') return;
if (viewer.camera.positionCartographic.height >= ENTER_POINT_ALT) return;
let res8Ready = currentRes === 8;
if (!res8Ready && !loading) { // ← here
res8Ready = await loadRes(8, h3_res8_url, { ... });
}
...
}
This is safe in the current code because every loadRes call site in the cell is followed by an await tryEnterPointModeIfNeeded(), so any in-flight load that prevents this call from acting will itself trigger a chase when it settles.
But the safety relies on this invariant — and a future contributor adding a new loadRes call site without the chase would silently break supersession recovery. The bug would only surface as a rare liveness regression that's hard to attribute back to the missing chase.
Proposed change
One-line comment near the !loading guard plus a short note in the helper's existing doc-block:
async function tryEnterPointModeIfNeeded() {
if (mode === 'point') return;
if (viewer.camera.positionCartographic.height >= ENTER_POINT_ALT) return;
let res8Ready = currentRes === 8;
// Invariant: when an unrelated loadRes is in flight (`loading === true`),
// we leave recovery to that call site's own post-await chase. Every
// loadRes caller in this cell must call tryEnterPointModeIfNeeded()
// afterwards — otherwise this short-circuit can strand the user.
if (!res8Ready && !loading) {
...
}
...
}
And a parallel sentence in the doc-block at the top of the helper.
Verification
grep -n 'loadRes(' explorer.qmd should return only call sites that are immediately followed by await tryEnterPointModeIfNeeded(), OR are inside tryEnterPointModeIfNeeded() itself, OR are in code paths where the user can't be at point altitude (e.g. inside exitPointMode flow).
Refs
Follow-up from #191 (issue #190 fix 2).
Context
tryEnterPointModeIfNeeded()(introduced in #191) short-circuits whencurrentRes !== 8 && loading === true:This is safe in the current code because every
loadRescall site in the cell is followed by anawait tryEnterPointModeIfNeeded(), so any in-flight load that prevents this call from acting will itself trigger a chase when it settles.But the safety relies on this invariant — and a future contributor adding a new
loadRescall site without the chase would silently break supersession recovery. The bug would only surface as a rare liveness regression that's hard to attribute back to the missing chase.Proposed change
One-line comment near the
!loadingguard plus a short note in the helper's existing doc-block:And a parallel sentence in the doc-block at the top of the helper.
Verification
grep -n 'loadRes(' explorer.qmdshould return only call sites that are immediately followed byawait tryEnterPointModeIfNeeded(), OR are insidetryEnterPointModeIfNeeded()itself, OR are in code paths where the user can't be at point altitude (e.g. insideexitPointModeflow).Refs
tryEnterPointModeIfNeeded()