Skip to content

fix(web): require user intent to cancel initial scroll - #1291

Merged
tiann merged 2 commits into
tiann:mainfrom
swear01:fix/issue-1288-session-scroll
Aug 2, 2026
Merged

fix(web): require user intent to cancel initial scroll#1291
tiann merged 2 commits into
tiann:mainfrom
swear01:fix/issue-1288-session-scroll

Conversation

@swear01

@swear01 swear01 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • require explicit pointer, keyboard, or wheel intent before cancelling initial chat scroll settling
  • keep programmatic and layout-driven upward scroll events from stranding a newly opened session at the top
  • reuse the explicit-input tracking already used by older-history loading

Fixes #1288

Testing

  • bun typecheck
  • bun run test:web — 204 files, 1761 tests passed
  • targeted HappyThread.test.tsx — 22 tests passed

@github-actions github-actions 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.

Findings

  • [Major] Preserve keyboard intent before consuming it — consumeExplicitUpwardIntent() clears keyboardResumeUntil, then the new settling guard re-reads the cleared state. When Home/PageUp starts outside the preload margin but lands inside it during initial settling, the gesture neither cancels settling nor starts the user history load, so a remaining timer can snap the viewport back to the bottom. Evidence: web/src/components/AssistantChat/HappyThread.tsx:677

    Suggested fix:

    const hadExplicitUpwardIntent = hasExplicitUpwardIntent(intent)
    const explicitUpwardIntent = needsCoverage && consumeExplicitUpwardIntent(intent)
    
    if (shouldCancelInitialScrollSettling(intent, hadExplicitUpwardIntent)) {
        // existing cancellation body
    }

Summary

Review mode: initial. One Major finding. The added helper tests do not cover the event-state transition where keyboard intent is consumed before the settling decision.

Testing

Not run (automation; static review only). Add an interaction test for Home/PageUp beginning outside coverage, landing inside coverage during initial settling, and asserting that settling is cancelled and the request source is user.

HAPI Bot


if (isInitialScrollSettling()) {
if (shouldCancelInitialScrollSettling(intent)) {
if (shouldCancelInitialScrollSettling(intent, hasExplicitUpwardIntent(intent))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MAJOR] Preserve keyboard intent before consuming it

explicitUpwardIntent is computed first, and consumeExplicitUpwardIntent() clears keyboardResumeUntil. This new call then rechecks hasExplicitUpwardIntent() and sees false. If Home/PageUp starts outside preload coverage but its resulting scroll lands inside coverage during the initial 1.8-second window, the keyboard gesture neither cancels settling nor starts the user history load; a remaining settling timer can snap the viewport back to the bottom.

Suggested fix:

const hadExplicitUpwardIntent = hasExplicitUpwardIntent(intent)
const explicitUpwardIntent = needsCoverage && consumeExplicitUpwardIntent(intent)

if (shouldCancelInitialScrollSettling(intent, hadExplicitUpwardIntent)) {

@github-actions github-actions 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.

Findings

  • None.

Summary

Review mode: follow-up after new commits. No issues found in the current full diff. The prior Major ordering issue is no longer present: explicit upward intent is captured before the consuming history-load check. Residual risk: the added tests exercise the pure cancellation helper, but not the event-state/timer interaction.

Testing

Not run (automation; static review only). GitHub test and pr-review checks were pending during review. Add an interaction test covering keyboard or wheel input during initial settling, including entry into the preload area and cancellation of remaining settle timers.

HAPI Bot

@tiann
tiann merged commit f213bc3 into tiann:main Aug 2, 2026
2 checks passed
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(web): session switch can leave chat scrolled to top

2 participants