Skip to content

refactor(kb-base): 正交提取 ChunkingStrategyPanel 等 4 个内联组件和 format-utils 到 _components 目录 - #550

Merged
ThreeFish-AI merged 1 commit into
feature/1.x.xfrom
ThreeFish-AI/curitiba-v1
May 16, 2026
Merged

refactor(kb-base): 正交提取 ChunkingStrategyPanel 等 4 个内联组件和 format-utils 到 _components 目录#550
ThreeFish-AI merged 1 commit into
feature/1.x.xfrom
ThreeFish-AI/curitiba-v1

Conversation

@ThreeFish-AI

Copy link
Copy Markdown
Owner

背景

  • 本次变更要解决的问题:knowledge/base/page.tsx 是一个 2,064 行的超大单体文件,其中 ChunkingStrategyPanel(1,491行)和 CorpusSettingsPanel(364行)等内联组件与主页面组件严重耦合,违反正交分解与单一职责原则
  • 关联上下文/文档:AGENTS.md 正交分解原则

核心变更

  • page.tsx 正交提取 4 个内联组件到 _components/ 目录:ChunkingStrategyPanel(322行)、CorpusSettingsPanel(389行)、CorpusStatusBadge(18行)、DocumentMetadataPanel(59行)
  • 提取 5 个工具函数到 _components/format-utils.ts(75行):formatCorpusConfigSummaryformatFileSizeformatDateTimeformatChunkLabeltoDocumentChunkCardViewModel
  • page.tsx 从 2,064 行降至 1,239 行,净减 825 行(-40%)
  • 纯提取重构,不修改任何运行时逻辑,所有组件保持完全相同的 props 接口和行为

风险与回滚

  • 主要风险:低。仅文件提取 + import 调整,TypeScript 编译 + ESLint 全量通过
  • 回滚方式:git revert

验证证据

  • 单元测试:已有 KnowledgeBasePage.test.tsx 等测试文件
  • 集成测试:pnpm exec tsc --noEmit 零新增错误
  • E2E/Workflow:pre-commit hooks(ESLint + Ruff)全部通过
  • 覆盖率/关键截图:N/A

影响范围

  • 前端:apps/negentropy-ui/app/knowledge/base/ 目录下 6 个文件(1 修改 + 5 新增)
  • 后端:无影响
  • GitHub Actions / 文档:无影响

Next Best Action

  • 继续对 knowledge-api.ts(3,063行)、conversation-tree.ts(1,815行)等超大文件执行正交分解(需先完成内部依赖图分析)

… 到 _components 目录;

将 knowledge/base/page.tsx 中的 4 个内联组件(ChunkingStrategyPanel 1491行、
CorpusSettingsPanel 364行、CorpusStatusBadge、DocumentMetadataPanel)
及 5 个工具函数(formatCorpusConfigSummary、formatFileSize、formatDateTime、
formatChunkLabel、toDocumentChunkCardViewModel)提取为独立模块,
page.tsx 从 2064 行降至 1239 行,净减 825 行。

🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini Code Assist](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
@ThreeFish-AI ThreeFish-AI changed the title refactor(kb-base): 正交提取 4 个内联组件和 format-utils 到 _components 目录 refactor(kb-base): 正交提取 ChunkingStrategyPanel 等 4 个内联组件和 format-utils 到 _components 目录 May 16, 2026
@ThreeFish-AI
ThreeFish-AI merged commit a88eeb4 into feature/1.x.x May 16, 2026
11 checks passed
@ThreeFish-AI
ThreeFish-AI deleted the ThreeFish-AI/curitiba-v1 branch May 17, 2026 06:02
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