Skip to content

refactor: metro session graph final [WPB-26295]#4960

Merged
Garzas merged 15 commits into
developfrom
refactor/metro-session-graph-final
Jun 15, 2026
Merged

refactor: metro session graph final [WPB-26295]#4960
Garzas merged 15 commits into
developfrom
refactor/metro-session-graph-final

Conversation

@Garzas

@Garzas Garzas commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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


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 in this PR?

This PR continues the Metro session graph migration and stabilizes runtime behavior around account/session transitions.

Metro session graph refactor

  • Introduces an explicit session-backed authentication boundary for screens that still need an existing session during auth/device flows.
  • Moves session-dependent ViewModel creation toward AppSessionViewModelGraph(userId) instead of relying on implicit current-session resolution.
  • Updates auth/login/device/profile/settings/calling/home ViewModel factories and callsites to pass session context more explicitly.
  • Keeps no-session auth flows on the root/auth graph, while session-backed screens resolve a session graph only when a valid UserId is available.
  • Updates tests for the changed current-session/session-transition behavior.

Runtime stability fixes

  • Keeps session graphs lifecycle-retained from WireActivity, so recomposition/navigation does not recreate session-scoped graph objects too aggressively.
  • Moves WireSessionImageLoader and image loading bindings from root graph to session graph, so avatar/image cache is tied to the active account and does not flicker/reset when navigating.
  • Makes MessageSharedState session-scoped instead of root-scoped.
  • Restores NewConversationViewModel as a graph-scoped dependency from NewConversationGraph, removing the temporary SharedNewConversationViewModel bridge.
  • Fixes focus trap behavior in HomeDrawer so drawer content is not skipped when focus trap is disabled.
  • Moves some conversation message loading work to IO dispatcher to avoid blocking UI when opening conversations.

Issues fixed / validated manually

This targets the regressions we saw during Metro migration:

  • app opening login screen while valid accounts already exist,
  • account switching keeping stale session data,
  • login to second account navigating back to previous account/home,
  • too-many-devices flow not opening or crashing on cancel/back,
  • logout of last account crashing or leaving a blank screen,
  • removed-client event causing crash/blank screen instead of dialog/login/account switch,
  • create conversation leaving stale creation screens on back stack,
  • drawer items appearing with noticeable delay,
  • avatar flicker/disappearing before conversation navigation,
  • delay when opening conversations.

How to test

Recommended manual health check:

  • Fresh install with no accounts -> login flow opens.
  • App startup with existing account(s) -> conversation list opens, not login screen.
  • Switch between two accounts -> selected account/user data changes correctly.
  • Add second account with too many devices -> remove-device screen opens.
  • Cancel/back from remove-device screen -> no crash, returns to expected auth/account flow.
  • Remove device and continue login -> registration proceeds.
  • Logout with one account -> app lands on login flow without crash.
  • Logout with two accounts -> app switches to remaining account.
  • Trigger removed-client event from another device:
    • one account: dialog appears, then login flow;
    • multiple accounts: dialog appears, then switches to another valid account.
  • Open drawer repeatedly -> items appear without delay.
  • Open conversation from list/profile -> no avatar flicker, conversation opens promptly.
  • Create group/channel conversation -> back/close returns to conversation list correctly.
  • Open Cells / Shared Drive -> no Metro graph crash.

@Garzas Garzas self-assigned this Jun 11, 2026
@Garzas Garzas requested a review from a team as a code owner June 11, 2026 18:26
@Garzas Garzas requested review from MohamadJaara, ohassine, saleniuk, sbakhtiarov and typfel and removed request for a team June 11, 2026 18:26
@Garzas Garzas removed the request for review from typfel June 11, 2026 18:30
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.00000% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.93%. Comparing base (6e68f67) to head (9dfd44a).

Files with missing lines Patch % Lines
...rc/main/kotlin/com/wire/android/ui/WireActivity.kt 0.00% 25 Missing ⚠️
...rsations/messages/ConversationMessagesViewModel.kt 46.15% 6 Missing and 1 partial ⚠️
...otlin/com/wire/android/ui/WireActivityViewModel.kt 64.70% 5 Missing and 1 partial ⚠️
.../main/kotlin/com/wire/android/ui/home/HomeState.kt 20.00% 4 Missing ⚠️
...i/authentication/AuthenticationViewModelFactory.kt 0.00% 3 Missing ⚠️
...tication/create/code/CreateAccountCodeViewModel.kt 0.00% 3 Missing ⚠️
...n/kotlin/com/wire/android/ui/home/HomeViewModel.kt 25.00% 0 Missing and 3 partials ⚠️
...ion/code/CreateAccountVerificationCodeViewModel.kt 0.00% 3 Missing ⚠️
.../android/ui/authentication/login/LoginViewModel.kt 0.00% 2 Missing ⚠️
...n/com/wire/android/ui/home/HomeViewModelFactory.kt 0.00% 2 Missing ⚠️
... and 4 more

❌ Your patch check has failed because the patch coverage (38.00%) 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    #4960      +/-   ##
===========================================
- Coverage    48.93%   48.93%   -0.01%     
===========================================
  Files          643      643              
  Lines        23030    23055      +25     
  Branches      3519     3521       +2     
===========================================
+ Hits         11270    11282      +12     
- Misses       10715    10727      +12     
- Partials      1045     1046       +1     
Files with missing lines Coverage Δ
...wire/android/ui/authentication/login/LoginState.kt 73.91% <100.00%> (ø)
...ndroid/ui/home/conversations/MessageSharedState.kt 75.00% <100.00%> (ø)
...tlin/com/wire/android/ui/home/drawer/HomeDrawer.kt 0.00% <ø> (ø)
.../home/settings/backup/BackupAndRestoreViewModel.kt 79.62% <100.00%> (ø)
.../home/settings/privacy/PrivacySettingsViewModel.kt 50.00% <100.00%> (ø)
...droid/ui/newauthentication/login/NewLoginAction.kt 100.00% <100.00%> (ø)
...id/ui/newauthentication/login/NewLoginViewModel.kt 78.44% <100.00%> (ø)
.../userprofile/avatarpicker/AvatarPickerViewModel.kt 91.78% <100.00%> (ø)
...id/ui/userprofile/self/SelfUserProfileViewModel.kt 58.15% <100.00%> (ø)
...serprofile/teammigration/TeamMigrationViewModel.kt 78.57% <100.00%> (ø)
... and 15 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 6e68f67...9dfd44a. Read the comment docs.

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

@Garzas Garzas changed the title Refactor: metro session graph final [WPB-26295] refactor: metro session graph final [WPB-26295] Jun 12, 2026
@pull-request-size

Copy link
Copy Markdown

Ups 🫰🟨

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

@Garzas Garzas force-pushed the refactor/metro-session-graph-final branch from ce20144 to e1e4ce6 Compare June 12, 2026 11:02
@Garzas Garzas force-pushed the refactor/metro-session-graph-final branch from f536419 to e8de862 Compare June 12, 2026 14:20
Comment thread app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
@@ -1135,12 +1190,16 @@ private data class SessionNavigationState(
private val noSessionAuthenticationGraphRoutes = setOf(

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.

Do we need all of these lists just to compare routes?
Can't we re-use the CurrentScreen where many destinations are already grouped into some meaningful groups?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This logic is not about UI grouping or analytics/current screen classification. It controls whether WireActivity is allowed to create a session graph, create a session-backed auth graph, or stay in no-session auth mode.
Some auth routes look similar from a “current screen” perspective, but differ in session ownership: login/account creation must not create a session graph, while remove/register-device screens need an explicit session user id.

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.

Ok, but keep in mind that from now on, devs need to be aware that when someone adds some new destination then it potentially needs to be added to one of these lists for the app to work properly, so either we find some better way or at least document it properly and make everyone aware of that 🤔

Comment thread app/src/main/kotlin/com/wire/android/ui/AppLockActivity.kt
@Garzas Garzas requested a review from saleniuk June 15, 2026 02:58
@Garzas Garzas added this pull request to the merge queue Jun 15, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 15, 2026
…sion-graph-final

# Conflicts:
#	app/stability/app-devDebug.stability
@Garzas Garzas enabled auto-merge June 15, 2026 11:14
@sonarqubecloud

Copy link
Copy Markdown

@Garzas Garzas added this pull request to the merge queue Jun 15, 2026
Merged via the queue into develop with commit e16d539 Jun 15, 2026
20 checks passed
@Garzas Garzas deleted the refactor/metro-session-graph-final branch June 15, 2026 11:47
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.

3 participants