🤖 refactor: simplify stats tab experiment to toggle #1224
Merged
+29
−40
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.
Convert the Stats Tab experiment setting from a 3-option dropdown to a simple on/off toggle, matching the UX pattern used for other experiments.
Changes:
setStatsTabOverride→setStatsTabEnabled📋 Implementation Plan
Plan: Simplify Stats Tab Experiment Toggle
Goal
Convert the Stats Tab experiment from a 3-option dropdown (
Default (experiment),Always on,Always off) to a simple on/off toggle, matching the pattern used for other experiments like Post-Compaction Context.Current State
ExperimentsSection.tsxrendersStatsTabOverrideRowwith a<select>dropdown containing 3 optionsFeatureFlagsContext.tsxexposesStatsTabStatewithvariant,override, andenabledfieldsfeatureFlagService.tsfetches PostHog variant and applies 3-way override logic~/.mux/config.jsonunderfeatureFlagOverrides[stats_tab_v1]api.tsdefinesStatsTabOverrideSchema = z.enum(["default", "on", "off"])Proposed Changes
1. Frontend: Replace dropdown with toggle (~-30 LoC)
File:
src/browser/components/Settings/sections/ExperimentsSection.tsxStatsTabOverrideRowwith a simpler row using<Switch>:statsTabState.enabledsetStatsTabOverride("on" | "off")based on new state2. Context: Simplify
setStatsTabOverridesignature (~-5 LoC)File:
src/browser/contexts/FeatureFlagsContext.tsxsetStatsTabOverride(override: StatsTabOverride)→setStatsTabEnabled(enabled: boolean)"on" | "off"when calling backend3. Backend & Schema: Unchanged
The backend already stores
"on" | "off" | "default"and computesenabledbased on PostHog variant + override. We keep this to allow future flexibility, but the UI will only ever set"on"or"off"(never"default").Alternative: Migrate to experiments system
We could move Stats Tab to the existing
EXPERIMENTS+ExperimentsContextpattern (localStorage-based), but:config.jsonto localStorageThis alternative is not recommended for this change.
Net LoC Estimate
~-25 lines (remove dropdown complexity, add simpler toggle, simplify context API)
Files Modified
src/browser/components/Settings/sections/ExperimentsSection.tsxsrc/browser/contexts/FeatureFlagsContext.tsxTesting
Generated with
mux• Model:anthropic:claude-opus-4-5• Thinking:high