Repository navigation
Conversation
Contributor
Author
|
Superseded by #401, which implements the same fix (keep the parent→child Promise result, end the loading state on failure, show a Retry action, and guard against stale prefetch overwriting current state) and predates this PR. Closing this to avoid stacking duplicate fixes on #396. If #401 stalls, I'm happy to rebase this branch ( |
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.
修复 #396:实验/案例详情加载失败后永久转圈,错误与重试都不显示。
根因
父组件把真实的异步结果丢掉了:
EvaluationCenter.loadDetail()失败时(ok:false,或ok:true但data为空)只return null,失败原因未进入任何 React state。onLoadDetail被包装成() => void loadDetail(...)。void让包装函数同步返回undefined,子组件await onLoadDetail()在下一个 microtask 就 resolve,早于 IPC settle —— 真实结果再也传不回来。setError(null)、随后setLoading(false);失败后detail === null且error === null,渲染条件if (loading || (detail === null && !error))恒真 → 永久停在 loading 分支。CaseDetail是同一机制的副本。改动
EvaluationCenter.tsxvoid,恢复 Promise 传递;新增两个按选中 id 稳定的useCallbackloader,避免每次渲染换身份导致子组件 effect 重跑、重复发起 IPCExperimentDetail.tsxonLoadDetail类型改为() => Promise<EvaluationExperimentDetail | null>;effectawait真实结果,null→ 设置可读错误;loading初值按detail === null决定(避免首帧错误闪现);失败分支加 Retry;cleanup 置cancelled防止旧请求回填CaseDetail.tsxevaluation.caseError)evaluation.test.tsx复用已有 i18n key(
evaluation.experimentError/evaluation.caseError/evaluation.retry),en-US 与 zh-CN 均已存在,无需新增。验证
bun test packages/ui/src/components/evaluation/evaluation.test.tsx→ 11 pass / 0 failtsc --noEmit -p packages/ui/tsconfig.json→ exit 0Fixes #396