feat(experiments): default end-experiment flow to leaving flag untouched#58681
Draft
raquelmsmith wants to merge 1 commit into
Draft
feat(experiments): default end-experiment flow to leaving flag untouched#58681raquelmsmith wants to merge 1 commit into
raquelmsmith wants to merge 1 commit into
Conversation
Make the "End experiment" modal an explicit two-way choice between keeping the feature flag as-is (now the default) and rolling out a variant to 100%. The previous default pre-selected the first non-control variant, so clicking "End experiment" could silently modify the linked feature flag. Generated-By: PostHog Code Task-Id: 60d2bd9f-f9e0-4b54-9c94-332f29de343e
Contributor
🦔 Preview instance✅ Preview deployment ready 🌐 Access the instanceURL: https://do-ci-hobby-pr-58681.posthog.cc SSH: IP: Mode: 🔄 Preview (persistent) Full instance detailsDeployment output |
Contributor
|
Size Change: +40.9 kB (+0.03%) Total Size: 117 MB 📦 View Changed
ℹ️ View Unchanged
|
Contributor
✅ Hobby deploy smoke test: PASSEDHobby deployment smoke test passed successfully. |
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.
Problem
Ending an experiment can silently update its linked feature flag. The current "End experiment" modal pre-selects the first non-control variant in a "Variant to keep" dropdown; if the user clicks "End experiment" without clearing that selection, the flag is rewritten to roll that variant out to 100% of users. For non-engineers who think they're just marking the experiment as finished, this is easy to do by accident, and feature flag mutations are high-blast-radius.
Changes
Replaces the implicit, pre-filled variant picker with an explicit two-way choice at the top of the modal:
endExperimentWithoutShipping, which marks the experiment ended without touching the flag.finishExperiment/ship_variantpath.Other details:
isSingleVariantShippedbranch (a variant is already at 100%) is unchanged — it still just confirms ending without modifying the flag.No backend, API, kea action, or test fixture changes —
finishExperiment({ selectedVariantKey })andendExperimentWithoutShipping()retain identical signatures and behavior.How did you test this code?
I'm an agent (PostHog Code). I did not perform manual browser testing — the dev server isn't running in this environment. Automated checks I did run:
pnpm --filter=@posthog/frontend format— completed with 0 errors (1165 pre-existing repo-wide warnings unchanged).pnpm --filter=@posthog/frontend exec tsc --noEmiton the touched file — the only TS error reported isTS7031on the({ key })destructuring in the variants.map(), which is pre-existing on master (line 714 before, line 739 after) and not introduced by this change.No existing tests reference the modal at the React level —
experimentLogic.test.tscovers the underlyingfinishExperimentaction, whose signature is unchanged.The commit was made with
--no-verifybecause the temp workspace lacks the Python venvbin/hogli format:jsneeds; the equivalent formatter (oxlint --fix+oxfmt) was run manually beforehand via the frontendformatscript.Publish to changelog?
no
Docs update
No docs changes required — the experiment lifecycle docs describe ending an experiment in terms of "ship a variant or end without shipping," which still matches this UI.
🤖 Agent context
Authored by PostHog Code in response to a sev-1 report where a non-engineer ended an experiment and unintentionally rolled a variant out to 100% of users.
Approach considered and rejected: removing the
ConclusionFormfrom the modal. The user's brief asked for the rollout decision specifically to be simple, but removing the conclusion form would drop a separate piece of experiment metadata (won/lost/inconclusive/stopped early) that isn't tied to the flag mutation problem. Kept the conclusion form unchanged.Approach considered and rejected: a
LemonDialogconfirm. Discarded because the variant picker only makes sense alongside the rollout option, andLemonDialogis awkward for that kind of conditional sub-input.Files touched:
frontend/src/scenes/experiments/ExperimentView/components.tsx—FinishExperimentModalrewritten to use aLemonRadiowithkeepas the default; helperwillModifyFlagcomputed once and reused for the action dispatch, the disabled-reason, and the "more precise control" banner.Created with PostHog Code