feat(chat): 单条调用直接渲染成工具卡片,两条及以上仍折叠成胶囊。 - #786
Open
leehom0123 wants to merge 1 commit into
Open
leehom0123 wants to merge 1 commit into
leehom0123 wants to merge 1 commit into
Conversation
A collapsed tool-group pill only earns its keep when there is more than one call to summarize. Unwrap a one-item group back to the direct ToolCallPart in the renderer so single calls between reasoning blocks read as plain cards; the adapter keeps wrapping runs uniformly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动
聊天记录里,思考块会把连续工具调用切成多段,经常出现一组只有 1 条调用的情况。此前这种单条调用也渲染成折叠胶囊("运行 1 个命令"),点开一次才能看到工具卡片。本 PR 让单条调用直接渲染成工具卡片,两条及以上仍折叠成胶囊。
content-parts-renderer.tsx:ToolGroupPart内items.length === 1时直接渲染ToolCallPart(+9 行,唯一的逻辑改动)。ai-elements-adapter.ts:更新groupConsecutiveToolCalls文档注释,与新渲染行为一致(无逻辑变更)。content-parts-tool-group.test.tsx:新增 3 个用例(单条直显、多条胶囊、空组渲染为空)。adapter 层分组逻辑不变(单条仍包成 tool-group),只在渲染端解包,影响面最小。
验证
pnpm test:493 个文件 7240 个用例全过。pnpm eslint:改动文件 0 问题。pnpm build静态导出构建通过,并在 server 模式(codeg-server+ 真实会话数据副本)浏览器实测:单条工具调用直接显示卡片(标题优先描述),多条仍折叠胶囊。