Skip to content

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

Merged
merged 3 commits into from
May 29, 2025

Conversation

Rain120
Copy link
Contributor

@Rain120 Rain120 commented May 12, 2025

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

💡 Background and Solution

Issue

20250512121050_rec_

Solution

image

📝 Change Log

Language Changelog
🇺🇸 English
🇨🇳 Chinese

Summary by CodeRabbit

  • 新功能

    • “新建对话”按钮现在会在请求进行中时阻止重复创建,并弹出错误提示。
  • 样式

    • 统一了部分样式对象的字符串引号格式。
    • 优化了部分占位组件的 JSX 格式和缩进。
  • 其他

    • 对 Prompts 相关样式对象增加了尾随逗号,提升代码一致性。

Copy link
Contributor

coderabbitai bot commented May 12, 2025

📝 Walkthrough
## Walkthrough

本次更改为“新对话”及“新会话”按钮的点击处理函数添加了请求进行中的保护条件,防止重复创建对话或会话。若代理正在请求,则显示错误信息并中止创建。此外,统一了部分样式对象的字符串引号格式,对部分 JSX 结构进行了细微格式调整,但未更改消息处理或会话状态管理的核心逻辑。

## Changes

| 文件/文件组                                         | 变更摘要                                                         |
|-----------------------------------------------------|------------------------------------------------------------------|
| docs/playground/independent.tsx, docs/playground/copilot.tsx | 为“新对话”及“新会话”按钮添加请求中断保护,显示错误消息;统一样式对象引号格式;调整 JSX 结构缩进和换行;在 Prompts 组件样式对象中添加尾随逗号。 |

## Poem

> 🐇  
> 按下按钮想新聊,  
> 兔儿机警早知晓。  
> 若有请求正忙碌,  
> 错误提示来报道。  
> 样式细节齐步调,  
> 代码整洁心欢笑!

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented May 12, 2025

Preview is ready

Copy link

Walkthrough

This 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

Files Summary
docs/playground/independent.tsx Added a check to prevent conversation creation during message requests and display an error message.

@@ -343,6 +343,13 @@ const Independent: React.FC = () => {
{/* 🌟 添加会话 */}
<Button
onClick={() => {
if (agent.isRequesting()) {

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.

Copy link

codecov bot commented May 12, 2025

Bundle Report

Changes will decrease total bundle size by 466 bytes (-0.34%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antdx-array-push 136.15kB -466 bytes (-0.34%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: antdx-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antdx.min.js -466 bytes 136.15kB -0.34%

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 12, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between e5f15d6 and 7638ed1.

📒 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问题。

Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.35%. Comparing base (10e3cc2) to head (3652bd5).
Report is 12 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kimteayon kimteayon merged commit f01aed9 into ant-design:main May 29, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants