Skip to content

feat: 下载进度增加跳转到cdk按钮 - #339

Merged
MistEO merged 3 commits into
MistEO:mainfrom
zmdyy0318:perf/2026090101
Sep 4, 2026
Merged

feat: 下载进度增加跳转到cdk按钮#339
MistEO merged 3 commits into
MistEO:mainfrom
zmdyy0318:perf/2026090101

Conversation

@zmdyy0318

@zmdyy0318 zmdyy0318 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

当5秒下载速度都低于 1024 KB/s 、没有填写cdk、interface配置了mirror,则显示加速下载按钮,点击后跳转到mxu-设置-更新栏
opus5.0

image image

Sourcery 总结

引导持续下载速度较慢的用户前往更新设置,以便配置基于 CDK 的加速功能。

新功能:

  • 当持续下载速度较低且未配置 CDK 时,显示慢速下载加速提示。
  • 允许用户直接从下载进度界面跳转到更新设置部分,并聚焦于 CDK 输入框。

改进:

  • 添加跨页面导航状态,使设置页面能够打开并滚动到指定部分。

杂项:

  • 为支持的语言添加本地化加速提示文本。
Original summary in English

Sourcery 摘要

引导持续下载速度较慢的用户前往更新设置,在那里配置 CDK 加速。

新功能:

  • 当基于镜像的下载在未配置 CDK 的情况下持续低于速度阈值时,显示本地化的下载缓慢提示。
  • 允许用户从下载进度页面直接跳转到更新设置中的 CDK 字段。

错误修复:

  • 正确映射 Rust 后端下载进度事件中的 snake_case 字段。

增强功能:

  • 跟踪持续的下载缓慢时段,避免在启动阶段短暂变慢时显示提示。
  • 添加跨页面导航状态,用于定位并滚动到设置中的指定部分。
Original summary in English

Summary by Sourcery

Guide users with sustained slow downloads toward update settings where they can configure CDK acceleration.

New Features:

  • Show a localized slow-download prompt when a mirror-backed download remains below the speed threshold without a configured CDK.
  • Allow users to jump from download progress directly to the update settings and CDK field.

Bug Fixes:

  • Correctly map snake_case download progress event fields from the Rust backend.

Enhancements:

  • Track sustained slow-download periods to avoid showing the prompt for brief startup slowdowns.
  • Add cross-page navigation state for targeting and scrolling to a settings section.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

嘿——我发现了 2 个问题

给 AI 代理的提示
请处理本次代码审查中的评论:

## 个别评论

### 评论 1
<location path="src/stores/appStore.ts" line_range="2048-2056" />
<code_context>
     downloadSavePath: null,
-    setDownloadStatus: (status) => set({ downloadStatus: status }),
-    setDownloadProgress: (progress) => set({ downloadProgress: progress }),
+    slowDownloadSince: null,
+    // 每次状态变化都重置慢速计时:'downloading' 表示新一轮下载开始,其余状态表示下载已结束
+    setDownloadStatus: (status) => set({ downloadStatus: status, slowDownloadSince: null }),
+    setDownloadProgress: (progress) =>
+      set((state) => ({
+        downloadProgress: progress,
+        slowDownloadSince:
+          progress && progress.speed < SLOW_DOWNLOAD_SPEED_BPS
+            ? (state.slowDownloadSince ?? Date.now())
+            : null,
+      })),
</code_context>
<issue_to_address>
**问题 (bug_risk):** 慢速下载计时器会在写入初始的零速率进度记录时启动,此时 `getUpdateSavePath` 和实际下载尚未开始。如果下载设置过程耗时至少五秒,那么第一次真实进度更新会被视为已经持续慢速五秒,即使测得的下载速度尚未持续低于阈值五秒,加速按钮也会立即出现。

**触发条件:** 选择保存路径或初始化下载耗时五秒或更长时间。

**建议修复:** 仅在下载实际开始后启动 `slowDownloadSince`,或者忽略速度为零的合成初始进度记录。
</issue_to_address>

### 评论 2
<location path="src/components/UpdateInfoCard.tsx" line_range="160-177" />
<code_context>
   );
 }

+/**
+ * 跳转到设置页的更新分区。
+ * 调用方通常还需要自行关闭当前的气泡/弹窗,否则会盖住设置页。
+ */
+export function useOpenUpdateSettings() {
+  const setSettingsTargetSection = useAppStore((s) => s.setSettingsTargetSection);
+  const setCurrentPage = useAppStore((s) => s.setCurrentPage);
+
+  return useCallback(() => {
+    setSettingsTargetSection('update');
+    setCurrentPage('settings');
+  }, [setSettingsTargetSection, setCurrentPage]);
+}
+
+/**
</code_context>
<issue_to_address>
**问题 (bug_risk):** 该提示只会在渲染期间检查经过的时间,并不会为五秒阈值设置计时器。如果下载以低速停滞期间进度事件停止,那么达到阈值后不会发生重新渲染,加速按钮也不会出现,直到某个无关的状态更新发生。

**触发条件:** 下载停滞,并且在 `SLOW_DOWNLOAD_DURATION_MS` 之后没有后续进度事件或其他组件更新。

**建议修复:** 使用计时器或定时器间隔,在达到阈值时使组件失效更新;当下载不再处于慢速状态或组件卸载时清除该计时器。
</issue_to_address>

Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享它们 ✨
帮助我变得更有用!请对每条评论点击 👍 或 👎,我会利用反馈来改进审查结果。
Original comment in English

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/stores/appStore.ts" line_range="2048-2056" />
<code_context>
     downloadSavePath: null,
-    setDownloadStatus: (status) => set({ downloadStatus: status }),
-    setDownloadProgress: (progress) => set({ downloadProgress: progress }),
+    slowDownloadSince: null,
+    // 每次状态变化都重置慢速计时:'downloading' 表示新一轮下载开始,其余状态表示下载已结束
+    setDownloadStatus: (status) => set({ downloadStatus: status, slowDownloadSince: null }),
+    setDownloadProgress: (progress) =>
+      set((state) => ({
+        downloadProgress: progress,
+        slowDownloadSince:
+          progress && progress.speed < SLOW_DOWNLOAD_SPEED_BPS
+            ? (state.slowDownloadSince ?? Date.now())
+            : null,
+      })),
</code_context>
<issue_to_address>
**issue (bug_risk):** The slow-download timer starts when the initial zero-speed progress record is written, before `getUpdateSavePath` and the actual download begin. If download setup takes at least five seconds, the first real progress update is treated as having been slow for five seconds and the acceleration button appears immediately even when the measured download speed has not been low for five seconds.

**Triggers:** When choosing the save path or initializing the download takes five seconds or longer.

**Suggested fix:** Start `slowDownloadSince` only after the download has actually started or ignore the synthetic initial progress record with speed zero.
</issue_to_address>

### Comment 2
<location path="src/components/UpdateInfoCard.tsx" line_range="160-177" />
<code_context>
   );
 }

+/**
+ * 跳转到设置页的更新分区。
+ * 调用方通常还需要自行关闭当前的气泡/弹窗,否则会盖住设置页。
+ */
+export function useOpenUpdateSettings() {
+  const setSettingsTargetSection = useAppStore((s) => s.setSettingsTargetSection);
+  const setCurrentPage = useAppStore((s) => s.setCurrentPage);
+
+  return useCallback(() => {
+    setSettingsTargetSection('update');
+    setCurrentPage('settings');
+  }, [setSettingsTargetSection, setCurrentPage]);
+}
+
+/**
</code_context>
<issue_to_address>
**issue (bug_risk):** The hint checks the elapsed time only during renders; it does not schedule a timer for the five-second threshold. If progress events stop while the download is stalled at a low speed, no render occurs after the threshold and the acceleration button never appears until some unrelated state update happens.

**Triggers:** When the download stalls and no subsequent progress event or other component update occurs after `SLOW_DOWNLOAD_DURATION_MS`.

**Suggested fix:** Use a timer or interval that invalidates the component at the threshold, and clear it when the download is no longer slow or the component unmounts.
</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.

Comment thread src/stores/appStore.ts
Comment thread src/components/UpdateInfoCard.tsx
@MistEO

MistEO commented Sep 2, 2026

Copy link
Copy Markdown
Owner

有点太硬了广告,要不 ”其他渠道“?

@zmdyy0318

Copy link
Copy Markdown
Contributor Author

有点太硬了广告,要不 ”其他渠道“?

改了再看看效果图

@MistEO MistEO changed the title perf: 下载进度增加跳转到cdk按钮 feat: 下载进度增加跳转到cdk按钮 Sep 4, 2026
@MistEO
MistEO merged commit fb05f97 into MistEO:main Sep 4, 2026
9 checks passed
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