Skip to content

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

Merged
liruifengv merged 4 commits into
mainfrom
refactor/app-components-remaining-imports
Nov 27, 2026
Merged

liruifengv merged 4 commits into
mainfrom
refactor/app-components-remaining-imports

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Stacked on #5548(refactor/app-components-tool-imports)。#5548 合入后会将 base 切回 main。

Requirement or Bug

继 #5548 清理工具卡片目录后,packages/app-components 内的聊天面板(ChatPane.vue、ActivityRun.vue、TurnFold.vue 等)和会话管理页(admin/*.vue)仍有 12 个文件、15 处通过自身公共桶文件 @moonshot-ai/app-components 导入工具函数、类型、composable 或兄弟组件。这些导入经由 index.ts 把剩余的 15 个文件绑在同一个运行时循环依赖环中。本 PR 是 Desktop 分阶段重构的 PR 1.2,将 app-components 的包内自引用与运行时循环依赖彻底清零。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路

只修改剩余 12 个组件的导入来源,使其指向真实定义模块或兄弟组件;同路径导入顺手合并,避免新增重复导入。不改动任何模板、逻辑、props 与 src/index.ts 的对外导出,浏览器相关组件未触碰。

 ChatPane.vue / ActivityRun.vue / TurnFold.vue / ThinkingBlock.vue
-  formatDuration / formatTokens  ← @moonshot-ai/app-components (index.ts)
-  turn 渲染函数与类型            ← @moonshot-ai/app-components (index.ts)
-  summarizeActivity / summarizeLive ← @moonshot-ai/app-components (index.ts)
+  formatDuration / formatTokens  ← @moonshot-ai/app-core/lib
+  turn 渲染函数与类型            ← ../chatTurnRendering
+  summarizeActivity / summarizeLive ← ../lib/activitySummary

 TurnDiffPanel.vue / TurnFilesSummary.vue
