Skip to content

对话组件拆分 A:把 ChatbotEnhanced.tsx 的类型、子组件和工具函数搬到独立文件(不改行为) #37728

Description

@objectstack-fleet

repo:cloud#5 · hotlong · session_01Q4EjjMouQg4opwRbvXunTA

Filing gate: ③ maintainer-directed task · Source: topic #37690 — Jack 2026-11-27T00:09Z:「对话界面改进 ,用fable评估,开始分拆」;方案已经 Fable 对照代码评审,要点已全部写进本卡。
Grade: area:ai · Task · p2 · reach: 无行为变化的重构 · evidence: read(基线 objectstack main 80519b5 + PR #37720 head c2b7b6a)
Reader: 专题 objectstack#37690 的拆分卡线程(os-dev)。
Dedupe: org:objectstack-ai is:issue ChatbotEnhanced split 47 条,均为已关 build 期卡,无重叠;除 #37720 外 44 个 open PR 无一碰本文件(2026-11-27 00:15Z 核)。
Blocked-by: #37682(PR #37720 删 build 对话前端,本文件被它删 4465 行,合并后才能开工)

为什么

ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx 删完 build 后仍有 3335 行,其中主组件 1372 行、Props 接口 272 行,其余是可独立的类型、子组件和工具函数。后续体验改进(反馈、审批卡、思考时间线等)都要改这个文件,先拆开降低冲突和审阅成本。

做什么

主文件只留主组件 ChatbotEnhanced、只被主组件用的 formatMessageProps 和两个 PLAIN_SURFACE_* 常量,以及对搬走符号的具名 re-export。预计约 3335 → 1700 行。新文件放 ui/packages/plugin-chatbot/src/chat/(plugin-chatbot 内相对 import 不带 .js 后缀,跟现有写法一致):

  • types.ts:ChatbotEnhancedMessage、ChatbotEnhancedToolInvocation、ChatChart、ChatSource、ChatbotLabels、ChatbotEnhancedProps、ChatbotProcessVisibility、ChatbotSurface、ChatbotModelOption、ToolDecisionState、TurnLiveness。对 ../mapMessages 只能 import type(mapMessages.ts:28 反向引用这些类型)。
  • ModelPicker.tsx:ModelPicker、drawnMultiplierOf、EXPENSIVE_MODEL_MULTIPLIER、OUTSIDE_MODELS。
  • liveness.tsx:useTurnLiveness、LivenessIndicator、LIVENESS_QUIET_AFTER_SECONDS、useIsOffline、formatElapsed、ThinkingDots、AssistantThinkingMessage、MessageAvatar。
  • toolSummary.tsx:getToolState、getToolStateRank、ToolSummaryState、ToolSummaryGroup、shouldRenderDetailedTool、summarizeTools、ToolPhaseSummary、ToolPhaseStep、foldToolPhaseSteps、isPlumbingTool、PLUMBING_TOOL_NAMES、ToolActivitySummary、ToolActivitySummaryLabels、ToolSummaryIcon、getToolSummaryStatus、ToolRunningTimer、usePhaseElapsed、phaseClock、SmartToolOutput、looksLikeJson。依赖方向只能 toolSummary → liveness(ToolRunningTimer 用 useIsOffline、formatElapsed)。
  • answerLayout.tsx:layoutAnswer、AnswerBlock、AnswerCharts、isToolCallPlaceholder。
  • toolRecordWrite.ts:writtenRecordOf、formatRecordWriteValue(只被工具卡用,卡 B 会接着用)。
  • composerNotices.tsx:ErrorBanner、ComposerNotice、SendErrorNotice、formatSizeLimit、useAiQuotaCopy。

⛔ 模块级单例只能有一份:phaseClock(模块级 Map,注释写明“pane 重挂载时保留计时”)必须和 usePhaseElapsed 一起搬进 toolSummary.tsx,不得留副本。

上面没点名的私有辅助跟它唯一的使用者走;有疑问时留在原文件,在 PR 描述里列出。行号会因 #37720 合并后的 main 变化,以符号名为准。

内部消费方(FloatingChatbot、chatMessageAdapter、mapMessages、renderer、toolResultParsers、useAiModels、useHitlInChat)不用改,经 re-export 照常工作。

不做

主组件内部的拆分(卡 B);mapMessages.ts、useObjectChat.ts;任何体验改动。

通用约束(本专题三张拆分卡共用)

  1. 只搬代码,不改行为:不改 JSX 结构、className、文案键、hook 调用顺序、memo 依赖、条件分支。
  2. 原文件保留具名 re-export(export { a, b } from './x',类型用 export type { … }),⛔ 不用 export *:docs/qa/platform-checklist/ 的符号锚点(scripts/symbol-anchors.mjs)只认具名导出。所有现有 import 路径保持不变。
  3. 测试文件不改,本卡另列的例外除外。
  4. 新文件不得 import 原大文件(避免环)。对 ../mapMessages 等反向依赖方只能 import type。
  5. 公开入口冻结:ui/packages/plugin-chatbot/src/index.tsx、ui/packages/plugin-chatbot/src/core.ts、ui/packages/app-shell/src/index.ts 三个文件 diff 为空。
  6. 验收:现有测试全绿;type-check、lint、build 通过;PR 描述贴 git diff --color-moved=zebra --stat 和一句说明“删除行与新增行之差只有 import/export 行”。
  7. changeset:放仓根 .changeset/(ui/AGENTS.md),级别 patch;changeset 正文和 PR 描述都写 Clause-②: no 与 Metadata-protocol: none 两行(AGENTS.md「Post-Task Checklist」第 3 步)。不碰 CHANGELOG。
  8. 推送前跑 overlap-check。cloud#5027 agent 效果专题优先:它若有在飞 PR 碰同一文件,本卡让路。

Activity

  1. added
    priority:p2
    pm:epic
    domain:ui
    area:ai
    on Nov 27, 2026
  2. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:cloud#5 · hotlong · session_01Q4EjjMouQg4opwRbvXunTA

    Claim: PM loop round 1 · epic #37690, maintainer order 「对话界面改进 ,用fable评估,开始分拆」 · 2026-11-27T00:28Z
    Session: session_01Q4EjjMouQg4opwRbvXunTA
    Thread session: session_01Q4EjjMaLacWen8f2akYQCJ
    Account: hotlong
    Branch: claude/project-thread-dvvo6j
    Worktree: objectstack-issue-37728
    Domain: domain:ui
    Seat: repo:cloud#5
    File surface: ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx, new files under ui/packages/plugin-chatbot/src/chat/ named on the card, one changeset (stop on breach; explain in the report)
    Container & model: M, mode:thread, model: default (no path-derived mandate), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: n/a — not a defect card (maintainer-directed task)
    Thread-read: none
    Premise: holds (symbol list read against PR #37720 head c2b7b6a and reviewed by Fable; re-check every symbol on main after #37720 merges)
    Serial constraints cleared: Blocked-by #37682 — PR #37720 (draft) rewrites this file; start from main after it merges, rehearsal on its head only, push nothing before. Sibling #37730 is another package, parallel; #37729 (same file) waits for this card. No cloud#5027 PR touches this file at claim time; overlap-check before every push.
    Order: the card body itself (plan record: project file ai-chat/split-plan-r2.md)

  3. added
    pm:dispatched
    and removed
    pm:epic
    on Nov 27, 2026
  4. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:ai · domain:ui · Task · priority:p2 · pm:dispatched · size M; rationale: chat component split A, a behaviour-neutral move of ChatbotEnhanced's types, sub-components and helpers. It is the maintainer-ordered follow-on to the build UI removal, and its body names #37682 as the blocker; the claim waits for #37682's PR. p2 as filed.

  5. removed
    pm:dispatched
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aidomain:uipriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions