Skip to content

Switch between National and Site by zoom, with preload and cross-fade (seamless handoff, Phase B) - #28

Merged
tcurtsinger merged 9 commits into
mainfrom
claude/seamless-handoff-phase-b
Sep 28, 2026
Merged

tcurtsinger merged 9 commits into
mainfrom
claude/seamless-handoff-phase-b

Conversation

@tcurtsinger

Copy link
Copy Markdown
Owner

What changes

Zoom now picks the radar source, the way RadarScope does:

  • Zoom in past 9 over a Site's coverage → that Site's Level II scan fades in over National (300 ms). National stays loaded underneath.
  • From zoom 8 the nearest Site's scan is preloaded, so the fade-in usually needs no network wait.
  • Zoom out below 8.5, or pan more than 230 km from the Site → the Site fades out and the same National history shows again, with nothing reloaded.
  • Moving between Sites goes through National. Only one Site layer ever exists.
  • The picker now flies the camera (to zoom 9.5 over a site, or to all of CONUS) and lets zoom choose the source. The camera is saved; the source is not. The auto rule always applies, even after a manual pick.
  • Only user-driven camera moves trigger a switch. Programmatic cameras (the test harnesses) never do.

How

  • Every one of the 155 sites in src/data/radar-sites.json now has a latitude and longitude. A Rust test checks them against the NEXRAD registry.
  • A pure autoSourcePolicy.ts makes the decision: enter at zoom ≥ 9 within 200 km, keep at zoom ≥ 8.5 within 230 km, preload at zoom ≥ 8.
  • RadarCustomLayer gains a u_opacity uniform; fade.ts eases it with smoothstep. The fade is skipped under prefers-reduced-motion.
  • National keeps acquiring and playing while a Site loads, and hides only once the Site has fully faded in.
  • A 320 MiB GPU ceiling on the Site layer.

Verification

  • npm run verify passes: frontend tests, build, and Rust fmt/clippy/test/check.
  • Packaged gate npm run test:national:phase4:packaged passes with 0 failures, using live NOAA data:
    • Zoom-in handoff: 338 ms, using the preloaded scan (generation 7 → 7), opacity 1, National resident. The camera did not move.
    • Zoom-out handoff: 348 ms. The same National generation returns (3 → 3), the Site layer is removed, and the camera did not move.
    • Manual reveal of National: 334 ms, including the 300 ms fade.
  • Two harness timing fixes:
    • Hold the sharp-playback window clear of background MRMS commits.
    • Record every change to the inspection readout with a MutationObserver instead of 16 ms polling.

Known limits

  • When a fade-in ends, National disappears outside the Site's range ring.
  • Playback time is not yet carried across a switch. That is Phase C.

Builds on #26 (Phase A, merged).

🤖 Generated with Claude Code

tcurtsinger and others added 8 commits September 28, 2026 13:41
The site catalog now carries latitude and longitude for all 155 sites:
150 from nexrad-model's registry (a Rust test keeps them in sync) and 5
the registry lacks (KBHX, KDOX, KHDC, KLGX, PAPD) from api.weather.gov.

decideAutoSource is the pure Phase B policy: a covering Site replaces
National at zoom 9 (center within 200 km), a displayed Site is kept down to
zoom 8.5 and within 230 km, the likely Site preloads from zoom 8, and moving
between Sites always passes through National. A picked Site is preferred
while the view stays inside its coverage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Site shader gains u_opacity. Like the display mode it changes only
shading, never the paint receipt, so a Site can draw its first frame at
opacity 0 and fade in over National. fadeOpacity eases between values
across animation frames and stops when superseded.

National is now always inserted, and re-inserted after context loss,
below the Site stack, so the fading Site layer is the upper one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Zoom now decides the source. After a camera move the operator makes, the
policy may fade a covering Site in over National (zoom 9, center within
200 km), keep it down to zoom 8.5 and within 230 km, or fade it back out to
the resident National. Moving between Sites passes through National.

- From zoom 8 the likely Site's newest scan is fetched ahead on the Site
  lane; the switch reuses that generation and paints without a network
  wait. Only one automatic switch runs at a time, and a Site that just
  failed is not retried for a minute.
- The Site paints its first frame at opacity 0, fades in over 300 ms
  (instant under reduced motion), and only then becomes the displayed
  source. Leaving it, National paints underneath first and the Site fades
  out before it is removed. National keeps playing until the Site covers it.
- Automatic switches never move the camera. The picker flies to a Site at
  zoom 9.5 (preloading during the flight from National), picking National
  zooms out to the country, recenter uses the same targets, and the camera
  is restored at launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
