Skip to content

fix(desktop): keep transcript still after expanding a fold near the bottom - #5353

Merged
wbxl2000 merged 2 commits into
release/2026-11-25from
chengluyu-fix-message-expand-jump
Nov 24, 2026
Merged

wbxl2000 merged 2 commits into
release/2026-11-25from
chengluyu-fix-message-expand-jump

Conversation

@chengluyu

@chengluyu chengluyu commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

桌面端和 Web UI 中,对话停在底部时点开「已工作 Xs」或「思考过程」,展开动画结束后整段对话会往上跳一下,刚点击的标题也跟着移位。本 PR 修复后,展开时被点击的标题保持原位,不再跳动。

Bug Reproduction Steps

  1. 打开一个已结束的会话,滚到最底部(处于自动跟随底部状态)。
  2. 点击最后一条回复的「已工作 Xs」展开,或再点开其中的「思考过程」。
  3. 约 200ms 后,整段对话向上跳动,跳动幅度等于展开新增的高度。

Root Cause

点击折叠标题时,组件调用 pinScroll → controller.hold(el),在 HOLD_MS(200ms)内锁定标题位置,展开内容向下增长。锁定结束时 releaseHold 用 followThreshold(transcript 里是 80px)判断是否"在底部":展开新增高度 ≤ 80px 时会被判为在底部,切回 follow 并执行 correct('follow'),把 scrollTop 直接写到 maxTop,于是视图一次性上移整段增量。

sequenceDiagram
    participant User
    participant Fold as TurnFold / ThinkingBlock
    participant Ctrl as ScrollController
    User->>Fold: 点击标题
    Fold->>Ctrl: hold(head) → anchored,锁定 200ms
    Fold->>Fold: grid-rows 过渡,内容向下增长 Δ
    Ctrl->>Ctrl: releaseHold:distance = Δ ≤ 80px
    Ctrl->>Ctrl: 切回 follow,scrollTop = maxTop(跳动 Δ)
Loading

这是根本修复:锁定结束后,只有确实贴底才恢复 follow。

Code Changes

只改了 releaseHold 的贴底判定:

 releaseHold
   held = null
-  if distance to bottom > followThreshold: stay anchored
+  if distance to bottom > USER_SCROLL_TOLERANCE (1px): stay anchored
   setMode(follow); correct('follow')

收起内容时,内容变短、浏览器把位置夹到底部,距离为 0,仍然恢复 follow;展开时下方多出内容(距离 > 1px),就保持 anchored,标题不动。用户之后向下滚回阈值内时,handleScroll 已有的逻辑会重新进入 follow。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
贴底时展开一个较小的折叠块(新增高度 ≤ 80px)后的滚动 200ms 后切回自动跟随并滚到底,视图上跳 保持在当前位置(anchored),不再自动跟随 desktop 与 web(kimi web)中停在底部点开折叠块的用户 向下滚回底部即恢复自动跟随
贴底时收起折叠块 恢复自动跟随 不变 — —
远离底部时展开/收起 保持 anchored 不变 — —

受影响模块:packages/app-core/src/lib/transcriptScroll/scrollController.ts(desktop 渲染端与 kimi web 共用)。

测试覆盖:packages/app-core/test/transcriptScroll/scrollController.test.ts

  • 新增 "keeps the clicked element still when content below it expands near the bottom":贴底时展开 20px,标题位置不变、保持 anchored,滚到底后恢复 follow。修复前失败(标题上移 20px)。
  • 既有 "returns to follow once the hold ends at the bottom" 继续钉住收起场景恢复 follow 的旧行为。
验证
  • pnpm exec vitest run --reporter=agent packages/app-core/test/transcriptScroll:5 files / 109 tests passed(release 分支基线上)
  • pnpm exec vitest run --reporter=agent packages/app-core/test/transcriptScroll packages/app-client/test packages/app-components/test:229 files / 3479 tests passed(main 基线上)
  • pnpm lint:exit 0
  • pnpm --filter kimi-code-app run typecheck:passed
  • 在 pnpm dev:desktop 中手动验证:贴底展开「已工作」与「思考过程」不再跳动(macOS)。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset. (Release-branch fix; no changeset per maintainer.)
  • Ran gen-docs skill, or this PR needs no doc update.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T10:18:56.286219Z 4155dc4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1a310c4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@wbxl2000
wbxl2000 merged commit baaab05 into release/2026-11-25 Nov 24, 2026
19 checks passed
@wbxl2000
wbxl2000 deleted the chengluyu-fix-message-expand-jump branch November 24, 2026 10:20
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
…ottom (#5353)

* fix(desktop): keep transcript still after expanding a fold near the bottom

* chore: drop changesets

---------

Co-authored-by: liruifengv <[email protected]>
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
…ottom (#5353)

* fix(desktop): keep transcript still after expanding a fold near the bottom

* chore: drop changesets

---------

Co-authored-by: liruifengv <[email protected]>
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.

3 participants