Repository navigation
fix(plans): label a plan's ramp the way Edit reads it - #1396
Conversation
formatBackendRampSchedule picked the list label from the stored ramp type alone. A weekly 20%/7d plan listed as "Weekly 20%" while Edit opened it as Custom 20% / 7 days, and a weekly 25%/14d plan listed as "Weekly 25%", hiding the 14-day interval. The label now uses the same preset-equality rule as Edit (rampRadioValue). It shows a preset name only when type, percent and interval all match, and otherwise shows "Custom N% every D days" (singular "day" for 1). The preset labels live next to PRESET_RAMPS so the two cannot drift. generatePlanName counted custom steps with Math.ceil, so 30% was named "(4 steps)" for a 3-step schedule. It now floors (minimum 1) like the backend's buildCustomRampSchedule and the schedule preview, and says "1 step" in the singular. Refs LeanerCloud#1185 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): APPROVE Blocking:
|
|
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 |
|
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 Plans list picked the "Ramp Schedule" label from the stored ramp type alone, so a plan stored as weekly 20% every 7 days showed "Weekly 20%" while Edit opened it as Custom 20% / 7 days, and a weekly 25% every 14 days plan showed "Weekly 25%", hiding the interval. The auto-generated plan name also rounded custom step counts up ("(4 steps)" for a 3-step 30% schedule). This PR labels ramps with the same preset-equality rule Edit uses and counts steps the way the backend does.
Closes #1185
What changed
frontend/src/plans.ts:formatBackendRampSchedulenow usesrampRadioValue, the same preset-equality check Edit uses. It shows a preset name only when type, percent and interval all matchPRESET_RAMPS, and otherwise "Custom N% every D days" ("day" when D is 1; "Custom N%" if no interval is stored). Unknown types still show the raw type. This is the only render site for the ramp label.PRESET_RAMPSgains alabelfield so preset names and matching stay together.generatePlanNameusesMath.max(1, Math.floor(100 / pct)), matchinginternal/api/types.gobuildCustomRampScheduleandplan-schedule-intent.ts, and says "1 step" in the singular.frontend/src/__tests__/plans-ramp-label.test.ts.Why this approach
Reusing
rampRadioValuemeans the list and the Edit dialog can't disagree again, which is the fix the issue proposes. The existing preset label text ("Weekly 25%", "Monthly 10%") is kept, so properly stored preset plans look exactly as before.Screenshots
Before is main (
a14dc8f2), after is this branch. Both are headless Chromium at 1440x900 against the repo's mocked e2e API, showing/planswith three mocked plans.Verification
Run on this branch's head
b98e8350on top of maina14dc8f2:a14dc8f2, 5 of the 10 fail (weekly 20/7, weekly 25/14, the "1 days" case, 30% naming and 60% naming). Randomized run: 10/10.index.html).Notes for review
weekly. That matches Edit, as the issue asks, but "Weekly 20%" for 7-day intervals is an alternative. The longer text wraps to two lines in the Ramp Schedule cell at 1440px (see the after shot).Overlaps
plans.tsis also touched by #18, #181, #37, #727, #737 and #739. Only #739 is close: it edits around lines 1037 and 1136-1140, next toformatBackendRampSchedule(1060-1070) and its call site at 1144. A textual conflict is unlikely, but the merge should be checked. Those PRs will be opened alongside this one and merged in sequence, with conflicts resolved on the later branch.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