feat(ui): auto-enter room chat after a successful login

Logging in to a room server (first-time prompt or a remembered password) used
to leave the user on the room list, needing a second Enter to open the chat.
onRoomLoginResult() now opens the room history on success via a shared
openDmHistory() helper (extracted from the Enter-on-contact path).

The login result is async, so the auto-enter is gated on the user still being
on that room in the picker: phase CONTACT_PICK, room mode, no context menu /
share / pick-target sub-flow active, and the result pubkey matching the
selected contact. Otherwise it stays put (no yanking the user into a screen
they navigated away from).

Resolves the "auto-enter after login" code-review item. Builds green:
WioTrackerL1_companion_solo_dual.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-07-06 20:42:05 +02:00
parent 8a9fb33a6a
commit 51a0c46828
3 changed files with 25 additions and 8 deletions

View File

@@ -621,6 +621,15 @@ public:
if (success) {
markRoomLoggedIn(pub_key);
the_mesh.saveRoomPassword(pub_key, _login_pw);
// Auto-enter the room's chat right after a successful login so the user
// doesn't have to press Enter a second time. The login result is async,
// so only do it if they're still sitting on this same room in the picker
// (didn't navigate away, open a menu, or enter a share/pick sub-flow).
if (_phase == CONTACT_PICK && _room_mode && !_ctx_menu.active
&& !_share_mode && !_pick_target
&& memcmp(_sel_contact.id.pub_key, pub_key, 4) == 0) {
openDmHistory();
}
} else {
// Saved password (if any) no longer works -- forget it so the next
// ENTER on this room falls back to a manual prompt instead of
@@ -630,6 +639,17 @@ public:
_task->showAlert(success ? "Login OK" : "Login failed", 1200);
}
// Open the message history for the currently selected contact/room and reset
// the scroll/selection view state. Shared by the Enter-on-contact path and the
// post-login auto-enter.
void openDmHistory() {
_task->clearDMUnread(_sel_contact.id.pub_key);
_dm_hist_sel = -1;
_dm_hist_scroll = 0;
_dm_fs.active = false;
_phase = DM_HIST;
}
// Background tick (called every UI loop, regardless of the active screen) that
// drives auto-resend of on-device DMs — forwarded to the history store.
void tickDmResends() { _history.tickDmResends(); }
@@ -1351,11 +1371,7 @@ public:
}
return true;
}
_task->clearDMUnread(_sel_contact.id.pub_key);
_dm_hist_sel = -1;
_dm_hist_scroll = 0;
_dm_fs.active = false;
_phase = DM_HIST;
openDmHistory();
if (_share_mode) beginShareCompose(false);
}
return true;