fix(desktop): hide the v1/v2 switch once the flip is locked
What
Once the v1 migration marker is written for an org, useIsV2CloudEnabled returns v2 before it ever reads the optInV2 override. The "Try Superset v2" switch in Experimental settings still rendered, so toggling it off wrote the override, fired surface_toggled, and snapped back on the next render. It looked interactive and did nothing.
This is live: one migrated user clicked it about 30 times post-flip (surface_toggled events, to=v1, after their v1_auto_migration_completed).
Change
- New
useIsV1FlipLocked: true when the org's migration marker is set at boot, or the forced-flip backstop is active. Both states ignoreoptInV2. ExperimentalSettingshides the switch row when the flip is locked. "Import from v1" stays visible as the recovery path.- Unlocked v1 users and voluntary v2 opt-ins (no marker) keep the working toggle.
Testing
- New unit tests: lock semantics (marker beats explicit opt-out, opt-in does not lock, no-org case) and settings rendering per state. Mutation-checked: reverting the render guard and inverting the marker-vs-override priority each fail a test.
- Full desktop suite: 2695 pass, 0 fail. Typecheck clean.
- Verified in the dev app over CDP, screenshots of Settings -> Experimental in all three states:
- v1 user, unmigrated: toggle visible and off.
- migrated machine with opt-out still set (the affected user's exact state): boots v2, toggle gone, Import from v1 present.
- voluntary v2 opt-in, no marker: toggle visible and on.
No v1 code paths change behavior: the row only disappears in states where the app already boots v2 unconditionally.
Summary by cubic
Hides the v1/v2 switch in Experimental settings once the v1→v2 flip is locked to remove a dead control. Previously, migrated or forced-flip users could toggle it, which wrote optInV2, fired surface_toggled, and immediately reverted to v2.
- Adds
useIsV1FlipLocked(true when the org’s migration marker is present at boot or the forced-flip backstop is active) and gates the switch on it; both states ignoreoptInV2. - Keeps the toggle for unlocked users (v1-era and voluntary v2 opt-ins); v2-only signups without a marker still see it. Import from v1 remains visible where applicable.
- Tests cover marker precedence, forced-flip activation, no-org case, and settings rendering; makes the
notifyQuotaExhaustedtoast interception order-immune by patching@superset/ui/sonner, and spreads real modules in test mocks so they survive any load order.
Summary by CodeRabbit
-
New Features
- Added safeguards that prevent switching back to v1 after migration or when the forced transition is active.
- Preserved the v1 import recovery option for eligible accounts.
-
Bug Fixes
- Updated Experimental Settings to hide the v2 toggle when v1 is locked.
- Ensured forced transition states consistently enable v2 and lock v1.
-
Tests
- Added coverage for migration states, opt-ins, opt-outs, inactive sessions, forced transitions, import recovery, and settings behavior.