Skip to content

fix: auto-scroll to bottom when sending messages#56

Open
TigerInYourDream wants to merge 2 commits intomainfrom
fix/auto-scroll-on-send
Open

fix: auto-scroll to bottom when sending messages#56
TigerInYourDream wants to merge 2 commits intomainfrom
fix/auto-scroll-on-send

Conversation

@TigerInYourDream
Copy link
Copy Markdown

@TigerInYourDream TigerInYourDream commented Apr 7, 2026

Summary

When a user sends a message (text or location), the timeline should automatically scroll to the bottom so the sent message is visible — matching the behavior of WeChat, Telegram, and other chat apps.

Approach

  • Introduces a MessageAction::MessageSubmittedLocally action, emitted directly from room_input_bar.rs at send time
  • room_screen.rs handles this action by scrolling to the last timeline item and enabling tail-range mode
  • Replaces the previous indirect approach of checking if the last appended timeline item's sender matches the current user

Why this approach is better

Aspect Old (sender matching in NewItems) New (MessageSubmittedLocally action)
Timing Waits for async timeline echo-back Fires immediately on send
Reliability Depends on timeline update arrival Always fires, no race conditions
Signal source Indirect inference (match sender) Direct intent ("I just sent a message")
Code separation Mixed into process_timeline_updates() Emit in input bar, handle in room screen
Makepad pattern Ad-hoc Follows cx.widget_action() communication pattern

Changes

  • src/room/room_input_bar.rs: Emit MessageSubmittedLocally after both location send and text send
  • src/home/room_screen.rs: Handle the action with set_first_id_and_scroll() + set_tail_range(true), remove old sender-matching logic

Test plan

  • Send a text message while scrolled to bottom → timeline stays at bottom, new message visible
  • Scroll up, then send a text message → timeline auto-scrolls to bottom, new message visible
  • Send a location message → same auto-scroll behavior
  • Receive a message from another user while scrolled up → should NOT auto-scroll (unchanged behavior)

When new items are appended to the timeline, check if the last item
was sent by the current user. If so, scroll to the bottom so the
user always sees their own sent message — regardless of current
scroll position.

Closes #55
@TigerInYourDream TigerInYourDream force-pushed the fix/auto-scroll-on-send branch from fb51812 to d810f4f Compare April 7, 2026 05:06
…o-scroll

Replace the indirect "check if last timeline item sender is current user"
approach with a direct MessageSubmittedLocally action emitted from
room_input_bar at send time. This follows Makepad's widget action
communication pattern and avoids async timing dependencies.
@tyreseluo tyreseluo marked this pull request as draft April 7, 2026 09:53
@tyreseluo tyreseluo marked this pull request as ready for review April 7, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants