Repository navigation
fix(frontend): keep the RI exchange reshape empty-state count current - #1395
Conversation
loadRIExchange loads the convertible RIs, reshape recommendations and history in parallel. When the reshape list came back empty before the RI list, its empty state quoted currentRIs from before the load (the previous scope's count, or "none are registered yet" on first load) and nothing rendered it again once the RIs arrived. Track whether currentRIs belongs to the scope being shown. Until it does, or when the RI list failed to load, the empty state says only "No reshape recommendations right now." After the AWS Promise.all, re-render the empty state for the same generation when the reshape load succeeded with no rows; a failed reshape load keeps its error message. Refs LeanerCloud#1135 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50. Or wait 59 minutes for your next included review. View limit details
Comment |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): APPROVE Blocking:
|
|
Local verification at
|
|
Marked ready and merged by IAmJSD's agent, at IAmJSD's request (IAmJSD reviewed the before/after screenshots; cristim is traveling), after the independent review and local verification above, all at |
The RI Exchange page loads convertible RIs, reshape recommendations and exchange history in parallel. When the reshape list came back empty before the RI list, its empty state quoted a stale RI count (the previous scope's, or "none are registered yet" on a first load) and was never re-rendered, so the page could list three convertible RIs and say right below that none are registered. This PR re-renders the empty state once both loads finish and shows neutral copy until the RI count is known.
Closes #1135
What changed
All in
frontend/src/riexchange.ts:currentRIsLoadedis set only after the current scope's RI list loads successfully, and cleared wherevercurrentRIsis reset (AWS reload start, the Azure/GCP paths, the account-resolve error).renderRecommendations' empty branch quotes the RI count only when the flag is set; otherwise it shows "No reshape recommendations right now."loadReshapeRecommendationsnow resolvestruewhen it rendered a fresh response andfalsewhen superseded or failed.loadRIExchangereads that from the AWSPromise.alland, for the same generation, re-renders the reshape empty state when the load succeeded with no rows. A failed reshape load keeps its "Failed to load recommendations" error.frontend/src/__tests__/riexchange.test.ts.Why this approach
This is the fix the issue proposes (re-render after the
Promise.allfor the same generation, keep errors), plus the loaded flag. Without the flag, the stale or "none registered" copy would still flash until the RI list arrived, and a failed RI load would leave the previous scope's count up permanently. Re-rendering fromloadConvertibleRIswould also work, but it would need to know whether the reshape load finished and succeeded; doing it afterPromise.allkeeps that decision in one place and follows the generation-guard pattern already in the file. ReturningPromise<boolean>fromloadReshapeRecommendationsis backward compatible, since existing callers ignore the result.Screenshots
Before is main (
a14dc8f2), after is this branch. Both are headless Chromium at 1440x900 against the repo's mocked e2e API. On a first load,/api/ri-exchange/instancesis delayed 1.5s and returns 3 RIs, while the reshape recommendations return an empty list immediately.Verification
Run on this branch's head
c22674edon top of maina14dc8f2:npm run lint: 0 errors (142 pre-existing warnings). Typecheck and build pass.riexchange.test.tspasses with--randomize(76/76).e2e-local.sh: 157 passed.scripts/test-git-secrets-allowlist.sh: 137 PASS.Notes for review
riexchange.tsis about 2480 lines, already far over the 500-line rule; this adds about 30.Overlaps
Several branches edit
frontend/src/riexchange.tsin other functions: #18 (large popover refactor that removes big blocks, so merge with care), #284, #321, #709, #727, #729, #737, #738 and #740. None touchloadRIExchange'sPromise.all,loadReshapeRecommendationsor therenderRecommendationsempty branch, so conflicts should be limited to line drift.Note for the UI owner
This changes UI code that @cristim owns. IAmJSD reviewed the before/after screenshots and asked for it to be merged; any design point you disagree with can be a follow-up.
🤖 Generated with Claude Code