fix(#424): fully fix logout→login cycle — clear ViewModel state + manage WS lifecycle (#429)

* fix(#424): fully fix logout→login cycle — clear ViewModel state + manage WS lifecycle

The previous fix (PR #427) fixed button responsiveness after logout
but left two issues that kept login-after-logout broken:

1. Stale ViewModel state — AuthLoginViewModel is Activity-scoped,
   so  stayed  from the first login. When
   the user returned to the login screen, LaunchedEffect fired
   instantly with the stale value and bounced them to ChatScreen
   without showing the form.

   Fix: DisposableEffect(onDispose) clears connectionSuccess,
   errorMessage, and isLoading when the screen leaves composition.

2. WebSocket lifecycle — logout() never disconnected the WS, so
   it stayed open with a null/stale token. After re-login, no one
   called connect() with the fresh credentials.

   Fix: HermesWsClient.disconnect() on logout,
   HermesWsClient.connect() after successful re-login.

* fix(#424): route landing screen clicks through navigateTo

Avoid direct backStack.add() calls to prevent duplicate screen overlay and unresponsive buttons.

* fix(#424): close drawer when gestures are disabled

Ensure the drawer is closed when transitioning to LandingScreen or LoginScreen to prevent the scrim overlay from intercepting clicks.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-06-30 17:16:17 +03:00
1 parent d80e4dc7b1
commit 546dc86a98
4 files changed
+27 -2

No files matched your search

@@ -66,12 +66,13 @@ private fun appEntryProvider(
openDrawer: () -> Unit,
) = entryProvider {
entry<LandingScreen> {
// B7 (Jun 30 2026, kanban t_424): route landing screen buttons through navigateTo to prevent duplicate screens
LandingScreenContent(
onAuthLogin = {
NavigationController.backStack?.add(AuthLoginScreen)
NavigationController.navigateTo(AuthLoginScreen)
},
onPairingLogin = {
NavigationController.backStack?.add(PairingCodeEntryScreen)
NavigationController.navigateTo(PairingCodeEntryScreen)
},
)
}
@@ -134,6 +135,13 @@ fun MainNavigation(sessionId: String? = null) {
val gesturesEnabled = currentScreen in DRAWER_GESTURE_SCREENS
val openDrawer: () -> Unit = { scope.launch { drawerState.open() } }
// B7 (Jun 30 2026, kanban t_424): close drawer if gestures are disabled to dismiss scrim
LaunchedEffect(gesturesEnabled) {
if (!gesturesEnabled && drawerState.isOpen) {
drawerState.snapTo(DrawerValue.Closed)
}
}
ModalNavigationDrawer(
drawerState = drawerState,
gesturesEnabled = gesturesEnabled,