yiekheng 991ff5fb22 feat(recurrence): redesign Repeats picker as a preset radio list
The old picker was a row of 5 frequency pills (One-off / Daily / Weekly /
Monthly / Yearly) followed by a separate detail panel — common cases
needed several clicks (interval, weekday list, etc.) and the visual
hierarchy didn't show what was selected at a glance.

New design — a vertical radio list with seven first-fire-aware presets
plus a Custom… expander:

  ○ Don't repeat                                      (one-off)
  ○ Every day
  ○ Every weekday                                     (Mon – Fri)
  ○ Every weekend                                     (Sat – Sun)
  ○ Every week on Wed                                 (matches start)
  ○ Every month on day 13                             (matches start)
  ○ Every year on May 13                              (matches start)
  ○ Custom…                                           ▼ expands

Custom… reveals the existing power-user controls (frequency dropdown,
interval input, weekday picker, day-of-month, end-condition) without
crowding the common path. Toggling between presets and custom is
lossless — the spec is the source of truth.

New helpers in `lib/recurrence.ts`:
- `presetToSpec(id, firstFire)` — canonical RecurrenceSpec for each
  preset (round-trippable).
- `matchPreset(spec, firstFire)` — reverse mapping; returns "custom"
  for anything that doesn't fit a shortcut, so the picker auto-flips
  into expanded mode for non-preset specs.
- `presetDescriptors(firstFire)` — list of preset id/label/hint with
  first-fire-aware copy ("Every week on Wed", "May 13", etc).

Wired into both:
- reminder-wizard/when-form-client.tsx (creating)
- reminder-edit/edit-when-form.tsx (editing a section in place)

Tests (+4, 134 web + 26 bot = 160 total green):
- recurrence.test.ts gains a "preset shortcuts" suite covering:
  * presetToSpec → canonical spec for each id
  * round-trip via matchPreset
  * matchPreset returns "custom" for non-shortcut specs
    (interval > 1, weekly Mon/Wed/Fri, end=after, monthly on a
    different day-of-month than the first fire)
  * presetDescriptors labels are first-fire-aware

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 10:18:39 +08:00
..