proveZoomHandoff preloads KTLX at zoom 8.3, requires zoom 9.6 to fade the
preloaded Site in over resident National without moving the camera, and
zoom 7.5 to fade back to the same National history with the Site removed.
The resident-handoff timing allows for the deliberate fade-out. docs/32
records the Phase B policy, switching, camera, and known limits; PRODUCT
and DESIGN note that zoom now decides the source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flight to where the camera already is may never emit moveend, so the
landing evaluation never ran. The picker, National choice, and recenter
now evaluate immediately when the camera is not moving after the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The packaged gate released its resident-evidence reservation before
measuring active playback, so a newer MRMS frame committing during the
1.5 s window (every ~2 minutes) failed "zero sharp-playback transfer and
upload work". The measurement now holds the same reservation the scrub
evidence uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gate

Exact point lookups now settle within one 16 ms polling interval, so the
gate could miss the neutral "--.- dBZ" pending state entirely and fail
at random. A MutationObserver on the playback bar records every readout
change during the window; the gate's requirements are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T19:26:51.885558Z 87d3c95 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87d3c95dae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/App.tsx Outdated
Comment on lines +1342 to +1346
const settleAutoSwitch = () => {
autoSwitchInFlight = false;
if (!pendingAutoEvaluation) return;
pendingAutoEvaluation = false;
evaluateAutoSource();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Re-evaluate after the intermediate National hop

When a user pans at detail zoom from the current Site's coverage into another Site's coverage, the policy first targets National, but pendingAutoEvaluation is normally false because there was only one moveend. Consequently settleAutoSwitch stops after National is revealed and never evaluates the unchanged camera again, leaving National displayed at zoom 10 until the user moves the map a second time. Re-evaluate after a successful Site-to-National switch so the intended National-to-new-Site leg can run.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 2d5cd1f: a switch that succeeds now re-checks the same camera, so one pan into another Site's coverage runs Site → National → Site. The packaged zoom proof adds a KTLX → KFWS pan and requires that exact sequence; it passed at 3.4 s with the camera untouched.

Comment thread src/App.tsx
Comment on lines +3323 to +3327
const painted = radarSessionCoordinatorRef.current?.snapshot().painted;
if (auto && instance && location && painted?.source.kind === "national") {
auto.prefetch(normalized);
auto.evaluateIfSettled();
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Route picked Site changes through National

When a Site is already painted and the operator picks a different Site, this condition is false, so the handler falls through to session.start(normalized) immediately. That directly replaces the current Site's frames without the required Site-to-National fade/handoff; the flight's moveend only sets pendingAutoEvaluation while that manual transition is active, and the manual promise never calls settleAutoSwitch. Handle the picker through the automatic route for painted Sites as well.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 2d5cd1f: picking a Site while another Site is shown now goes through the zoom policy too. The policy hops a displayed Site to National when a different picked Site covers the center at zoom ≥ 9 (this also covers picks closer than 230 km, e.g. KTLX → KVNX, which previously would have stayed on KTLX). Moves made during a manual switch are now evaluated once it ends, via a coordinator subscription.

Comment thread src/App.tsx
Comment on lines +3366 to +3369
if (auto && instance) {
auto.evaluateAfterNextMove();
flyToNational(instance);
auto.evaluateIfSettled();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow National selection to recenter a National view

The newly added National flight is unreachable when National is already the settled painted source because the earlier guard returns first. Thus, if the user has panned or zoomed a National view regionally—for example over an area without Site coverage—choosing National again does not perform the promised flight to the CONUS bounds. The source-transition guard should not suppress the camera action.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 2d5cd1f: picking National always flies out to CONUS; being on National already only skips the redundant source switch and the inspection reset.

- A switch that succeeds re-checks the same camera, so a pan from one
  Site's coverage into another's runs both legs (Site, National, Site)
  from one camera move instead of stopping on National.
- A camera move made during a manual switch is evaluated once that
  switch ends.
- Picking a Site while another Site is shown flies there and fades
  through National, instead of replacing the frames in place. The
  policy now hops a displayed Site to National when a different picked
  Site covers the center at detail zoom, and drops a pick once the view
  leaves its range.
- Picking National always flies out to the country, even when National
  is already shown.
- The packaged zoom proof adds a KTLX to KFWS pan and requires the
  KTLX > national > KFWS sequence with the camera untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tcurtsinger
tcurtsinger merged commit 16c9eca into main Sep 28, 2026
@tcurtsinger
tcurtsinger deleted the claude/seamless-handoff-phase-b branch September 28, 2026 19:40
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