Skip to content
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

chore: dev and site support React 19 #432

Merged
merged 14 commits into from
Dec 31, 2024
Merged

chore: dev and site support React 19 #432

merged 14 commits into from
Dec 31, 2024

Conversation

YumoImer
Copy link
Collaborator

@YumoImer YumoImer commented Dec 30, 2024

本 PR 做了几件事情:

  • 升级开发环境、站点对 React 19 的支持
  • 优化了测试工具的逻辑
  • 使用 kebab case 对 useXAgentuseXChat 进行更正
  • 升级了 Petercat 的依赖版本

fix: #427
fix: #426

fix: #425
fix: #422

Summary by CodeRabbit

Summary by CodeRabbit

  • 依赖更新
    • @petercatai/assistant 依赖版本从 ^2.0.5 升级到 ^2.0.10
    • dumi 依赖版本从 ^2.4.10 升级到 ^2.4.17
    • reactreact-dom 依赖版本从 ^18.3.1 升级到 ^19.0.0
    • 新增依赖 @ant-design/v5-patch-for-react-19,版本为 ^1.0.3
  • 组件改进
    • SemanticPreview 组件中的 timerRef 初始化为 null,提高类型安全性。
    • ComponentChangelog 组件中的 cloneElement 方法参数类型更新为 React.ReactElement<any>,增强类型安全性。
    • PrevAndNext 组件中的 React.cloneElement 调用参数类型更新为 React.ReactElement<any>,扩大类型接受范围。
    • DocLayout 组件中对 timerRef 的处理和清理函数进行了改进,增强生命周期管理的安全性。
    • Sender 组件中的类型定义和接口进行了简化和清晰化。
  • 类型移除
    • 删除了 components/sender/interface.tscomponents/suggestion/interface.ts 文件,移除了相关类型定义。
  • 测试改进
    • 更新了测试工具中的 renderHook 函数返回类型,增强类型安全性。
    • 重命名了测试文件中的 baseTextbaseTest,保持功能不变。
    • 新增了 use-x-agentuse-x-chat 组件的测试用例。
  • 文件改动
    • 更新了 components/index.ts 中的导出命名规范,采用了 kebab-case。

Copy link

github-actions bot commented Dec 30, 2024

Preview is ready

Copy link

Walkthrough

This pull request updates the version of the @petercatai/assistant package from ^2.0.5 to ^2.0.10 in the package.json file. This change is likely aimed at incorporating new features, bug fixes, or improvements provided in the updated version of the package.

Changes

File Summary
package.json Updated @petercatai/assistant version from ^2.0.5 to ^2.0.10.
bun.lockb Lock file updated to reflect the new version of @petercatai/assistant.
🪧 Tips For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.

Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

📝 Walkthrough

变更概述

步骤说明

该拉取请求主要更新了 package.json 文件中 @petercatai/assistant 依赖的版本,从 ^2.0.5 升级到 ^2.0.10。更新还包括 dumi 依赖的版本从 ^2.4.10 升级到 ^2.4.17,以及 react-dom 依赖的版本从 ^18.3.1 升级到 ^19.0.0。此外,其他文件中也进行了类型安全的增强和代码简化。未涉及其他配置变更。

变更

文件 变更摘要
package.json 更新 @petercatai/assistant 依赖版本从 ^2.0.5^2.0.10,更新 dumi 依赖版本从 ^2.4.10^2.4.17,更新 react-dom 依赖版本从 ^18.3.1^19.0.0
.dumi/components/SemanticPreview.tsx timerRef 初始化为 null,增强类型安全
.dumi/theme/common/ComponentChangelog/ComponentChangelog.tsx 更新 cloneElement 方法的类型参数为 React.ReactElement<any>
.dumi/theme/common/PrevAndNext.tsx 更新 React.cloneElement 调用的类型为 ReactElement<any>
.dumi/theme/layouts/DocLayout/index.tsx useEffect 中添加对 timerRef.current 的检查
components/attachments/index.tsx 简化 upload 方法中对文件输入元素的查询
components/sender/index.tsx 更新 SubmitType 类型定义及相关接口
components/sender/interface.ts 删除与提交和自定义相关的类型定义
components/suggestion/interface.ts 删除与组件类型定义相关的文件
tests/utils.tsx 修改 renderHook 函数的返回类型以支持 null
components/x-request/__tests__/demo.test.ts baseText 变量重命名为 baseTest
components/x-stream/__tests__/demo.test.ts baseText 变量重命名为 baseTest
tests/shared/demoTest.tsx baseText 函数重命名为 baseTest,更新参数处理
components/use-x-agent/__tests__/demo.test.ts 新增测试,调用 baseTest 函数
components/use-x-chat/__tests__/demo.test.ts 新增测试,调用 baseTest 函数
components/use-x-chat/__tests__/index.test.tsx 更新 useXAgent 的导入路径
components/use-x-chat/demo/stream-cancel.tsx 更改导入顺序
components/use-x-chat/index.ts 更新 XAgent 的导入路径

可能相关的拉取请求

目标与问题的评估

目标 已解决 说明
更新 @petercatai/assistant 依赖版本以解决对话框关闭按钮消失问题 (#427, #426)
更新类型定义以增强类型安全 (#425, #422)

兔子庆祝诗

🐰 依赖升级,版本跳跃
小兔子欢呼,代码轻快
从 2.0.5 到 2.0.10
包裹里的魔法,悄然绽放
更新的节奏,代码的舞蹈!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7c987d and 2f7926e.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (1)
  • package.json (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.

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. (Beta)
  • @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.

package.json Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 30, 2024

Bundle Report

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

Detailed changes
Bundle name Size Change
antdx-array-push 155.37kB 614 bytes (-0.39%) ⬇️

Copy link

socket-security bot commented Dec 30, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/browserslist@4.24.3 Transitive: environment, filesystem, shell +6 2.38 MB
npm/dayjs@1.11.13 None 0 670 kB iamkun
npm/jest-environment-node@29.7.0 unsafe Transitive: environment, eval, filesystem +18 1.02 MB simenb
npm/minimist@1.2.8 None 0 54.5 kB ljharb
npm/regenerator-runtime@0.14.1 None 0 27.9 kB benjamn

🚮 Removed packages: npm/@types/lodash@4.17.13, npm/typescript@5.7.2

View full report↗︎

Copy link

cloudflare-workers-and-pages bot commented Dec 30, 2024

Deploying ant-design-x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2f7926e
Status: ✅  Deploy successful!
Preview URL: https://cb43c4bc.ant-design-x.pages.dev
Branch Preview URL: https://chore-update-dep.ant-design-x.pages.dev

View logs

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 (3)
.dumi/theme/common/PrevAndNext.tsx (2)

144-144: 建议:使用更具体的类型替代 ReactElement。

目前将类型指定为 ReactElement 会放宽对组件标签属性的校验,可能导致类型安全性降低。若已知要传递的属性结构,建议使用更精确的泛型参数来增强可读性与可靠性。


148-148: 相同问题:请考虑提升类型安全性。

与上一段相同,应尽可能避免使用 ReactElement 这种宽泛的类型声明。若后续需扩展该元素,可以使用更具体的类型来确保编译期校验。

.dumi/theme/common/ComponentChangelog/ComponentChangelog.tsx (1)

309-309: 同类类型注释:避免使用 React.ReactElement。

对于需要 clone 的子元素,若能够在内部明确属性结构,可使用更具体的泛型声明,以便在编译时捕捉到潜在的类型错误并提升可维护性。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb3315a and 1f0bdc5.

📒 Files selected for processing (9)
  • .dumi/components/SemanticPreview.tsx (1 hunks)
  • .dumi/theme/common/ComponentChangelog/ComponentChangelog.tsx (1 hunks)
  • .dumi/theme/common/PrevAndNext.tsx (1 hunks)
  • .dumi/theme/layouts/DocLayout/index.tsx (2 hunks)
  • components/attachments/index.tsx (1 hunks)
  • components/sender/index.tsx (2 hunks)
  • components/sender/interface.ts (0 hunks)
  • components/suggestion/interface.ts (0 hunks)
  • tests/utils.tsx (1 hunks)
💤 Files with no reviewable changes (2)
  • components/suggestion/interface.ts
  • components/sender/interface.ts
✅ Files skipped from review due to trivial changes (1)
  • components/attachments/index.tsx
🔇 Additional comments (6)
tests/utils.tsx (1)

35-35: 将返回类型更改为可为 null 有助于提升类型安全性。

此处将 React.RefObject<T> 改为 React.RefObject<T | null> 可避免在对 result.current 执行后续操作时出现类型错误,更好地反映真实的引用状态。

.dumi/theme/layouts/DocLayout/index.tsx (1)

Line range hint 38-59: 为计时器使用 useRef(null) 并在清理时进行空值检查是更安全的做法。

useRef(null) 能提供更明确的初始值,避免在清除计时器时可能出现的空引用错误。在 return 中加入空值检查也能防止 clearTimeouttimerRef.current 不存在时抛出异常。

.dumi/components/SemanticPreview.tsx (1)

106-106: timerRef 中使用空值初始化有助于避免潜在的引用错误。

timerRef 初始化为 null 并在副作用清理函数中执行空值检查,有效防止了在 timerRef.current 尚未赋值时调用 clearTimeout 导致的可能问题。

components/sender/index.tsx (3)

20-21: 定义提交类型使逻辑更加清晰
在这里添加 SubmitType 类型,有助于在业务层面上明确区分不同提交方式,代码可读性和可维护性得到提升。


26-26: 替换自定义组件类型为 React.ComponentType
CustomizeComponent<TextareaProps> 更改为 React.ComponentType<TextareaProps> 对齐了常规的 React 组件定义方式,有助于减少类型歧义并与社区习惯保持一致。


84-85: 统一 getComponent 函数返回类型
defaultComponent 与返回值统一为 React.ComponentType<T>,使组件类型更具扩展性,兼容更多组件使用场景。

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.45%. Comparing base (b21e9b7) to head (2f7926e).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
components/attachments/index.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #432   +/-   ##
=======================================
  Coverage   91.45%   91.45%           
=======================================
  Files          67       67           
  Lines        1462     1462           
  Branches      385      370   -15     
=======================================
  Hits         1337     1337           
  Misses        125      125           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 (1)
tests/shared/demoTest.tsx (1)

90-94: 打印错误信息可提升调试效率,但需注意日志量。

在批量测试时,console.log 可能输出大量信息,建议后续考虑使用更精确的日志监控或条件式打印,避免过多干扰。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f172d3 and 5591bb1.

⛔ Files ignored due to path filters (6)
  • components/attachments/__tests__/__snapshots__/demo-extend.test.ts.snap is excluded by !**/*.snap
  • components/attachments/__tests__/__snapshots__/demo.test.tsx.snap is excluded by !**/*.snap
  • components/bubble/__tests__/__snapshots__/demo.test.ts.snap is excluded by !**/*.snap
  • components/sender/__tests__/__snapshots__/demo-extend.test.ts.snap is excluded by !**/*.snap
  • components/suggestion/__tests__/__snapshots__/demo-extend.test.ts.snap is excluded by !**/*.snap
  • components/welcome/__tests__/__snapshots__/demo.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • components/x-request/__tests__/demo.test.ts (1 hunks)
  • components/x-stream/__tests__/demo.test.ts (1 hunks)
  • tests/shared/demoTest.tsx (5 hunks)
✅ Files skipped from review due to trivial changes (2)
  • components/x-stream/tests/demo.test.ts
  • components/x-request/tests/demo.test.ts
🔇 Additional comments (9)
tests/shared/demoTest.tsx (9)

6-6: 导入 React 的方式可接受。

此处只是简单引入 React,没有发现问题。


29-29: 重命名函数符合语义。

baseText 改为 baseTest 更加贴合实际功能,是合理的命名更新。


35-35: 拼接路径更统一。

通过 file.split(path.sep).join('/') 将不同操作系统的路径分隔符统一为 /,有助于在多平台环境下保持一致性,没有问题。


38-38: 条件判断逻辑可读性良好。

通过判断 options.skip 来决定是否跳过测试,逻辑清晰且可维护。


44-44: 测试语句信息完善。

测试名称可读性高,可帮助快速定位具体用例。对测试结果的可追溯性有帮助。


53-53: 动态引入 Demo 需要注意错误处理。

这里使用 require 动态载入可以灵活处理 Demo 文件。若文件路径不正确或导出有误时,可能造成运行时错误。建议在后续如发生异常时,进一步捕获并提示相关信息。


109-109: 在扩展测试时强制注入上下文。

调用 baseTest(true, ...) 以注入 TriggerMockContext,可方便对弹窗类组件的测试;无明显问题。


116-116: 默认测试逻辑良好。

这里选择 baseTest(false, ...) 测试常规情况,保证覆盖面足够全面。


120-135: kebab-case 检查与根属性测试增强了测试完善度。

  1. 测试组件名与路径是否一致,可避免因命名约定不符导致的文件查找异常。
  2. rootPropsTest 可验证根元素特性,提升组件可插拔性与一致性。
    以上逻辑非常实用,建议保留。

@YumoImer YumoImer changed the title chore: update @petercatai/assistant version chore: dev and site support React 19 Dec 30, 2024
@YumoImer
Copy link
Collaborator Author

之前的基线版本有问题,所以 Size Limit 会挂掉。该 CI 暂时不用管。

@YumoImer YumoImer requested a review from a team December 30, 2024 11:43
@afc163
Copy link
Member

afc163 commented Dec 31, 2024

图片

还是挂的?

@YumoImer
Copy link
Collaborator Author

图片 还是挂的?

之前的基线版本有问题,所以会挂掉。目前的基线是没问题的。先合并了。

@YumoImer YumoImer merged commit 7bdd7a0 into main Dec 31, 2024
14 of 16 checks passed
@YumoImer YumoImer deleted the chore/update-dep branch December 31, 2024 08:47
@YumoImer YumoImer linked an issue Jan 10, 2025 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

官网对话框关闭按钮消失问题 官网对话框关闭按钮消失问题 React 19 support
2 participants