You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(native-chat): add a setting to keep the scroll position when sending - #38162
In the desktop chat, sending a message always jumps you to the bottom, even if you had scrolled up to re-read something. This adds a setting, Scroll to latest when sending, that you can turn off to stay where you were. It is on by default, so nothing changes unless you turn it off.
Files
Added
Deleted
Net
Test
3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$71
$\color{#cf222e}{\Huge{\mathbf{−}}}$1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$70
Prod
28
$\color{#1a7f37}{\Huge{\mathbf{+}}}$168
$\color{#cf222e}{\Huge{\mathbf{−}}}$35
$\color{#1a7f37}{\Huge{\mathbf{+}}}$133
What Changed
Before
Every send from a chat pane (composer, retry, answering a question or approval card, queue actions, conversation commands and slash commands) brought the latest into view and followed the reply, wherever you had scrolled. There was no way to turn this off.
After
New switch in Settings > Chat > Behavior: "Scroll to latest when sending" (default on, same behavior as today).
When it is off:
Sending while scrolled up leaves your scroll position alone.
If you are already at the end, the transcript keeps following the reply as it does today (that comes from the existing follow state, which this PR does not touch).
"Jump to latest" still works and brings you back to the end.
Mechanism
New optional setting nativeChatScrollToLatestOnSend (absent means on, default true), added to NativeChatGlobalSettings next to the other chat settings.
One gate where the message list answers its revealLatest handle: every send path already reports there (from fix(native-chat): sending brings the latest into view and follows the reply #24514). When the setting is off, the list skips the reveal unless the reader is at the end. It reads the setting when you send, so it adds no store subscription and no re-renders.
"At the end" means following, or within the Jump to latest threshold (48px) of the end, judged where the reader is at the press. A reader can sit at the end without following, for example after a rail jump that clamps at the end or a small nudge up. Those readers still follow their reply. A reader whom output has since grown past does not.
Most send paths reveal at the press, so they read the live position then. A structured message reveals only once the host admits it, and its echo row is laid out before that. So it captures the reader's position at the press (captureRevealLatest, passed to the composer as captureAdmittedReveal) and the list uses that captured answer when the reveal runs.
Not affected: the "Jump to latest" button (it calls the message list's jumpToLatest directly), find navigation (revealFindMatch), and the message list handle itself. The test that fails when a send path forgets to report the reveal is unchanged.
The UI row, settings search entry and strings follow the existing Chat > Behavior rows (e.g. Link previews). The English strings are added, plus translations for the other locales, as in Keep terminal scroll position on input #30889.
Why
#24514 made sending reveal the latest on purpose, and that is a good default. But if you scroll up to re-read an earlier answer and reply based on it, every send throws away your reading position. The terminal already has the same opt-out ("Scroll to Bottom on Input", #30889), so this gives the chat a matching setting.
Gating the single revealLatest callback the send paths share, instead of each send path, keeps the change to one line of behavior. New send paths get the setting automatically, and the existing "every send reports" contract stays as it is.
Before, with the setting on (the default and main's behaviour): the reader scrolls up, sends, and is taken to the end.
before-setting-on.mp4
After, with the setting off: the reader scrolls up and sends, and stays in place. Then Jump to latest, a send from the end, and the reply is followed.
after-setting-off.mp4
To try it in a dev build of /Users/kelvinamoaba/orca/workspaces/orca/chat-keep-scroll-on-send:
Turn off Settings > Chat > Behavior > Scroll to latest when sending.
In a chat with a long reply, scroll up and send a message: the view stays put.
Click Jump to latest and send again: the reply is followed.
Testing
NativeChatMessageList.reader-navigation.spec.tsx (run by NativeChatMessageList.scroll-behavior.test.tsx), with the setting off and the send's echo laid out before its reveal:
A reader who scrolled up stays where they were. This fails without the setting.
A reader detached 20px short of the end still follows the reply. This fails if the gate skips every reveal while off.
A reader who nudged up and then had ten rows of output grow past them stays in place. This fails if the check uses the reader's last scroll position.
Ran all native-chat and settings tests (448 files, 4,589 tests), plus i18n and locale-catalog tests. All pass. pnpm tc:web, oxlint, oxfmt and the changed-code quality gate pass. The unit-test step of pnpm check:changed hit its 30-minute limit (the change to the default settings and locale files pulls in a very large set of related tests), so I ran the scoped suites above instead.
Ran a real Claude chat in a hidden dev build, measuring the transcript's scroll position before and after each send:
Setting on, scrolled to the top: the send jumps to the end, as on main.
Setting off, scrolled to the top: scrollTop stays at 0 through the send and the reply.
Setting off, at the end: the reply is followed and the distance from the end stays at 0.
Setting off, nudged 20px up (detached): the reply is followed and the distance from the end stays at 0. The echo and reply grew the content by 184px, so checking at reveal time instead of at the press would have left this reader behind.
I couldn't make Claude stream output past a nudged reader in the live run, because its reply lands in one piece, so that case is covered only by the spec.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
The riskiest part is the gate itself. If it misfired with the setting on, sends would stop revealing the latest. It only skips when the setting is explicitly false, and existing profiles have no value, which means on. The setting is a renderer-only preference: it isn't sent to the host, the mobile app or SSH/remote hosts. Turning it off affects only reveals from your own sends. Jump to latest, find and following at the end are unchanged. To back it out, revert the PR. A saved nativeChatScrollToLatestOnSend value would stay in the settings file and do nothing.
Level: Low
AI Disclosure
Implemented with Claude Code (claude-opus-5-5)
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
…ding
Own sends from a pane bring the latest into view and follow the reply.
A new Chat > Behavior setting, "Scroll to latest when sending" (on by
default), turns that off: a reader who scrolled up stays in place, one
at the end keeps following the reply, and Jump to latest still works.
The gate sits in the one reveal every send path reports to, so the
explicit Jump to latest button and find navigation are unaffected.
Fixesstablyai#38153
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
The native chat scroll-preference change has no active review issues.
No open issues 🎉
What changed in this PR
Adds a default-on native chat preference that lets users keep their reading position when sending, while preserving existing follow behavior and “Jump to latest.”
Changes:
Adds the optional setting and gates the shared send-triggered reveal callback.
Adds a searchable switch under Settings > Chat > Behavior, with localized text.
Adds tests for switch updates and preserving scroll position when disabled.
No actionable comments were generated in the recent review.
Walkthrough
Adds a default-on setting that controls whether sending a message reveals the latest chat content. The chat behavior settings include a searchable switch with localized text. When the setting is off, the message list preserves a scrolled-up position and continues following replies when the reader is near the end. The transcript scroll hook exposes the reader’s end position. The reveal flow captures that position before send admission. Tests cover scroll retention and following replies near the end.
Severity of issue fixed: Medium
Merge Risk: Minimal · up to b54e4
The change is ready to merge with no established remaining correctness or availability risk.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: adding a native-chat setting that preserves scroll position when sending.
Description check
The description includes all required sections, a clear user-facing explanation, linked issue, visual proof, testing details, risk assessment, AI disclosure, and checklist. It also explains the scoped…
Linked Issues check
Issue #38153 requires a default-on desktop native-chat setting. When off, sends from a scrolled-up reader must keep the scroll position. Readers at the end must keep following replies. Jump to latest …
Out of Scope Changes check
Changes from the merge base c866025 to head b54e452 relate to issue #38153 scope: - Setting: the field and helper in native-chat-appearance-settings.ts, the default in default-global-settings.ts, …
Full details: Description check
Explanation
The description includes all required sections, a clear user-facing explanation, linked issue, visual proof, testing details, risk assessment, AI disclosure, and checklist. It also explains the scoped test limitation and remaining CI coverage.
Full details: Linked Issues check
Explanation
Issue #38153 requires a default-on desktop native-chat setting. When off, sends from a scrolled-up reader must keep the scroll position. Readers at the end must keep following replies. Jump to latest must still work.
src/shared/native-chat/native-chat-appearance-settings.ts adds nativeChatScrollToLatestOnSend?: boolean. nativeChatScrollsToLatestOnSend returns false only for an explicit false, so an absent value means on.
NativeChatMessageList.tsx adds revealSent. It reads the setting from useAppStore.getState().settings at send time. When the setting is off and the reader was not at the end, it returns without calling jumpToLatest. Otherwise it calls jumpToLatest.
use-native-chat-reveal-latest.ts passes readerAtEnd into the message-list handle. The handle's default for readerAtEnd is alwaysAtEnd, so a list without the reader-position function keeps the prior always-reveal behavior.
captureRevealLatest reads readerAtEnd() at the press. The structured-message path uses it through captureAdmittedReveal, so the reader position is taken before the echo moves the end. This covers the composer, retry, question and approval answers, and queue actions.
ChatBehaviorSetting.tsx, chat-behavior-search.ts and the locale files add the settings row, search entry and strings.
NativeChatMessageList.reader-navigation.spec.tsx (+69 lines) covers the off-state cases: scrolled-up reader stays in place, detached reader at the end still follows, and output growth past a reader.
I did not run the spec. The test outcomes are taken from the PR description and the file summary. The code paths above support the required behavior. No coding requirement is unmet.
Full details: Out of Scope Changes check
Explanation
Changes from the merge base c866025 to head b54e452 relate to issue #38153 scope:
Setting: the field and helper in native-chat-appearance-settings.ts, the default in default-global-settings.ts, the row in ChatBehaviorSetting.tsx, the search entry in chat-behavior-search.ts, and the locale strings.
Send gate: NativeChatMessageList.tsx and use-native-chat-reveal-latest.ts. These implement the off-state decision.
Reader position: readerAtEnd in the transcript scroll hook and types, and geometryOf and hasMeasurableViewport moved to native-chat-autoscroll.ts. These support the at-end decision.
Structured send path: captureRevealLatest and captureAdmittedReveal, the reveal object in the composer transport, completeNativeChatStructuredUserAction, NativeChatInterruptedContinue.tsx, and use-structured-native-chat-submit-reveal.ts. These capture the reader position at the press for structured sends, which the issue scope covers.
Tests and test mocks: the reader-navigation spec and mock handles that expose readerAtEnd, which match the new handle contract.
I found no demonstrated unrelated change. The signature changes in the structured send path are refactoring that the capture-at-press behavior requires.
Full details: Docstring Coverage
Explanation
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 20 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…end is off
A reader can sit at the end without following (a rail jump that clamps at
the end, a short nudge up). The setting's gate skipped their reveal, so
the sent message and its reply grew below the viewport. The list now
decides: off skips only readers who stopped away from the end, judged by
where they last scrolled so the send's own echo doesn't count.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Thanks @manuelmeurer, the gate at the shared reveal was the right place. I pushed two commits on top. The first moves the gate into the message list, so a reader who sits at the end without following (after a rail jump that clamps there, or a small nudge up) still follows their reply when the setting is off. That was CodeRabbit's point. The second reads the setting through one helper and drops the switch's call-shape test.
… the press
The last-scroll distance stayed small after output grew past a reader who
had nudged up, so a later send still jumped them with the setting off.
The list now reads live geometry, and a structured message, which reveals
only once the host admits it, captures that answer at the press, before
its own echo moves the end.
Pushed 4298f46: with the setting off, the at-end check now uses where the reader is at the press rather than where they last scrolled. Output that grew past a reader who had nudged up no longer counts as the end, which was CodeRabbit's second point. A structured message captures that answer before its echo lands, since it reveals only after the host admits it.
Add a setting-off structured-composer regression test.
The current tests bypass the timing under test and do not exercise captureAdmittedReveal. Add a structured send with nativeChatScrollToLatestOnSend disabled, capture a near-end reader position before rendering the echo, and assert that the admitted send follows the reply.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 4664c676-c5bf-4c41-b00d-b1e3a8bcbb3a
Commits
Reviewing files that changed from the base of the PR and between de1eb5a and 4298f46.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
In the desktop chat, sending a message always jumps you to the bottom, even if you had scrolled up to re-read something. This adds a setting, Scroll to latest when sending, that you can turn off to stay where you were. It is on by default, so nothing changes unless you turn it off.
What Changed
Before
After
Mechanism
nativeChatScrollToLatestOnSend(absent means on, defaulttrue), added toNativeChatGlobalSettingsnext to the other chat settings.revealLatesthandle: every send path already reports there (from fix(native-chat): sending brings the latest into view and follows the reply #24514). When the setting is off, the list skips the reveal unless the reader is at the end. It reads the setting when you send, so it adds no store subscription and no re-renders.captureRevealLatest, passed to the composer ascaptureAdmittedReveal) and the list uses that captured answer when the reveal runs.jumpToLatestdirectly), find navigation (revealFindMatch), and the message list handle itself. The test that fails when a send path forgets to report the reveal is unchanged.Why
#24514 made sending reveal the latest on purpose, and that is a good default. But if you scroll up to re-read an earlier answer and reply based on it, every send throws away your reading position. The terminal already has the same opt-out ("Scroll to Bottom on Input", #30889), so this gives the chat a matching setting.
Gating the single
revealLatestcallback the send paths share, instead of each send path, keeps the change to one line of behavior. New send paths get the setting automatically, and the existing "every send reports" contract stays as it is.Alternatives considered:
Linked Issue
Fixes #38153
Visual Proof
The new switch under Settings > Chat > Behavior:
Before, with the setting on (the default and main's behaviour): the reader scrolls up, sends, and is taken to the end.
before-setting-on.mp4
After, with the setting off: the reader scrolls up and sends, and stays in place. Then Jump to latest, a send from the end, and the reply is followed.
after-setting-off.mp4
To try it in a dev build of
/Users/kelvinamoaba/orca/workspaces/orca/chat-keep-scroll-on-send:Testing
NativeChatMessageList.reader-navigation.spec.tsx(run byNativeChatMessageList.scroll-behavior.test.tsx), with the setting off and the send's echo laid out before its reveal:Ran all native-chat and settings tests (448 files, 4,589 tests), plus i18n and locale-catalog tests. All pass.
pnpm tc:web, oxlint, oxfmt and the changed-code quality gate pass. The unit-test step ofpnpm check:changedhit its 30-minute limit (the change to the default settings and locale files pulls in a very large set of related tests), so I ran the scoped suites above instead.Ran a real Claude chat in a hidden dev build, measuring the transcript's scroll position before and after each send:
scrollTopstays at 0 through the send and the reply.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
The riskiest part is the gate itself. If it misfired with the setting on, sends would stop revealing the latest. It only skips when the setting is explicitly
false, and existing profiles have no value, which means on. The setting is a renderer-only preference: it isn't sent to the host, the mobile app or SSH/remote hosts. Turning it off affects only reveals from your own sends. Jump to latest, find and following at the end are unchanged. To back it out, revert the PR. A savednativeChatScrollToLatestOnSendvalue would stay in the settings file and do nothing.Level: Low
AI Disclosure
Implemented with Claude Code (claude-opus-5-5)
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)