fix(surveys): honor choice option shuffling - #811
Open
lucasheriques wants to merge 2 commits into
Open
Conversation
Replace a fixed 100 ms wait between retry attempts with the existing bounded polling helper. An in-flight first upload could otherwise swallow the second flush and leave the test waiting for a retry it never requested. Verification: make test passed (794 Swift Testing tests, plus legacy tests).
Use the existing shuffleOptions flag in the shared choice renderer. Keep Other last and retain original choice indices for selection, translated labels and response mapping. Store the order in view state and reset it when moving to another question or changing the choice count. Match the web fallback when randomization returns the original order. Add parameterized shuffle, disabled, short-list and duplicate-choice tests. Verification: make test; focused SurveyChoiceOrderTests; make format; make lint; make apiCheck; CodeScene safeguard passed. make build passed iOS, macOS and Catalyst, then stopped at missing tvOS SDK. watchOS and visionOS SDKs are also unavailable locally. No public API changes.
3 tasks
Contributor
Prompt To Fix All With AI### Issue 1
PostHog/Surveys/QuestionTypes.swift:192
**Translation reshuffles active choices**
When a live translation changes the current question's choice count, this ID recreates `MultipleChoiceOptions` and generates a new random display order. The parent keeps the selected indices and open-choice input, so the visible options can move beneath an existing selection while the person is still answering. This breaks the intended stable display order and the existing in-place translation update behavior.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(surveys): honor choice option shuffl..." | Re-trigger Greptile |
| shuffleOptions: question.shuffleOptions | ||
| ) | ||
| .id(question.choices.count) | ||
|
|
Contributor
There was a problem hiding this comment.
Translation reshuffles active choices
When a live translation changes the current question's choice count, this ID recreates MultipleChoiceOptions and generates a new random display order. The parent keeps the selected indices and open-choice input, so the visible options can move beneath an existing selection while the person is still answering. This breaks the intended stable display order and the existing in-place translation update behavior.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: PostHog/Surveys/QuestionTypes.swift
Line: 192
Comment:
**Translation reshuffles active choices**
When a live translation changes the current question's choice count, this ID recreates `MultipleChoiceOptions` and generates a new random display order. The parent keeps the selected indices and open-choice input, so the visible options can move beneath an existing selection while the person is still answering. This breaks the intended stable display order and the existing in-place translation update behavior.
**Knowledge Base Used:**
- [Surveys](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/posthog-ios/-/docs/surveys.md)
- [In-app experiences](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/posthog-ios/-/docs/in-app-experiences.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Contributor
posthog-ios Compliance ReportDate: 2026-09-09 22:06:34 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
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.
💡 Motivation and Context
Honor the existing
shuffleOptionsflag in the built-in iOS survey UI, moving toward survey feature parity across all PostHog SDKs. Matches web behavior for single- and multiple-choice questions:No public API changes. The shared renderer owns the display order; the raw survey choices remain unchanged. Separate from partial responses/resume (#807) and auto-submit (#808). Android counterpart: PostHog/posthog-android#772.
💚 How did you test it?
make testpassed: 794 Swift Testing tests plus the legacy suite.make format,make lint,make apiCheckand the CodeScene safeguard passed.make buildthen stopped at the unavailable tvOS SDK; watchOS/visionOS SDKs are also missing locally. No new mounted iOS UI tests in this PR.The full suite exposed a logs-queue test relying on a 100 ms retry delay; a separate test-only commit replaces it with bounded polling.
📝 Checklist
pnpm changeset.🤖 Agent context
Autonomy: Human-driven (agent-assisted). Codex implemented and tested this through CLI tools. Human review is required.