Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@hylin
Copy link
Contributor

@hylin hylin commented Jan 7, 2026

中文版模板 / 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?)

🔗 Related Issues

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

close #1587

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English
🇨🇳 Chinese

hylin and others added 14 commits December 30, 2025 17:32
* chore: changelog of 2.1.2

* chore: changelog of 2.1.2
* feat: test

* feat: x-sdk default messages

* feat: x-sdk default messages

* feat: x-sdk default messages

* test: x-sdk

* feat: x-sdk default messages

* feat: x-sdk default messages

* feat: x-sdk default messages

* feat: x-sdk default messages

* test: x-sdk

* test: x-sdk

* feat:s-sdk

* feat:s-sdk

* feat:s-sdk

* test: x-sdk

* test: x-sdk

* test: x-sdk

* test: x-sdk

* feat:s-sdk

* feat:s-sdk

* feat:s-sdk

* feat:s-sdk

* feat:s-sdk

* feat:s-sdk

* feat: push

* fix: geshi

* fix: geshi
* chore: changelog of 2.1.3

* chore: changelog of 2.1.3

* chore: changelog of 2.1.3
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix: attachments

* fix: attachments

* feat: browseeruse

* test: snap

* test: snap

* test: file card

* test: file card

* test: file card

* feat: test

* feat: test

* fix: attachments

* fix: attachments

* fix: attachments
* fix: inster container

* feat: cursor

* feat: cursor

* feat: cursor

* feat: slot test

* test: custom slot

* feat: test of sender

* feat: test of sender

* test: sender

* test: sender

* feat: hook cursor

* feat: hook cursor

* feat: hook cursor
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-request-retry

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Preview failed

@dosubot dosubot bot added the enhancement New feature or request label Jan 7, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hylin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust retry mechanism for the XRequest utility within the @ant-design/x-sdk, enhancing its resilience against network issues. Alongside this core feature, it delivers several key improvements across the codebase, including refined file attachment handling, more robust and tested slot component behavior, and general dependency updates. The changes aim to bolster the stability, user experience, and maintainability of the SDK and its associated components.

Highlights

  • XRequest Retry Mechanism: Introduced a new retry mechanism for XRequest in @ant-design/x-sdk, allowing requests to be automatically retried upon failure or interruption. New options retryInterval and retryTimes are available, and the onError callback can now return a number to specify a dynamic retry interval.
  • File Attachment Enhancements: Updated the Attachments and FileCard components to improve type safety and correct handling of file types and state management. This includes using a CARD_TYPE enum for file classification and refining how fileList is managed.
  • Sender Component Refinements: Significant refactoring and expansion of test cases for the Sender component, along with improvements to cursor handling, selection logic (including Ctrl+A), and slot insertion/deletion mechanisms. Old test files related to slot boundaries and errors were removed.
  • Dependency Updates & Code Quality: Updated several development dependencies, including @testing-library/react, inquirer, and openai. The biome.json configuration was adjusted to enable noUndeclaredDependencies for improved code quality, and classnames was replaced with clsx in use-slot-builder.ts.
  • Documentation Updates: The x-request documentation (both English and Chinese) has been updated to reflect the newly added retry options and their usage. Minor typo fixes were also applied to XProvider documentation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 7, 2026

Deploying ant-design-x with  Cloudflare Pages  Cloudflare Pages

Latest commit: f87ca3c
Status: ✅  Deploy successful!
Preview URL: https://5dc5e50f.ant-design-x.pages.dev
Branch Preview URL: https://feat-request-retry.ant-design-x.pages.dev

View logs

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a retry mechanism for XRequest, which is a great addition for improving request reliability. The implementation correctly handles retry intervals, retry limits, and resuming SSE streams using Last-Event-ID.

Beyond the core feature, this PR includes a substantial amount of valuable refactoring and cleanup across the codebase:

  • Dependency updates and replacement of classnames with clsx.
  • Enabling the noUndeclaredDependencies lint rule in biome.json to improve dependency management.
  • Significant refactoring of tests for the Sender component, making them more structured and maintainable.
  • Improvements in the Sender component's internal logic, especially around cursor handling and DOM manipulation, which enhance robustness.
  • Refactoring in FileCard and Attachments components to use enums and resolve prop name collisions, improving code clarity.

I have one suggestion regarding the implementation of the retry logic in XRequest to improve maintainability by avoiding state mutation in an async context. Overall, this is a high-quality contribution with many positive changes.

Comment on lines 322 to 338
clearTimeout(this.retryTimer);
this.retryTimer = setTimeout(() => {
const originalHeaders = this.options.headers;
if (this.lastEventId) {
// Temporarily add Last-Event-ID header for retry
this.options.headers = {
...(originalHeaders || {}),
[LastEventId]: this.lastEventId,
};
}
this.init(this.lastManualParams);
// Restore original headers after initiating the retry request
this.options.headers = originalHeaders;
}, retryInterval);
this.retryTimes = this.retryTimes + 1;
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for retrying with Last-Event-ID temporarily mutates this.options.headers. While this works because init() is synchronous in its setup, mutating instance properties within an asynchronous callback can be fragile and is generally considered a code smell. It can lead to race conditions if the class's logic changes in the future.

