explorer: collapse dual mode state to single source of truth (#208 step 1)#213
Open
rdhyee wants to merge 1 commit into
Open
explorer: collapse dual mode state to single source of truth (#208 step 1)#213rdhyee wants to merge 1 commit into
rdhyee wants to merge 1 commit into
Conversation
…sorg#208 step 1) Step 1 of the isamplesorg#208 state-management refactor. The closure-private \`mode\` variable in the zoomWatcher OJS cell duplicated \`viewer._globeState.mode\`; both were updated together but the duplication caused transient sync mismatches during boot (the URL round-trip harness's iter 1 captures this — \`waitReadyAndPointMode\` succeeds against \`_globeState.mode\` then the snapshot sees a brief cluster state shortly after). Codex's retrospective on PR isamplesorg#203 recommended making \`_globeState.mode\` the single source of truth and wrapping mode transitions in one setter. This change does exactly that: - **\`getMode()\` getter** reads from \`viewer._globeState.mode\`. All former \`mode === ...\` reads in the zoomWatcher cell (10 sites: tryEnterPointModeIfNeeded, source-filter handler, facet-filter handler, camera-changed handler targetMode + transitions + stats guard, hashchange post-flight reconciliation) now go through it. - **\`setExplorerMode(next)\` setter** is the only writer. Used by \`enterPointMode\` and \`exitPointMode\`, which previously did the redundant \`mode = X; viewer._globeState.mode = X;\` pair. - **Closure \`let mode = 'cluster';\` removed.** This is foundation work for step 2 (introduce \`writeGlobeHash\` / \`reconcileCameraState\` and centralize the URL writers — Codex smell 1). Verification: \`url_roundtrip_investigation.js\` — 5/6 iterations green. The iter 1 anomaly ("mode A=cluster B=point" on no-op flight) is the same pre-existing boot-transition timing that Codex flagged in the original retrospective; it's neither caused nor worsened by this refactor and will be addressed when the camera reconciliation path is centralized in step 2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rdhyee
added a commit
to rdhyee/isamplesorg.github.io
that referenced
this pull request
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 1 of the #208 state-management refactor. Foundational.
Problem
The zoomWatcher OJS cell carried explorer mode in two places:
Both were updated together (`mode = 'point'; viewer._globeState.mode = 'point';`), but the duplication caused transient sync mismatches during boot. The URL round-trip harness captures this: `waitReadyAndPointMode` succeeds against `_globeState.mode` then a snapshot moments later sees a brief cluster state — the harness's iter 1 "mode A=cluster B=point" anomaly.
Codex's retrospective on PR #203 (item 7) recommended making `_globeState.mode` the single source of truth and wrapping transitions in one setter.
What this changes
20 insertions, 16 deletions. No behavioral changes intended — just collapses the duplication.
Verification
Risks
Sequencing reminder
Per Codex's recommended sequence (in #208):
Each step gets its own PR with Codex review.
Test plan
🤖 Generated with Claude Code