Skip to content

Keep National resident behind a displayed Site (seamless handoff, Phase A) - #26

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

tcurtsinger merged 6 commits into
mainfrom
claude/seamless-handoff-phase-a

Conversation

@tcurtsinger

Copy link
Copy Markdown
Owner

Summary

Phase A of the seamless National ↔ Site handoff (decisions in docs/32_SEAMLESS_RADAR_HANDOFF.md). Switching to a Site no longer destroys National. It stays resident: frames stay on the GPU, backfill and polling keep running, and nothing is drawn or claimed. Switching back is one fenced paint under the original generation. Before this, returning meant a new generation, a backend reset, and a full 60-frame rebuild.

Transfer lanes (Rust + TS). The broker and client held one global generation and one two-credit pool, so every Site acquisition invalidated National's in-flight work. Each source now owns a lane with its own generation, cancellation token, and two credits. Generations stay unique across lanes, so releases still find their owner from (session, generation). Commands pick their lane server-side.

Resident renderer mode. NationalGridLayer.setVisibility("resident") lets staging, history commits, and context recovery complete on GPU fences without drawing. Those receipts carry presented: false and live in residentReceipt; paintReceipt stays reserved for frames actually drawn, so the truth contract is unchanged.

  • A draw that completes after hide is downgraded to a resident receipt.
  • Frame selection is refused while hidden.
  • revealAndWait() lets an in-progress hidden commit finish, then resolves only after a real draw.

App and coordinator.

  • The coordinator can reveal a resident source under its existing generation.
  • Site requests no longer cancel National, and National's ownership checks follow its lane.
  • Hidden work cannot overwrite the Site's timeline, status, error notice, or inspection.
  • A failed Site request leaves National as it was and resumes its playback.
  • Smooth/Native applies to both layers. This also fixes the audit's U-2 revert bug.

Also fixed.

  • Play/Pause flicker: the icon briefly flickered to Play on every background National commit. That hold now reports resumingAfterReplacement, and the chrome keeps showing Pause.
  • Site memory ceiling: the Site layer gains a 320 MiB GPU ceiling, for a combined bound of 3,904 MiB.

Validation

  • npm run verify is green: 363 frontend tests, 133 Rust tests, build, fmt, clippy.
    • New unit coverage: broker and client lane isolation, coordinator/session reveal, and a fake-WebGL state-machine suite (hidden commit, reveal, downgrade, late hidden fence, recovery while hidden, reveal waiting out a commit).
  • npm run test:national:phase4:packaged: PASS, 0 failures. This is the first packaged run at 60 frames, so it also covers Batch National chunk transfers and extend history to 60 frames #25.
    • Reveal took 20.3 ms, with zero network, decode, and bulk IPC activity and the same generation (3 → 3).
    • All 60 frames stayed retained while the Site was shown, with both lanes active.
    • The failed-Site proof kept the same generation, did not restart backfill, and resumed playback.
    • 1,000 resident transitions with zero hot-path activity; peak GPU 2.98 GB.
  • The first packaged run failed two older checks, both fixed here:
    • scrub targets still pointed at index 19 of the old 20-frame loop;
    • the Play/Pause flicker above.

Changed from the approved plan

  • National code stays in App.tsx (about 290 changed lines) instead of first moving into a NationalRadarEngine module. Doing both at once would mix a large code move with behavior changes. The extraction is a separate follow-up.
  • Site credits are still taken before the live long-poll wait. With per-lane pools, National can no longer be starved by it, so moving it wasn't needed.

Not in Phase A

  • The camera still recenters on a manual switch.
  • Layer order after a context restore is not pinned yet; it matters once both layers draw (Phase B cross-fade).
  • The Site is still torn down when National shows.
  • Resident National keeps its host memory alive while a Site is shown: about 2.8 GiB WebView heap plus up to the 4 GiB backend target. That is the same footprint National uses while visible.

🤖 Generated with Claude Code

tcurtsinger and others added 5 commits September 28, 2026 12:14
The transfer broker and client held one global generation and one pool of
two credits, so any Site acquisition invalidated in-flight National work and
the reverse. Each lane now owns its generation, cancellation token, and two
credits; generations stay unique across lanes so a release still finds its
owner from (session, generation). Commands pick their lane server-side.

Behavior is unchanged for now: starting one source still cancels the other
lane explicitly (beginExclusiveLane), matching the former single generation.
This is the groundwork for keeping National resident while a Site is shown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setVisibility("resident") keeps every frame on the GPU and lets staging,
history commits, and context recovery complete on GPU fences, but draws
nothing. Such receipts carry presented: false and land in residentReceipt;
paintReceipt stays reserved for frames that were actually drawn. A draw
that completes after hide is downgraded, frame selection is refused while
hidden, and revealAndWait() resolves only after a real visible draw.

Adds a fake-WebGL state-machine test covering hidden commits, reveal,
downgrade, a hidden fence finishing after reveal, and recovery while hidden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
National no longer tears down when a Site paints. Its layer turns resident
(frames stay on the GPU, commits complete on fences, nothing is drawn or
claimed), its backfill and polling keep running on the National lane, and
switching back is one fenced paint under the original generation.

- Coordinator: transitions can reveal a resident source under its
  existing generation; NationalMrmsSession chooses acquire or reveal.
- App: Site requests no longer cancel National; ownership checks follow
  the National lane; hidden work cannot overwrite the Site timeline,
  status, error notice, or inspection; a failed Site leaves National as it
  was and resumes its playback; Smooth/Native applies to both layers.
- Site layer gains a 320 MiB GPU ceiling (combined bound 3,904 MiB).
- Packaged diagnostics: proveFailedSiteKeepsNational replaces the restart
  proof, and proveResidentHandoff requires a zero-acquisition reveal
  within 250 ms.
- docs/32 records the decisions and marks the superseded credit rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit described both fixes but did not include them:
selectDisplayMode now sets the mode on the Site and National layers, so a
resident layer can never reverse-sync an older mode into the UI; and a
National reveal removes the Site before restoring the history status,
because the Site teardown resets that shared status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A background National commit briefly pauses playback for its atomic
residency swap and then resumes on its own. The controller now reports
that hold as resumingAfterReplacement, the chrome keeps showing Pause for
it, and toggling during the hold still pauses. The packaged chrome gate
samples the visible Play/Pause control instead of the raw controller flag.

The packaged scrub checks also targeted index 19, a leftover of the
20-frame history; they now scrub the last of the 60 frames.

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-28T18:33:21.952897Z c5bbbf9 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: c5bbbf9173

ℹ️ 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 +1133 to +1135
resumeNationalPlaybackAfterSiteFailure = playbackToSettle
? await playbackToSettle.pauseAndWait(false)
: false;

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 Preserve playback intent across superseded Site requests

When National is playing and a user starts a second Site selection before the first finishes, the first invocation records true and pauses playback, but the second invocation sees the already-paused controller and overwrites this shared flag with false. If the second Site request then fails, restoreNationalAfterSiteFailure reads false and leaves National paused rather than restoring its pre-transition playback state. Preserve the original resume intent across superseding Site requests, for example by accumulating it until a Site handoff succeeds or the final request fails.

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 d4e5eca: the resume intent now accumulates (||=) across superseding Site requests, is consumed by the final failure, cleared when a Site paints, and cleared when a fresh National session replaces the controller.

A second Site pick found National already paused and overwrote the first
request's "was playing" flag with false, so a failed second request left
National paused. Accumulate the intent until a Site paints or the last
request fails, and drop it when a fresh National session replaces the
controller it belonged to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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