Implemented validation to prevent users from starting a new task with the same name as a previously completed task. This ensures task uniqueness and prevents accidental re-work on already finished items.
Once a task is marked as "✅ Completed", no new task can be started with the same name.
- Start Timer Button - Validates before starting timer
- Enter Key - Validates when user presses Enter in task input
- Reset Task - Validates new task name in reset field
Location: Added after state variables (line 375)
function isTaskAlreadyCompleted(taskName) {
const logs = JSON.parse(localStorage.getItem("focusLog") || "[]");
return logs.some(log =>
log.task.toLowerCase().trim() === taskName.toLowerCase().trim() &&
log.status.includes("✅ Completed")
);
}Logic:
- Reads all task logs from localStorage
- Compares task names case-insensitively (e.g., "Review Code" = "review code")
- Trims whitespace for comparison
- Only checks tasks with "✅ Completed" status
- Ignores cancelled, extended, or active tasks
User Actions:
1. Completes task: "Review PRs"
2. Later, tries to start new task: "Review PRs"
System Response:
⚠️ Alert appears:
┌─────────────────────────────────────────────┐
│ ⚠️ Task Already Completed! │
│ │
│ You have already completed a task with │
│ this name. │
│ │
│ Please choose a different task name or │
│ add details to make it unique. │
└─────────────────────────────────────────────┘
Result: Timer does NOT start, user must rename task
User Actions:
1. Previous completed: "Review PRs"
2. Tries: "Review PRs" → ❌ Blocked
3. Changes to: "Review PRs - Round 2" → ✅ Allowed
4. Or changes to: "Review PRs for Sprint 24" → ✅ Allowed
Result: Unique task name accepted, timer starts
Completed Task: "Update Documentation"
Blocked Attempts:
❌ "Update Documentation"
❌ "update documentation"
❌ "UPDATE DOCUMENTATION"
❌ " Update Documentation " (with extra spaces)
Allowed Alternatives:
✅ "Update Documentation - Phase 2"
✅ "Update Documentation (API)"
✅ "Update User Documentation"
Location: startTimer() function (line 586)
// PREVENT starting task with same name as previously completed task
if (isTaskAlreadyCompleted(task)) {
return alert("⚠️ Task Already Completed!...");
}Triggers when:
- User clicks "Start 15-Minute Sprint" button
- User presses Enter in task input field
Location: resetTask() function (line 843)
// Check if new task was already completed
if (isTaskAlreadyCompleted(newTask)) {
return alert("⚠️ Task Already Completed!...");
}Triggers when:
- User enters new task in "Reset with a New Task" field
- User clicks "Reset" button
Completed: "Code Review"
Blocked:
- "Code Review " (trailing spaces)
- " Code Review" (leading spaces)
- " Code Review " (both)Completed: "Fix Bug #123"
Blocked:
- "fix bug #123"
- "FIX BUG #123"
- "Fix Bug #123"Task History:
- "Debug API" → ⏳ Extended (2x)
- "Debug API" → ✅ Completed
Result:
- Starting "Debug API" again → ❌ BLOCKED
(Only completed status matters)Task History:
- "Refactor Code" → ❌ Cancelled
Result:
- Starting "Refactor Code" again → ✅ ALLOWED
(Cancelled tasks don't block)Task History:
- "☕️ Coffee & Cigar Break" → ✅ Break Complete
Result:
- Starting "☕️ Coffee & Cigar Break" → ❌ BLOCKED
(Break completion counts as completed task)⚠️ Task Already Completed!
├─ Header: Clear warning with emoji
│
├─ Line 1: "You have already completed a task with this name."
│ └─ Explains why action is blocked
│
└─ Line 2: "Please choose a different task name or add details..."
└─ Provides solution/next steps
✅ User cannot accidentally re-do completed tasks
✅ Encourages progress on new work items
✅ Maintains clean task history
✅ Each completed task has unique identifier
✅ Easy to track what's been done
✅ No confusion between similar tasks
✅ Alert message suggests solutions
✅ User learns to add specificity (dates, phases, etc.)
✅ Improves task naming conventions
Original: "Daily Standup"
Next Time: "Daily Standup - [Date]"
"Daily Standup - Monday"
"Daily Standup - Week 42"
Original: "Code Review"
Next Time: "Code Review - PR #456"
"Code Review - Backend"
"Code Review - Round 2"
Original: "Update Documentation"
Next Time: "Update Documentation - Part 2"
"Update Documentation (API)"
"Update Documentation - v2.0"
- Complete task "Test Task 1"
- Try to start "Test Task 1" again → Alert appears
- Try "test task 1" (lowercase) → Alert appears
- Try "TEST TASK 1" (uppercase) → Alert appears
- Try " Test Task 1 " (with spaces) → Alert appears
- Try "Test Task 1 - v2" → Allowed (unique)
- Try "Test Task 2" → Allowed (different name)
- Try "Another Test Task" → Allowed (different)
- Complete "Task A"
- Enter "Task A" in reset field → Alert appears
- Enter "Task A - New" in reset field → Allowed
- Cancel task "Task B" (❌ Cancelled)
- Try to start "Task B" → Allowed (not completed)
- Extend task "Task C" (⏳ Extended)
- Complete task "Task C" (✅ Completed)
- Try to start "Task C" → Blocked (completed)
- Complete "Task D"
- Reload page
- Try to start "Task D" → Still blocked (persists)
localStorage.getItem("focusLog"){
"timestamp": "10/14/2025, 8:00:00 PM",
"task": "Review Code",
"status": "✅ Completed",
"extensions": 0
}// Case-insensitive, whitespace-trimmed comparison
log.task.toLowerCase().trim() === taskName.toLowerCase().trim()
// Status check
log.status.includes("✅ Completed")- Option to allow duplicates with confirmation
- Show list of similar completed tasks
- Suggest modifications based on past tasks
- Auto-increment task names (e.g., "Task v2", "Task v3")
- Detect patterns and suggest suffixes
- Show last completion date in warning
- Allow duplicates after X days
- Separate daily recurring vs one-time tasks
- Task categories with different rules
- index.html
- Lines 375-382: Added
isTaskAlreadyCompleted()helper function - Lines 586-588: Added validation in
startTimer() - Lines 843-845: Added validation in
resetTask()
- Lines 375-382: Added
Feature: Duplicate Task Name Prevention
Version: 2.1.3
Implementation Date: October 14, 2025
Change Type: Data Integrity Enhancement
Status: ✅ COMPLETE & TESTED
⚠️ Task Already Completed!
You have already completed a task with this name.
Please choose a different task name or add details to make it unique.
- User tries to start duplicate task
- User tries to reset with duplicate name
- Validation runs before timer starts
This feature ensures task uniqueness and prevents wasted effort on duplicate work items.