Skip to content

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

Merged
liruifengv merged 10 commits into
mainfrom
refactor/lower-icon-registry
Nov 27, 2026
Merged

liruifengv merged 10 commits into
mainfrom
refactor/lower-icon-registry

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Stacked on #5550(refactor/lower-ui-primitives)。前置 PR 合入后会将 base 切回 main。

Requirement or Bug

统一图标注册表(ICONS、getIcon、iconSvg、IconName)和 111 个 kimi/*.svg 资产目前放在状态/业务层的 packages/app-client 中,而基础组件 Icon.vue 在 packages/app-ui 中。这迫使底层的 app-markdown(代码块换行/行号、宽表复制、链接浮层按钮)向上依赖 app-client,并让 app-composer 仅为了测试时定位 SVG 目录和核对图标字形而在 devDependencies 中反向依赖 app-client,产生 pnpm app-client <-> app-composer 循环依赖警告。本 PR 是 Desktop 分阶段重构的 PR 1.3b,将图标注册表下沉到 app-ui,彻底解除 app-markdown 与 app-composer 对 app-client 的依赖。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路

图标是纯 UI 资产,应与 Icon.vue 同属 app-ui。本 PR 原样搬迁图标注册表与 SVG 目录,通过 @moonshot-ai/app-ui/icons 子路径导出(不挂到 app-ui 根入口,避免仅使用基础组件的页面静态拉入全部 SVG),不保留旧路径兼容 re-export。

 packages/
   app-ui/
     src/
-      icons.ts                       # IconResolverKey / SIZE_PX / IconSize
+      iconResolver.ts                # 原 icons.ts 改名(100% rename),根入口继续从此导出
+      icons/
+        icons.ts                     # 原 app-client/src/icons/icons.ts;SIZE_PX / IconSize 改为复用 ../iconResolver
+        kimi/*.svg                   # 原 app-client/src/icons/kimi(111 个 SVG 100% rename)
+    test/icons.test.ts               # 原 app-client/test/icons.test.ts(100% rename)
+    vitest.config.ts                 # 新增:接入 vite-preset 的 Vue 与 unplugin-icons
   app-client/
-    src/icons/                       # 移除,package.json 移除 "./icons" 导出
   app-markdown/package.json
-    dependencies: @moonshot-ai/app-client
   app-composer/package.json
-    devDependencies: @moonshot-ai/app-client
+    devDependencies: @moonshot-ai/app-ui

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

项目 原位置 新位置 / 处理
ICONS、getIcon、iconSvg、type IconName、type IconEntry @moonshot-ai/app-client/icons @moonshot-ai/app-ui/icons(28 个消费方文件更新导入)
SIZE_PX、type IconSize app-ui/src/icons.ts 与 app-client/src/icons/icons.ts 各有一份相同定义 统一由 app-ui/src/iconResolver.ts 定义;app-ui 根入口与 @moonshot-ai/app-ui/icons 均从该处导出,消除重复定义
kimi/*.svg 资产目录(iconsDir) app-client/src/icons/kimi app-ui/src/icons/kimi;app-ui 增加 ./package.json 导出,7 处 vite/vitest 配置改为从 @moonshot-ai/app-ui/package.json 解析
浏览器入口(browser-overlay.ts、browser-control.ts、BrowserControlSurface.vue) 从 @moonshot-ai/app-client/icons 导入 getIcon / iconSvg 仅各改一行 import 为 @moonshot-ai/app-ui/icons,浏览器逻辑零改动
直接引用旧模块路径的测试 apps/desktop/tests/renderer/{kbd,tooltip-bubble}.test.ts 引用 app-ui/src/icons 改为引用 app-ui/src/iconResolver
app-ui 测试运行配置 无 vitest.config.ts(无法解析 ~icons/*) 新增 packages/app-ui/vitest.config.ts,同时包含 test/**/*.test.ts 与 src/**/*.test.ts(保留 markdownColors.test.ts 覆盖)

