Skip to content

Conversation

@RC-CHN
Copy link
Member

@RC-CHN RC-CHN commented Oct 13, 2025


Motivation / 动机

之前的测试功能只能一次性测试所有provider,需要等待的时间较长且不方便

Modifications / 改动点

在itemcard组件内添加了插槽,允许添加一个provider特有的测试按钮,同时处理了单provider测试的相关逻辑

Verification Steps / 验证步骤

在/providers页面下测试即可

Screenshots or Test Results / 运行截图或测试结果

image

Compatibility & Breaking Changes / 兼容性与破坏性变更

  • 这是一个破坏性变更 (Breaking Change)。/ This is a breaking change.
  • 这不是一个破坏性变更。/ This is NOT a breaking change.

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Sourcery 总结

通过添加每个项目的“测试”按钮、重构批量测试逻辑以跟踪每个提供商的测试,并相应地同步 UI 加载状态,实现服务提供商的独立测试。

新功能:

  • 在项目卡中添加一个按提供商的“测试”按钮槽,以触发单个提供商可用性检查
  • 实现 testSingleProvider 方法和 isProviderTesting 状态,以执行和跟踪单个提供商的测试
  • 引入 testingProviders 数组来管理并发提供商测试的加载状态

改进:

  • 重构 fetchProviderStatus,仅使用 testingProviders 并行测试已启用的提供商,而不是使用单个加载标志
  • 更新全局刷新按钮和默认操作按钮以反映每个提供商的加载状态

文档:

  • 为新的可用性测试按钮添加英文和中文的 i18n 条目

杂项:

  • 将 Vite 开发服务器代理目标从 localhost 更改为 127.0.0.1
Original summary in English

Summary by Sourcery

Enable independent testing of service providers by adding a per-item Test button, refactor batch testing logic to track tests per provider, and sync UI loading states accordingly

New Features:

  • Add a per-provider “Test” button slot in the item card to trigger individual provider availability checks
  • Implement testSingleProvider method and isProviderTesting state to perform and track single-provider tests
  • Introduce testingProviders array to manage loading states for concurrent provider tests

Enhancements:

  • Refactor fetchProviderStatus to only test enabled providers in parallel using testingProviders instead of a single loading flag
  • Update the global refresh button and default action buttons to reflect per-provider loading states

Documentation:

  • Add i18n entries for the new availability test button in English and Chinese

Chores:

  • Change Vite dev server proxy target from localhost to 127.0.0.1

@auto-assign auto-assign bot requested review from Larch-C and Raven95676 October 13, 2025 03:18
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

你好 - 我已审阅了你的更改 - 以下是一些反馈:

  • 使用单个 testingProviders 数组来控制全局刷新和单个提供商测试会耦合这些状态——考虑将全局和每个提供商的加载状态分开,以避免意外阻塞。
  • fetchProviderStatustestSingleProvider 中,初始化和更新 providerStatuses(以及错误处理)的代码重复——将其提取到共享 helper 中以减少重复。
  • vite.config.ts 中将代理目标硬编码为 127.0.0.1 可能不适用于所有环境——考虑通过环境变量使目标可配置。
AI 代理提示
请解决此代码审查中的评论:

## 总体评论
- 使用单个 `testingProviders` 数组来控制全局刷新和单个提供商测试会耦合这些状态——考虑将全局和每个提供商的加载状态分开,以避免意外阻塞。
-`fetchProviderStatus``testSingleProvider` 中,初始化和更新 `providerStatuses`(以及错误处理)的代码重复——将其提取到共享 helper 中以减少重复。
-`vite.config.ts` 中将代理目标硬编码为 `127.0.0.1` 可能不适用于所有环境——考虑通过环境变量使目标可配置。

## 单独评论

### 评论 1
<location> `dashboard/src/views/ProviderPage.vue:643` </location>
<code_context>
-        }
+      // 1. 初始化UI为pending状态,并将所有待测试的 provider ID 加入 loading 列表
+      this.providerStatuses = providersToTest.map(p => {
+        this.testingProviders.push(p.id);
+        return { id: p.id, name: p.id, status: 'pending', error: null };
+      });
</code_context>

<issue_to_address>
**issue (bug_risk):** `testingProviders` 数组中可能存在重复的提供商 ID。

如果 `fetchProviderStatus` 在完成前被多次触发,可能会出现重复。为防止这种情况,请确保 `testingProviders` 中的 ID 是唯一的,例如在插入前进行检查或使用 `Set`。
</issue_to_address>

### 评论 2
<location> `dashboard/src/views/ProviderPage.vue:683` </location>
<code_context>
+    },
+
+    async testSingleProvider(provider) {
+      if (this.isProviderTesting(provider.id)) return;
+
+      this.testingProviders.push(provider.id);
</code_context>

<issue_to_address>
**suggestion:** 静默返回可能导致用户缺乏反馈。

考虑在测试已在进行中时通知用户,以增强用户体验。

```suggestion
      if (this.isProviderTesting(provider.id)) {
        this.$message && this.$message.warning
          ? this.$message.warning('该服务商正在测试中,请稍候。')
          : alert('该服务商正在测试中,请稍候。');
        return;
      }
```
</issue_to_address>

### 评论 3
<location> `dashboard/src/components/shared/ItemCard.vue:31` </location>
<code_context>
         variant="outlined"
         color="error"
         rounded="xl"
+        :disabled="loading"
         @click="$emit('delete', item)"
       >
</code_context>

<issue_to_address>
**question:** 基于加载状态禁用按钮可能会阻塞不相关的操作。

审查在加载期间真正需要禁用的操作;像复制这样的操作可能不需要被阻塞,以获得更好的用户体验。
</issue_to_address>

Sourcery 对开源项目免费 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请点击 👍 或 👎 对每个评论进行评价,我将利用这些反馈来改进你的评论。
Original comment in English

Hey there - I've reviewed your changes - here's some feedback:

  • Using a single testingProviders array to gate both the global refresh and individual provider tests couples those states—consider splitting global and per-provider loading states to avoid unintended blocking.
  • There's repeated code for initializing and updating providerStatuses (and error handling) in both fetchProviderStatus and testSingleProvider—extract that into a shared helper to reduce duplication.
  • Hard-coding the proxy target to 127.0.0.1 in vite.config.ts may not work across all environments—consider making the target configurable via an environment variable.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using a single testingProviders array to gate both the global refresh and individual provider tests couples those states—consider splitting global and per-provider loading states to avoid unintended blocking.
- There's repeated code for initializing and updating providerStatuses (and error handling) in both fetchProviderStatus and testSingleProvider—extract that into a shared helper to reduce duplication.
- Hard-coding the proxy target to 127.0.0.1 in vite.config.ts may not work across all environments—consider making the target configurable via an environment variable.

## Individual Comments

### Comment 1
<location> `dashboard/src/views/ProviderPage.vue:643` </location>
<code_context>
-        }
+      // 1. 初始化UI为pending状态,并将所有待测试的 provider ID 加入 loading 列表
+      this.providerStatuses = providersToTest.map(p => {
+        this.testingProviders.push(p.id);
+        return { id: p.id, name: p.id, status: 'pending', error: null };
+      });
</code_context>

<issue_to_address>
**issue (bug_risk):** Potential for duplicate provider IDs in testingProviders array.

Duplicates may occur if fetchProviderStatus is triggered multiple times before completion. To prevent this, ensure IDs are unique in testingProviders, such as by checking before insertion or using a Set.
</issue_to_address>

### Comment 2
<location> `dashboard/src/views/ProviderPage.vue:683` </location>
<code_context>
+    },
+
+    async testSingleProvider(provider) {
+      if (this.isProviderTesting(provider.id)) return;
+
+      this.testingProviders.push(provider.id);
</code_context>

<issue_to_address>
**suggestion:** Silent return may lead to lack of user feedback.

Consider notifying the user when a test is already in progress to enhance user experience.

```suggestion
      if (this.isProviderTesting(provider.id)) {
        this.$message && this.$message.warning
          ? this.$message.warning('该服务商正在测试中,请稍候。')
          : alert('该服务商正在测试中,请稍候。');
        return;
      }
```
</issue_to_address>

### Comment 3
<location> `dashboard/src/components/shared/ItemCard.vue:31` </location>
<code_context>
         variant="outlined"
         color="error"
         rounded="xl"
+        :disabled="loading"
         @click="$emit('delete', item)"
       >
</code_context>

<issue_to_address>
**question:** Disabling buttons based on loading state may block unrelated actions.

Review which actions truly need to be disabled during loading; actions like copy may not need to be blocked for a better user experience.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

variant="outlined"
color="error"
rounded="xl"
:disabled="loading"
Copy link
Contributor

Choose a reason for hiding this comment

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

question: 基于加载状态禁用按钮可能会阻塞不相关的操作。

审查在加载期间真正需要禁用的操作;像复制这样的操作可能不需要被阻塞,以获得更好的用户体验。

Original comment in English

question: Disabling buttons based on loading state may block unrelated actions.

Review which actions truly need to be disabled during loading; actions like copy may not need to be blocked for a better user experience.

@RC-CHN
Copy link
Member Author

RC-CHN commented Oct 13, 2025

才想起来把vite代理监听127.0.0.1推上去了( 不过这也是个之前就想做的更改 在我的网络环境下填写localhost可能会代理向ipv6而非框架正监听的ipv4导致不可达,可以考虑更改为127.0.0.1?

@Soulter Soulter merged commit 93fcac4 into AstrBotDevs:master Oct 13, 2025
5 checks passed
@RC-CHN RC-CHN deleted the test_single_provider branch October 13, 2025 05:59
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