Skip to content

Show cached patches as blue boxes on the map#55

Merged
aivanchenk merged 4 commits into
38-patch-extentfrom
cached-patches
Jul 14, 2026
Merged

Show cached patches as blue boxes on the map#55
aivanchenk merged 4 commits into
38-patch-extentfrom
cached-patches

Conversation

@aivanchenk

Copy link
Copy Markdown
Collaborator

Adds a third overlay layer that visualizes which patches are currently held in the in-memory LRU cache, so you can see the real footprint of what's been downloaded as you click around — not just the single active patch.

The colour story

The map now reads as a cool teal → blue → violet ramp, each hue a distinct role:

Overlay Colour Meaning
Cell teal the single pixel you clicked
Patch violet (#51) the 40×40 chunk this click just downloaded
Cached blue every distinct lat/lon patch still in the LRU cache

Blue boxes render beneath the violet patch and teal cell, so the active selection always stays on top.

How it works

  • ZarrChunkReader now exposes getCachedPatches() (distinct lat/lon patches, de-duplicated across time chunks) plus a subscribe() / getCacheVersion() pair, so the map updates reactively — including when background prefetch completes.
  • chunkIndicesToPatchBounds() extracted from chunkPatchBounds() to turn chunk indices straight into geo bounds.
  • A cache toggle (stacked-squares icon) appears in the nav once anything is cached, mirroring the patch toggle.

Verify

  • eslint, next build (incl. its TypeScript pass), and vitest (44 tests, +1 for chunkIndicesToPatchBounds) all pass.
  • Not yet visually confirmed in a running browser — the overlay geometry/colours should be eyeballed on a real click.

Base

Stacked on 38-patch-extent (#51) because it reuses that PR's violet patch tokens. Retarget to main once #51 merges.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a feature to visualize cached patches on the map, adding a toggle button in the navigation bar, updating the map overlay to render cached bounds, and implementing a subscription mechanism in ZarrChunkReader to track cache mutations. The review feedback highlights a fragile cache key parsing implementation that could fail if variable names contain colons, and suggests batching cache change notifications using queueMicrotask to prevent rapid, redundant re-renders during concurrent chunk loads.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/lib/zarr/ZarrChunkReader.ts Outdated
Comment thread src/lib/zarr/ZarrChunkReader.ts Outdated
Comment thread src/lib/zarr/ZarrChunkReader.ts Outdated
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

🚀 Vercel preview deployed

Preview URL: https://earth-prints-guk9otaka-anastasiia-s-projects10.vercel.app

@aivanchenk aivanchenk marked this pull request as ready for review July 14, 2026 07:47
@aivanchenk aivanchenk requested a review from lazarusA July 14, 2026 07:48
@aivanchenk aivanchenk merged commit aff6e71 into 38-patch-extent Jul 14, 2026
2 checks passed
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.

2 participants