Skip to content

fix(surveys): honor choice option shuffling - #772

Open
lucasheriques wants to merge 1 commit into
mainfrom
lucas/surveys-shuffle-options
Open

fix(surveys): honor choice option shuffling#772
lucasheriques wants to merge 1 commit into
mainfrom
lucas/surveys-shuffle-options

Conversation

@lucasheriques

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Honor the existing shuffleOptions flag in Android Compose surveys, moving toward survey feature parity across all PostHog SDKs. Matches web behavior for single- and multiple-choice questions:

  • Shuffle regular choices, keeping Other last. False or absent keeps the configured order.
  • Preserve the order while selecting, typing and restoring saved UI state.
  • Keep the configured choice list unchanged so answers and branching still refer to the selected value.

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.
  • Ignoring the flag in the renderer made all four enabled-shuffle interaction cases fail; disabled cases still passed. The order tests also cover web's unchanged-order fallback, empty/short lists and duplicate labels.

The additional build configuration and lockfile entries enable the Compose interaction tests in CI; runtime dependencies are unchanged.

📝 Checklist

  • Reviewed the code and added regression tests.
  • Added a patch changeset with pnpm changeset.
  • Public API unchanged.

🤖 Agent context

Autonomy: Human-driven (agent-assisted). Codex implemented and tested this through CLI tools. Human review is required.

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.
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor
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

Comment on lines +27 to +29
private val multiple: Boolean,
private val open: Boolean,
private val shuffle: Boolean,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

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