Skip to content

0.1.0-beta.21: the lens hides its townships once the sections have loaded - #38

Merged
alexandermccormick merged 4 commits into
mainfrom
fix/lens-hide-on-load
Nov 18, 2026
Merged

alexandermccormick merged 4 commits into
mainfrom
fix/lens-hide-on-load

Conversation

@alexandermccormick

Copy link
Copy Markdown
Member

Stops shapesLens flashing its newly covered townships clear on each recentre, and bumps to 0.1.0-beta.21.

Cause

A frame-by-frame browser repro found the problem. The townships' lensHidden feature state applied at the next render, but the sections drew only after MapLibre's worker and tile reload. For 2 frames per recentre:

  • the newly covered townships showed clear;
  • the townships the lens leaves (all of them on release) showed through the old sections.

Change

  • shapesLens keeps the wanted hidden set as pending and applies it whole once the sections' source has loaded:
    • on a sourcedata tile or idle event with isSourceLoaded, never metadata/content;
    • on an error for that source;
    • at the map's idle;
    • at once when nothing is loading or the sections have no layers.
  • A recentre during a load applies only the latest set.
  • Teardown clears the set and removes the listeners.
  • GlMapLike gains isSourceLoaded(id), which MapLibre's Map already has. This is a type change only for hosts that wrap the GL map.
  • No lens-rule or message-key changes. Hosts see no other change.

Known limit: when the view spans tiles that finish in different frames, a township can show through its new sections for one frame, as a tint and never clear.

Spec: docs/superpowers/specs/2026-11-17-lens-hide-on-load-design.md. Plan: docs/superpowers/plans/2026-11-17-lens-hide-on-load.md.

Tests

  • Client: 9 new tests in tests/client/plugins/shapes-lens.test.ts:
    • pending until tiles load;
    • metadata/content ignored;
    • only the latest recentre applies;
    • error applies;
    • another source's events are ignored;
    • a change with no new sections applies at once;
    • the sections' scale going unavailable shows the townships;
    • idle applies;
    • teardown.
  • Browser: recentring never shows a township clear, or under its sections, for a frame reads every rendered frame across 4 recentres and a release. It fails on main and passes here. The full browser project passed 9 of 9 runs under taskset -c 0,1.
  • npm test 1317 passed; check, lint and the bundle check are clean.

@alexandermccormick
alexandermccormick merged commit 39643a8 into main Nov 18, 2026
1 check passed
@alexandermccormick
alexandermccormick deleted the fix/lens-hide-on-load branch November 18, 2026 04:29
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