Bug
Checking in an 'x times a week' habit (on the /habits page or the right-side Habits panel) shows a contradictory optimistic state: the streak flame jumps to '1 week' but 'This week n/x' stays at the old count and the current-week strip cell stays grey, until the next 30s poll or a page reload corrects it.
A second check-in in the same week would also wrongly bump the streak to '2 weeks'.
Root cause
HabitsClient.handleToggle and ProjectLayout.handleCheckInToggle optimistically update only doneToday / currentStreak (±1) / recentCheckIns. They were never updated for the frequency fields added in #75 (thisWeekCount, recentWeeks), and the ±1 streak bump is a day-unit shift applied to a week-unit streak.
Server data is correct (confirmed by reload) - this is purely the optimistic UI.
Found
During the v2.18.0 browser verification (#75).
Fix direction
Extract a shared pure helper that branches on weeklyTarget: for frequency habits adjust thisWeekCount, recompute the current-week cell, and only move the week-streak on the 0<->1 weekly threshold; keep the day ±1 for day-pattern habits. Wire both handlers to it.
Bug
Checking in an 'x times a week' habit (on the /habits page or the right-side Habits panel) shows a contradictory optimistic state: the streak flame jumps to '1 week' but 'This week n/x' stays at the old count and the current-week strip cell stays grey, until the next 30s poll or a page reload corrects it.
A second check-in in the same week would also wrongly bump the streak to '2 weeks'.
Root cause
HabitsClient.handleToggleandProjectLayout.handleCheckInToggleoptimistically update onlydoneToday/currentStreak (±1)/recentCheckIns. They were never updated for the frequency fields added in #75 (thisWeekCount,recentWeeks), and the±1streak bump is a day-unit shift applied to a week-unit streak.Server data is correct (confirmed by reload) - this is purely the optimistic UI.
Found
During the v2.18.0 browser verification (#75).
Fix direction
Extract a shared pure helper that branches on
weeklyTarget: for frequency habits adjustthisWeekCount, recompute the current-week cell, and only move the week-streak on the 0<->1 weekly threshold; keep the day ±1 for day-pattern habits. Wire both handlers to it.