Skip to content

refactor: migrate viewmodel creation to metro [WPB-25946]#4945

Open
Garzas wants to merge 2 commits into
developfrom
refactor/metro-viewmodel-base
Open

refactor: migrate viewmodel creation to metro [WPB-25946]#4945
Garzas wants to merge 2 commits into
developfrom
refactor/metro-viewmodel-base

Conversation

@Garzas

@Garzas Garzas commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

https://wearezeta.atlassian.net/browse/WPB-25946


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new

Migrates ViewModel creation to Metro/MetroX.

This introduces shared Metro-backed ViewModel factory/bindings and updates app, Cells, and Meetings ViewModel call sites to resolve ViewModels through Metro-backed APIs.

Why

This moves us closer to the final Metro DI model where ViewModel construction is handled by Metro scopes instead of Hilt-style/manual bridge objects.

The important part is scope-safe ViewModel lookup. Session ViewModels must include the current session/account scope in their key, otherwise Compose can reuse a ViewModel created for another account after account switching, logout, or client removal.

Changes

  • Added shared Metro ViewModel factory wiring.
  • Added app-level ViewModel bindings.
  • Added Cells and Meetings ViewModel bindings.
  • Added scopedMetroViewModel and scopedAssistedMetroViewModel helpers with KDoc.
  • Updated ViewModel helper functions to use Metro/MetroX with scoped keys.
  • Preserved special auth key handling for login/remove-device flows that use route args or ViewModelStoreOwner.
  • Included feature module ViewModel binding containers in the root WireApplicationGraph, so the app-level MetroViewModelFactory can resolve Cells and Meetings ViewModels.

@Garzas Garzas self-assigned this Jun 9, 2026
@Garzas Garzas requested a review from a team as a code owner June 9, 2026 21:15
@Garzas Garzas requested review from emmaoke-w and yamilmedina and removed request for a team June 9, 2026 21:15
@pull-request-size

Copy link
Copy Markdown

Ups 🫰🟨

This PR is too big. Please try to break it up into smaller PRs.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.43902% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.08%. Comparing base (72cc855) to head (2c66548).

⚠️ Current head 2c66548 differs from pull request most recent head bd13018

Please upload reports for the commit bd13018 to get more accurate results.

Files with missing lines Patch % Lines
...rc/main/kotlin/com/wire/android/ui/WireActivity.kt 0.00% 14 Missing ⚠️
...id/feature/cells/ui/CellsMetroViewModelBindings.kt 0.00% 14 Missing ⚠️
...ture/meetings/ui/MeetingsMetroViewModelBindings.kt 0.00% 5 Missing ⚠️
.../ui/authentication/AuthenticationViewModelGraph.kt 0.00% 3 Missing ⚠️
...i/authentication/AuthenticationViewModelFactory.kt 0.00% 2 Missing ⚠️
...c/main/kotlin/com/wire/android/model/ImageAsset.kt 33.33% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (2.43%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4945      +/-   ##
===========================================
- Coverage    49.14%   49.08%   -0.06%     
===========================================
  Files          650      643       -7     
  Lines        22989    23017      +28     
  Branches      3518     3518              
===========================================
+ Hits         11297    11298       +1     
- Misses       10645    10672      +27     
  Partials      1047     1047              
Files with missing lines Coverage Δ
...n/kotlin/com/wire/android/ui/MiscViewModelGraph.kt 0.00% <ø> (ø)
...re/android/ui/connection/ConnectionActionButton.kt 0.00% <ø> (ø)
...m/wire/android/ui/debug/DebugInfoViewModelGraph.kt 0.00% <ø> (ø)
...ations/details/options/GroupConversationOptions.kt 0.00% <ø> (ø)
...nversations/edit/MessageOptionsModalSheetLayout.kt 0.00% <ø> (ø)
...id/ui/home/conversations/messages/QuotedMessage.kt 0.00% <ø> (ø)
...ndroid/ui/home/conversations/model/MessageTypes.kt 14.28% <ø> (ø)
.../ui/home/messagecomposer/EnabledMessageComposer.kt 0.00% <ø> (ø)
...nConversation/JoinConversationViaDeepLinkDialog.kt 85.71% <ø> (ø)
...i/authentication/AuthenticationViewModelFactory.kt 0.00% <0.00%> (ø)
... and 5 more

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72cc855...bd13018. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant