Skip to content

refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives - #5550

Merged
wbxl2000 merged 2 commits into
refactor/app-components-remaining-importsfrom
refactor/lower-ui-primitives
Nov 27, 2026
Merged

wbxl2000 merged 2 commits into
refactor/app-components-remaining-importsfrom
refactor/lower-ui-primitives

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Stacked on #5549(refactor/app-components-remaining-imports)。前置 PR 合入后会将 base 切回 main。

Requirement or Bug

packages/app-markdown 作为底层渲染包,目前仍向上依赖 packages/app-client 中的滚动条几何计算、全局 IME 组合输入锁存以及 PinScrollKey 注入键;而这些符号本身在 app-client/src 内几乎没有业务使用,实际消费方都是 app-markdown、app-components 和渲染端视图。本 PR 是 Desktop 分阶段重构的 PR 1.3,将这三个纯 UI / 滚动契约下沉到 app-ui 与 app-core/contracts,消除 app-markdown 的非图标向上依赖,且完全不触碰浏览器相关文件。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路

按「基础 UI 原语归 app-ui,跨包滚动注入契约归 app-core/contracts」原样搬迁模块,不保留旧路径的兼容 re-export,所有消费方直接改为从新归属导入。图标注册表(icons/)因涉及 3 个浏览器入口的 import,拆到紧随其后的独立 PR 处理,保持本 PR 聚焦且不碰浏览器子系统。

 packages/
   app-core/src/contracts.ts
+    PinScrollKey                       # 原 app-client/contracts
   app-ui/src/composables/
+    useOverlayScrollbar.ts             # 原 app-client/composables(100% 原样搬迁)
+    imeComposition.ts                  # 原 app-client/lib(100% 原样搬迁)
     useImeComposition.ts               # 保留:组件级组合输入状态
   app-client/src/
-    composables/useOverlayScrollbar.ts
-    lib/imeComposition.ts
-    contracts.ts (移除 PinScrollKey)
   app-markdown/src/
-    向上 import @moonshot-ai/app-client/{contracts,composables,lib}
+    改从 @moonshot-ai/app-core/contracts 与 @moonshot-ai/app-ui 导入

useImeComposition(随组件挂载/卸载、监听 window focus 事件重置)与 imeComposition(全局单例 latch,供非 Vue 组件的 DOM 浮层如 linkTooltip、SelectionActionBubble 复用同一份组合状态)生命周期不同,因此保持两个模块并存,不做强行合并。

旧路径功能清单与新归属对照

迁移符号 原位置 新位置 消费方更新
overlayScrollbarThumb、dragOverlayScrollbarThumb、useOverlayScrollbar、OverlayScrollbarThumb、UseOverlayScrollbar @moonshot-ai/app-client/composables @moonshot-ai/app-ui(src/composables/useOverlayScrollbar.ts) app-markdown/lib/codeScrollbars.ts、app-components/composer/menuScroll.ts、PinnedSessionList.vue、sidebar/SessionListPanel.vue
installImeCompositionLatch、isImeKeyEvent @moonshot-ai/app-client/lib @moonshot-ai/app-ui(src/composables/imeComposition.ts) app-markdown/lib/linkTooltip.ts、SelectionActionBubble.vue、FontSettingsPage.vue、HostsPanel.vue、SettingsSubpage.vue、渲染端 App.vue、ChatDock.vue
PinScrollKey @moonshot-ai/app-client/contracts @moonshot-ai/app-core/contracts app-markdown/Markdown.vue、app-client/composables/useTranscriptScroll.ts、ChatPane.vue、ActivityRun.vue、TurnFold.vue、ThinkingBlock.vue、AgentDetailPanel.vue、SideChatPanel.vue、GoalNotice.vue、ToolDisclosure.vue
对应单测 packages/app-client/test/{overlay-scrollbar,imeComposition}.test.ts packages/app-ui/test/(断言与用例不变,仅更新相对导入路径) 随 app-ui 测试运行

类型配置与基线说明

  • packages/app-ui/tsconfig.json 补充 "lib": ["ES2023", "DOM", "DOM.Iterable"]。此前 app-ui 未声明 DOM lib,导致类型感知 lint 把 DOM 类型当作 any;补齐后:
    • useToastTimer.ts:44 的 window.matchMedia?.('(hover: none)').matches === true 被识别为冗余布尔比较,去掉 === true(可选链短路时同样得到 falsy,行为完全等价)。
    • 消除了 app-ui 原有的 7 条 no-unsafe-assignment / no-unsafe-member-access / no-unsafe-return 基线。
    • imeComposition.ts 及其测试的 keyCode === 229 告警从 app-client 基线 1:1 平移至 app-ui;useImeComposition.ts 中既有的同一 IME 保护也因补齐 DOM 类型首次被扫到。为不改变输入法边界行为,使用 node scripts/checks/ratchet.mjs --update --allow-increase 登记该存量条目(全仓总告警数从 3085 降至 3068)。
  • app-boundaries 的 upward-package-import 从 6 处降至 4 处(app-markdown 仅剩 3 处 iconSvg 引用及 app-ui/toastTypes.ts)。

阅读指南

先看 packages/app-ui/src/index.ts、packages/app-core/src/contracts.ts 与 packages/app-ui/tsconfig.json 了解新归属和类型配置;两个迁移的 src/composables/*.ts 为 100% rename 可略读;其余 24 个文件均为导入路径拆分/合并。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
列表、菜单与 Markdown 代码块/表格的悬浮滚动条几何与拖拽 由 app-client 提供计算与 composable 同一实现迁至 app-ui,计算、900ms 隐藏延时、CSS 变量名均不变 Desktop 与 Web 会话列表、固定会话、Markdown 代码块用户 N/A
输入法组合期间(含 compositionend 后 100ms 与 keyCode === 229)的 Escape/Enter 拦截 由 app-client/lib 提供全局 latch 同一实现迁至 app-ui,监听捕获阶段与自愈重置时机不变 使用中文等 IME 输入法的 Desktop 与 Web 用户 N/A
Markdown 宽表切换/异步高度变化时钉住滚动位置 PinScrollKey 定义在 app-client/contracts PinScrollKey 定义在 app-core/contracts,provide/inject 键仍为同一模块内 Symbol('pinScroll') Desktop 与 Web 聊天阅读用户 N/A
触屏设备 Toast 时长额外增加 5000ms matchMedia?.('(hover: none)').matches === true matchMedia?.('(hover: none)').matches(布尔值/falsy 判断等价) 触屏设备上的 Desktop 与 Web 用户 N/A
验证记录
  • pnpm lint:通过(0 退出)。
  • pnpm --filter kimi-code-app run typecheck:通过(主进程 tsc --noEmit 与渲染端 vue-tsc --noEmit -p tsconfig.renderer.json)。
  • pnpm exec vitest run --reporter=agent packages/app-ui packages/app-markdown packages/app-composer packages/app-client packages/app-components:308 个测试文件、4691 个用例全部通过(含迁移后的 overlay-scrollbar.test.ts 12 例、imeComposition.test.ts 6 例、MarkdownAsyncHeight.test.ts、linkTooltip.test.ts、toastTimer.test.ts)。
  • pnpm run check:duplication 88553c7d2ccc126ccafccac710d62f09f23455ff:通过,无新增重复片段。
  • 平台核对:IME 组合输入在 macOS / Windows 上均依赖 keyCode === 229 与 100ms 保护窗,本 PR 未改动相关判断逻辑;上述检查在 macOS 本地通过,Linux 与 Windows 由 CI 验证。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).(内部重构 PR 1.3,无关联 issue,依赖 refactor(app-components): remove remaining self-package barrel imports #5549)
  • I have added tests that prove my feature works.(纯模块下沉,原 overlay-scrollbar / imeComposition 单测随模块迁移至 app-ui/test 并全部通过,复用 5 个 app-* 包共 4691 个用例验证)
  • 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.(私有 app-* UI 层内部重构,无用户可感知变化,无需 changeset)
  • Ran gen-docs skill, or this PR needs no doc update.(不改变用户可见功能,无需更新用户文档)

@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8bfa809

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 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-26T14:34:54.981944Z 8bfa809 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 26, 2026 •

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

commit: 8bfa809

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

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

Reviewed commit: 8bfa809b96

ℹ️ 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 25c0c2e into refactor/app-components-remaining-imports Nov 27, 2026
22 checks passed
@wbxl2000
wbxl2000 deleted the refactor/lower-ui-primitives branch November 27, 2026 03:54
liruifengv added a commit that referenced this pull request Nov 27, 2026
#5549)

* refactor(app-components): import tool card helpers from their defining modules

* refactor(app-components): remove remaining self-package barrel imports

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives (#5550)

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives

* fix(app-components): import shared anchored menu css directly and scope IME lint suppressions
liruifengv added a commit that referenced this pull request Nov 27, 2026
)

* refactor(app-components): import tool card helpers from their defining modules

* refactor(app-components): remove remaining self-package barrel imports

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives

* fix(app-components): import shared anchored menu css directly and scope IME lint suppressions

* refactor(app-ui): move unified icon registry down from app-client

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives (#5550)

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives

* fix(app-components): import shared anchored menu css directly and scope IME lint suppressions

* build(nix): update pnpmDeps hash after removing app-client dependency
liruifengv added a commit that referenced this pull request Nov 27, 2026
…ontracts from api (#5561)

* refactor(app-components): import tool card helpers from their defining modules

* refactor(app-components): remove remaining self-package barrel imports

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives

* fix(app-components): import shared anchored menu css directly and scope IME lint suppressions

* refactor(app-ui): move unified icon registry down from app-client

* refactor(app-core): split composables entrypoint and decouple toast contracts from api

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives (#5550)

* refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives

* fix(app-components): import shared anchored menu css directly and scope IME lint suppressions

* refactor(desktop): break main process window and browser runtime cycles (#5568)

* refactor(desktop): extract main window registry and terminal menu focus state

* refactor(desktop): extract browser overlay state to break main browser cycle

* build(nix): update pnpmDeps hash after removing app-client dependency
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.

2 participants