Skip to content

Conversation

@ThomasK33
Copy link
Member

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:

  • Replace dropdown with Switch component in ExperimentsSection
  • Simplify FeatureFlagsContext API: setStatsTabOverridesetStatsTabEnabled
  • Remove PostHog implementation details from user-facing description
  • Backend schema unchanged (preserves flexibility)

📋 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

  • UI: ExperimentsSection.tsx renders StatsTabOverrideRow with a <select> dropdown containing 3 options
  • Frontend context: FeatureFlagsContext.tsx exposes StatsTabState with variant, override, and enabled fields
  • Backend service: featureFlagService.ts fetches PostHog variant and applies 3-way override logic
  • Storage: Backend stores override in ~/.mux/config.json under featureFlagOverrides[stats_tab_v1]
  • Schema: api.ts defines StatsTabOverrideSchema = z.enum(["default", "on", "off"])

Proposed Changes

1. Frontend: Replace dropdown with toggle (~-30 LoC)

File: src/browser/components/Settings/sections/ExperimentsSection.tsx

  • Replace StatsTabOverrideRow with a simpler row using <Switch>:
    • Label: "Stats tab"
    • Description: "Show timing statistics in the right sidebar" (no PostHog mention)
    • Toggle reflects statsTabState.enabled
    • Toggle calls setStatsTabOverride("on" | "off") based on new state

2. Context: Simplify setStatsTabOverride signature (~-5 LoC)

File: src/browser/contexts/FeatureFlagsContext.tsx

  • setStatsTabOverride(override: StatsTabOverride)setStatsTabEnabled(enabled: boolean)
  • Internally convert boolean to "on" | "off" when calling backend
  • No more "default" option exposed to UI

3. Backend & Schema: Unchanged

The backend already stores "on" | "off" | "default" and computes enabled based 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 + ExperimentsContext pattern (localStorage-based), but:

  • That would lose PostHog A/B tracking capability
  • Would require data migration from config.json to localStorage
  • The current feature flag service is already correct; simplifying the UI is sufficient

This alternative is not recommended for this change.

Net LoC Estimate

~-25 lines (remove dropdown complexity, add simpler toggle, simplify context API)

Files Modified

  1. src/browser/components/Settings/sections/ExperimentsSection.tsx
  2. src/browser/contexts/FeatureFlagsContext.tsx

Testing

  • Manual: Open Settings → Experiments → verify toggle works
  • Existing typecheck and lint will catch regressions

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

Convert the Stats Tab experiment setting from a 3-option dropdown
(Default/Always on/Always off) to a simple on/off toggle, matching
the UX pattern used for other experiments like Post-Compaction Context.

Changes:
- Replace dropdown with Switch component in ExperimentsSection
- Simplify FeatureFlagsContext API: setStatsTabOverride → setStatsTabEnabled
- Remove PostHog implementation details from user-facing description
- Backend schema unchanged (preserves flexibility)

Change-Id: I3dfad1c229690a4806cdbcf2ebb2d758f205c14f
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33 ThomasK33 added this pull request to the merge queue Dec 19, 2025
Merged via the queue into main with commit beaf779 Dec 19, 2025
20 checks passed
@ThomasK33 ThomasK33 deleted the settings-y58q branch December 19, 2025 11:59
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