Repository navigation
fix(desktop): keep transcript still after expanding a fold near the bottom - #5353
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
…ottom (#5353) * fix(desktop): keep transcript still after expanding a fold near the bottom * chore: drop changesets --------- Co-authored-by: liruifengv <[email protected]>
…ottom (#5353) * fix(desktop): keep transcript still after expanding a fold near the bottom * chore: drop changesets --------- Co-authored-by: liruifengv <[email protected]>
Requirement or Bug
桌面端和 Web UI 中,对话停在底部时点开「已工作 Xs」或「思考过程」,展开动画结束后整段对话会往上跳一下,刚点击的标题也跟着移位。本 PR 修复后,展开时被点击的标题保持原位,不再跳动。
Bug Reproduction Steps
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(跳动 Δ)这是根本修复:锁定结束后,只有确实贴底才恢复 follow。
Code Changes
只改了
releaseHold的贴底判定:收起内容时,内容变短、浏览器把位置夹到底部,距离为 0,仍然恢复 follow;展开时下方多出内容(距离 > 1px),就保持 anchored,标题不动。用户之后向下滚回阈值内时,
handleScroll已有的逻辑会重新进入 follow。Behavior Changes and Affected Users
kimi web)中停在底部点开折叠块的用户受影响模块:
packages/app-core/src/lib/transcriptScroll/scrollController.ts(desktop 渲染端与kimi web共用)。测试覆盖:
packages/app-core/test/transcriptScroll/scrollController.test.ts验证
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 0pnpm --filter kimi-code-app run typecheck:passedpnpm dev:desktop中手动验证:贴底展开「已工作」与「思考过程」不再跳动(macOS)。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset. (Release-branch fix; no changeset per maintainer.)gen-docsskill, or this PR needs no doc update.