Skip to content

Rename PreviewParameterProvider subclasses to the PreviewParam suffix - #7468

Open
hayaksi1 wants to merge 1 commit into
element-hq:developfrom
hayaksi1:fix/4657-preview-param-suffix
Open

Rename PreviewParameterProvider subclasses to the PreviewParam suffix#7468
hayaksi1 wants to merge 1 commit into
element-hq:developfrom
hayaksi1:fix/4657-preview-param-suffix

Conversation

@hayaksi1

Copy link
Copy Markdown
Contributor

Content

The Provider suffix on PreviewParameterProvider subclasses reads as a dependency provider rather than as preview data, and it collides with the real providers in the codebase — StringProvider, PickerProvider, and the login feature's own AccountProvider domain type — so the name does not say which of the two a class is. This renames them all to a PreviewParam suffix, as agreed on the issue.

195 classes move, along with the 185 files named after them, the konsist rule that enforces the convention, the two presentation-class file templates plus their settings, and the onboarding documentation.

It cannot be split. Konsist.scopeFromProduction() scans the whole project, so flipping the assertion before every class has moved leaves the rule red, and a rule accepting either suffix during a transition would be the kind of compatibility layer this change exists to avoid.

Two judgement calls inside the rule are worth calling out. The name.endsWith("PreviewProvider").not() clause is dropped, because its only job was to reject a redundant Preview in front of Provider and the new suffix already contains Preview; no class currently ends with PreviewProvider, so this changes nothing today. And EditableAvatarViewUriProvider is renamed in the exclusion list rather than removed, even though no such class exists in this repository — it presumably comes from the modules overlaid for the enterprise build, so any PreviewParameterProvider still named *Provider over there will need the same rename before the flipped rule passes for that variant.

Nothing else keyed off the old suffix. No snapshot filename contains a provider class name, so there is no Paparazzi churn, and the Kover variants match on *Presenter, *State and *ViewKt, so the coverage bounds do not move.

Motivation and context

Part of #4657.

Tests

tests/konsist/.../KonsistClassNameTest.kt is the test for this convention: the rule now requires the PreviewParam suffix, and its "more than 100 classes found" guard still holds. Run with ./gradlew :tests:konsist:testDebugUnitTest --rerun — konsist scans sources at execution time, so a cached run proves nothing.

./gradlew :tests:uitests:compileDebugUnitTestKotlin compiles every module the rename touches (188 of them) and is green, and ./gradlew ktlintFormat handled the import re-ordering that the renames forced.

git status --porcelain -- tests/uitests/src/test/snapshots is empty, which is the check that no snapshot changed.

No new test: a naming convention has nothing behavioural to assert beyond the konsist rule.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • I am aware of the etiquette.
  • This PR was made with the help of AI:
    • Yes. In this case, please request a review by Copilot.
    • No.
  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly defines what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

The `Provider` suffix reads as a dependency provider rather than as preview
data, and it collides with the real providers in the codebase — `StringProvider`,
`PickerProvider`, the login feature's `AccountProvider` — so the name says
nothing about which of the two a class is. `PreviewParam` says it.

195 classes are renamed, along with the 185 files named after them, the konsist
rule that enforces the convention, the presentation-class file templates and the
onboarding documentation.

This cannot be split. `Konsist.scopeFromProduction()` scans the whole project, so
flipping the assertion before every class has moved leaves the rule red, and a
rule that accepted either suffix during a transition would be exactly the kind of
compatibility layer this convention change is meant to remove.

Two judgement calls in the rule itself. The `name.endsWith("PreviewProvider")`
exclusion is dropped: its only job was to reject a redundant `Preview` before
`Provider`, and the new suffix already contains it; no class currently ends with
`PreviewProvider`, so removing it changes nothing today. And
`EditableAvatarViewUriProvider` is renamed rather than deleted from the exclusion
list even though no such class exists in this repository, since it presumably
comes from the modules overlaid for the enterprise build.

Nothing keyed off the old suffix: no snapshot filename contains a provider class
name, so no Paparazzi image changes, and the Kover variants match on `*Presenter`,
`*State` and `*ViewKt`, so coverage bounds are unaffected.
@hayaksi1
hayaksi1 requested a review from a team as a code owner August 17, 2026 14:41
@hayaksi1
hayaksi1 requested review from jmartinesp and removed request for a team August 17, 2026 14:41
@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant