Repository navigation
refactor(plugin-chatbot): move renderToolDetail out of ChatbotEnhanced into chat/toolDetail.tsx - #37964
Conversation
… across a re-render Added on the baseline, before renderToolDetail moves out of ChatbotEnhanced.tsx, so the split is judged against it. Claude-Session: https://claude.ai/code/session_016WV4cwGVgec21LwQTtRY85 Co-authored-by: Claude <noreply@anthropic.com>
Move-only: the tool-card closure becomes the module-level function renderToolDetail(tool, ctx). Its body is byte-identical to the closure's after a four-space dedent; ctx carries what the closure read from the component scope. Imports the component no longer uses are dropped. Claude-Session: https://claude.ai/code/session_016WV4cwGVgec21LwQTtRY85 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwGVgec21LwQTtRY85 Final head for review: |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 L1 verdict (L1-a): ACCEPT at head 席位核对Shape and gates. 4 files, +723/-463. Check-runs at 41c8aba: 39 success, 13 skipped, 0 failed. Not governed. Point 1, the move is byte-identical: measured. I took the closure from Point 2, Point 3, the import/export sentence with its qualifier: accepted. The Point 4, the pre-split test: accepted. Constraints. The public entries are frozen: Point 5, main not merged: fine. #37932 touches none of these files, and overlap-check is clean. Changeset, sentence by sentence. It says this is a move-only split with no behaviour change and the same element tree: true by the byte diff above. It says the function is module-level and called with one context object: true. It says the entry points and published API are unchanged: true. Landing: not governed, under 3000 lines, no narrowing. The area lands it. |
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwGVgec21LwQTtRY85 Landing · area o1-D · 2026-11-27T13:37Z |
Requested by Elon · project thread
Fixes #37729
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
A move-only split of
ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx: 1514 → 1097 lines. TherenderToolDetailclosure (447 body lines) becomes the module-level functionrenderToolDetail(tool, ctx)in the newui/packages/plugin-chatbot/src/chat/toolDetail.tsx(580 lines), the card's preferred form.diffof the two bodies: no difference over 447 lines). It still returns theToolelement atkey={tool.toolCallId}with the samedefaultOpenexpression. The first statement destructuresctxinto the same 41 names the closure read from the component scope, so not one reference in the body changed.ctx.ChatbotEnhancedbuilds one plain object,toolDetailCtx, where the closure used to be (no hook, no memo, so the hook order is unchanged) and callsrenderToolDetail(tool, toolDetailCtx)where it calledrenderToolDetail(tool). Its type,ToolDetailContext, is spelled fromChatbotEnhancedProps: aRequiredpick of the props that have defaults, a plain pick of the four that have none (toolDecisions,onToolApprove,onOpenRecordForm,onOpenRecord), plustt,L,toolStatusLabels,heldForApprovalLabelanddetectPackageRemovedResult.toolDetail.tsximports../tool-display,../elements/tool,./toolSummary,./toolRecordWrite(the card names this one) and, as types only,./typesand../mapMessages. It never importsChatbotEnhanced.tsx.detectPackageRemovedResultrides inctx. It is a value exported by../mapMessages, and shared constraint 4 allows onlyimport typefrom that module, so the component (which already imported it) hands it in; the new module takes its type only.renderToolDetailandToolDetailContextare exported from the new module only, because the component uses them. Nothing is added to or removed from whatChatbotEnhanced.tsxexports, so its re-export block is unchanged and every import path still works.ChatbotEnhanced.tsx, all of them now used only inside the card: seven lucide icons,humanizeToolName,unwrapToolResult,Tool/ToolHeader/ToolContent/ToolInput(theToolStatusLabelstype stays, now asimport type),ChatbotEnhancedToolInvocation,SmartToolOutput,ToolRunningTimer,formatRecordWriteValue,writtenRecordOf.ui/packages/plugin-chatbot/src/index.tsx,ui/packages/plugin-chatbot/src/core.tsandui/packages/app-shell/src/index.tshave an empty diff.Tests
One new file, the only one the card allows; no existing test file is touched.
src/__tests__/ChatbotEnhanced.toolCardOpenState-37729.test.tsxrenders a turn with two tool cards, one that starts closed (completed) and one that starts open (failed), flips both by clicking their headers, re-renders the component with two more messages and a fresh props object, and asserts that each card still shows what the user chose (aria-expanded). It was committed on the baseline first (30a3737, before the split) and run green there; it stays green after the split.Acceptance notes
ChatbotEnhanced.tsx, 580 for the new module.ctxplumbing the card prescribes: theToolDetailContexttype, theconst { … } = ctx;destructure, thetoolDetailCtxobject, the new function's signature line and the call site's added argument, and the new module's license header and module comment. Nothing inside the card's body differs.--color-moved=zebraalone does not paint the moved block, because every moved line is four spaces shallower;git diff --color-moved=zebra --color-moved-ws=allow-indentation-change origin/main...HEADdoes.react-refresh/only-export-componentswarning. eslint overChatbotEnhanced.tsxreports the same one warning before and after the split.main. Since its base,maingained the QuestionCard work inplugin-chatbot(new files plus anindex.tsxexport); it touches none of this PR's files andoverlap-checkreports a clean merge.Verification
Read first:
chat/toolDetail.tsx'sToolDetailContextand its destructure (the only new logic-shaped text), then thetoolDetailCtxobject inChatbotEnhanced.tsx.Two-minute check:
pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.toolCardOpenState-37729.test.tsxfrom the repository root; expect 1 file, 1 test passed.The deleted lines and the added lines differ only in import/export lines, plus the
ctxobject, its type and its destructure that the card'srenderToolDetail(tool, ctx)form requires.Local readings (objectstack-ai/objectstack, head 41c8aba on merge base f926dfa; main since moved to d1139f9, which merges cleanly)
pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.toolCardOpenState-37729.test.tsx: 1 file, 1 test passed.aria-expanded"false", expected "true").pnpm --dir ui exec vitest run packages/plugin-chatbot/: 70 files, 662 tests passed.pnpm --filter @object-ui/plugin-chatbot run type-check(tsc --noEmitandtsc -p tsconfig.test.json, whose include covers the new test): exit 0.pnpm --filter @object-ui/plugin-chatbot run build: exit 0.ChatbotEnhanced.tsx,chat/toolDetail.tsxand the new test: exit 0, 0 errors, 1 warning (react-refresh/only-export-componentsonChatbotEnhanced.tsx); the baseline file has the same one warning.dispatch-gates --ranreconciles 38 of 38, 0 NOT-MEASURED, every line with its exit code.pnpm --dir ui check:new-line-citations: 0 new.check-platform-checklist --changed-from origin/main: exit 0, no anchored file in the change set.overlap-check: merges cleanly withorigin/main; no open PR shares a file.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cwGVgec21LwQTtRY85