Skip to content

fix: skip app state restore after explicit logout#41

Merged
ZhangHanDong merged 7 commits intomainfrom
fix/clear-ui-state-on-logout
Apr 3, 2026
Merged

fix: skip app state restore after explicit logout#41
ZhangHanDong merged 7 commits intomainfrom
fix/clear-ui-state-on-logout

Conversation

@TigerInYourDream
Copy link
Copy Markdown

@TigerInYourDream TigerInYourDream commented Apr 3, 2026

Summary

Fixes #31.

This PR fixes the case where, after an explicit logout and then logging back into the same account, the Home area can still show stale UI from the previous session instead of starting from a clean state.

Root Cause

There were multiple pieces contributing to the stale UI during logout -> re-login:

  1. The persisted AppState restore path could automatically restore the previous Home/dock workspace on the next login.
  2. Some cached UI widgets, especially the room and space sidebars, still retained in-memory session state until fresh updates arrived.
  3. Some timeline update send paths still used unwrap() and could panic if the receiver had already been dropped during logout/re-login races.

Fix

This PR applies three focused fixes:

  • Skip automatic app-state restore once after explicit logout

    • When explicit logout reaches the point of no return, Robrix writes a per-user one-shot marker.
    • On the next login for that user, handle_load_app_state() consumes that marker and skips restoring the previous persisted Home/dock workspace.
    • Persisted local state is preserved on disk and is not deleted.
  • Reset room and space widgets on logout

    • RoomsList and SpacesBar now clear their session-bound cached UI state when LogoutAction::ClearAppState is received.
    • This prevents stale room/space UI from flashing briefly before fresh data arrives.
  • Avoid panicking when timeline receivers are dropped

    • Timeline update sends in pagination/member-loading paths no longer use unwrap().
    • If the receiver is already gone during logout/re-login, the update is dropped with a log message instead of panicking a Tokio worker thread.

Effect

  • logout -> re-login no longer restores the previous Home/dock workspace automatically.
  • Room/space sidebar UI is cleared during logout, reducing stale UI flashes on re-login.
  • Dropped timeline receivers no longer cause SendError(..) panics during logout/re-login races.
  • Persisted local state is preserved.
  • Normal message syncing/loading is still allowed after re-login.
  • account switch behavior is not intentionally changed by this fix.

Files changed

  • src/logout/logout_state_machine.rs
  • src/sliding_sync.rs
  • src/persistence/app_state.rs
  • src/home/rooms_list.rs
  • src/home/spaces_bar.rs

Suggested verification

  • Log in to an account, open some Home/dock content, logout, then log back into the same account. The old Home workspace should not be auto-restored.
  • Verify the room/space sidebars do not briefly show stale data from the previous session before refreshing.
  • Repeat logout -> re-login multiple times. Each cycle should start from a clean workspace.
  • Verify that normal room/message loading still works after re-login.
  • Verify that no SendError(..) panic occurs during pagination/member-loading while logging out or re-logging in.

@TigerInYourDream TigerInYourDream force-pushed the fix/clear-ui-state-on-logout branch from e8ac93a to 2ab1b5f Compare April 3, 2026 05:20
@TigerInYourDream TigerInYourDream changed the title fix: clear UI session state on logout to prevent stale room data fix: skip app state restore after explicit logout Apr 3, 2026
- Extract duplicated point-of-no-return blocks into enter_point_of_no_return()
- Fix missed sender.send().unwrap() on MessageEdited path
- Reset display_filter, sort_fn, and drawn_previously on logout
- Drain PENDING_ROOM_UPDATES and PENDING_SPACE_UPDATES in ClearAppState handlers
Resolve import conflict in spaces_bar.rs: keep both LogoutAction
(from this branch) and AppState/i18n imports (from main).
@ZhangHanDong ZhangHanDong merged commit b4e3210 into main Apr 3, 2026
@TigerInYourDream TigerInYourDream deleted the fix/clear-ui-state-on-logout branch April 7, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Re-login leaves stale room information behind.

2 participants