Skip to content

fix: motion configuration does not work properly#53902

Merged
thinkasany merged 10 commits intomasterfrom
motion
Jun 6, 2025
Merged

fix: motion configuration does not work properly#53902
thinkasany merged 10 commits intomasterfrom
motion

Conversation

@wanpan11
Copy link
Copy Markdown
Member

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

💡 Background and Solution

ConfigProvider 多层嵌套后 motion 失效

📝 Change Log

Language Changelog
🇺🇸 English 修复 ConfigProvider 多层嵌套后 motion 失效
🇨🇳 Chinese Fix motion configuration does not work properly

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2025

📝 Walkthrough

Summary by CodeRabbit

  • 新功能

    • Motion 配置现已支持通过上下文共享,允许嵌套组件感知 motion 状态变化。
  • 修复

    • 切换 ConfigProvider 的 motion 配置时,不会导致子组件重新挂载。
  • 测试

    • 优化和统一 Modal 相关测试用例的 motion 配置管理,移除冗余的 motion mock。
    • 新增 motion 配置切换不触发组件重挂载的测试用例。
    • 优化测试工具函数参数类型,提升类型兼容性。
  • 文档

    • GlobalConfigProps 接口现已对外导出,便于类型引用。
## Summary by CodeRabbit

- **测试**
  - 统一测试中全局配置的设置方式,新增了辅助函数和组件以禁用动效,提升测试一致性和可维护性。
  - 优化了控制台错误监控,减少无关警告对测试输出的干扰。
  - 简化了部分测试用例的上下文包装和生命周期管理。

- **文档**
  - 公开了全局配置属性接口,便于外部模块访问和类型推断。

## Walkthrough

本次更改主要优化了 ConfigProvider 及其 motion 配置的逻辑。MotionWrapper 组件中引入了 MotionCacheContext 以支持嵌套组件共享 motion 状态,结合上下文和 ref 标志决定是否包裹 MotionProvider。测试用例统一引入禁用 motion 的配置包装器,提升测试一致性。同时,GlobalConfigProps 接口被导出以便外部访问。

## Changes

| 文件/分组                                                         | 变更摘要                                                                                      |
|-------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| components/config-provider/MotionWrapper.tsx                      | 新增 MotionCacheContext,上下文与 ref 结合决定是否包裹 MotionProvider,支持嵌套组件共享状态。  |
| components/config-provider/index.tsx                              | 为 GlobalConfigProps 接口添加了 export 关键字,提升其模块外部可见性。                          |
| components/modal/__tests__/confirm.test.tsx                       | 引入 configWarp 辅助函数统一配置,所有 ConfigProvider.config 调用改用 configWarp,完善错误抑制。 |
| components/modal/__tests__/hook.test.tsx                          | 新增 ConfigWarp 组件,所有 contextHolder 测试均用其包裹,统一禁用 motion 的上下文环境。           |
| components/config-provider/__tests__/index.test.tsx               | 新增测试验证 motion 配置切换不会导致组件重新挂载。                                           |
| tests/utils.tsx                                                   | 修改 customRender 函数参数类型,允许传入更灵活的 RenderOptions 配置。                         |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Parent
    participant MotionWrapper
    participant MotionCacheContext
    participant MotionProvider
    participant Children

    Parent->>MotionWrapper: 渲染(motion)
    MotionWrapper->>MotionCacheContext: 提供 needWrapMotionProvider 状态
    MotionWrapper->>MotionProvider: 条件包裹 Children
    MotionProvider->>Children: 渲染

Assessment against linked issues

Objective Addressed Explanation
独立为 Menu 设置 theme.token.motion = true 时,Menu 能正确启用过渡效果(#53784
全局 ConfigProvider 设置 theme.token.motion = false 时,其他组件可继承并正确禁用 motion(#53784

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Suggested reviewers

  • afc163
  • thinkasany

Poem

兔子跳跃代码间,
Motion 配置更简单。
包裹逻辑一目了,
测试环境更完善。
组件灵活如春风,
变化随心舞东风。
🐇✨


</details>

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgAzeAAPLmZ8cXwsJgxEomwqDKxafGlIDHTIAHd8CgBrHgp8bkovWVDY9Fpaf0REUrRIAWwiFCxcWBJIAEEMXEgAEWl4IiwveAEqFz8SL2oYggiJyDTChRzl/Op4TKr1BDGjgGFM3KtGiXglPiZmbkz2DQwI5IByTfAMBj5ZCVCZYZ7nIhvfAfL4oZDkRA0ejMbzibjRCLwNiIcIMNDYRDwDAjcaTE7XLB9XDianIA4CUQsSZUkjxeKicRSQFwSaJJLbRD4LxSNkIZC8QTRZjhMgOChUmmwajHdIMs65S6FaE1epMCj+MStSAkKRYSp3Y64+D4ya7WSUZD4eKQeGvd6fShlEIa4VHfy7LFo0FoiJUBi1GLYDCogDi6gAEtgBFHgmVHBy+ABWADMAHYABwAFlDkwYWuprvwI0QzQY8ESpXG2tpkDFCnNAtldN1N2yBoKeo5Wo+NVGg3SsEgAFFqWtEIvMPRHvdpJMlIgGOruEaNOZLM9WOxkA4nC43EdMlafmxZvwHh5vL5/EEQjH4o1mEOSYKUDSpMG4TAAEZIPCGF8HsLV/HoHsaExCVcTZeClDSDBMQKSYezFGsFEvV8qQYLxsH3dAsCJNBSHQZk0DrF85nXfB7WpID+DwH4wW9FCQnCXhpEcFQrQkNA1loK4uK7OYe3pUcXguCcbnKSoqhNeVGmaCgrTQeIaD4QjkkBAA5eC0C6dQGSkyBaCQSFegZcIf0xBkSX4Ph+ToARmPqSpKEmBUURiKluOfK9TwMfRjHAKAyHoL0cAIYgyGUSMotmLheH4YQBUkUo5AUL4VDUTRtF0MBDBMKB3GQVBMFSwhSHIfD6Gyzg/DQTSb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aG5uhSOASJIGPHji1HNp8vOStr0W5goDyFlmLh8A4mnkwHkAcAEB9h7SDtTutqVKTOkBQTyUolORGD+BoGZpmvYUjqU07uMTaDK2CnPTqMQDmTmEMQsR53kD1mOJszaziMfyOHdr1GtKVHYBJNupyQSSLXuQ8nKOezjx5IbS6rHq4D83VDEGn2uuOEoAKTrJ7A2hszLtwibOUTJrbN5spu0QFoMTFs5VeSZvCWGSgCJ2Cz1FcXSTBwkroC4FlWRpYCDpfkEq4CnLECXAPvVn4FDtwnfL9vUGTsU3brDsgAjriOjoP2dQwcxCwZSpwfgDwdUNwEIdh2Id/sQHfPjuMT4S8Coa+Bodwj0APxGNVvVofQfzYsDUMAMDqjIWSm9HJDSm6VzS6i4CoD6gIKGjV1GgqgmmqlqgShIn9ojU+Cv38A+GULoAjW4UhqmjUdoAACZIJCxSwAA2eIBgSsHx8seIAABhIE8c8eLECbJGLG8YAE5SxIJixIJknPGEnywwmDlCxCwLHVGrHUYUmEZ4hPHyxCxyw/GuhixywBAkmBAGBsnaAanKxKwwn/I0AsnknSw0BixJg4oPGYmInKwDk0BSwBB4hIJ4gEnCwGBKnKxCxmIpnaBynaB4hQmwnPHaBVAlBPH8m1GsnIIZITY/HUnmnIJyxiwEnPHCw/HxnFmrmsnUmImSAEnmn4m/HKx9mrH1n2mGBPmqmknSmwm0BoJFmKwGBIJPGGA6nKx/nywVBPHDJyxKnvQBnCmpnPmBBPH4hCxKwBBLn/nKw0BfHiwBBCwwm/HIJemEm/HQmEmywfH+QqXvmIBIBTnSxaBIIwmGAEmSASABA/HYXyXrnamcXWm0BUYSAeWBBWn4guWAn6B0W2XSxKwynCxjnPGAm4WhWGAKx/H4g/G0BTnKxaWVniw/HfGGBZnVXSxWWoBPGBBxnIJIXRBCxBXHWsnwnLXBWugGArnOXiWSBywkX8WNW8n3GrHnx1BbHaB7GbQIktSI0koLGgA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=ant-design/ant-design&utm_content=53902):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `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 explain this code block.`
  -	`@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 explain its main purpose.`
  - `@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](https://www.coderabbit.ai/contact-us/support) 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](https://docs.coderabbit.ai/finishing-touches/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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2025

Preview is ready

@petercat-assistant
Copy link
Copy Markdown

Walkthrough

This pull request addresses a bug where the motion configuration does not work properly when ConfigProvider is nested multiple times. The solution involves modifying the logic to ensure that the MotionProvider is only wrapped when motion is enabled.

Changes

File Summary
components/config-provider/MotionWrapper.tsx Fixed logic to wrap MotionProvider only when motion is enabled.
components/config-provider/index.tsx Exported GlobalConfigProps interface.
components/modal/__tests__/confirm.test.tsx Updated tests to use configWarp function for consistent configuration.
components/modal/__tests__/hook.test.tsx Updated tests to use ConfigWarp component for consistent configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2025

👁 Visual Regression Report for PR #53902 Passed ✅

🎯 Target branch: master (8abb52f)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

Comment thread components/config-provider/MotionWrapper.tsx Outdated
@coderabbitai coderabbitai Bot requested a review from afc163 May 23, 2025 08:10
@wanpan11 wanpan11 mentioned this pull request May 23, 2025
17 tasks
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2025

size-limit report 📦

Path Size
dist/antd.min.js 450.29 KB (+16 B 🔺)
dist/antd-with-locales.min.js 537.62 KB (+32 B 🔺)

@coderabbitai coderabbitai Bot added lgtm This PR has been approved by a maintainer skip-verify-files labels May 23, 2025
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 23, 2025

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2025

Bundle Report

Changes will increase total bundle size by 152 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.39MB 152 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 76 bytes 1.85MB 0.0%
antd.min.js 76 bytes 1.54MB 0.0%

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 23, 2025

Deploying ant-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2b7b1c1
Status: ✅  Deploy successful!
Preview URL: https://12ab0774.ant-design.pages.dev
Branch Preview URL: https://motion.ant-design.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (8abb52f) to head (2b7b1c1).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #53902   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          774       774           
  Lines        14023     14027    +4     
  Branches      3713      3713           
=========================================
+ Hits         14023     14027    +4     

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

Comment thread components/config-provider/MotionWrapper.tsx Outdated
@afc163 afc163 requested a review from Copilot June 3, 2025 13:44

This comment was marked as outdated.

@wanpan11 wanpan11 requested a review from zombieJ June 3, 2025 16:11
Comment thread components/config-provider/MotionWrapper.tsx Outdated
Comment thread components/config-provider/MotionWrapper.tsx Outdated
Comment thread components/config-provider/MotionWrapper.tsx Outdated
@coderabbitai coderabbitai Bot requested a review from thinkasany June 4, 2025 09:55
@wanpan11 wanpan11 requested a review from zombieJ June 4, 2025 10:20
@thinkasany thinkasany requested a review from Copilot June 6, 2025 03:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes motion settings not being applied when nesting multiple ConfigProvider layers by introducing a motion context and updating tests and types accordingly.

  • Added a MotionCacheContext to propagate a “no-motion” flag across nested providers
  • Updated MotionWrapper to wrap children with MotionProvider when any ancestor disables motion
  • Refactored modal tests to use a ConfigWarp/configWarp helper for consistent motion configuration and exported GlobalConfigProps for type safety

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
components/config-provider/MotionWrapper.tsx Introduce MotionCacheContext and adjust wrapping logic
components/config-provider/index.tsx Export GlobalConfigProps for external use
components/modal/tests/hook.test.tsx Replace manual motion mocking with ConfigWarp component
components/modal/tests/confirm.test.tsx Replace CSSMotion mock with configWarp global setup
Comments suppressed due to low confidence (1)

components/modal/tests/hook.test.tsx:27

  • [nitpick] Component helpers should start with an uppercase letter. Rename configWarp in confirm tests to ConfigWarp for consistency, or vice versa in this file.
const ConfigWarp = (conf?: ConfigProviderProps) => {

Comment thread components/config-provider/MotionWrapper.tsx Outdated
Comment thread components/config-provider/MotionWrapper.tsx Outdated
@wanpan11 wanpan11 requested a review from zombieJ June 6, 2025 04:32
@wanpan11
Copy link
Copy Markdown
Member Author

wanpan11 commented Jun 6, 2025

测试结果

image

Copy link
Copy Markdown
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/utils.tsx (1)

32-33: 类型更改允许覆盖默认包装器,请确认这是预期行为

参数类型从 Omit<RenderOptions, 'wrapper'> 更改为 Partial<RenderOptions> 现在允许传递 wrapper 选项,这将覆盖默认的 StrictMode 包装器。虽然这为测试提供了更大的灵活性(如在新的动作配置测试中看到的 wrapper: undefined!),但也改变了函数的核心行为。

请确认这种行为变更是有意为之,并考虑在文档中说明这种覆盖能力。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74285da and 2b7b1c1.

📒 Files selected for processing (3)
  • components/config-provider/MotionWrapper.tsx (1 hunks)
  • components/config-provider/__tests__/index.test.tsx (2 hunks)
  • tests/utils.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/config-provider/MotionWrapper.tsx
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: test-react-legacy (17, 2/2)
  • GitHub Check: test-react-legacy (17, 1/2)
  • GitHub Check: build
  • GitHub Check: test-react-legacy (16, 2/2)
  • GitHub Check: test-react-legacy (16, 1/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: build preview
  • GitHub Check: lint
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: build
  • GitHub Check: size
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build
🔇 Additional comments (2)
components/config-provider/__tests__/index.test.tsx (2)

10-10: 导入顺序调整

Form 导入被移动到 Input 之前,这是一个小的整理性变更。


189-226: 优秀的测试用例验证动作配置修复

这个新测试用例很好地验证了 PR 的核心修复:

  • 使用 mountTime 计数器巧妙地追踪组件重新挂载
  • 测试了 motion: false -> true -> false 的完整状态转换序列
  • 使用 wrapper: undefined! 覆盖默认包装器,与 utils.tsx 的更改配合使用
  • 每次状态变更后都断言 mountTime 保持为 1,确保没有发生不必要的重新挂载

这个测试直接验证了嵌套 ConfigProvider 中动作配置的修复是否有效,完全符合 PR 目标。

@thinkasany thinkasany merged commit afbec02 into master Jun 6, 2025
47 checks passed
@thinkasany thinkasany deleted the motion branch June 6, 2025 09:01
@wanpan11 wanpan11 restored the motion branch June 6, 2025 09:02
@wanpan11 wanpan11 deleted the motion branch June 6, 2025 09:02
@wanpan11 wanpan11 mentioned this pull request Jun 8, 2025
17 tasks
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 skip-verify-files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

motion配置失效

6 participants