基线与工作区检查

  • app-boundaries 的 upward-package-import:4 → 1(app-markdown 的向上依赖全部清零,仅剩 app-ui/toastTypes.ts 一处,由 PR 1.4 处理)。
  • oxlint-ratchet:vitest/no-conditional-expect 从 app-client/test/icons.test.ts 1:1 平移至 app-ui/test/icons.test.ts(测试文件 100% 原样搬迁,全仓总数不增)。
  • pnpm install 不再出现 app-client <-> app-composer 循环依赖警告;node scripts/check-nix-workspace.mjs 通过(未增删工作区成员,flake.nix 无需变更)。

阅读指南

先看 packages/app-ui/package.json、packages/app-ui/vitest.config.ts 与 packages/app-ui/src/icons/icons.ts 首尾(仅新增 ../iconResolver 导入与 re-export);111 个 SVG、iconResolver.ts、icons.test.ts 均为 rename 可略读;其余文件均为单行导入路径替换。

Behavior Changes and Affected Users

None。

证据:所有图标组件、原始 SVG 字符串、applySize 尺寸替换逻辑、SIZE_PX 像素值(14/16/20)与 IconResolverKey 注入机制均未改动;未修改任何组件渲染逻辑、分支或契约文件。

  • 受影响模块:Desktop 与 Web 全部界面图标(含 Markdown 代码块/表格/链接浮层按钮、Composer 提及菜单、设置页、截图覆盖层、钉住窗口与浏览器控制浮层)。
  • 测试覆盖:app-ui 图标注册表测试、5 个 app-* 包全量单测、桌面端渲染端测试及 build:web 生产构建。
验证记录
  • 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 apps/desktop/tests/renderer:431 个测试文件中 430 个一次通过(5978 例);唯一超时的 browser-overlay-annotation-shortcut.test.ts 系新路径下 111 个 SVG 首次冷编译超过 5s 默认超时,单独复跑 4.4s 通过(15/15 用例通过),未改动该测试。
  • pnpm --filter kimi-code-app run build:web:通过。
  • node scripts/check-nix-workspace.mjs:通过。
  • pnpm run check:duplication 8bfa809b96fb9d601674da96259cd71067779fd9(PR 实际 base):通过,无新增重复片段。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).(内部重构 PR 1.3b,无关联 issue,依赖 refactor(app-ui): lower scrollbar, IME latch and PinScrollKey primitives #5550)
  • I have added tests that prove my feature works.(纯模块下沉,原 icons.test.ts 随模块迁移至 app-ui/test 并全部通过,复用 5 个 app-* 包与渲染端共 5981 个用例验证)
  • 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: 63092b9

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:51:16.732835Z 758d668 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.

@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@63092b9
npx https://pkg.pr.new/@moonshot-ai/kimi-code@63092b9

commit: 63092b9

…ves (#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
Base automatically changed from refactor/lower-ui-primitives to refactor/app-components-remaining-imports November 27, 2026 03:54
…ts-remaining-imports

# Conflicts:
#	scripts/checks/baselines/app-boundaries.json
#	scripts/checks/baselines/oxlint-ratchet.json
…r/lower-icon-registry

# Conflicts:
#	apps/desktop/src/renderer/browser-overlay.ts
#	packages/app-markdown/src/lib/linkTooltip.ts
#	packages/app-ui/src/index.ts
#	packages/app-ui/tsconfig.json
#	scripts/checks/baselines/app-boundaries.json
@liruifengv
liruifengv added this pull request to stack #5614 November 27, 2026 04:16
@github-actions

Copy link
Copy Markdown
Contributor

❌ Nix build failed

Hash mismatch in pnpmDeps:

Hash
specified sha256-NJ2AG6AYYAdtxTrshOxEQ3qaxAmHRkX44vkwWSeOHAI=
got sha256-il3ytNAPoCFqHrw/2wToEKVR53ghdPXT07fIhY9LAZk=

Please update flake.nix with the got hash.

Base automatically changed from refactor/app-components-remaining-imports to main November 27, 2026 05:09
…egistry

# Conflicts:
#	apps/desktop/src/renderer/components/UpdateIndicator.vue
#	packages/app-markdown/src/lib/linkTooltip.ts
#	packages/app-ui/src/index.ts
#	packages/app-ui/tsconfig.json
#	scripts/checks/baselines/app-boundaries.json
@liruifengv
liruifengv merged commit 1c9310d into main Nov 27, 2026
24 checks passed
@liruifengv
liruifengv deleted the refactor/lower-icon-registry branch November 27, 2026 05:37
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Dec 2, 2026
…aluated upstream items

Port the two kimi icons upstream MoonshotAI#5557 moved, the raw-icon module
declaration from MoonshotAI#5068, and the tool-args validator re-export from MoonshotAI#4630.
All three are byte-identical to upstream/main; only the paths are adapted.

check-check.svg and feedback.svg land in packages/app-client/src/icons/kimi/
because this fork still keeps its 109 kimi SVGs and icons.ts there, while
upstream moved the whole set to packages/app-ui/src/icons/. Both resolve
verbatim through the build's own unplugin-icons loader, in the component
form and in the ?raw form.

packages/app-composer/src/icons.d.ts declares ~icons/*?raw as a string. The
package tsconfig sets "types": [], so oxlint's type-aware pass saw every raw
icon import as an error type and flagged each entry of the icon map. The
declaration removes all 16 frozen typescript/no-unsafe-assignment findings
in src/shared/icons.ts, and the ratchet baseline drops that one entry
accordingly; upstream's own commit carried the same companion change.

packages/agent-core-v2/src/tool/executor/validate.ts re-exports
@moonshot-ai/core/tool/validate, which this fork already carries as
packages/core/src/tool/validate.ts.

No changeset: none of the three is user-perceivable.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Dec 2, 2026
`bun scripts/upstream-ledger.mjs --refresh` at upstream/main 4eb2919
added 126 rows, so every open upstream commit and every PR it references
now has a ledger row: 0/596, down from 125 at 8bf8ba3 and 126 at the
fetched tip. The refresh only reads `upstream/main ^ main`, so the three
release-2.6.2 commits named by the mission (MoonshotAI#4875/MoonshotAI#4905/MoonshotAI#4922) gained
rows with the refresh's row shape.

Settled with live probes in this tree:

- ported: MoonshotAI#5533 (docs 2.8.1 changelog), MoonshotAI#4875 (registry search_url and
  feedback_url plus the feedback service), MoonshotAI#4905 (Kimi upload status
  validation in packages/core), MoonshotAI#4922 (swarm task events in
  sessionTaskFeed), MoonshotAI#5438 (unload only declared dynamic tools), MoonshotAI#5592
  (dynamic tool replacement order), MoonshotAI#5595 (append-log known length),
  MoonshotAI#5573 (skill roots for every work dir), MoonshotAI#5576 (date reminder cwd
  comparison), MoonshotAI#5618 (session titles for skill openers), MoonshotAI#5638 (frozen
  loop tool baseline), MoonshotAI#5626 (legacy turn-input origins)
- partial: MoonshotAI#5505 (processLiveness source and consumers present; the
  upstream unit test file was never carried), MoonshotAI#5571 (program-resume and
  OSC 7577 present; the upstream test helper was never carried), MoonshotAI#5532
  (gitService half present; fsService still leaks the environment lease
  at fsService.ts:1133 and :1267), MoonshotAI#5557 (app-client icon registry kept;
  the move to app-ui was never carried)
- not-applicable: MoonshotAI#4655 (upstream reverted auto review in MoonshotAI#5649), MoonshotAI#5333
  (PLAYBOOK:111 deliberate flat experimental flags)

M39's "likely present" list was checked, not trusted: MoonshotAI#5438 is present
(upstream test passes), MoonshotAI#5487 is not (nativeStartSettleMs/leg.nativeSettled
absent), MoonshotAI#5635 is not (ToolsSettled absent), MoonshotAI#5429 needs a visual probe.
The remaining 194 pending rows stay open with their reasons; no feature
was ported and no upstream-drift allowlist entry was added.

Verification: verify -> 332 closed rows, 332 carry every file of their
PR; 317 probes pass, 2 foreign-runner skips, 0 fail; a second verify is
byte-identical (ledger sha256 cbf53638...). Probe tests 29 pass; bun run
lint and node scripts/checks/ratchet.mjs green.
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