From 51a0c46828c5e3136e9d86ed9a65a3afc1f53658 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Mon, 6 Jul 2026 20:42:05 +0200 Subject: [PATCH] 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 --- .../message_screen/message_screen.md | 4 +-- .../companion_radio/ui-new/QuickMsgScreen.h | 26 +++++++++++++++---- release-notes.md | 3 ++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/solo_features/message_screen/message_screen.md b/docs/solo_features/message_screen/message_screen.md index c025ca5b..0ac2ae49 100644 --- a/docs/solo_features/message_screen/message_screen.md +++ b/docs/solo_features/message_screen/message_screen.md @@ -42,9 +42,9 @@ Sensor placeholders appear automatically in the placeholder picker when the corr ### Rooms — logging in -Posting to a **room server** requires a login handshake first, so the device can log in on its own — no phone app needed. The first time you press **Enter** on a room, a password prompt opens automatically; type the room's password and press the **✓** key (leave it empty and submit for open / no-password rooms). +Posting to a **room server** requires a login handshake first, so the device can log in on its own — no phone app needed. The first time you press **Enter** on a room, a password prompt opens automatically; type the room's password and press the **✓** key (leave it empty and submit for open / no-password rooms). Once the login succeeds the room's chat **opens automatically** — no second Enter needed (as long as you're still on that room in the list). -- **Passwords are remembered across reboots.** After a successful login the password is saved on the device, so picking that room again — even after a power cycle — logs back in silently without re-prompting. +- **Passwords are remembered across reboots.** After a successful login the password is saved on the device, so picking that room again — even after a power cycle — logs back in silently and drops you straight into the chat. - **A wrong or changed password self-heals.** If a saved password stops working (e.g. the server's password was changed), the failed login forgets it, so the next **Enter** prompts you to type a new one. - **Re-login any time** with **Hold Enter** on the room → **Login…** (see the room context menu below) — useful to switch to a new password without waiting for a failure. - Passwords set from the **phone app** are saved on the device too, so it can post to that room standalone after a reboot. diff --git a/examples/companion_radio/ui-new/QuickMsgScreen.h b/examples/companion_radio/ui-new/QuickMsgScreen.h index 56461c5f..12a97411 100644 --- a/examples/companion_radio/ui-new/QuickMsgScreen.h +++ b/examples/companion_radio/ui-new/QuickMsgScreen.h @@ -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; diff --git a/release-notes.md b/release-notes.md index aa7b05ba..84b65ae5 100644 --- a/release-notes.md +++ b/release-notes.md @@ -20,7 +20,8 @@ - toggling a **channel's favourite from its context menu** could retarget the menu onto a different channel once the list re-sorted. - **A repeater could appear twice** on the discovery scan and in the app — a discover response often arrives more than once (the direct copy plus a re-flooded copy carry different packet hashes, so the mesh's duplicate filter passes both), and each copy was listed. Duplicate copies of the same response are now dropped for a few seconds after the first. - **Favourites self-heal** — a pinned favourite whose contact no longer exists (e.g. after clearing contacts) now reverts to an empty **+** tile instead of showing **(gone)**, and the stale pin is cleared from prefs. -- **Radio preset names no longer seed `{loc}`/`{time}` placeholders** — those only make sense in a message; the preset-name keyboard (Settings › Radio and Tools › Repeater "+ Save current…") now opens empty. The message-slot editor still keeps them. +- **Radio preset names no longer seed `{loc}`/`{time}` placeholders** — those only make sense in a message; the preset-name keyboard (Settings › Radio and Tools › Repeater "+ Save current…") now opens empty. The message-slot editor still keeps them. The room-login **password** keyboard drops them too. +- **Room chat opens automatically after a successful login** — logging in to a room server (first-time or a remembered password) used to drop you back on the room list, needing a second **Enter** to actually open the chat. The chat now opens on its own once the login succeeds, as long as you're still on that room in the picker. ### Under the hood