Repository navigation
fix(app-client): keep selection quote menu after triple-click - #5375
Merged
liruifengv merged 2 commits intoNov 25, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 3a5196e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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. |
commit: |
kimi-agent-bot
pushed a commit
that referenced
this pull request
Nov 25, 2026
* fix(app-client): keep selection quote menu after triple-click * chore: drop CLI changeset for triple-click quote fix --------- Co-authored-by: liruifengv <[email protected]>
kimi-agent-bot
pushed a commit
that referenced
this pull request
Nov 25, 2026
* fix(app-client): keep selection quote menu after triple-click * chore: drop CLI changeset for triple-click quote fix --------- Co-authored-by: liruifengv <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
在桌面端和 Web UI 的对话里,双击选中文字后,「评论 / 添加到对话」菜单能正常弹出;三击选中一整段时,菜单会闪一下然后消失,没法引用整段。这个 PR 修好之后,三击选中的段落也能正常引用。
Bug Reproduction Steps
Root Cause
三击选中段落时,Chrome 会把选区的终点越过段落末尾,延伸到下一个区块里第一个可选中的位置。终点前面会跨过一段
user-select: none的文字,比如活动分组的标题「运行了 1 条命令」,最后停在工具行「运行」标签的末尾。在 Chrome 里实测,Selection.toString()只有这段正文,但Range.toString()会把不可选中的标题和标签也算进去。endsAtContainerBoundary原本只在终点是元素节点、或文本偏移量为 0 时,才认为选区「只是停在段落外侧的边界上」;判断容器后面有没有多选内容时,用的又是Range.toString()。三击的终点是一个偏移量不为 0 的文本节点,不可选中的文字也被当成了多选的内容,于是选区被判定为跨区块,菜单就被收起了。双击能正常显示的那一下菜单,就是消失前看到的那一下。这次是根本修复:判断尾部内容时,只统计用户真正能选中的文字。
Code Changes
改动只在一个判断函数里:
去掉偏移量为 0 的前提,是因为三击的终点本来就落在一个文本节点的中间。现在由「尾部有没有可选中的文字」单独决定选区算不算跨区块,所以只要多选了下一个区块里真正可选中的文字,选区仍然会被拒绝。
selectionQuoteAnchor和selectionOwnedByRoot都调用这个函数,所以气泡锚点和selectionchange的归属判断用的是同一套规则。getRootNode的类型判断沿用了这个文件里已有的防御写法。原来的早返回会挡住不带getRootNode的测试替身,去掉早返回之后要靠这个判断来保护。Behavior Changes and Affected Users
user-select: none的标签)受影响的人群:桌面端和
kimi web的用户,两者共用同一套渲染层。TUI、VS Code、ACP 和 SDK 不受影响。测试覆盖:
packages/app-client/test/quote-selection-boundary.test.ts新增 3 个用例:终点越过不可选中的标题时仍保留锚点(修复前会失败);终点落在下一个区块可选中的代码里时仍拒绝;被跨过的标题本身可选中时仍拒绝。验证过程
user-select: none标题的活动分组),用真实鼠标三击:修复前selectionQuoteAnchor返回null,修复后返回整段文字;把选区拉进下一个区块的代码里,仍然返回null。pnpm exec vitest run --reporter=agent packages/app-client/test packages/app-components/test/selectionActionBubble.test.ts packages/app-components/test/transcriptList.test.ts:128 个文件、2436 个用例全部通过。pnpm --filter kimi-code-app run typecheck:通过。pnpm lint:通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.