Skip to content

fix(web): prevent chat scroll yank while browsing history - #1553

Merged
wbxl2000 merged 5 commits into
mainfrom
fix/web-history-scroll-yank
Jul 12, 2026
Merged

fix(web): prevent chat scroll yank while browsing history#1553
wbxl2000 merged 5 commits into
mainfrom
fix/web-history-scroll-yank

Conversation

@wbxl2000

@wbxl2000 wbxl2000 commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

None — this is a reproducible bug in conversation history scrolling; the problem is explained below.

Problem

While a user browses older messages, two independent timing problems can move the chat viewport against their input:

  1. Images or other content above the viewport can finish laying out after the user has scrolled up. The conversation pane disabled browser scroll anchoring globally, so those height changes shifted the visible content.
  2. A wheel, touch, or scrollbar drag can signal an upward user action before the resulting scroll event. A previously queued bottom-follow frame could run in that gap and pull the viewport back down.

Loading another page of history has a related requirement: prepended turns must not move the current reading position, but that correction must be scoped to the session that started the request and must preserve scrolling that happens while the request is in flight.

What changed

  • Keep native scroll anchoring enabled while browsing history, and disable it only while intentionally following the bottom or restoring a prepended history page.
  • Treat wheel, touch, and scrollbar-pointer input as immediate user intent. Upward input cancels queued bottom-follow work, smooth scrolling, and stale pin state before the browser emits scroll; input that cannot move a short conversation keeps following.
  • Cancel old scroll writers before switching sessions or navigating through the conversation outline, so a follow lock from the previous target cannot pull the new viewport to the bottom.
  • Restore prepended history from nearby turn or tool-call anchors plus the current scroll position. Stable tool ids cover a single long assistant turn that crosses a page boundary while new output is still arriving.
  • Keep load state and deferred restoration per session, so switching sessions during a request cannot adjust the wrong conversation.
  • Stop treating arbitrary DOM mutations as proof that a new message arrived; actual turn changes still control the new-message indicator.

The change stays inside the existing chat scroll state machine and adds no dependency or new module.

Verification:

  • pnpm --filter @moonshot-ai/kimi-web typecheck
  • pnpm --filter @moonshot-ai/kimi-web test (390 tests)
  • pnpm --filter @moonshot-ai/kimi-web build
  • pnpm --filter @moonshot-ai/kimi-web check:style
  • Real Chromium checks for delayed layout shifts, upward input racing bottom-follow, history prepend stability, and no console errors

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works. (kimi-web has no component layout harness; the existing logic suite and real Chromium exercise cover the observable behavior.)
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. (This restores expected behavior without changing the documented interface.)

@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7e6dc54

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 11, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@7e6dc54
npx https://pkg.pr.new/@moonshot-ai/kimi-code@7e6dc54

commit: 7e6dc54

@wbxl2000 wbxl2000 changed the title fix(web): preserve scroll position while loading older messages fix(web): prevent chat scroll yank while browsing history Jul 11, 2026
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 7033926495

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-web/src/components/chat/ConversationPane.vue Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: f22a776e9c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 046fd7d43e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 7e6dc5419c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000
wbxl2000 merged commit 264525e into main Jul 12, 2026
10 checks passed
@wbxl2000
wbxl2000 deleted the fix/web-history-scroll-yank branch July 12, 2026 03:36
@github-actions github-actions Bot mentioned this pull request Jul 12, 2026
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.

1 participant