Restrict Calendar Editing to Last 3 Days
📌 Context
The calendar currently displays daily habit logs, but there is no clear restriction on which days can be edited.
For the MVP, we want to allow users to edit habit logs only for the last 3 calendar days (including today).
This balances flexibility (fixing recent forgetfulness) with data integrity, without adding extra complexity.
⚠️ Note:
In this iteration, streaks are NOT affected, and there is no distinction between on-time vs late completion.
🎯 Goal
Implement a rule that allows habit logs to be edited only for the last 3 calendar days, while older days remain read-only.
✅ Functional Rules
- A day is editable if:
date >= today - 2 days
- (today, yesterday, and the day before yesterday)
- Days outside this range:
- must not allow toggling or updates
- must not trigger any mutations
- The rule must be based on calendar days, not hours (do NOT use a 72h window).
🧠 Expected UX Behavior
Editable Day
- The user can mark / unmark the habit.
- The day behaves normally.
Non-editable Day
- The day is displayed normally (no visual changes required for MVP).
- The day does not respond to interactions.
- Optional (nice-to-have): subtle feedback such as a tooltip or toast:
“You can only edit the last 3 days”
🛠️ Technical Tasks
1. Create a reusable utility
Implement a helper function, for example:
canEditDay(date: Date | YYYY-MM-DD): boolean
Rules:
- Compare against
today
- Use only year / month / day (ignore time)
- Must work across month and year boundaries
2. Apply the rule in the Calendar UI
For each calendar day:
- Determine whether the day is editable
- If not editable:
- prevent toggle actions
- block calls to update/mutation logic
- Editable days should keep the current behavior
3. Defensive validation (if applicable)
If there is a handler or mutation for updating habit logs:
- Add a guard to prevent updates for dates outside the allowed range
- Do not rely only on UI-level checks
🧪 Test Cases
- ✅ Today → editable
- ✅ Yesterday → editable
- ✅ Day before yesterday → editable
- ❌ 3+ days ago → not editable
- Editing days across month boundaries (e.g. early month dates)
- Navigating between months and years does not break the rule
🚫 Out of Scope
- ❌ Modifying streak logic
- ❌ Adding on-time / late completion tracking
- ❌ User-configurable edit windows
- ❌ Calendar UI redesign
📈 Future Improvements (Not in this Issue)
This change prepares the system for:
- on-time vs late completion tracking
- more accurate streak calculations
- clearer historical integrity
These enhancements will be addressed in future iterations.
Restrict Calendar Editing to Last 3 Days
📌 Context
The calendar currently displays daily habit logs, but there is no clear restriction on which days can be edited.
For the MVP, we want to allow users to edit habit logs only for the last 3 calendar days (including today).
This balances flexibility (fixing recent forgetfulness) with data integrity, without adding extra complexity.
🎯 Goal
Implement a rule that allows habit logs to be edited only for the last 3 calendar days, while older days remain read-only.
✅ Functional Rules
date >= today - 2 days🧠 Expected UX Behavior
Editable Day
Non-editable Day
🛠️ Technical Tasks
1. Create a reusable utility
Implement a helper function, for example:
Rules:
today2. Apply the rule in the Calendar UI
For each calendar day:
3. Defensive validation (if applicable)
If there is a handler or mutation for updating habit logs:
🧪 Test Cases
🚫 Out of Scope
📈 Future Improvements (Not in this Issue)
This change prepares the system for:
These enhancements will be addressed in future iterations.