Skip to content

chore(quality): add Konsist rules for MVI UI conventions - #11952

Open
BenjaminGROISNE wants to merge 4 commits into
thunderbird:mainfrom
BenjaminGROISNE:feat/konsist-mvi-rules
Open

BenjaminGROISNE wants to merge 4 commits into
thunderbird:mainfrom
BenjaminGROISNE:feat/konsist-mvi-rules

Conversation

@BenjaminGROISNE

Copy link
Copy Markdown
Contributor

Contribution Summary

Linked Issue/Ticket: Closes #11857

Description

Adds Konsist rules (quality/konsist/.../ui/ValidateMviConventions.kt) for the conventions in ui-architecture.md and module-structure.md:

  • ViewModels extend BaseViewModel or BaseStateMachineViewModel (matched by fully qualified name).
  • UI contracts declare State, Event and Effect, nested or as the type arguments of a shared MVI type.
  • ViewModels and *Screen composables reside in ui packages.
  • Only *Screen composables, or entry points with a koinViewModel() default, take a ViewModel. This covers the case detekt's ViewModelForwarding misses.

Existing violations are baselined in MviBaseline.kt. The rules also fail on stale entries, so the baseline can only shrink: 35 on main, 28 after this PR.

Fixes, one commit each:

  • Move the changelog UI classes into a ui package.
  • Move the debug settings UI classes into a ui package.
  • Migrate RecentChangesViewModel from LiveData to BaseViewModel. The message list fragments collect it with the existing Flow.observe helper, which now returns its Job.

Testing

  • :quality:konsist:test passes on each commit. A temporary file with one violation per rule made each rule fail.
  • New RecentChangesViewModelTest (5 cases). Both apps' DependencyInjectionTest pass.
  • ./gradlew test lint detekt spotlessCheck passes, except ImapServerSettingsValidatorTest, which fails the same way on a clean main locally.

AI Disclosure

  • This contribution does not include any changes created or assisted by AI.
  • This contribution includes changes assisted by AI.
  • This contribution includes changes created by AI.

Contribution Checklist

  • I have read, and I affirm that my contribution adheres to Mozilla’s Community Participation Guidelines
  • This contribution is in Kotlin where possible
  • This contribution does not use merge commits
  • This contribution adheres to the existing codestyle (run gradlew spotlessCheck to check and gradlew spotlessApply to format your source code; will be checked by CI).
  • This contribution does not break existing unit tests (run gradlew testDebugUnitTest; will be checked by CI).
  • This contribution includes tests for any new functionality and maintains tests for any updated functionality.
  • This contribution adheres to our Engineering process (RFC/Technical Design/ADR)

🤖 Generated with Claude Code

Enforce the MVI conventions from docs/architecture/ui-architecture.md and
the ui package layout from docs/architecture/module-structure.md:

- ViewModels extend BaseViewModel or BaseStateMachineViewModel
- contracts with a nested ViewModel declare State, Event and Effect,
  nested or as the type arguments of a shared MVI type
- ViewModels and *Screen composables reside in ui packages
- only *Screen composables, or entry points that inject their ViewModel
  with koinViewModel(), take a ViewModel

Base classes are matched by fully qualified name, so the catalog's own
BaseViewModel copy is not mistaken for the shared one. The 35 existing
violations are baselined by path and name; the rules fail on new
violations and on baseline entries that no longer match.

Closes thunderbird#11857
Move ChangelogContract, ChangelogScreen, ChangelogViewModel and
RecentChangesViewModel to net.thunderbird.feature.changelog.internal.ui,
as described in docs/architecture/module-structure.md, and remove their
entries from the MVI baseline.
Move the debug settings screen, its sections and their ViewModels and
contracts to net.thunderbird.feature.debug.settings.ui, as described in
docs/architecture/module-structure.md, and remove their entries from the
MVI baseline. Navigation and dependency injection stay where they are.
Add RecentChangesContract and expose the recent changes hint as MVI
state instead of LiveData. The message list fragments collect the state
with flowWithLifecycle, so the hint is still only shown while the view is
started, and send OnRecentChangesHintDismissed instead of calling the
ViewModel directly.

Remove the last changelog entry from the MVI baseline.
@github-actions

Copy link
Copy Markdown
Contributor

Missing report label. Set exactly one of: report: include, report: exclude OR report: highlight.

@thunderbird-botmobile thunderbird-botmobile Bot added the pr-sentinel: ready for review Passed all automated PR Sentinel checks. Ready for maintainer review. label Nov 24, 2026

This branch was successfully deployed

2 active deployments
botmobile — 13564401 Deployed Nov 24, 2026 by BenjaminGROISNE via PR Sentinel #523
review — 13564401 Deployed Nov 24, 2026 by BenjaminGROISNE via label-tb-team #718
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-sentinel: ready for review Passed all automated PR Sentinel checks. Ready for maintainer review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Konsist: enforce MVI UI conventions

2 participants