Conversation
…xperience (#177) - Set PRODUCTION URL to China mirror (http://release.echoplayer.z2blog.com/api/releases) - Add CN_ALPHA and CN_BETA URLs for Chinese users' pre-release channels - Simplify AppUpdater logic to use PRODUCTION URL for all stable releases - Maintain GitHub URLs for non-CN users in test mode - Improve logging to distinguish China mirror usage
…gger without description (#179) - Add logic to automatically fetch release description from GitHub API when manual workflow trigger doesn't provide release_body - Fallback to informative default message if release not found or has no description - Maintain existing behavior when release_body is explicitly provided - Improve user experience by eliminating need to manually copy descriptions
WalkthroughAdds prerelease trigger and description-fetch fallback to the GitHub Actions workflow. Updates feed URLs with CN-specific endpoints. Modifies AppUpdater to route feeds based on IP-derived country, selecting CN alpha/beta or production feeds for China users while preserving GitHub-based logic for others; production always uses production feed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant App as AppUpdater
participant IP as IP Service
participant GH as GitHub Releases
participant CN as CN Release API
User->>App: checkForUpdates(mode, channel, testPlan?)
App->>IP: _getIpCountry()
IP-->>App: countryCode
alt mode == production
App->>CN: setFeedURL(FeedUrl.PRODUCTION)
App-->>User: proceed with production updates
else mode == latest (test plan latest)
alt countryCode == CN
App->>CN: setFeedURL(FeedUrl.PRODUCTION)
App-->>User: using production releases for CN user
else Non-CN
App->>GH: setFeedURL(FeedUrl.GITHUB_LATEST)
App-->>User: using GitHub latest releases
end
else mode == prerelease (specific tag)
alt countryCode == CN
App->>CN: setFeedURL(FeedUrl.CN_ALPHA or FeedUrl.CN_BETA)
App-->>User: using CN prerelease feed
else Non-CN
App->>GH: compute prerelease URL from tag
App->>GH: setFeedURL(prerelease URL)
App-->>User: using GitHub prerelease feed
opt if missing prerelease URL
App->>CN: setFeedURL(FeedUrl.PRERELEASE_LOWEST)
App-->>User: fallback to lowest prerelease, channel LATEST
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (8)
.github/workflows/sync-release-to-gitcode.yml (2)
399-415: Uploader step: minor hardening.
chmod +xis unnecessary since you invoke vianode(harmless though).- Fail fast: enable
set -eo pipefailto surface partial failures.- # Make upload script executable - chmod +x ./scripts/upload-assets.js + # Fail-fast in this step + set -eo pipefail
236-239: Avoid putting the GitCode token in URLs — use an Authorization header.Query params like ?access_token= can leak in logs/proxies; GitCode supports Authorization: Bearer (and also PRIVATE-TOKEN), so send the token in a header instead. (docs.gitcode.com)
File: .github/workflows/sync-release-to-gitcode.yml — lines: 236-239 (also applies to: 264-267, 318-319, 366-366)
- "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/tags?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}") + -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \ + "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/tags") @@ - "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/tags/${{ steps.release.outputs.tag_name }}?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}") + -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \ + "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/tags/${{ steps.release.outputs.tag_name }}") @@ - "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}") + -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \ + "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases") @@ - "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/${{ steps.release.outputs.tag_name }}?access_token=${{ secrets.GITCODE_ACCESS_TOKEN }}") + -H "Authorization: Bearer ${{ secrets.GITCODE_ACCESS_TOKEN }}" \ + "$GITCODE_API_BASE/repos/$GITCODE_OWNER/$GITCODE_REPO/releases/${{ steps.release.outputs.tag_name }}")src/main/services/AppUpdater.ts (6)
117-139: IP-based routing: privacy default and UA.
- Defaulting to 'CN' on any error will misroute most users when ipinfo fails. Default to non‑CN (or persist last known).
- Reuse your existing generateUserAgent() for consistency.
- Log with object-literal payload per project guideline.
private async _getIpCountry() { try { // add timeout using AbortController const controller = new AbortController() const timeoutId = setTimeout(() => controller.abort(), 5000) - const ipinfo = await fetch('https://ipinfo.io/json', { + const ipinfo = await fetch('https://ipinfo.io/json', { signal: controller.signal, headers: { - 'User-Agent': - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', + 'User-Agent': generateUserAgent(), 'Accept-Language': 'en-US,en;q=0.9' } }) clearTimeout(timeoutId) const data = await ipinfo.json() - return data.country || 'CN' + return (data.country || 'ZZ').toUpperCase() } catch (error) { - logger.error('Failed to get ipinfo:', error) - return 'CN' + logger.error('Failed to get ipinfo', { error }) + return 'ZZ' } }
172-193: CN routing gated on release presence; CN users may never hit CN feeds.
if (testPlan && release)guards the CN prerelease path. When GitHub is blocked or rate‑limited (common in CN),releaseis null and CN users fall through to production feeds. Move CN selection to depend only ontestPlanandchannel, not onrelease.Apply:
private async _setFeedUrl( channel: UpgradeChannel, testPlan: boolean, release: GithubReleaseInfo | null = null ) { logger.info('Setting feed URL - testPlan:', testPlan) - - // 获取IP地址归属地 - const ipCountry = await this._getIpCountry() - logger.info('Detected IP country:', ipCountry) - const isChinaUser = ipCountry.toLowerCase() === 'cn' + const ipCountry = await this._getIpCountry() + logger.info('Detected IP country', { ipCountry }) + const isChinaUser = ipCountry.toLowerCase() === 'cn' if (channel === UpgradeChannel.LATEST) { this.autoUpdater.channel = UpgradeChannel.LATEST - if (isChinaUser) { - this.autoUpdater.setFeedURL(FeedUrl.PRODUCTION) - logger.info('Using production releases for CN user') - } else { - this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST) - logger.info('Using GitHub latest releases for test plan') - } + this.autoUpdater.setFeedURL(isChinaUser ? FeedUrl.PRODUCTION : FeedUrl.GITHUB_LATEST) + logger.info(isChinaUser ? 'Using production releases for CN user' : 'Using GitHub latest releases for non-CN user') return }
220-230: Production mode feed selection: simplify and fix double logging.You set PRODUCTION, then overwrite with GITHUB_LATEST for non‑CN. Make it explicit and log once.
- // Production mode - this.autoUpdater.channel = UpgradeChannel.LATEST - this.autoUpdater.setFeedURL(FeedUrl.PRODUCTION) - logger.info('Using production feed URL') - - logger.info('Detected IP country:', ipCountry) - if (ipCountry.toLowerCase() !== 'cn') { - this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST) - logger.info('Using GitHub releases for non-CN region') - } + // Production mode + this.autoUpdater.channel = UpgradeChannel.LATEST + if (isChinaUser) { + this.autoUpdater.setFeedURL(FeedUrl.PRODUCTION) + logger.info('Using production feed URL for CN region') + } else { + this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST) + logger.info('Using GitHub releases for non-CN region') + }
76-115: Sorting by published_at may be NaN; fall back to created_at.If
published_atis null (drafty prereleases),getTime()is NaN and sort becomes unstable.- const release = matchingReleases.sort( - (a, b) => - new Date(b.published_at || '').getTime() - new Date(a.published_at || '').getTime() - )[0] + const ts = (r: GithubReleaseInfo) => + new Date(r.published_at || r.created_at).getTime() + const release = matchingReleases.sort((a, b) => ts(b) - ts(a))[0]
37-45: Logging style: use object-literal payloads; align with loggerService convention.Several calls pass non‑object second args or string interpolation. Prefer
logger.*('msg', { key })consistently and consider centralizing onloggerServiceper project guidelines.Do you want a sweep patch updating the touched lines to
logger.*('...', { ... })and switching to the shared logger service in main?Also applies to: 47-50, 66-67, 98-101, 109-114, 177-183, 186-193, 201-209, 213-216, 223-229, 239-245, 282-289
256-270: Avoid unnecessary GitHub API when routing to CN.You always query GitHub before deciding region. For CN, this adds latency/failure. Consider resolving IP country first and skipping
_getPreReleaseVersionFromGithubwhen CN.I can propose a small refactor to fetch
ipCountryincheckForUpdates()and passisChinaUserto_setFeedUrl()to short‑circuit GH calls.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/sync-release-to-gitcode.yml(4 hunks)packages/shared/config/constant.ts(1 hunks)src/main/services/AppUpdater.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: 在组件/Hook 中避免硬编码尺寸和时长,优先使用 useTheme() 的 token(如 motionDurationMid、borderRadiusSM/MD 等)或集中定义的样式变量
定制 antd 组件样式时优先使用 styled-components(styled(Component) 包装),避免通过全局 SCSS 与全局 className 覆盖
项目使用 Zustand 结合 Immer 中间件与自定义中间件栈(持久化、DevTools、订阅选择器)进行状态管理
Files:
src/main/services/AppUpdater.tspackages/shared/config/constant.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{tsx,ts}: Zustand 必须在组件/Hook 顶层使用 selector(useStore(selector));禁止在 useMemo/useEffect 内部调用 store Hook
避免使用返回对象的 useStore 选择器(如 useStore(s => ({ a: s.a, b: s.b }))),应使用单字段选择器或配合 shallow 比较器
Files:
src/main/services/AppUpdater.tspackages/shared/config/constant.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: 统一使用 loggerService 记录日志,禁止使用 console
logger 使用示例:logger.error('Error in :', { error }); 第二个参数必须是对象字面量 {}
Files:
src/main/services/AppUpdater.tspackages/shared/config/constant.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test (macos-latest, 20)
- GitHub Check: test (windows-latest, 20)
- GitHub Check: test (ubuntu-latest, 20)
🔇 Additional comments (2)
.github/workflows/sync-release-to-gitcode.yml (1)
5-5: Triggering on prereleases is good. Ensure idempotency.This will fire on both prereleased and later published events; your existence checks should prevent duplicates. Looks good.
If you’ve seen duplicate runs still creating noise, consider adding a run-concurrency group keyed by tag to collapse redundant executions. Want a snippet?
packages/shared/config/constant.ts (1)
27-33: Switch updater feeds to HTTPS (critical — MITM risk)HTTP update feeds allow MITM metadata/URL rewriting — change PRODUCTION/CN_BETA/CN_ALPHA to HTTPS. (owasp.org)
- PRODUCTION = 'http://release.echoplayer.z2blog.com/api/releases', + PRODUCTION = 'https://release.echoplayer.z2blog.com/api/releases', @@ - CN_BETA = 'http://release.echoplayer.z2blog.com/api/beta/releases', - CN_ALPHA = 'http://release.echoplayer.z2blog.com/api/alpha/releases' + CN_BETA = 'https://release.echoplayer.z2blog.com/api/beta/releases', + CN_ALPHA = 'https://release.echoplayer.z2blog.com/api/alpha/releases'If HTTPS isn’t available, hard‑pin SHA512 and enforce strict signature verification, or front these endpoints with a TLS‑terminating CDN (or adopt TUF-style signed metadata). (arxiv.org)
I couldn't reach the HTTPS endpoints during this check — confirm release.echoplayer.z2blog.com serves TLS or apply the mitigations above. ()
| # Handle release body - fetch from GitHub if not provided | ||
| if [ -z "${{ github.event.inputs.release_body }}" ]; then | ||
| echo "📄 No release description provided, fetching from GitHub API..." | ||
|
|
||
| release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
| "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}") | ||
|
|
||
| if [ "$(echo "$release_response" | jq -r '.message // empty')" = "Not Found" ]; then | ||
| echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description" | ||
| github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}" | ||
| else | ||
| github_release_body=$(echo "$release_response" | jq -r '.body // empty') | ||
| if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then | ||
| echo "⚠️ No description found in GitHub release, using default description" | ||
| github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}" | ||
| else | ||
| echo "✅ Successfully fetched release description from GitHub" | ||
| fi | ||
| fi | ||
|
|
||
| echo "release_body<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$github_release_body" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "📝 Using provided release description" | ||
| echo "release_body<<EOF" >> $GITHUB_OUTPUT | ||
| echo "${{ github.event.inputs.release_body }}" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
| fi |
There was a problem hiding this comment.
🧹 Nitpick
Robust fallback for release_body; add HTTP code check and safer EOF delimiter.
Current logic assumes a successful 200. If rate‑limited or permissioned, jq parses an HTML/JSON error and we might emit an empty body. Also, the EOF delimiter could collide with content edge‑cases.
- Check curl HTTP code and branch on non‑200.
- Use a unique heredoc delimiter.
Apply:
- release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
- "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}")
+ release_response=$(curl -s -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
+ "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}")
+ http_code="${release_response: -3}"
+ release_json="${release_response%???}"
- if [ "$(echo "$release_response" | jq -r '.message // empty')" = "Not Found" ]; then
+ if [ "$http_code" != "200" ] || [ "$(echo "$release_json" | jq -r '.message // empty')" = "Not Found" ]; then
echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
- github_release_body=$(echo "$release_response" | jq -r '.body // empty')
+ github_release_body=$(echo "$release_json" | jq -r '.body // empty')
if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then
echo "⚠️ No description found in GitHub release, using default description"
github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}"
else
echo "✅ Successfully fetched release description from GitHub"
fi
fi
- echo "release_body<<EOF" >> $GITHUB_OUTPUT
- echo "$github_release_body" >> $GITHUB_OUTPUT
- echo "EOF" >> $GITHUB_OUTPUT
+ delim="RELEASE_BODY_$(uuidgen)"
+ {
+ echo "release_body<<$delim"
+ echo "$github_release_body"
+ echo "$delim"
+ } >> "$GITHUB_OUTPUT"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Handle release body - fetch from GitHub if not provided | |
| if [ -z "${{ github.event.inputs.release_body }}" ]; then | |
| echo "📄 No release description provided, fetching from GitHub API..." | |
| release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}") | |
| if [ "$(echo "$release_response" | jq -r '.message // empty')" = "Not Found" ]; then | |
| echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description" | |
| github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}" | |
| else | |
| github_release_body=$(echo "$release_response" | jq -r '.body // empty') | |
| if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then | |
| echo "⚠️ No description found in GitHub release, using default description" | |
| github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}" | |
| else | |
| echo "✅ Successfully fetched release description from GitHub" | |
| fi | |
| fi | |
| echo "release_body<<EOF" >> $GITHUB_OUTPUT | |
| echo "$github_release_body" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "📝 Using provided release description" | |
| echo "release_body<<EOF" >> $GITHUB_OUTPUT | |
| echo "${{ github.event.inputs.release_body }}" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| fi | |
| # Handle release body - fetch from GitHub if not provided | |
| if [ -z "${{ github.event.inputs.release_body }}" ]; then | |
| echo "📄 No release description provided, fetching from GitHub API..." | |
| release_response=$(curl -s -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.tag_name }}") | |
| http_code="${release_response: -3}" | |
| release_json="${release_response%???}" | |
| if [ "$http_code" != "200" ] || [ "$(echo "$release_json" | jq -r '.message // empty')" = "Not Found" ]; then | |
| echo "⚠️ Release not found for tag: ${{ github.event.inputs.tag_name }}, using default description" | |
| github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}" | |
| else | |
| github_release_body=$(echo "$release_json" | jq -r '.body // empty') | |
| if [ -z "$github_release_body" ] || [ "$github_release_body" = "null" ]; then | |
| echo "⚠️ No description found in GitHub release, using default description" | |
| github_release_body="Release created via manual trigger for tag ${{ github.event.inputs.tag_name }}" | |
| else | |
| echo "✅ Successfully fetched release description from GitHub" | |
| fi | |
| fi | |
| delim="RELEASE_BODY_$(uuidgen)" | |
| { | |
| echo "release_body<<$delim" | |
| echo "$github_release_body" | |
| echo "$delim" | |
| } >> "$GITHUB_OUTPUT" | |
| else | |
| echo "📝 Using provided release description" | |
| echo "release_body<<EOF" >> $GITHUB_OUTPUT | |
| echo "${{ github.event.inputs.release_body }}" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| fi |
🤖 Prompt for AI Agents
.github/workflows/sync-release-to-gitcode.yml lines 65-93: the current
fetch-from-GitHub logic assumes a 200 response and uses a generic EOF which can
collide with content; update the curl call to capture both body and HTTP status
(e.g., curl -s -w "%{http_code}" ...) and parse/branch only when the status
equals 200 otherwise treat as not-found/error and set the default release_body;
also switch the GITHUB_OUTPUT heredoc delimiter to a unique token (e.g.,
RELEASE_BODY_EOF) to avoid collisions and ensure you only run jq on a successful
JSON response.
| if (testPlan && release) { | ||
| const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}` | ||
| if (preReleaseUrl) { | ||
| this.autoUpdater.setFeedURL(preReleaseUrl) | ||
| if (isChinaUser) { | ||
| // 为中国用户使用对应的预发布渠道 | ||
| const chineseFeedUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA | ||
| this.autoUpdater.setFeedURL(chineseFeedUrl) | ||
| this.autoUpdater.channel = channel | ||
| logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`) | ||
| return | ||
| } | ||
| logger.info(`Using Chinese pre-release URL: ${chineseFeedUrl} with channel: ${channel}`) | ||
| } else { | ||
| const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}` | ||
| if (preReleaseUrl) { | ||
| this.autoUpdater.setFeedURL(preReleaseUrl) | ||
| this.autoUpdater.channel = channel | ||
| logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`) | ||
| return | ||
| } | ||
|
|
||
| // if no prerelease url, use lowest prerelease version to avoid error | ||
| logger.warn('No prerelease URL found, falling back to lowest prerelease version') | ||
| this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST) | ||
| this.autoUpdater.channel = UpgradeChannel.LATEST | ||
| // if no prerelease url, use lowest prerelease version to avoid error | ||
| logger.warn('No prerelease URL found, falling back to lowest prerelease version') | ||
| this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST) | ||
| this.autoUpdater.channel = UpgradeChannel.LATEST | ||
| } |
There was a problem hiding this comment.
Uncouple CN prerelease from GitHub availability; add proper fallback for non‑CN.
- Always route CN test plans to CN_ALPHA/CN_BETA feeds regardless of GitHub.
- For non‑CN, use GitHub prerelease when
releaseis available; otherwise fall back toPRERELEASE_LOWEST.
- if (testPlan && release) {
- if (isChinaUser) {
- // 为中国用户使用对应的预发布渠道
- const chineseFeedUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA
- this.autoUpdater.setFeedURL(chineseFeedUrl)
- this.autoUpdater.channel = channel
- logger.info(`Using Chinese pre-release URL: ${chineseFeedUrl} with channel: ${channel}`)
- } else {
- const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
- if (preReleaseUrl) {
- this.autoUpdater.setFeedURL(preReleaseUrl)
- this.autoUpdater.channel = channel
- logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`)
- return
- }
-
- // if no prerelease url, use lowest prerelease version to avoid error
- logger.warn('No prerelease URL found, falling back to lowest prerelease version')
- this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
- this.autoUpdater.channel = UpgradeChannel.LATEST
- }
- return
- }
+ if (testPlan) {
+ if (isChinaUser) {
+ const cnUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA
+ this.autoUpdater.setFeedURL(cnUrl)
+ this.autoUpdater.channel = channel
+ logger.info('Using Chinese pre-release URL', { channel, url: cnUrl })
+ return
+ }
+ if (release) {
+ const ghUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}`
+ this.autoUpdater.setFeedURL(ghUrl)
+ this.autoUpdater.channel = channel
+ logger.info('Using GitHub pre-release URL', { channel, url: ghUrl })
+ return
+ }
+ logger.warn('No prerelease info available; falling back to lowest prerelease version')
+ this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
+ this.autoUpdater.channel = UpgradeChannel.LATEST
+ return
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (testPlan && release) { | |
| const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}` | |
| if (preReleaseUrl) { | |
| this.autoUpdater.setFeedURL(preReleaseUrl) | |
| if (isChinaUser) { | |
| // 为中国用户使用对应的预发布渠道 | |
| const chineseFeedUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA | |
| this.autoUpdater.setFeedURL(chineseFeedUrl) | |
| this.autoUpdater.channel = channel | |
| logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`) | |
| return | |
| } | |
| logger.info(`Using Chinese pre-release URL: ${chineseFeedUrl} with channel: ${channel}`) | |
| } else { | |
| const preReleaseUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}` | |
| if (preReleaseUrl) { | |
| this.autoUpdater.setFeedURL(preReleaseUrl) | |
| this.autoUpdater.channel = channel | |
| logger.info(`Using pre-release URL: ${preReleaseUrl} with channel: ${channel}`) | |
| return | |
| } | |
| // if no prerelease url, use lowest prerelease version to avoid error | |
| logger.warn('No prerelease URL found, falling back to lowest prerelease version') | |
| this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST) | |
| this.autoUpdater.channel = UpgradeChannel.LATEST | |
| // if no prerelease url, use lowest prerelease version to avoid error | |
| logger.warn('No prerelease URL found, falling back to lowest prerelease version') | |
| this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST) | |
| this.autoUpdater.channel = UpgradeChannel.LATEST | |
| } | |
| if (testPlan) { | |
| if (isChinaUser) { | |
| const cnUrl = channel === UpgradeChannel.ALPHA ? FeedUrl.CN_ALPHA : FeedUrl.CN_BETA | |
| this.autoUpdater.setFeedURL(cnUrl) | |
| this.autoUpdater.channel = channel | |
| logger.info('Using Chinese pre-release URL', { channel, url: cnUrl }) | |
| return | |
| } | |
| if (release) { | |
| const ghUrl = `https://github.com/mkdir700/EchoPlayer/releases/download/${release.tag_name}` | |
| this.autoUpdater.setFeedURL(ghUrl) | |
| this.autoUpdater.channel = channel | |
| logger.info('Using GitHub pre-release URL', { channel, url: ghUrl }) | |
| return | |
| } | |
| logger.warn('No prerelease info available; falling back to lowest prerelease version') | |
| this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST) | |
| this.autoUpdater.channel = UpgradeChannel.LATEST | |
| return | |
| } |
🤖 Prompt for AI Agents
In src/main/services/AppUpdater.ts around lines 196-216, the current logic ties
selecting the Chinese CN_ALPHA/CN_BETA feed to the presence of a GitHub
`release` and uses a redundant truthy check for the constructed `preReleaseUrl`;
change it so CN test plans always set the feed URL to CN_ALPHA or CN_BETA and
return immediately, and for non-China users check if `release` exists — if so
set the GitHub prerelease URL and return, otherwise log the warning and fall
back to FeedUrl.PRERELEASE_LOWEST with channel UpgradeChannel.LATEST. Ensure you
remove the unnecessary `if (preReleaseUrl)` truthy check and instead test `if
(release)` before using the GitHub URL.
Summary by CodeRabbit