-
-
Notifications
You must be signed in to change notification settings - Fork 675
feat: demo在消息请求过程中不可创建会话 #816
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
📝 Walkthrough## Walkthrough
本次更改为“新对话”及“新会话”按钮的点击处理函数添加了请求进行中的保护条件,防止重复创建对话或会话。若代理正在请求,则显示错误信息并中止创建。此外,统一了部分样式对象的字符串引号格式,对部分 JSX 结构进行了细微格式调整,但未更改消息处理或会话状态管理的核心逻辑。
## Changes
| 文件/文件组 | 变更摘要 |
|-----------------------------------------------------|------------------------------------------------------------------|
| docs/playground/independent.tsx, docs/playground/copilot.tsx | 为“新对话”及“新会话”按钮添加请求中断保护,显示错误消息;统一样式对象引号格式;调整 JSX 结构缩进和换行;在 Prompts 组件样式对象中添加尾随逗号。 |
## Poem
> 🐇
> 按下按钮想新聊,
> 兔儿机警早知晓。
> 若有请求正忙碌,
> 错误提示来报道。
> 样式细节齐步调,
> 代码整洁心欢笑! Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
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 (
|
WalkthroughThis pull request improves the demo by preventing the creation of a new conversation while a message request is in progress. It adds a check to display an error message if a user attempts to create a conversation during an ongoing request. Changes
|
@@ -343,6 +343,13 @@ const Independent: React.FC = () => { | |||
{/* 🌟 添加会话 */} | |||
<Button | |||
onClick={() => { | |||
if (agent.isRequesting()) { |
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.
Ensure that the agent.isRequesting()
method is reliable and correctly identifies the request state to prevent any false positives or negatives when blocking conversation creation.
Bundle ReportChanges will decrease total bundle size by 466 bytes (-0.34%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antdx-array-pushAssets Changed:
|
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: 0
🧹 Nitpick comments (4)
docs/playground/copilot.tsx (4)
359-359
: 添加了尾随逗号,提高代码一致性在样式对象中添加了尾随逗号,这有助于保持代码风格的一致性,并使未来添加新属性时的差异更清晰。
386-389
: 改进了占位符对象的缩进调整了placeholder对象内部属性的缩进,使代码结构更加清晰和一致,提高了可读性。
248-271
: 建议:进一步优化用户体验目前的实现在用户尝试创建新会话时会显示错误信息,但可以考虑使用更友好的交互方式,比如禁用按钮或显示加载状态。
考虑以下替代实现:
<Button type="text" icon={<PlusOutlined />} + disabled={agent.isRequesting()} onClick={() => { if (agent.isRequesting()) { message.error( 'Message is Requesting, you can create a new conversation after request done or abort it right now...', ); return; } if (messages?.length) { const timeNow = dayjs().valueOf().toString();
或者更简洁的实现:
<Button type="text" icon={<PlusOutlined />} + disabled={agent.isRequesting()} onClick={() => { - if (agent.isRequesting()) { - message.error( - 'Message is Requesting, you can create a new conversation after request done or abort it right now...', - ); - return; - } - if (messages?.length) { const timeNow = dayjs().valueOf().toString();
248-251
: 建议:翻译错误信息为中文考虑到应用的用户群体,建议将错误信息翻译为中文,以保持整个应用的语言一致性。
- message.error( - 'Message is Requesting, you can create a new conversation after request done or abort it right now...', - ); + message.error( + '消息请求正在进行中,请等待请求完成或中止请求后再创建新会话...', + );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/playground/copilot.tsx
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: test / react component workflow
- GitHub Check: build preview
- GitHub Check: size
🔇 Additional comments (1)
docs/playground/copilot.tsx (1)
248-254
: 添加了防止请求过程中创建新会话的保护逻辑这个改动很好地解决了在消息请求过程中创建新会话可能导致的问题。通过检查
agent.isRequesting()
状态并提供明确的错误提示,防止了用户在不适当的时候创建新会话,有效避免了潜在的状态混乱和race condition问题。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #816 +/- ##
=======================================
Coverage 92.35% 92.35%
=======================================
Files 66 66
Lines 1492 1492
Branches 388 405 +17
=======================================
Hits 1378 1378
Misses 114 114 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
中文版模板 / Chinese template
🤔 This is a ...
💡 Background and Solution
Issue
Solution
📝 Change Log
Summary by CodeRabbit
新功能
样式
其他