-
-
Notifications
You must be signed in to change notification settings - Fork 884
feat: add tbox agent & docs #1063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthrough本次更新主要新增了 Tbox 智能体集成的中英文文档与完整 React 组件示例,并对现有文档的分组标题与排序元数据进行了调整优化。此外,增加了 Changes
Sequence Diagram(s)sequenceDiagram
participant User as 用户
participant UI as React 组件(Independent)
participant Tbox as Tbox AI 服务
User->>UI: 选择/创建会话或输入消息
UI->>Tbox: 通过 tbox-nodejs-sdk 发起 chat 请求(流式)
Tbox-->>UI: 返回数据流(data、end、error事件)
UI->>UI: 解析流数据,更新消息列表
UI-->>User: 实时显示 AI 回复、支持中断、重试等操作
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 分钟 Suggested labels
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
🧹 Nitpick comments (7)
docs/react/model-use-other.zh-CN.md (1)
21-22: 示例代码占位符易产生歧义
fetch()未传入 URL,读者可能误认为空参数即可正常调用。可在示例中明确占位符,减少困惑:- const response = await fetch(); + const response = await fetch('https://your-model-endpoint');docs/react/use-with-next.zh-CN.md (1)
4-4:group.order与根级order数值重复,可能引起阅读者困惑虽然 YAML 解析上不会冲突,但同时把两个层级都设为
3缺乏语义区分,后期维护者难以判断哪个数字真正影响排序。建议只在需要的层级保留一个order,或保持不同值以体现层级含义。docs/react/use-with-next.en-US.md (1)
4-4: 重复的排序值同样存在,可考虑精简与中文版相同,
group.order与根级order都为3,阅读上可能造成歧义。参考上面的建议进行统一即可。docs/react/model-use-other.en-US.md (1)
20-23: 示例代码可读性小改进
await fetch()缺少 URL/Request 参数,新手阅读时可能误以为可直接调用。建议补充占位符,提高可读性:- const response = await fetch(); + const response = await fetch('/your/api');docs/playground/agent-tbox.en-US.md (1)
1-10: 校验 frontmatter 中order冲突本文件与同组其他示例均设置
order: 0,Dumi 渲染时若存在重复order,排序结果将依赖文件名而非显式权重,可能导致文档顺序不可预测。建议为各示例设定唯一order值(例如 0, 1, 2 …)。docs/playground/agent-tbox.zh-CN.md (1)
1-10: 校验 frontmatter 中order冲突同上,建议在「智能体样板间」分组内确保
order唯一,避免排序混乱。docs/playground/agent-tbox.tsx (1)
383-387: 使用 setTimeout 处理异步问题不够优雅使用
setTimeout来处理异步时序问题是一种不可靠的解决方案,可能在不同环境下表现不一致。建议使用 Promise 或状态管理来确保正确的执行顺序,而不是依赖固定的延迟时间。注释中已经提到未来版本会通过 sessionId 来解决这个问题。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (32)
docs/playground/agent-tbox.en-US.md(1 hunks)docs/playground/agent-tbox.tsx(1 hunks)docs/playground/agent-tbox.zh-CN.md(1 hunks)docs/playground/copilot.en-US.md(1 hunks)docs/playground/copilot.zh-CN.md(1 hunks)docs/playground/independent.en-US.md(1 hunks)docs/playground/independent.zh-CN.md(1 hunks)docs/react/agent-use-tbox.en-US.md(1 hunks)docs/react/agent-use-tbox.zh-CN.md(1 hunks)docs/react/contributing.en-US.md(1 hunks)docs/react/contributing.zh-CN.md(1 hunks)docs/react/dangerously-api-key.en-US.md(1 hunks)docs/react/dangerously-api-key.zh-CN.md(1 hunks)docs/react/faq.en-US.md(1 hunks)docs/react/faq.zh-CN.md(1 hunks)docs/react/model-use-openai.en-US.md(1 hunks)docs/react/model-use-openai.zh-CN.md(1 hunks)docs/react/model-use-other.en-US.md(2 hunks)docs/react/model-use-other.zh-CN.md(2 hunks)docs/react/model-use-qwen.en-US.md(1 hunks)docs/react/model-use-qwen.zh-CN.md(1 hunks)docs/react/use-with-create-react-app.en-US.md(1 hunks)docs/react/use-with-create-react-app.zh-CN.md(1 hunks)docs/react/use-with-next.en-US.md(1 hunks)docs/react/use-with-next.zh-CN.md(1 hunks)docs/react/use-with-rsbuild.en-US.md(1 hunks)docs/react/use-with-rsbuild.zh-CN.md(1 hunks)docs/react/use-with-umi.en-US.md(1 hunks)docs/react/use-with-umi.zh-CN.md(1 hunks)docs/react/use-with-vite.en-US.md(1 hunks)docs/react/use-with-vite.zh-CN.md(1 hunks)package.json(1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
docs/react/contributing.zh-CN.md (2)
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
docs/react/model-use-other.zh-CN.md (1)
Learnt from: YumoImer
PR: #293
File: components/x-request/demo/custom-transformer.tsx:75-79
Timestamp: 2024-12-04T03:46:13.221Z
Learning: When reviewing code examples in components/x-request/demo/custom-transformer.tsx that use mockFetch, it's unnecessary to suggest enhancements to the TransformStream implementation, such as adding error handling and data validation, since the code is intended as a simple demonstration.
docs/playground/agent-tbox.zh-CN.md (2)
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
docs/react/model-use-other.en-US.md (1)
Learnt from: YumoImer
PR: #293
File: components/x-request/demo/custom-transformer.tsx:75-79
Timestamp: 2024-12-04T03:46:13.221Z
Learning: When reviewing code examples in components/x-request/demo/custom-transformer.tsx that use mockFetch, it's unnecessary to suggest enhancements to the TransformStream implementation, such as adding error handling and data validation, since the code is intended as a simple demonstration.
docs/react/agent-use-tbox.zh-CN.md (2)
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
🪛 Biome (2.1.2)
docs/playground/agent-tbox.tsx
[error] 296-296: This variable implicitly has the any type.
Variable declarations without type annotation and initialization implicitly have the any type. Declare a type or initialize the variable with some value.
(lint/suspicious/noImplicitAnyLet)
🔇 Additional comments (24)
docs/react/model-use-qwen.zh-CN.md (1)
4-4: 元数据调整正确,保持一致性 👍为
group增补order: 1能确保“模型接入”分组在侧边栏中的排序一致,改动无风险。docs/react/model-use-openai.zh-CN.md (1)
4-4: 排序字段补充合理同样为“模型接入”追加
order: 1,与其他中文文档保持一致,OK。docs/react/faq.en-US.md (1)
4-4: 新增 order 字段无异议
Other分组补充order: 4有助于统一 FAQ 在导航中的位置,改动良好。docs/react/model-use-openai.en-US.md (1)
4-4: 一致性排序更新为“Model Integration”组添加
order: 1,与其他英文文档保持一致。docs/react/model-use-qwen.en-US.md (1)
4-4: 文档侧边栏排序调整确认补充
order: 1与同组文档对齐,暂无其他问题。docs/react/contributing.zh-CN.md (1)
4-4: 补充排序权重 👍增加
group.order: 4与其他文档保持一致,可保证侧边栏顺序统一。实现正确,无其他问题。docs/react/faq.zh-CN.md (1)
4-4: 一致性更新已确认同样的
group.order: 4调整与其它文档保持同步,便于分组排序。docs/react/dangerously-api-key.zh-CN.md (1)
4-4: 元数据排序 OK
group.order字段补充正确,与其它文档保持一致。docs/react/model-use-other.zh-CN.md (1)
4-4: 元数据完善为“模型接入”组显式加
order: 1,逻辑正确。docs/playground/independent.zh-CN.md (1)
3-3: 分组标题调整已同步将组名改成“模型样板间”以匹配其余文档,改动无误。
docs/playground/copilot.zh-CN.md (1)
2-4: 更改符合分组命名规范,保持一致性即可已将
title更新为「模型样板间」,与其他文档保持一致,无问题。docs/react/use-with-create-react-app.en-US.md (1)
2-5:group.order与根级order可能产生冲突,建议确认导航排序此处新增
group.order: 3,而根级仍为order: 1。如果站点生成器同时读取两处order字段,可能导致排序结果不可预期,请确认规范。docs/playground/independent.en-US.md (1)
2-4: 分组标题更新无误英文版同步至「Model Sample」,保持中英一致,OK。
docs/playground/copilot.en-US.md (1)
2-4: 分组标题与排序同步,符合重构目标把
Sample→Model Sample且order设为 0,与其他示例统一,良好。docs/react/use-with-rsbuild.en-US.md (1)
2-5: 检查group.order与根级order的相对优先级此文件设置
group.order: 3,而根级order为 5。若站点侧边栏先按组再按根级排序,可能与预期不符;请确认排序逻辑或对齐两处值。docs/react/dangerously-api-key.en-US.md (1)
4-4: ✅ 补充order字段提升分组排序可控性在
group元数据中新增order: 4与现有根级order不冲突,可精细控制左侧导航分组顺序。实现正确,无其他隐患。docs/react/contributing.en-US.md (1)
4-4: 👍 合理增加分组排序字段
group内加入order: 4可保证「Other」分组在侧边栏中的期望位置,改动简单且安全。docs/react/use-with-rsbuild.zh-CN.md (1)
4-4: 分组排序字段添加正确,但需确认多语言一致性新增
group.order: 3与根级order: 5搭配合理。为了保持中英双语文档结构一致,请确认英文版对应文件也同步了该排序。docs/react/use-with-create-react-app.zh-CN.md (1)
4-4: 新增 group.order 元数据合理
仅为文档导航排序补充字段,不影响正文内容或构建流程。docs/react/use-with-umi.en-US.md (1)
4-4: 新增 group.order 元数据合理
纯文档层级调整,无需额外修改。docs/react/use-with-umi.zh-CN.md (1)
4-4: 新增 group.order 元数据合理
仅调整文档分组排序,对其他内容无副作用。docs/react/use-with-vite.zh-CN.md (1)
4-4: 新增 group.order 字段无问题
该修改仅影响侧边栏排序,内容保持不变。docs/react/use-with-vite.en-US.md (1)
4-4: 添加 group.order 元数据 OK
属于文档结构优化,可直接合并。package.json (1)
91-92: 确认 [email protected] 在浏览器端可用性与打包体积影响
- npm Metadata:该包未声明
browser字段,但在exports中同时提供了 ESM(import→./dist/tbox-nodejs-sdk.js)和 CJS(require→./dist/tbox-nodejs-sdk.umd.cjs)入口,主流打包器(Webpack/Vite)可直接选用 ESM 构建。- 运行时依赖:已在
dist目录下扫描,未发现对 Node 内置模块(http/https/stream等)的引用,可安全在浏览器环境中运行,无需配置resolve.fallback。- 打包体积:SDK 以整体包形式发布、内部依赖
eventemitter3,无子模块拆分,可能造成首屏包体积增加。建议:
- 按需通过
import()动态加载,避免首页加载全部 SDK;- 若业务场景较轻量,可考虑直接调用 REST API 或官方 Web SDK(若有)并使用
fetch封装最小客户端。以上确认后,可正常引入该包,必要时再针对体积进行优化。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (5)
docs/playground/agent-tbox.tsx (5)
34-39: 安全隐患:API 密钥硬编码API 密钥和配置不应硬编码在源代码中,即使是演示代码也存在安全风险。
252-256: 安全问题:应用ID硬编码
appId硬编码存在安全风险,应从环境变量或配置中获取。
316-318: 国际化支持不一致错误消息硬编码为英文,与应用的双语支持不一致。
350-353: 国际化支持不一致另一处错误消息也硬编码为英文,应支持国际化。
584-592: 内存泄漏风险
messageHistory状态无限制累积消息历史,可能导致内存泄漏。
🧹 Nitpick comments (2)
docs/playground/agent-tbox.tsx (2)
41-44: 类型定义过于宽泛
BubbleDataType类型定义过于简单,缺少必要的类型约束。建议定义更具体的类型:
-type BubbleDataType = { - role: string; - content: string; -}; +type BubbleDataType = { + role: 'user' | 'assistant'; + content: string; + timestamp?: number; + status?: 'loading' | 'success' | 'error'; +};
233-607: 组件复杂度过高整个组件超过 370 行,承担了过多职责,建议拆分为更小的子组件。
建议将组件拆分为:
ChatSidebar- 侧边栏组件ChatMessageList- 消息列表组件ChatSender- 发送消息组件useConversation- 会话管理逻辑钩子useTboxChat- Tbox 聊天逻辑钩子这样可以提高代码的可维护性和可测试性。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/playground/agent-tbox.tsx(1 hunks)package.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
docs/playground/agent-tbox.tsx (6)
Learnt from: YumoImer
PR: #293
File: components/x-request/tests/index.test.tsx:21-25
Timestamp: 2024-12-03T13:19:38.409Z
Learning: 在测试代码中,可以使用硬编码的测试 API 密钥作为测试值。
Learnt from: afc163
PR: #293
File: components/x-request/demo/custom-transformer.tsx:51-51
Timestamp: 2024-12-04T03:23:41.937Z
Learning: 在代码中避免使用 any 类型,应该定义具体的类型以提高类型安全性。
Learnt from: YumoImer
PR: #293
File: components/x-request/demo/custom-transformer.tsx:75-79
Timestamp: 2024-12-04T03:46:13.221Z
Learning: When reviewing code examples in components/x-request/demo/custom-transformer.tsx that use mockFetch, it's unnecessary to suggest enhancements to the TransformStream implementation, such as adding error handling and data validation, since the code is intended as a simple demonstration.
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: wzc520pyfm
PR: #833
File: components/use-x-chat/index.ts:256-256
Timestamp: 2025-05-17T05:29:02.977Z
Learning: 在 'use-x-chat' 组件中,'updating' 状态的消息应被视为正常的内容返回,不应被过滤掉。与 'loading' 和 'error' 状态不同,'updating' 状态代表内容正在更新的中间状态,但仍然是有效内容。
🔇 Additional comments (1)
docs/playground/agent-tbox.tsx (1)
32-32: 依赖兼容性验证完成:tbox-nodejs-sdk 与项目 axios 版本兼容已验证
- [email protected] 发布的依赖项为
• axios ^1.10.0
• eventemitter3 ^5.0.1
• eventsource-parser ^3.0.2
• vite-plugin-dts ^4.5.4- 项目 package.json 中声明的 axios 为 ^1.7.7,二者均在 SemVer 1.x 范围内,安装后将统一解析到 1.10.x,无多版本冲突,兼容性良好。
无需对现有依赖版本进行额外调整。
Bundle ReportBundle size has no change ✅ |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1063 +/- ##
=======================================
Coverage 92.39% 92.39%
=======================================
Files 69 69
Lines 1564 1564
Branches 406 423 +17
=======================================
Hits 1445 1445
Misses 119 119 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if (messages?.length) { | ||
| setMessageHistory((prev) => ({ | ||
| ...prev, | ||
| [curConversation]: messages, | ||
| })); | ||
| } | ||
| }, [messages]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
兔子提的问题需要看下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
docs/playground/agent-tbox.tsx (2)
34-39: 安全隐患:API密钥硬编码问题依然存在代码中仍然存在硬编码的API密钥,这是一个安全风险。虽然这是演示代码,但应该从环境变量或安全配置中获取密钥。
307-307: 安全问题:appId仍然硬编码
appId仍然是硬编码的,应该从环境变量或安全配置中获取。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.dumi/theme/layouts/GlobalLayout.tsx(1 hunks)docs/playground/agent-tbox.tsx(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .dumi/theme/layouts/GlobalLayout.tsx
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
docs/playground/agent-tbox.tsx (7)
Learnt from: YumoImer
PR: #293
File: components/x-request/tests/index.test.tsx:21-25
Timestamp: 2024-12-03T13:19:38.409Z
Learning: 在测试代码中,可以使用硬编码的测试 API 密钥作为测试值。
Learnt from: afc163
PR: #293
File: components/x-request/demo/custom-transformer.tsx:51-51
Timestamp: 2024-12-04T03:23:41.937Z
Learning: 在代码中避免使用 any 类型,应该定义具体的类型以提高类型安全性。
Learnt from: YumoImer
PR: #293
File: components/x-request/demo/custom-transformer.tsx:75-79
Timestamp: 2024-12-04T03:46:13.221Z
Learning: When reviewing code examples in components/x-request/demo/custom-transformer.tsx that use mockFetch, it's unnecessary to suggest enhancements to the TransformStream implementation, such as adding error handling and data validation, since the code is intended as a simple demonstration.
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
PR: ant-design/x#0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: wzc520pyfm
PR: #833
File: components/use-x-chat/index.ts:256-256
Timestamp: 2025-05-17T05:29:02.977Z
Learning: 在 'use-x-chat' 组件中,'updating' 状态的消息应被视为正常的内容返回,不应被过滤掉。与 'loading' 和 'error' 状态不同,'updating' 状态代表内容正在更新的中间状态,但仍然是有效内容。
Learnt from: YumoImer
PR: #479
File: components/bubble/demo/debug-list.tsx:39-57
Timestamp: 2025-01-27T09:36:11.490Z
Learning: In the Bubble.List debug demo component, the different typing behavior between pushBubble (sets typing: true) and unshiftBubble (no typing property) operations is intentional to facilitate testing different scenarios.
🔇 Additional comments (9)
docs/playground/agent-tbox.tsx (9)
41-101: 国际化实现符合最佳实践国际化的实现很好地遵循了之前的反馈,将所有文本统一组织在对象中,支持通过key调用。语言检测逻辑也适合嵌入式组件的使用场景。
103-173: 数据结构设计合理常量定义清晰,很好地利用了国际化系统,数据结构一致且易于维护。
175-284: 样式实现完整且响应式使用 antd-style 创建的样式定义完整,布局考虑了响应式设计,组件样式组织清晰。
286-298: 状态管理和类型安全改进组件状态管理结构合理,
messageHistory的类型定义相比之前的any类型有所改进,使用了typeof messages提供更好的类型安全性。
304-393: Agent和Chat钩子配置实现优秀
useXAgent和useXChat的配置实现很好,包含了完整的流处理、错误处理和消息转换逻辑。AbortController 的集成也很恰当,类型安全性得到改善。
395-412: 事件处理实现恰当事件处理函数实现良好,包含了适当的加载状态检查和用户反馈,验证逻辑合理。
659-667: 消息历史持久化逻辑正确
useEffect中的消息历史更新逻辑实现正确,能够正确地将当前会话的消息保存到历史记录中。注意:之前提到的内存泄漏问题(已删除会话的消息历史未清理)仍然存在,建议在删除会话时同步清理对应的消息历史。
670-682: 组件渲染结构清晰组件的渲染逻辑结构清晰,三个主要部分(sidebar、chat list、sender)组织合理。
469-472: 需注意:setTimeout 时序处理可能影响菜单切换定位:
docs/playground/agent-tbox.tsx第 469–472 行setTimeout(() => { setCurConversation(val); setMessages(messageHistory?.[val] || []); }, 100);• 问题:当前使用固定 100ms 延时来更新会话和消息,快速切换或在请求中断(abort)后,可能会出现旧状态覆盖新状态的竞态条件,导致 UI 与数据不同步。
• 建议:
- 考虑通过
useEffect监听curConversation或使用会话标识(sessionId)来触发状态更新,确保过期的异步操作不会影响当前会话;- 或在 abortController 回调中明确清理或跳过延时任务,避免定时器回调执行后再更新已切换的会话。
请确认上述时序问题是否存在,并评估替换该
setTimeout方案的必要性。
* feat: add tbox agent * chore: update version * chore: update ci * chore: update ci * chore: update abort * chore: update abort * chore: update hide petercat * chore: update ci * chore: i18n * chore: loading * chore: loading * chore: i18n



中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
Background:
Developers often need to integrate intelligent agent capabilities into their applications, but implementing flexible UIs and connecting to the underlying agent platform can be complex and time-consuming.
Solution:
We have integrated support for the Tbox AI Agent Platform, allowing developers to easily leverage its agent capabilities via the new X component. By using the X component, developers can quickly build customizable agent UIs and access the full power of the Tbox platform. To facilitate adoption, we also provide an interactive online demo and comprehensive documentation.
📝 Change Log
Summary by CodeRabbit
新功能
文档
杂项