-  type TurnFileChange ← @moonshot-ai/app-components
+  type TurnFileChange ← @moonshot-ai/app-core/client/types

 admin/*.vue (6 个文件)
-  useAnchoredMenu / pageItems / formatAdminTime ← @moonshot-ai/app-components
-  FilterSelect / MultiSelectMenu / SessionAdminTable / SessionAdminPagination ← @moonshot-ai/app-components
-  type SessionAdminBatchDirection ← @moonshot-ai/app-components
+  useAnchoredMenu / pageItems / formatAdminTime ← ../composables/useAnchoredMenu、./pageItems、./formatAdminTime
+  兄弟组件                                 ← ./*.vue(默认导入)
+  type SessionAdminBatchDirection         ← @moonshot-ai/app-client/client

旧路径功能清单与符号映射

涉及文件 原导入符号 新路径
chat/ChatPane.vue 16 个回合渲染函数(turnBlocks、splitAssistantFold、renderBlockKey 等)、type AssistantFold、type AssistantRenderBlock ../chatTurnRendering(合并值与类型导入)
chat/ChatPane.vue formatTokens @moonshot-ai/app-core/lib(合并进已有的 copyTextToClipboard, formatMessageTime 导入)
chat/ActivityRun.vue formatDuration;toolStackKey、type ActivityItem;summarizeActivity、summarizeLive、type SummaryClause、type SummaryTone @moonshot-ai/app-core/lib;../chatTurnRendering;../lib/activitySummary(SummaryClause/SummaryTone 由该模块原样 re-export)
chat/TurnFold.vue formatDuration;renderBlockKey、turnWorkMs、type AssistantRenderBlock @moonshot-ai/app-core/lib;../chatTurnRendering
chat/ThinkingBlock.vue formatDuration @moonshot-ai/app-core/lib
chat/TurnDiffPanel.vue、chat/TurnFilesSummary.vue type TurnFileChange @moonshot-ai/app-core/client/types(TurnDiffPanel 合并进已有的 DiffViewLine 导入)
admin/FilterSelect.vue、MultiSelectMenu.vue、SessionAdminMenu.vue useAnchoredMenu ../composables/useAnchoredMenu
admin/SessionAdminPagination.vue pageItems ./pageItems
admin/SessionAdminTable.vue formatAdminTime、formatAdminTimeCompact;type SessionAdminBatchDirection ./formatAdminTime;@moonshot-ai/app-client/client(合并进已有的 useKimiWebClient 导入)
admin/SessionAdminView.vue type SessionAdminBatchDirection;FilterSelect、MultiSelectMenu、SessionAdminTable、SessionAdminPagination @moonshot-ai/app-client/client(合并类型导入);./*.vue 默认导入

测试与基线

  • packages/app-components/test/dockTaskStopStates.test.ts:移除已失效的 vi.mock('@moonshot-ai/app-components', () => ({ formatDuration: ... }))。refactor(app-components): extract shared tool card and task list setup hooks #5543 抽取 useTaskList 后,TasksPane / SubagentGrid 已从 @moonshot-ai/app-core/lib 获取 formatDuration,且该测试只断言图标、按钮禁用态和状态文案,不再依赖此 mock。
  • 运行 node scripts/checks/app-boundaries.mjs --update 与 node scripts/checks/ratchet.mjs --update,基线只降不升:
    • self-package-import:全仓库清零(基线中该规则条目整体移除)。
    • app-components 的 runtime-cycle:15 → 0(剩余 15 个文件全部退环;全仓仅剩主进程 12 文件环、浏览器 3 文件环与 app-client/stores 6 文件环,按计划后续阶段处理)。
    • oxlint import/no-cycle 在 app-components 全部清零,import/no-duplicates 在 SessionAdminView.vue 清零、ActivityRun.vue 从 3 降至 1。

阅读指南

先看 packages/app-components/src/chat/ActivityRun.vue、packages/app-components/src/admin/SessionAdminView.vue 与 packages/app-components/src/chat/ChatPane.vue(涉及多符号拆分与合并),其余 9 个组件均为单行导入替换;测试与基线文件可略读。

Behavior Changes and Affected Users

None。

证据:所有符号均指向 src/index.ts 原本 re-export 的同一模块定义;兄弟组件原本就是具名 re-export .vue 默认导出,改为相对路径默认导入拿到同一组件对象;未改动任何分支、默认值、模板、样式、公共导出面或契约文件。

  • 受影响模块:Desktop 与 Web 的主聊天面板(回合折叠、活动流、思考块、文件变更摘要与 diff 面板)以及会话管理页(筛选下拉、多选菜单、行操作菜单、分页与管理表格)。
  • 测试覆盖:packages/app-components 全部 1063 个单测(含聊天渲染、管理页分页/时间格式化/菜单、任务面板等)。
验证记录
  • 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-components packages/app-core/test/activitySummary.test.ts:103 个测试文件、1063 个用例全部通过。
  • pnpm run check:duplication 88553c7d2ccc126ccafccac710d62f09f23455ff:通过,无新增重复片段。
  • 桌面端 Playwright E2E(e2e:headless):本地未运行,因其默认执行 pnpm run build 触发全量桌面构建;本 PR 仅调整 ESM 导入路径,等价性由类型检查、全量组件单测及 CI build / windows 任务验证。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).(内部重构 PR 1.2,无关联 issue,依赖 refactor(app-components): import tool card helpers from their defining modules #5548)
  • I have added tests that prove my feature works.(纯导入路径重构,复用 app-components 现有 1063 个单测与 app-boundaries 门禁验证;清理 dockTaskStopStates.test.ts 失效 mock)
  • 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: f5acbbc

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-26T13:55:07.246836Z f3e9359 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@f5acbbc
npx https://pkg.pr.new/@moonshot-ai/kimi-code@f5acbbc

commit: f5acbbc

Base automatically changed from refactor/app-components-tool-imports to main November 27, 2026 03:54
…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
…ts-remaining-imports

# Conflicts:
#	scripts/checks/baselines/app-boundaries.json
#	scripts/checks/baselines/oxlint-ratchet.json
@liruifengv
liruifengv added this pull request to stack #5614 November 27, 2026 04:16
@liruifengv
liruifengv merged commit 304a65a into main Nov 27, 2026
22 checks passed
@liruifengv
liruifengv deleted the refactor/app-components-remaining-imports branch November 27, 2026 05:09
@7Sageer 7Sageer mentioned this pull request Nov 27, 2026
6 tasks done
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