Repository navigation
Conversation
res.data.prediction.active 是 0-1 概率:active === 0(已归档/不活跃
仓库)是 API 的成功结果。此前的 truthy 守卫把 0 当成获取失败显示
"failed to fetch data" 错误,而非显示 0% 进度条。{predict && ...}
的 truthy 渲染守卫同理隐藏了 0% 结果区。
改为 typeof === 'number' 判定 + predict !== null 渲染守卫。
|
@zjncs is attempting to deploy a commit to the codersett's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This branch has not been deployed
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.
Problem
Experience.tsx:54treatsactive === 0as a fetch failure:The live endpoint
POST /api/beta/predictreturns{"prediction":{"active":0.8265}}— a 0-1 probability. When the model returns exactly0(dead/archived repo), the truthy guard fails and a successful request renders the "failed to fetch data" error instead of a 0% progress bar.Secondary falsy-zero:
{predict && ...}hides the result section whenpredictis0.Fix
typeof res?.data?.prediction?.active === 'number'(0 is a valid number result){predict !== null && ...}(0 must display)Verification
New
Experience.test.tsx: mockgetDataresolving{status:200, data:{prediction:{active:0}}}, assert the error message does NOT appear. RED before (truthy guard fails on 0, error shows), GREEN after.Risk
None — 0 is now correctly rendered as a 0% bar instead of an error message.