Skip to content

Add presence tracking and typing indicators#205

Open
clementmouchet wants to merge 5 commits into
basecamp:mainfrom
clementmouchet:presence
Open

Add presence tracking and typing indicators#205
clementmouchet wants to merge 5 commits into
basecamp:mainfrom
clementmouchet:presence

Conversation

@clementmouchet

Copy link
Copy Markdown

Summary

Adds real-time presence tracking in direct chats and improves typing indicators.

When users connect/disconnect in any room, direct chat entries now refresh for all relevant members so avatar presence badges and online/offline labels stay current. Typing indicator text is also made human-readable and announced accessibly.

Changes

  • Broadcast presence updates from PresenceChannel on present/absent.
  • Refresh direct-room sidebar entries for impacted users whenever a user’s presence changes.
  • Add presence badges to direct chat avatars (online/offline) and show aggregate direct-room presence text (online, offline, or N online).
  • Update typing indicator copy:
    • Alice is typing...
    • Alice and Bob are typing...
    • Alice, Bob, and N others are typing...
  • Add aria-live="polite" and aria-atomic="true" for typing announcements.
  • Add/extend tests for:
    • Presence channel broadcasts to direct-chat members.
    • System-level direct chat presence behavior.
    • System-level typing indicator message rendering.
  • Harden system test sign-in helper to open the email/password form when collapsed.

Copilot AI review requested due to automatic review settings May 22, 2026 07:17

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds real-time presence indicators for direct chats and improves typing indicator messaging/accessibility, along with supporting UI styles and tests.

Changes:

  • Render online/offline state for direct chat avatars and a textual presence summary in the sidebar.
  • Broadcast presence updates to refresh direct room entries for affected users.
  • Add typing indicator message formatting + accessibility attributes, with new system/channel tests.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/test_helpers/system_test_helper.rb Makes sign-in helper expand the email/password form when needed to reduce system test flakiness.
test/system/presence_indicators_test.rb Adds system tests covering online status and typing indicator behavior.
test/channels/presence_channel_test.rb Adds channel tests asserting broadcasts on subscribe for direct-room updates.
app/views/users/sidebars/rooms/_direct.html.erb Adds presence-aware avatar rendering and “online/offline” summary for direct rooms.
app/views/rooms/show/_composer.html.erb Adds ARIA live region attributes for typing indicator announcements.
app/javascript/models/typing_tracker.js Introduces user-friendly typing messages (“X is typing…”, “X and Y are typing…”, etc.).
app/controllers/users/sidebars_controller.rb Minor formatting change in placeholder selection logic.
app/channels/presence_channel.rb Broadcasts presence + forces re-render of direct room list entries on presence changes.
app/assets/stylesheets/sidebar.css Styles the new direct presence summary text.
app/assets/stylesheets/avatars.css Adds presence dot styling for online/offline avatars.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/javascript/models/typing_tracker.js Outdated
Comment thread app/assets/stylesheets/avatars.css Outdated
Comment thread app/views/users/sidebars/rooms/_direct.html.erb Outdated
Comment thread app/views/users/sidebars/rooms/_direct.html.erb Outdated
Comment thread app/views/users/sidebars/rooms/_direct.html.erb Outdated
Comment thread app/channels/presence_channel.rb
Comment thread app/controllers/users/sidebars_controller.rb
Comment thread test/test_helpers/system_test_helper.rb Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 22, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Comment thread app/views/users/sidebars/rooms/_direct.html.erb Outdated
Comment thread app/channels/presence_channel.rb
Comment thread app/channels/presence_channel.rb Outdated
Comment thread app/assets/stylesheets/avatars.css
Comment thread test/test_helpers/system_test_helper.rb Outdated
Comment thread app/controllers/users/sidebars_controller.rb
Comment thread app/javascript/models/typing_tracker.js Outdated
@clementmouchet
clementmouchet requested a review from Copilot May 22, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comment thread app/views/users/sidebars/show.html.erb Outdated
Comment thread app/channels/presence_channel.rb Outdated
Comment thread test/test_helpers/system_test_helper.rb Outdated
Comment thread app/controllers/users/sidebars_controller.rb
- Typing grammar fix for singular/plural “other/others” in typing_tracker.js.
- Moved online-presence DB work out of the direct-room partial:
 - Added Membership.online_lookup_by_room in membership.rb.
 - Compute/pass lookup from sidebars_controller.rb and show.html.erb.
 - Partial now does O(1) hash lookups in _direct.html.erb.
- Reduced presence-channel fan-out query churn:
 - Batched direct room IDs + memberships, removed find_each, and passed lookup locals in presence_channel.rb.
- Ensured new direct-room broadcasts pass the same lookup in directs_controller.rb.
- CSS robustness tweaks in avatars.css: explicit .avatar--presence::before selector and position: relative.
- Reduced unnecessary wait time in system sign-in helper in system_test_helper.rb.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comment thread app/views/users/sidebars/show.html.erb Outdated
Comment thread app/controllers/rooms/directs_controller.rb Outdated
Comment thread app/channels/presence_channel.rb Outdated
Comment thread app/views/users/sidebars/rooms/_direct.html.erb Outdated
- Disabled collection caching for direct-room partial render so presence state can’t go stale with dynamic locals: app/views/users/sidebars/show.html.erb
- Replaced map(&:user_id) with SQL pluck(:user_id) in direct-room broadcast setup: app/controllers/rooms/directs_controller.rb
- Replaced Ruby-side map(&:user_id).uniq with SQL distinct.pluck(:user_id) in presence channel: app/channels/presence_channel.rb
- Handled single-user fallback explicitly in direct sidebar partial so fallback user doesn’t render offline incorrectly: app/views/users/sidebars/rooms/_direct.html.erb
- Updated sign-in helper to avoid wait: 0 timing sensitivity per feedback: test/test_helpers/system_test_helper.rb
- Added room: : users preload in app/channels/presence_channel.rb to avoid
  membership. room.users N+1 during broadcast renders.
Copilot AI review requested due to automatic review settings May 22, 2026 09:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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