Repository navigation
Commit 754e216
refactor(plugin-chatbot): move ChatbotEnhanced types, subcomponents and helpers into chat/ (#37799)
<!-- claude-projects-attribution: {"github_login":"hotlong"} -->
_Requested by **Jack** · [project
thread](https://claude.ai/code/project/chan_01EF41AQooqveF2DGD8nqPzS?thread=cmsg_01EF41AQooqveF2DGD8nqPzSXwAvEjYZpZeyqoxsu2k7jv)_
Fixes #37728
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户看到的变化:没有。只把 `ChatbotEnhanced.tsx` 里的类型、子组件和工具函数搬到 `src/chat/` 下 7
个文件,不改行为。
- 为什么:删完 build 后这个文件还有 3335 行,后续对话体验改动都要改它;先拆开,降低冲突和审阅成本(专题 #37690 的拆分
A,拆分 B #37729 接着做)。
- 出问题会怎样:最坏是某个导入路径断了,类型检查和测试会直接红;回滚这一个合并即可。
- 需要你做的:改动行数 3870,超过 3000 行,按规则要授权账号批准或你亲手合并。
## What changes
A move-only split of
`ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx`: 3335 → 1514 lines.
The file keeps the `ChatbotEnhanced` component, `formatMessageProps` and
the two `PLAIN_SURFACE_*` constants, and re-exports by name (`export { …
} from`, `export type { … } from`, no `export *`) every symbol it
exported before. Every existing import path keeps working, so
`FloatingChatbot`, `chatMessageAdapter`, `mapMessages`, `renderer`,
`toolResultParsers`, `useAiModels`, `useHitlInChat` and the tests are
untouched.
New modules under `src/chat/`, exactly as the card lists them:
| File | Symbols |
|:--|:--|
| `types.ts` | `ChatbotEnhancedMessage`,
`ChatbotEnhancedToolInvocation`, `ChatChart`, `ChatSource`,
`ChatbotLabels`, `ChatbotEnhancedProps`, `ChatbotProcessVisibility`,
`ChatbotSurface`, `ChatbotModelOption`, `ToolDecisionState`,
`TurnLiveness` |
| `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` |
| `answerLayout.tsx` | `layoutAnswer`, `AnswerBlock`, `AnswerCharts`,
`isToolCallPlaceholder` |
| `toolRecordWrite.ts` | `writtenRecordOf`, `formatRecordWriteValue` |
| `composerNotices.tsx` | `ErrorBanner`, `ComposerNotice`,
`SendErrorNotice`, `formatSizeLimit`, `useAiQuotaCopy` |
Every top-level declaration of the old file is named in the card, so no
private helper had to be placed by judgement and none stayed behind.
- **One `phaseClock`.** The module-level `Map` moved with
`usePhaseElapsed` into `toolSummary.tsx`; there is no other copy.
- **Dependency direction.** `toolSummary → liveness` (`ToolRunningTimer`
reads `useIsOffline` and `formatElapsed`), every module → `types`. No
new module imports `ChatbotEnhanced.tsx`, and `types.ts` reaches
`../mapMessages` with `import type` only.
- **Exports.** A moved symbol is exported from its new module only when
another file uses it, or when the old file exported it.
- **Frozen entries.** `plugin-chatbot/src/index.tsx`,
`plugin-chatbot/src/core.ts` and `app-shell/src/index.ts` have an empty
diff.
The split was generated by a script that works from symbol names
(TypeScript AST), not line numbers. It was first run on #37720's head
and re-run on main after #37720 landed; the second run produced
byte-identical files.
## Why
Card #37728, split A of topic #37690. Upcoming chat changes (feedback,
approval cards, a thinking timeline) all land in this file; split B
(#37729) moves `renderToolDetail` next and builds on
`toolRecordWrite.ts`.
## Verification
```
git diff --color-moved=zebra --stat origin/main..HEAD
.changeset/37728-chatbot-enhanced-split-a.md | 10 +
ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx | 1901 +-------------------
.../plugin-chatbot/src/chat/ModelPicker.tsx | 219 +++
.../plugin-chatbot/src/chat/answerLayout.tsx | 107 ++
.../plugin-chatbot/src/chat/composerNotices.tsx | 237 +++
ui/packages/plugin-chatbot/src/chat/liveness.tsx | 300 +++
.../plugin-chatbot/src/chat/toolRecordWrite.ts | 35 +
.../plugin-chatbot/src/chat/toolSummary.tsx | 471 +++++
ui/packages/plugin-chatbot/src/chat/types.ts | 590 ++++++
9 files changed, 2009 insertions(+), 1861 deletions(-)
```
The deleted lines and the added lines differ only in import/export
lines: comparing the two multisets of the diff, what is not in both is
import specifiers, the new re-export block, `export` added in front of
moved declarations, and each new file's license header and one-paragraph
module comment. Nothing else changed.
Readings on head `2ed21c64`, against main `6e8f6637`:
- `pnpm run type-check` in `ui/packages/plugin-chatbot` (`tsc --noEmit`
and `tsc -p tsconfig.test.json`): exit 0.
- `pnpm run build` in `ui/packages/plugin-chatbot`: exit 0.
- `pnpm --dir ui exec vitest run packages/plugin-chatbot/
packages/core/src/utils/__tests__/column-identity.ratchet.test.ts`: 70
files, 668 tests passed.
- eslint over `ChatbotEnhanced.tsx` and `src/chat/`: 0 errors, 9
warnings. Before the split the file had 2 warnings (one
`react-refresh/only-export-components`, one
`react-hooks/set-state-in-effect`). The 7 new ones are all
`react-refresh/only-export-components`: the card's layout puts
components and helpers in the same modules (for example `liveness.tsx`
exports `formatElapsed` beside `ThinkingDots`). It is a fast-refresh
hint, no gate counts warnings, and splitting further would leave the
card's layout.
- dispatch-gates, all 32 derived commands: exit 0, including `pnpm --dir
ui exec vitest run scripts/` (which covers
`one-authority-per-exported-name-6273`), `check-adr-0087-registration
--base origin/main`, `check-empty-changeset`, `check-changeset-no-major`
and `check:test-source-alias`. Also `pnpm check:changeset-fixed`, `pnpm
--dir ui check:new-line-citations` (0 new) and `check-platform-checklist
--changed-from origin/main`: exit 0.
- `overlap-check`: merges cleanly with main, no open PR shares a file.
Changeset: `.changeset/37728-chatbot-enhanced-split-a.md`, `patch` for
`@object-ui/plugin-chatbot`, with both declaration lines.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Q4EjjMaLacWen8f2akYQCJ)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Q4EjjMaLacWen8f2akYQCJ
Co-authored-by: Claude <noreply@anthropic.com>1 parent 006840d commit 754e216
9 files changed
Lines changed: 2009 additions & 1861 deletions
File tree
- .changeset
- ui/packages/plugin-chatbot/src
- chat
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments