Skip to content

fix(code): preserve session scroll position across window focus#1886

Merged
sakce merged 1 commit into
mainfrom
fix/preserve-scroll-on-window-focus
Apr 28, 2026
Merged

fix(code): preserve session scroll position across window focus#1886
sakce merged 1 commit into
mainfrom
fix/preserve-scroll-on-window-focus

Conversation

@sakce

@sakce sakce commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The conversation view's visibilitychange handler in ConversationView.tsx was calling scrollToBottom() unconditionally whenever the document became visible — so cmd+tab away and back always reset the user's scroll position.
  • Mirror the at-bottom state already reported by VirtualizedList into a ref and only re-pin to the bottom on visibility return when the user was already following the stream. Manual scroll positions are now preserved across focus changes; streaming auto-scroll continues to work because it has its own at-bottom check.

Test plan

  • pnpm --filter code typecheck
  • pnpm --filter code test (947 pass; one unrelated archive/service.integration.test.ts > unarchive with recreateBranch timeout in main-process git code)
  • Manual: scroll up mid-conversation, cmd+tab away and back → position preserved, scroll-to-bottom button stays visible
  • Manual: scroll to bottom, cmd+tab away and back → still pinned to bottom
  • Manual: while at bottom with a streaming response, hide the window and return → newest content visible

The visibilitychange handler in ConversationView unconditionally scrolled
the conversation to the bottom whenever the document became visible again,
so cmd+tab away and back would always destroy the user's reading position.

Gate the scroll on the same at-bottom state already reported by
VirtualizedList, so we only re-pin to the bottom when the user was already
following the stream. Manual scroll positions now survive focus changes.

Generated-By: PostHog Code
Task-Id: 2297f0c5-16fb-475d-8a2b-13cbcae500dd
@greptile-apps

greptile-apps Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(code): preserve session scroll posit..." | Re-trigger Greptile

@sakce sakce requested a review from charlesvien April 26, 2026 16:59
@sakce sakce merged commit 096173e into main Apr 28, 2026
15 of 16 checks passed
@sakce sakce deleted the fix/preserve-scroll-on-window-focus branch April 28, 2026 18:37
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