Skip to content

fix(app-ui): keep hover tooltips closed on touch input - #5370

Merged
liruifengv merged 2 commits into
release/2026-11-25from
fix/mobile-tooltip-stuck
Nov 25, 2026
Merged

liruifengv merged 2 commits into
release/2026-11-25from
fix/mobile-tooltip-stuck

Conversation

@liruifengv

@liruifengv liruifengv commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

移动端浏览器(如 iOS Safari 打开 kimi web)里,点按带悬停提示的元素——最明显的是折叠后的工具调用摘要栏(“编辑了 4 处”、“运行了 1 条命令”)——会弹出一直不消失的 Tooltip 气泡。滚动会话或点按其他位置后,多个白色气泡仍悬浮在正文上方。本 PR 让触屏输入不再触发悬停 Tooltip,点按只执行元素本身的动作。

Bug Reproduction Steps

  1. 在手机 Safari 中打开 kimi web,进入一段包含已折叠工具调用记录的会话。
  2. 先点按一个折叠的摘要栏,再点按另一个。第一次点按会让全局指针追踪器进入已就绪状态;第二次点按坐标发生了变化,能通过合成移动检查,150ms 后弹出 Tooltip。
  3. 滚动会话或点按空白处,气泡仍然固定在屏幕上,不会关闭。

Root Cause

这是在共享的 TooltipBubble 触发层做的根治,而不是在各个调用点打补丁。

TooltipBubble 监听 pointermove 时没有检查 event.pointerType。手机 Safari 在点按带 :hover 样式的元素时,会在 click 之前派发一次 pointerType: 'touch' 的 pointermove。一旦此前的指针采样让 pointerMovement 进入已就绪状态,点按带来的坐标变化会让 isSyntheticPointerMove 返回 false,从而执行 show()。

sequenceDiagram
    participant User as 用户
    participant Safari as 移动 Safari
    participant Tip as TooltipBubble
    User->>Safari: 点按摘要栏
    Safari->>Tip: pointermove(pointerType: 'touch',坐标改变)
    Note over Tip: 已就绪后 isSyntheticPointerMove() === false
    Tip->>Tip: 150ms 后执行 show()(Teleport 到 body,position: fixed)
    User->>Safari: 滚动会话 / 点按空白处
    Note over Safari,Tip: 不触发 mouseout / mouseleave / focusout,也不触发 resize
    Note over Tip: 气泡一直停留在屏幕上
Loading

气泡弹出后,在触屏上没有任何关闭路径:滚动或点按不可悬停区域不会触发 mouseout/mouseleave/focusout;subscribeViewportChange 只监听 window.resize(不随滚动关闭是桌面鼠标用户的有意设计);同时每个 TooltipBubble 实例各自管理 open 状态,因此屏幕上会同时残留多个气泡。

Code Changes

在 TooltipBubble 的 pointermove 入口(IconButton/NumberInput 使用的 target 模式,以及 Tooltip 使用的 delegate 模式)增加悬停守卫,并新增 pointerdown 监听。被拦截的指针会取消待弹出或已打开的悬停气泡,避免混合设备上鼠标静止悬停时手指点按仍留下气泡。键盘 :focus-visible 的 onFocus 逻辑保持不变。

+hoverBlocked(event)
+  if event.pointerType === 'touch': return true
+  if event.pointerType === 'mouse': return false
+  return window.matchMedia?.('(any-hover: none)').matches === true

 onDirectPointerMove(event) / onDelegatePointerMove(event)
+  if hoverBlocked(event):
+    hide()
+    return
   if hovering or isSyntheticPointerMove(event): return
     hovering = true
     show()

+onPointerDown(event)
+  if hoverBlocked(event): hide()
  • pointerType === 'touch' 一律拦截,覆盖纯触屏设备以及主输入支持悬停的混合设备上的手指点按。
  • pointerType === 'mouse' 一律放行,因为 CSS 的 hover 只描述主指针:在触屏仍是主指针((hover: none))的混合设备上,外接鼠标依然可以正常悬停。
  • 其他指针类型(pen 或未知类型)仅在所有可用指针都不支持悬停((any-hover: none))时拦截。
  • 增加 pointerdown 处理是为了覆盖部分浏览器在触摸按下前不派发 pointermove 的情况,在 150ms 计时器触发前将其取消。

Behavior Changes and Affected Users

行为 改动前 改动后 依赖旧行为的人群 逃生口
Tooltip / IconButton / NumberInput 触发元素上的 pointerType: 'touch' pointermove / pointerdown 150ms 后弹出悬停气泡,在移动端通常会一直残留在屏幕上 取消待弹出/已打开的悬停气泡,点按不再弹出 Tooltip 桌面端与 Web(kimi web)触屏用户 无
纯触屏设备上仅通过 Tooltip 展示的静态或开关类详情(ContextComposition.vue 不可选择模式下的角色消息条数 row.count;MediaTool.vue .media-title 的完整路径 media.path) 点按文字可以弹出 Tooltip 查看(伴随气泡不消失的 bug) 点按不再展示;行内的 token 数/占比、文件名/类型/大小/尺寸仍正常显示 此前靠点按这些文字查看完整条数或路径的纯触屏 Web 与桌面端用户(已确认的取舍;点按查看的 Popover 不在本次热修范围内) 键盘 :focus-visible,或打开媒体预览
触屏为主指针((hover: none) 仍为 true)的混合输入设备上,pointerType: 'mouse' 的 pointermove 弹出悬停气泡 仍然弹出悬停气泡(鼠标显式豁免媒体查询限制) 外接鼠标或触控板的 Android / 二合一设备用户 不适用
没有任何指针支持悬停((any-hover: none))时,pointerType: 'pen' 或未知类型的 pointermove 坐标变化后弹出悬停气泡 取消待弹出/已打开的悬停气泡,不再弹出 使用不支持悬停手写笔的触屏优先移动端 Web 与平板用户 键盘 :focus-visible,或改用支持悬停的指针
支持悬停的鼠标/触控板悬停,以及所有设备上的键盘 :focus-visible 悬停或键盘聚焦时展示,移出/失焦/窗口尺寸变化时关闭 不变 桌面端与 Web 鼠标、键盘用户 不适用

受影响模块与测试覆盖:

  • packages/app-ui/src/components/ui/TooltipBubble.vue:桌面端和 Web 所有 Tooltip、IconButton、NumberInput 共用的气泡组件。Markdown 链接/代码预览(linkTooltip.ts、codeTooltip.ts)和输入区的 mentionTooltip.ts 是独立实现,未改动。

  • packages/app-components/test/tooltipViewportListeners.test.ts:在 tooltip hover input 下新增 6 条回归测试,覆盖:

    • 直接绑定目标上的触摸移动,随后真实鼠标悬停仍可弹出;
    • delegate 触发器(ActivityRun 摘要栏模式)上的触摸移动不弹出;
    • (any-hover: none) 匹配时手写笔移动不弹出;
    • 混合输入设备 (hover: none) 匹配时鼠标悬停仍可弹出;
    • 没有前置 pointermove 的触摸 pointerdown 能取消待触发的鼠标悬停计时器;
    • 鼠标静止不动时,触摸 pointermove 能关闭已打开的 delegate 气泡。

    每条新增测试在修复前都会失败、修复后通过;原有的桌面鼠标悬停、窗口尺寸变化关闭和忽略滚动的测试未改动。

验证详情
  • pnpm exec vitest run --reporter=agent packages/app-components/test/tooltipViewportListeners.test.ts packages/app-components/test/browserActivityRun.test.ts packages/app-components/test/genericTool.test.ts packages/app-components/test/workspaceEditDialog.test.ts packages/app-components/test/sessionListPanelRerender.test.ts packages/app-components/test/sessionRowWorkspaceLabel.test.ts packages/app-components/test/sessionRatingRow.test.ts — 7 个文件、110 条用例全部通过。
  • pnpm --filter kimi-code-app run typecheck — 通过。
  • pnpm lint — 通过。
  • pnpm run check:duplication 2b1b095f3bbf48e83632b0aaaabce6773caf4469 — 通过,无新增重复代码。
  • 未在真机或实时浏览器会话中验证。

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.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 55c4de9

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

This PR includes changesets to release 2 packages
Name Type
kimi-code-app Patch
@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

@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-24T15:34:11.636650Z 55c4de9 Manual request
ℹ️ 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.

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026 •

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

commit: 55c4de9

@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: 557fb8bf44

ℹ️ 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".

@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 55c4de9334

ℹ️ 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".

@liruifengv
liruifengv merged commit 82ace45 into release/2026-11-25 Nov 25, 2026
30 of 31 checks passed
@liruifengv
liruifengv deleted the fix/mobile-tooltip-stuck branch November 25, 2026 03:28
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
* fix(app-ui): keep hover tooltips closed on touch input

* fix(app-ui): preserve mouse hover and cancel pending hover on touch
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
* fix(app-ui): keep hover tooltips closed on touch input

* fix(app-ui): preserve mouse hover and cancel pending hover on touch
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