Skip to content

Conversation

@caidaodumogu
Copy link

@caidaodumogu caidaodumogu commented Dec 4, 2025

📝 Description

解决#4004 中所涉及的问题,之前应该是判断allowLoop非布尔类型时候走
doValidate(allowLoop) 方法,但是 allowLoop 方法内部本身就是 return false, 所以会误拦截正常连线情况。

🖼️ Screenshot

Before After

💡 Motivation and Context

判断函数类型的allowLoop返回值如果非明确的 true,就启用false设置,

如果此改动违背设计初衷,请忽视,可能设计本意是要在allowLoop里做更深层次的逻辑,不仅仅是写一个固定的 return false;

#4004

🧩 Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Enhancement (changes that improvement of current feature or performance)
  • Refactoring (changes that neither fixes a bug nor adds a feature)
  • Test Case (changes that add missing tests or correct existing tests)
  • Code style optimization (changes that do not affect the meaning of the code)
  • Docs (changes that only update documentation)
  • Chore (changes that don't modify src or test files)

🔍 Self Check before Merge

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

1414038519 added 2 commits December 4, 2025 17:46
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @caidaodumogu, 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!

此拉取请求旨在解决 AntV X6 库中关于边验证的一个 bug(#4004)。此前,当 allowLoop 配置为一个函数时,其验证逻辑可能导致对自环的错误判断,从而阻止了本应允许的连接。本次修复通过精确处理 allowLoop 函数的返回值,确保了自环判断的准确性,从而恢复了正确的连线行为。

Highlights

  • 修复循环连接判断逻辑: 解决了当 allowLoop 为函数类型时,误判导致正常连线被拦截的问题。
  • 优化 allowLoop 函数处理: 调整了 allowLoop 为函数时的验证逻辑,现在会检查函数返回值和源/目标视图是否相同,以正确判断是否允许自环。
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.

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

这个 Pull Request 修复了当 allowLoop 是一个函数时连接验证的逻辑问题。之前的实现会错误地对所有连接应用 allowLoop 函数,而不仅仅是自环连接,这可能导致意外地阻止所有连接。

你提出的修复方向是正确的,即只在检测到自环连接时(sourceView === targetView)才调用 allowLoop 函数。然而,当前的修改在调用 allowLoop 函数时没有传递任何参数 (allowLoop.call(this.graph)), 这与 allowLoop 函数的类型定义 (this: Graph, args: ValidateConnectionArgs) => boolean 不符。这可能会导致在 allowLoop 函数实现中访问 args 参数时出现运行时错误。

为了保持 API 的一致性并避免潜在的 bug,建议使用 doValidate(allowLoop) 来调用 allowLoop 函数,因为它会正确地构造并传递 ValidateConnectionArgs 参数。

1414038519 and others added 4 commits December 4, 2025 18:10
commit

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

2 participants