fix(surveys): honor choice option shuffling - #772
lucasheriques wants to merge 1 commit into
Conversation
Apply the existing shuffleOptions flag in the shared Compose choice UI. Shuffle original indices, keep Other last and preserve the display order through selection, text edits and saved-state restoration. Preserve the configured choice list and submit the selected label or open-choice text. Add parameterized order tests and eight mounted interaction cases covering single/multiple selection, open choice, disabled shuffling, restoration, response values and advancing to a question with a different choice count. Run the Compose debug suite in CI and record its test dependency locks. Verification: make testSurveyUI (25 tests); Compose build and local publish; formatting and CodeScene safeguard passed. Full build/release verification is recorded in the PR description.
Prompt To Fix All With AI### Issue 1
posthog-android-surveys-compose/src/testDebug/java/com/posthog/android/surveys/compose/internal/ui/SurveyShuffleInteractionTest.kt:27-29
**Unclear Boolean parameter names**
The parameters `multiple`, `open`, and `shuffle` do not clearly communicate that they control multiple-choice mode, open-choice support, and option shuffling. This violates the repository directive to use variable names that clearly indicate their purpose. Rename them to descriptive names such as `isMultipleChoice`, `hasOpenChoice`, and `shouldShuffleOptions`; this repository requirement must be satisfied before merging.
---
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 |
| private val multiple: Boolean, | ||
| private val open: Boolean, | ||
| private val shuffle: Boolean, |
There was a problem hiding this comment.
Unclear Boolean parameter names
The parameters multiple, open, and shuffle do not clearly communicate that they control multiple-choice mode, open-choice support, and option shuffling. This violates the repository directive to use variable names that clearly indicate their purpose. Rename them to descriptive names such as isMultipleChoice, hasOpenChoice, and shouldShuffleOptions; this repository requirement must be satisfied before merging.
Rule Used: Use descriptive variable names that clearly indica... (source)
Learned From
PostHog/posthog#32928
Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog-android-surveys-compose/src/testDebug/java/com/posthog/android/surveys/compose/internal/ui/SurveyShuffleInteractionTest.kt
Line: 27-29
Comment:
**Unclear Boolean parameter names**
The parameters `multiple`, `open`, and `shuffle` do not clearly communicate that they control multiple-choice mode, open-choice support, and option shuffling. This violates the repository directive to use variable names that clearly indicate their purpose. Rename them to descriptive names such as `isMultipleChoice`, `hasOpenChoice`, and `shouldShuffleOptions`; this repository requirement must be satisfied before merging.
**Rule Used:** Use descriptive variable names that clearly indica... ([source](https://app.greptile.com/posthog-org-19734/-/custom-context?memory=350bd1c2-e8ad-4a3d-b397-dc32abce28bc))
**Learned From**
[PostHog/posthog#32928](https://github.com/PostHog/posthog/pull/32928)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
💡 Motivation and Context
Honor the existing
shuffleOptionsflag in Android Compose surveys, moving toward survey feature parity across all PostHog SDKs. Matches web behavior for single- and multiple-choice questions:The change lives in the shared choice renderer. No public API changes. Separate from partial responses/resume (#768) and auto-submit (#769); iOS counterpart: PostHog/posthog-ios#811.
💚 How did you test it?
make testSurveyUI: 25 tests passed, including 8 parameterized order tests and 8 mounted interaction cases. Covers both choice types, enabled/disabled shuffle, Other text, saved-state restoration, exact responses and advancing to a question with fewer choices.CI=true make compile, Compose debug/release build,make checkRelease, formatting and the CodeScene safeguard passed.The additional build configuration and lockfile entries enable the Compose interaction tests in CI; runtime dependencies are unchanged.
📝 Checklist
pnpm changeset.🤖 Agent context
Autonomy: Human-driven (agent-assisted). Codex implemented and tested this through CLI tools. Human review is required.