Skip to content

feat(group-chat): global auto-scroll toggle (#1120)#1131

Open
jSydorowicz21 wants to merge 4 commits into
rcfrom
triage/issue-1120-autoscroll-toggle
Open

feat(group-chat): global auto-scroll toggle (#1120)#1131
jSydorowicz21 wants to merge 4 commits into
rcfrom
triage/issue-1120-autoscroll-toggle

Conversation

@jSydorowicz21

@jSydorowicz21 jSydorowicz21 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1120. Adds a global on/off setting to disable auto-scroll in group chats so users can read earlier messages without the view snapping to the bottom on every new message.

Changes

  • New persisted groupChatAutoScroll setting (default true, preserving current behavior), wired through the settings store the same way as other global booleans: state + action interfaces, default, setter, window.maestro.settings persistence, load/hydration patch, useSettings type, getSettingsActions(), and settingsMetadata.
  • GroupChatMessages now gates its scroll-to-bottom effect on the setting.
  • New Display > Group Chats toggle (mirrors the existing toggle-switch pattern) plus a searchableSettings entry so it is discoverable in settings search.

Verification

  • npm run lint (tsc x3): clean
  • vitest run settings store plus a new GroupChatMessages render test proving the effect scrolls when enabled and does NOT when disabled: 157 tests pass
  • eslint + prettier: clean
  • Independently reviewed by codex exec (read-only); review findings (test reset leak, action/search registration) addressed.

Summary by CodeRabbit

  • New Features
    • Added a new Display setting: “Group Chats → Auto-scroll to newest message.”
    • Persisted the preference and made it searchable in settings.
  • Bug Fixes
    • Updated group chat auto-scrolling to respect the setting: scrolls on initial load; only auto-scrolls on new messages when enabled; switching chats no longer forces unwanted scrolling.
  • Tests
    • Added/expanded coverage for scrolling behavior across enabled/disabled transitions and chat switches, plus setting persistence.

Adds a persisted groupChatAutoScroll setting (default true) wired through the settings store, metadata, and a Display-tab toggle. GroupChatMessages now gates its auto-scroll-to-bottom effect on the setting, so users can keep their scroll position while reading earlier messages. Covered by store + component tests.
… reset (#1120)

Codex review fixes: add setGroupChatAutoScroll to getSettingsActions(), add a searchableSettings Display entry so the toggle is deep-linkable, and reset groupChatAutoScroll in the test resetStore() to remove order-dependent state leak. Skipped main SETTINGS_DEFAULTS by design: renderer-only display prefs (chatRawTextMode, markdownEditMode, bionifyReadingMode, userMessageAlignment) are all absent there too; the renderer + metadata defaults cover it.
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a global setting for group chat auto-scroll. The main changes are:

  • A persisted groupChatAutoScroll setting with default enabled.
  • A Display tab toggle and searchable settings entry.
  • Group chat message scrolling that respects the setting after the initial chat load.
  • Tests for setting persistence, toggles, chat switches, and new-message scrolling.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The auto-scroll toggle no longer triggers a scroll by itself.
  • Switching group chats resets the initial scroll state for the new chat.
  • The new setting uses the same key across the store, persistence, UI, and metadata.

Important Files Changed

Filename Overview
src/renderer/components/GroupChatMessages.tsx Reads the new setting, keeps setting changes out of the scroll effect dependency, and resets initial scroll state when the chat id changes.
src/renderer/components/GroupChatPanel.tsx Passes the active group chat id into the messages component.
src/renderer/stores/settingsStore.ts Adds the new boolean setting, setter, persisted load path, and actions export.
src/renderer/components/Settings/tabs/DisplayTab.tsx Adds the Display tab switch for group chat auto-scroll.
src/renderer/hooks/settings/useSettings.ts Extends the settings hook type for the new setting and setter.
src/shared/settingsMetadata.ts Adds metadata for the new group chat auto-scroll setting.
src/renderer/components/Settings/searchableSettings.ts Adds the new Display setting to settings search.
src/tests/renderer/components/GroupChatMessages.test.tsx Adds render tests for enabled, disabled, toggled, and chat-switch auto-scroll behavior.
src/tests/renderer/stores/settingsStore.test.ts Adds store coverage for the new setting default and persistence setter.

Reviews (3): Last reviewed commit: "fix(group-chat): reset initial-scroll tr..." | Re-trigger Greptile

Comment thread src/renderer/components/GroupChatMessages.tsx Outdated
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8654296a-2887-4173-b32b-fed7fd2bdca7

📥 Commits

Reviewing files that changed from the base of the PR and between 40e0829 and 5f5ed72.

📒 Files selected for processing (3)
  • src/__tests__/renderer/components/GroupChatMessages.test.tsx
  • src/renderer/components/GroupChatMessages.tsx
  • src/renderer/components/GroupChatPanel.tsx

📝 Walkthrough

Walkthrough

Adds a global groupChatAutoScroll setting in shared metadata and the settings store, exposes it in Display settings, and makes GroupChatMessages skip auto-scrolling when the setting is off. Tests cover store persistence and component scroll behavior.

Changes

Group chat auto-scroll setting

Layer / File(s) Summary
Setting contract and persistence
src/shared/settingsMetadata.ts, src/renderer/hooks/settings/useSettings.ts, src/renderer/stores/settingsStore.ts, src/__tests__/renderer/stores/settingsStore.test.ts
Adds groupChatAutoScroll to shared metadata, store state/actions/defaults/hydration/persistence, and store tests for the default and setter.
Display settings toggle
src/renderer/components/Settings/searchableSettings.ts, src/renderer/components/Settings/tabs/DisplayTab.tsx
Adds a searchable Display entry and a Group Chats toggle bound to groupChatAutoScroll.
Group chat scroll gating
src/renderer/components/GroupChatMessages.tsx, src/renderer/components/GroupChatPanel.tsx, src/__tests__/renderer/components/GroupChatMessages.test.tsx
Makes GroupChatMessages read groupChatAutoScroll before scrolling, passes the current chat id into the component, and adds jsdom coverage for the scroll transitions.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DisplayTab
  participant settingsStore
  participant GroupChatPanel
  participant GroupChatMessages
  participant chatContainer

  User->>DisplayTab: toggle Auto-scroll to newest message
  DisplayTab->>settingsStore: setGroupChatAutoScroll(value)
  settingsStore->>settingsStore: persist groupChatAutoScroll

  GroupChatPanel->>GroupChatMessages: pass chatId
  GroupChatMessages->>settingsStore: read groupChatAutoScroll
  alt initial chat load
    GroupChatMessages->>chatContainer: scroll to bottom
  else new message arrives and setting enabled
    GroupChatMessages->>chatContainer: scroll to bottom
  else new message arrives and setting disabled
    GroupChatMessages->>chatContainer: keep current scrollTop
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

ready to merge

Poem

A rabbit tapped a setting switch,
and group chats skipped the scroll-down hitch.
New messages hop when asked to do,
but sit quite still when set to “no.”
🐇🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a global group-chat auto-scroll toggle.
Linked Issues check ✅ Passed The PR implements the requested global on/off auto-scroll setting with default-on behavior and applies it across group chats.
Out of Scope Changes check ✅ Passed The changes all support the auto-scroll toggle feature; no unrelated scope appears introduced.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch triage/issue-1120-autoscroll-toggle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40e082987f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Auto-scroll on new messages
// Auto-scroll on new messages (unless disabled via the global setting)
useEffect(() => {
if (!groupChatAutoScroll) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep initial group chat load at the latest message

When groupChatAutoScroll is off, this early return also skips the scroll that used to happen when a populated group chat is first mounted or when handleOpenGroupChat replaces the messages after switching chats. In that scenario the scroll container keeps its previous scrollTop (or 0 on first mount), so users who disabled auto-scroll to read older incoming messages can open another existing chat and land at the top or an arbitrary old offset instead of the newest message. Consider still scrolling on mount/chat-change and only suppressing scrolls for subsequent appends.

Useful? React with 👍 / 👎.

Comment on lines +2289 to +2290
if (allSettings['groupChatAutoScroll'] !== undefined)
patch.groupChatAutoScroll = allSettings['groupChatAutoScroll'] as boolean;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore reset fallback for groupChatAutoScroll

When a user disables this setting and then resets it externally, for example maestro-cli settings reset groupChatAutoScroll, the key is removed from maestro-settings.json; because this new key was not added to src/main/stores/defaults.ts, the settings:getAll snapshot has no value for it, and this guard leaves the existing false value in the Zustand store since setState(patch) merges rather than resets. The documented default is true, so reset or deletion does not take effect until the user explicitly sets it back to true or restarts into the renderer default.

Useful? React with 👍 / 👎.

// Auto-scroll on new messages
// Auto-scroll on new messages (unless disabled via the global setting)
useEffect(() => {
if (!groupChatAutoScroll) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply the global toggle to mobile group chats

This new setting only gates the desktop GroupChatMessages component. The web/mobile group chat path still auto-scrolls unconditionally in src/web/mobile/GroupChatPanel.tsx when chatState.messages.length changes, and the web settings snapshot currently hardcodes autoScroll: true, so users viewing group chats through the remote/mobile interface will still be snapped to the bottom despite turning off the global group-chat auto-scroll setting in Display. If this is intended as a global group chat preference, thread groupChatAutoScroll through the web settings payload and consume it in the mobile group chat panel too.

Useful? React with 👍 / 👎.

…ly new-message auto-scroll (#1120)

Review fix: the first scroll-to-bottom (initial mount / first non-empty messages load) always runs so a chat opens at its latest message even when auto-scroll is off; only subsequent new-message scrolls respect the setting. Effect now depends on [messages] with a render-time setting ref, so toggling no longer yanks the reader's scroll position. Adds two tests. Declined the reset-fallback (sibling chatRawTextMode behaves identically); deferred mobile to a follow-up.
@jSydorowicz21

Copy link
Copy Markdown
Contributor Author

@greptile re-review please

Comment thread src/renderer/components/GroupChatMessages.tsx
#1120)

Round-3 review fix: GroupChatMessages is reused (not keyed) across group chats, so hasAutoScrolledRef persisted and switching chats skipped the initial scroll-to-newest. Thread a chatId prop and reset the ref when it changes so each newly opened chat lands at its latest message even with auto-scroll off. +2 tests.
@jSydorowicz21

Copy link
Copy Markdown
Contributor Author

@greptile re-review please

@jSydorowicz21 jSydorowicz21 added the ready to merge This PR is ready to merge label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge This PR is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant