菜单「检查更新」第一次点击无任何反馈,第二次点击才提示「正在下载」
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 401
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
### 问题描述 / What happened
**实际行为**
客户端有可用新版本时,点击左上角菜单 → 检查更新:**第一次点击没有任何反馈**(沉默持续整个补丁下载时长,可达数分钟);随后再点一次「检查更新」,才立刻弹出「正在下载新版本,请稍后…」toast。
**期望行为**
点击「检查更新」后立即有反馈(检查中提示);检测到新版本进入下载时,应立刻告知「正在下载」,而不是等下载完成后 toast 才出现。
**根因分析(代码级定位,供参考)**
1. 渲染层 `apps/desktop/src/renderer/lib/checkForUpdateWithToast.ts`:`await window.electronAPI.checkForUpdate()` 之后才根据返回值弹 toast,await 期间没有任何 loading 态。
2. 主进程 `apps/desktop/src/main/updateService.ts` 的 `update-check-now` handler(约 L2144):status 不是 `downloading / superseding / ready` 时走 `await checkForUpdate()`。
3. `checkForUpdate()` → `doCheckForUpdate()` 会一直 await 到**整个补丁下载完成**(fetchManifest → 版本比较 → `setStatus('downloading')` → `await download(...)` → 写 patch-info)才返回。
4. 结果:第一次点击恰好是「触发下载」的那次,IPC 响应要等下载完才回来 → toast 迟迟不弹;第二次点击时 `currentStatus === 'downloading'`,handler 走短路分支 `return { result: 'downloading' }` 秒回 → 立即弹「正在下载」。
5. 下载期间也没有其他可见反馈:侧边栏 UpdateBanner 在 `checking` / `downloading` 态不渲染(`UpdateBanner.tsx` 约 L328 直接 return null);`app-update-progress` 进度事件只有启动 splash 流程消费。
`update-check-now` 短路分支的注释本身已承认该问题:"we don't want the user to wait for an entire download just to see the toast"——但该保护只对第二次及以后的点击生效;第一次点击(真正发起下载那次)依然要等全程。
### 环境 / Environment
- Cindy 版本或 commit / version or commit: 桌面正式版(根因分析基于 main @ f6c037cc9 的代码)
- 平台与版本 / platform & OS version: Windows 11
- 安装方式 / install method: 官方安装包(packaged)
### 复现步骤 / Steps to reproduce
1. 客户端有可用新版本(线上 manifest 版本 > 当前版本),且当前不在下载中;
2. 点击左上角菜单 → 检查更新;
3. 实际:无任何提示(沉默到补丁下载完成,可达数分钟);
4. 再点一次「检查更新」→ 立刻弹出「正在下载新版本,请稍后…」。
### 日志与截图 / Logs & screenshots
未附日志;根因已在代码层面定位(见问题描述)。关键路径:`update-check-now`(updateService.ts)→ `checkForUpdate()` → `doCheckForUpdate()` await 整个下载;第二次点击命中 `currentStatus === 'downloading'` 短路分支立即返回 'downloading'。
Contributor guide
Research direction
Start with apps/desktop/src/renderer/lib/checkForUpdateWithToast.ts and apps/desktop/src/main/updateService.ts, especially the update-check-now handler and checkForUpdate flow. Review apps/desktop/src/renderer/components/UpdateBanner.tsx and the app-update-progress event usage to understand existing feedback. Done means the first update-check click immediately shows checking or downloading feedback instead of waiting for the patch download to finish.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, typescript
- Domain
- desktop, release
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100