Skip to content

fix: reset settings scroll position when switching sections - #2082

Merged
cjpais merged 2 commits into
cjpais:mainfrom
wesleymatosdev:fix/settings-scroll-reset
Sep 19, 2026
Merged

cjpais merged 2 commits into
cjpais:mainfrom
wesleymatosdev:fix/settings-scroll-reset

Conversation

@wesleymatosdev

Copy link
Copy Markdown
Contributor

Before Submitting This PR

  • I have searched existing issues and pull requests (including closed ones) to ensure this isn't a duplicate
  • I have read CONTRIBUTING.md

Human Written Description

I noticed that in Settings, if you scroll down while viewing History and then switch to Models (or any other section), the new section opens already scrolled down instead of at the top. This is confusing since each section has different, unrelated content, and it can hide the top of a section behind the previous scroll offset. It's a small but noticeable UX papercut that's easy and low-risk to fix.

Related Issues/Discussions

Fixes #2081

Root Cause

All settings sections (General/History/Models/...) render inside one persistent scrollable container in src/App.tsx (<div className="flex-1 overflow-y-auto">, around line 373). Because renderSettingsContent() swaps only the child content and the scroll container itself never unmounts/remounts between section switches, the container's scrollTop carries over from whichever section was scrolled last.

Fix

  • Added a settingsScrollRef ref on the scroll container
  • Added a useLayoutEffect keyed on currentSection that calls settingsScrollRef.current?.scrollTo({ top: 0 }) — this runs synchronously before paint, so there's no visible flash of the old scroll position

This is a single, self-contained, regression-testable UI fix — 3 edits total in src/App.tsx (ref declaration, effect, ref attachment).

Testing

  • Manual repro: opened Settings → History → scrolled down → clicked Models → confirmed Models now opens at the top (previously retained History's scroll offset)
  • Repeated across all settings sections to confirm no regressions in normal scroll behavior within a section
  • bunx tsc --noEmit passes cleanly with no new errors

Screenshots/Videos (if applicable)

N/A — behavioral fix, visually the difference is scroll position on section switch.

AI Assistance

  • AI was used (please describe below)

If AI was used:

  • Tools used: Claude Code (Anthropic)
  • How extensively: Claude Code diagnosed the shared-scroll-container root cause and implemented the ref + useLayoutEffect fix; I reviewed and verified the fix by reproducing the bug and confirming it's resolved.

Settings sections (General/History/Models/...) render inside one
persistent scrollable container that never unmounts between
switches. As a result, scroll position carried over from one
section to the next (e.g. scroll down in History, click Models,
Models opens already scrolled).

Add a ref to the scroll container and a useLayoutEffect keyed on
currentSection that resets scrollTop to 0 before paint on every
section change.

Co-Authored-By: Claude Code (Anthropic) <agent@nousresearch.com>
Copilot AI lite review requested due to automatic review settings September 13, 2026 13:08

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.

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

Resets the Settings scroll position when switching sections.

Changes:

  • Added a scroll-container ref.
  • Reset scroll position on section changes with useLayoutEffect.
  • Attached the ref to the shared settings container.
File summaries
File Summary
src/App.tsx Resets scroll position when changing Settings sections.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cjpais

cjpais commented Sep 13, 2026

Copy link
Copy Markdown
Owner

This is a really good catch. We will definitely pull this in ASAV as soon as I

@cjpais
cjpais merged commit 7c31572 into cjpais:main Sep 19, 2026
NairoDorian added a commit to NairoDorian/S2B2S that referenced this pull request Sep 25, 2026
…cjpais#2033, cjpais#2040, cjpais#2082, cjpais#2106)

Integrates changes from cjpais/Handy:main adapted for ZER0's Solid 2
frontend, Tauri 3 backend, and Multi-STT pipeline:

- compound shortcuts (upstream cjpais#1862): emit parseable compact names
  for compound keys (e.g. `scrolllock`, `capslock`, `numlock`) while
  preserving friendly display labels; add backend Hotkey / Shortcut
  parser regression test and test:keyboard script
- history clipboard (upstream cjpais#2011): extract copyToClipboard helper
  with error handling and unit tests; display error toast if clipboard
  write fails; add copyError translation across all 26 locales
- reset bindings (upstream cjpais#2033): reject unknown shortcut binding IDs
  via settings::get_stored_binding with unit tests
- settings scroll reset (upstream cjpais#2082): reset settings container scroll
  position to top on section change in App.tsx using Solid 2 createEffect
- empty audio model unload (upstream cjpais#2106): ensure FinishGuard calls
  maybe_unload_immediately on drop for both standard and multi-STT
  recording completion or early termination
- docs (upstream cjpais#2040): document recording overlay workaround for
  Hyprland / Omarchy with Wayland in README.md

Cost: no new runtime threads, polls, or external dependencies.
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.

[BUG] Settings sections inherit scroll position from previously viewed section

3 participants