A safer and cleaner approach is to avoid mutation by passing any request-specific headers down through the call chain.

You could refactor init to accept an additional extraHeaders parameter and merge it when creating the request.

For example:

  1. Modify the init method signature:

    private init(extraParams?: Partial<Input>, extraHeaders?: Record<string, string>) {
  2. Update header creation inside init:

    const { headers = {}, ... } = this.options;
    // ...
    const requestInit: XRequestOptions<Input, Output> = {
      // ...
      headers: { ...globalOptions.headers, ...headers, ...extraHeaders },
      // ...
    };
  3. Update the setTimeout callback in the catch block to pass the headers without mutation:

    this.retryTimer = setTimeout(() => {
      const extraHeaders = this.lastEventId ? { [LastEventId]: this.lastEventId } : undefined;
      this.init(this.lastManualParams, extraHeaders);
    }, retryInterval);
    this.retryTimes += 1;

This avoids side effects and makes the data flow more explicit.

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 96.77419% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.15%. Comparing base (b6fb495) to head (f87ca3c).
⚠️ Report is 1 commits behind head on feature.

Files with missing lines Patch % Lines
packages/x-sdk/src/x-request/index.ts 96.77% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           feature    #1629      +/-   ##
===========================================
- Coverage    97.16%   97.15%   -0.01%     
===========================================
  Files          140      140              
  Lines         4296     4322      +26     
  Branches      1211     1209       -2     
===========================================
+ Hits          4174     4199      +25     
- Misses         120      121       +1     
  Partials         2        2              

☔ 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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

size-limit report 📦

Path Size
packages/x/dist/antdx.min.js 441.23 KB
packages/x-sdk/dist/x-sdk.min.js 7.88 KB (+184 B 🔺)
packages/x-markdown/dist/x-markdown.min.js 28.77 KB
packages/x-markdown/dist/plugins/latex.min.js 61.95 KB

@codecov
Copy link

codecov bot commented Jan 7, 2026

Bundle Report

Changes will decrease total bundle size by 56.45kB (-1.8%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
x-markdown-array-push 106.64kB -1.26MB (-92.21%) ⬇️
antdx-array-push 2.97MB 1.21MB (68.47%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: x-markdown-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
x-markdown.min.js (New) 103.89kB 103.89kB 100.0% 🚀
x-markdown.min.css (New) 2.75kB 2.75kB 100.0% 🚀
latex.min.js (Deleted) -268.81kB 0 bytes -100.0% 🗑️
static/KaTeX_AMS-Regular.*.ttf (Deleted) -63.63kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Regular.*.ttf (Deleted) -53.58kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Bold.*.ttf (Deleted) -51.34kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Italic.*.ttf (Deleted) -33.58kB 0 bytes -100.0% 🗑️
static/KaTeX_AMS-Regular.*.woff (Deleted) -33.52kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-BoldItalic.*.ttf (Deleted) -32.97kB 0 bytes -100.0% 🗑️
static/KaTeX_Math-Italic.*.ttf (Deleted) -31.31kB 0 bytes -100.0% 🗑️
static/KaTeX_Math-BoldItalic.*.ttf (Deleted) -31.2kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Regular.*.woff (Deleted) -30.77kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Bold.*.woff (Deleted) -29.91kB 0 bytes -100.0% 🗑️
static/KaTeX_AMS-Regular.*.woff2 (Deleted) -28.08kB 0 bytes -100.0% 🗑️
static/KaTeX_Typewriter-Regular.*.ttf (Deleted) -27.56kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Regular.*.woff2 (Deleted) -26.27kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Bold.*.woff2 (Deleted) -25.32kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Bold.*.ttf (Deleted) -24.5kB 0 bytes -100.0% 🗑️
latex.min.css (Deleted) -24.32kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Italic.*.ttf (Deleted) -22.36kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Italic.*.woff (Deleted) -19.68kB 0 bytes -100.0% 🗑️
static/KaTeX_Fraktur-Bold.*.ttf (Deleted) -19.58kB 0 bytes -100.0% 🗑️
static/KaTeX_Fraktur-Regular.*.ttf (Deleted) -19.57kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Regular.*.ttf (Deleted) -19.44kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-BoldItalic.*.woff (Deleted) -19.41kB 0 bytes -100.0% 🗑️
static/KaTeX_Math-Italic.*.woff (Deleted) -18.75kB 0 bytes -100.0% 🗑️
static/KaTeX_Math-BoldItalic.*.woff (Deleted) -18.67kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-Italic.*.woff2 (Deleted) -16.99kB 0 bytes -100.0% 🗑️
static/KaTeX_Main-BoldItalic.*.woff2 (Deleted) -16.78kB 0 bytes -100.0% 🗑️
static/KaTeX_Script-Regular.*.ttf (Deleted) -16.65kB 0 bytes -100.0% 🗑️
static/KaTeX_Math-Italic.*.woff2 (Deleted) -16.44kB 0 bytes -100.0% 🗑️
static/KaTeX_Math-BoldItalic.*.woff2 (Deleted) -16.4kB 0 bytes -100.0% 🗑️
static/KaTeX_Typewriter-Regular.*.woff (Deleted) -16.03kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Bold.*.woff (Deleted) -14.41kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Italic.*.woff (Deleted) -14.11kB 0 bytes -100.0% 🗑️
static/KaTeX_Typewriter-Regular.*.woff2 (Deleted) -13.57kB 0 bytes -100.0% 🗑️
static/KaTeX_Fraktur-Bold.*.woff (Deleted) -13.3kB 0 bytes -100.0% 🗑️
static/KaTeX_Fraktur-Regular.*.woff (Deleted) -13.21kB 0 bytes -100.0% 🗑️
static/KaTeX_Caligraphic-Bold.*.ttf (Deleted) -12.37kB 0 bytes -100.0% 🗑️
static/KaTeX_Caligraphic-Regular.*.ttf (Deleted) -12.34kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Regular.*.woff (Deleted) -12.32kB 0 bytes -100.0% 🗑️
static/KaTeX_Size1-Regular.*.ttf (Deleted) -12.23kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Bold.*.woff2 (Deleted) -12.22kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Italic.*.woff2 (Deleted) -12.03kB 0 bytes -100.0% 🗑️
static/KaTeX_Size2-Regular.*.ttf (Deleted) -11.51kB 0 bytes -100.0% 🗑️
static/KaTeX_Fraktur-Bold.*.woff2 (Deleted) -11.35kB 0 bytes -100.0% 🗑️
static/KaTeX_Fraktur-Regular.*.woff2 (Deleted) -11.32kB 0 bytes -100.0% 🗑️
static/KaTeX_Script-Regular.*.woff (Deleted) -10.59kB 0 bytes -100.0% 🗑️
static/KaTeX_Size4-Regular.*.ttf (Deleted) -10.36kB 0 bytes -100.0% 🗑️
static/KaTeX_SansSerif-Regular.*.woff2 (Deleted) -10.34kB 0 bytes -100.0% 🗑️
static/KaTeX_Script-Regular.*.woff2 (Deleted) -9.64kB 0 bytes -100.0% 🗑️
static/KaTeX_Caligraphic-Bold.*.woff (Deleted) -7.72kB 0 bytes -100.0% 🗑️
static/KaTeX_Caligraphic-Regular.*.woff (Deleted) -7.66kB 0 bytes -100.0% 🗑️
static/KaTeX_Size3-Regular.*.ttf (Deleted) -7.59kB 0 bytes -100.0% 🗑️
static/KaTeX_Caligraphic-Bold.*.woff2 (Deleted) -6.91kB 0 bytes -100.0% 🗑️
static/KaTeX_Caligraphic-Regular.*.woff2 (Deleted) -6.91kB 0 bytes -100.0% 🗑️
static/KaTeX_Size1-Regular.*.woff (Deleted) -6.5kB 0 bytes -100.0% 🗑️
static/KaTeX_Size2-Regular.*.woff (Deleted) -6.19kB 0 bytes -100.0% 🗑️
static/KaTeX_Size4-Regular.*.woff (Deleted) -5.98kB 0 bytes -100.0% 🗑️
static/KaTeX_Size1-Regular.*.woff2 (Deleted) -5.47kB 0 bytes -100.0% 🗑️
static/KaTeX_Size2-Regular.*.woff2 (Deleted) -5.21kB 0 bytes -100.0% 🗑️
static/KaTeX_Size4-Regular.*.woff2 (Deleted) -4.93kB 0 bytes -100.0% 🗑️
static/KaTeX_Size3-Regular.*.woff (Deleted) -4.42kB 0 bytes -100.0% 🗑️
static/KaTeX_Size3-Regular.*.woff2 (Deleted) -3.62kB 0 bytes -100.0% 🗑️
view changes for bundle: antdx-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antdx.js (New) 2.97MB 2.97MB 100.0% 🚀
antdx.min.js (Deleted) -1.76MB 0 bytes -100.0% 🗑️

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 8, 2026
@kimteayon kimteayon merged commit 8dcd057 into feature Jan 8, 2026
12 of 13 checks passed
@kimteayon kimteayon deleted the feat-request-retry branch January 8, 2026 02:41
@kimteayon kimteayon linked an issue Jan 8, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XRequest中暴露出 EventSource 便于去实现可控的重连机制

4 participants