Skip to content

fix(#262): heatmap-OFF force-reloads altitude-appropriate marker layer#7

Open
rdhyee wants to merge 1 commit into
mainfrom
fix/heatmap-off-restore-262
Open

fix(#262): heatmap-OFF force-reloads altitude-appropriate marker layer#7
rdhyee wants to merge 1 commit into
mainfrom
fix/heatmap-off-restore-262

Conversation

@rdhyee
Copy link
Copy Markdown
Owner

@rdhyee rdhyee commented Jun 2, 2026

Summary

  • Bug: after toggling heatmap OFF (especially from a &heatmap=1 deep-link boot), the globe shows an empty cluster layer — no markers render even after zooming out.
  • Root cause: the heatmap-OFF branch of #heatmapToggle's change handler only called clearHeatmap() + applyLayerVisibility(). That flips viewer.h3Points.show = true but never loads data into it. A session that lived entirely in heatmap mode had an empty viewer.h3Points. Additionally, even when phase-1 data was present, currentRes could equal the target altitude's resolution, causing the camera handler's target !== currentRes guard to skip the subsequent reload on zoom-out.
  • Fix (explorer.qmd):
    • Make the change listener async.
    • On heatmap-OFF: set currentRes = null (defeats the same-res skip guard), then use the existing helpers (loadRes/enterPointMode/tryEnterPointModeIfNeeded) to force a data reload, all wrapped in busyAcquire()/busyRelease() (try/finally) matching the source-filter handler pattern.
    • On heatmap-ON: applyLayerVisibility() + syncFacetNote() moved inside the if branch (no semantic change, symmetry).
    • Add h3PointsLen to window.__a1globe() for test assertions.
  • New test: tests/playwright/heatmap-off-restore.mjs — standalone mode-matrix harness (plain chromium, NOT .spec.js) covering 6 scenarios: T1 boot heatmap on/hidden, T2 the actual bug, T3 low-alt point mode, T4 search active, T5 normal regression, T6 heatmap-on suppression.

Verification needed (build + run locally)

# In the worktree (or after checking out fix/heatmap-off-restore-262):
quarto render explorer.qmd
python3 dev_server.py --dir docs --port 8076

# Regression (must stay green):
HEADLESS=1 A1_CLOSE=1 node tests/playwright/a1-verify.mjs

# New mode-matrix harness:
HEADLESS=1 node tests/playwright/heatmap-off-restore.mjs

Test plan

🤖 Generated with Claude Code

…opriate marker layer

Root cause: the `#heatmapToggle` change handler only called `clearHeatmap()`
+ `applyLayerVisibility()` on heatmap-OFF.  `applyLayerVisibility()` flips
`.show = true` on `viewer.h3Points` (or `.samplePoints`) but never loads data
into it.  A session that lived entirely in heatmap mode could have an empty
`viewer.h3Points`; revealing an empty layer produces the "no clusters after
heatmap-off" symptom.  Even when phase-1 data was present, `currentRes` might
equal the target altitude's resolution, causing the camera handler's
`target !== currentRes` guard to skip the reload on subsequent zooms.

Fix (explorer.qmd):
- Make the listener `async`.
- On heatmap-OFF: call `clearHeatmap()` + `applyLayerVisibility()` +
  `syncFacetNote()` as before, then wrap a data reload in
  `busyAcquire()`/`busyRelease()` (try/finally):
  * Set `currentRes = null` to defeat the same-res skip guard.
  * If `searchIsActive()` or altitude < `ENTER_POINT_ALT`: `await enterPointMode(false)`.
  * Else: `await loadRes(target, resUrls[target])` + chase with
    `tryEnterPointModeIfNeeded()` (mirrors the source-filter handler pattern).
- On heatmap-ON path: move `applyLayerVisibility()` + `syncFacetNote()` inside
  the `if` branch (no semantic change, just symmetry).
- Add `h3PointsLen` to `window.__a1globe()` so test assertions can confirm
  clusters are actually loaded, not just shown.

Also adds `tests/playwright/heatmap-off-restore.mjs` — a standalone mode-matrix
harness (plain chromium, `node ...`, NOT a .spec.js) that exercises:
  T1. Boot `heatmap=1` at cluster alt → heatmap shown, markers hidden.
  T2. Toggle heatmap OFF → H3 cluster points load and render (the bug).
  T3. Toggle heatmap OFF at point altitude → sample points load.
  T4. Toggle heatmap OFF with search active → filtered point markers.
  T5. Normal cluster→heatmap ON→OFF still works (regression).
  T6. Heatmap ON still suppresses markers (regression).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rdhyee rdhyee force-pushed the fix/heatmap-off-restore-262 branch from 5c9d4da to e8f4d2f Compare June 2, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant