feat: 下载进度增加跳转到cdk按钮 - #339
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
嘿——我发现了 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>帮助我变得更有用!请对每条评论点击 👍 或 👎,我会利用反馈来改进审查结果。
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Owner
|
有点太硬了广告,要不 ”其他渠道“? |
Contributor
Author
改了再看看效果图 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
当5秒下载速度都低于 1024 KB/s 、没有填写cdk、interface配置了mirror,则显示加速下载按钮,点击后跳转到mxu-设置-更新栏
opus5.0
Sourcery 总结
引导持续下载速度较慢的用户前往更新设置,以便配置基于 CDK 的加速功能。
新功能:
改进:
杂项:
Original summary in English
Sourcery 摘要
引导持续下载速度较慢的用户前往更新设置,在那里配置 CDK 加速。
新功能:
错误修复:
增强功能:
Original summary in English
Summary by Sourcery
Guide users with sustained slow downloads toward update settings where they can configure CDK acceleration.
New Features:
Bug Fixes:
Enhancements: