- Created useSearch hook for search state and debouncing - Created useFilters hook for filter state management - Created useOptimisticUpdate hook for optimistic UI updates - Created useScrollPosition hook for scroll preservation - Updated SearchBar, GlobalSearch, and ListDetailView to use new hooks - Added comprehensive documentation for all hooks Validates: Requirements 6.4, 7.3, 7.4, 8.3 Task: 9. Implement client-side state management
9.0 KiB
Implementation Plan: Ultimate Lists App
-
1. Enhance database schema with missing fields
- Update Prisma schema to add tags (JSON array) and notes fields to Item model
- Run database migration to apply schema changes
- Regenerate Prisma client with updated types
- Requirements: 5.3, 5.4
-
* 1.1 Write property test for metadata round-trip
- Property 4: Task metadata round-trip
- Validates: Requirements 1.4, 5.1, 5.2, 5.3, 5.4
-
2. Implement core server actions for enhanced task operations
- Add updateItem server action with support for all metadata fields
- Add deleteItem server action with proper revalidation
- Add deleteList server action with cascade behavior
- Add updateList server action for renaming
- Requirements: 1.2, 1.3, 2.4, 2.5
-
* 2.1 Write property test for task updates preserve identity
- Property 2: Task updates preserve identity
- Validates: Requirements 1.2
-
* 2.2 Write property test for task deletion
- Property 3: Task deletion removes from queries
- Validates: Requirements 1.3
-
* 2.3 Write property test for cascade deletion
- Property 9: Cascade deletion
- Validates: Requirements 2.4
-
* 2.4 Write property test for list rename preserves items
- Property 10: List rename preserves items
- Validates: Requirements 2.5
-
3. Implement search functionality
- Create searchItems server action that searches across title, description, notes, and tags
- Add support for list-scoped search vs global search
- Implement text highlighting utility function
- Requirements: 8.1, 8.2, 8.5
-
* 3.1 Write property test for search result completeness
- Property 21: Search result completeness
- Validates: Requirements 8.1
-
* 3.2 Write property test for search highlight correctness
- Property 22: Search highlight correctness
- Validates: Requirements 8.2
-
* 3.3 Write property test for search scope correctness
- Property 24: Search scope correctness
- Validates: Requirements 8.5
-
4. Implement filtering and sorting
- Create getItemsByFilter server action with support for priority, completed, tags, and due date filters
- Implement compound filter logic (AND conditions)
- Add sorting by createdAt, dueDate, priority, and title
- Handle null due dates in sorting (place at end)
- Requirements: 6.1, 6.2, 6.3, 6.5
-
* 4.1 Write property test for sort order correctness
- Property 15: Sort order correctness
- Validates: Requirements 6.1
-
* 4.2 Write property test for filter matching correctness
- Property 16: Filter matching correctness
- Validates: Requirements 6.2
-
* 4.3 Write property test for compound filter conjunction
- Property 17: Compound filter conjunction
- Validates: Requirements 6.3
-
* 4.4 Write property test for null due date sorting
- Property 19: Null due date sorting
- Validates: Requirements 6.5
-
5. Create item detail page and form components
- Build /list/[id]/item/[itemId] page for viewing full item details
- Create ItemForm component with fields for all metadata (priority, due date, tags, notes)
- Create ItemDetail component to display all item information
- Add form validation for item inputs
- Requirements: 1.1, 1.2, 5.1, 5.2, 5.3, 5.4
-
* 5.1 Write property test for task creation preserves description
- Property 1: Task creation preserves description
- Validates: Requirements 1.1
-
6. Enhance list management UI
- Add ListForm component for creating and editing lists
- Implement list deletion with confirmation dialog
- Add list renaming functionality
- Update ListCard to show accurate item counts
- Requirements: 2.1, 2.2, 2.4, 2.5
-
* 6.1 Write property test for list creation with unique identifiers
- Property 6: List creation with unique identifiers
- Validates: Requirements 2.1
-
* 6.2 Write property test for list retrieval completeness
- Property 7: List retrieval completeness
- Validates: Requirements 2.2
-
7. Build list detail page with item management
- Create /list/[id] page showing all items in a list
- Add ItemCard component with completion toggle, priority badge, and due date display
- Implement inline item creation
- Add item deletion functionality
- Show overdue indicators for past due dates
- Requirements: 1.3, 1.5, 2.3, 5.5
-
* 7.1 Write property test for task completion toggle
- Property 5: Task completion toggle
- Validates: Requirements 1.5
-
* 7.2 Write property test for list filtering correctness
- Property 8: List filtering correctness
- Validates: Requirements 2.3
-
* 7.3 Write property test for overdue task identification
- Property 14: Overdue task identification
- Validates: Requirements 5.5
-
8. Add search and filter UI components
- Create SearchBar component with debounced input
- Build FilterPanel component with controls for priority, completion, tags, and due date
- Add sort controls (field and direction)
- Implement filter clear functionality
- Display search results with highlighted text
- Requirements: 6.1, 6.2, 6.3, 6.4, 8.1, 8.2, 8.3
-
* 8.1 Write property test for filter clear restoration
- Property 18: Filter clear restoration
- Validates: Requirements 6.4
-
* 8.2 Write property test for search clear restoration
- Property 23: Search clear restoration
- Validates: Requirements 8.3
-
9. Implement client-side state management
- Create useSearch hook for search state and debouncing
- Create useFilters hook for filter state management
- Create useOptimisticUpdate hook for optimistic UI updates
- Add scroll position preservation logic
- Requirements: 6.4, 7.4, 8.3
-
* 9.1 Write property test for scroll position preservation
- Property 20: Scroll position preservation
- Validates: Requirements 7.4
-
10. Checkpoint - Ensure all tests pass
- Ensure all tests pass, ask the user if questions arise.
-
11. Set up PWA infrastructure
- Create service worker (public/sw.js) with caching strategies
- Implement cache-first strategy for static assets
- Implement stale-while-revalidate for API responses
- Add offline fallback page
- Update manifest.json with complete metadata
- Add service worker registration in app layout
- Requirements: 4.1, 4.3, 4.4
-
* 11.1 Write property test for offline resource availability
- Property 12: Offline resource availability
- Validates: Requirements 4.4
-
12. Implement offline synchronization
- Create useOfflineSync hook for detecting connectivity
- Implement mutation queue for offline operations
- Add background sync for pending mutations
- Show offline indicator in UI
- Handle sync conflicts gracefully
- Requirements: 4.5
-
* 12.1 Write property test for offline mutation synchronization
- Property 13: Offline mutation synchronization
- Validates: Requirements 4.5
-
13. Add PWA assets and metadata
- Generate app icons in multiple sizes (192x192, 512x512)
- Create favicon and apple-touch-icon
- Add meta tags for PWA in app layout
- Configure theme color and background color
- Test "Add to Home Screen" functionality in Safari
- Requirements: 4.1, 4.2
-
14. Implement responsive design enhancements
- Ensure all components are mobile-responsive
- Add touch-optimized controls (larger tap targets)
- Test on various screen sizes
- Optimize layout for mobile and desktop
- Requirements: 7.1, 7.2
-
15. Add visual feedback and polish
- Implement loading states for async operations
- Add success/error toast notifications
- Create smooth transitions between views
- Add empty states for lists and items
- Implement skeleton loaders
- Requirements: 7.3
-
16. Implement error handling
- Add try-catch blocks to all server actions
- Implement error boundaries in React components
- Add user-friendly error messages
- Handle database connection failures gracefully
- Implement retry logic for failed operations
- Requirements: All (error handling is cross-cutting)
-
17. Add input validation
- Validate all form inputs before submission
- Add inline validation errors
- Prevent empty task/list creation
- Validate date formats
- Sanitize user inputs
- Requirements: 1.1, 2.1
-
18. Optimize performance
- Add database indexes for frequently queried fields
- Implement pagination for large lists
- Optimize bundle size with code splitting
- Add loading states to prevent layout shift
- Use React.memo for expensive components
- Requirements: All (performance is cross-cutting)
-
19. Final checkpoint - Ensure all tests pass
- Ensure all tests pass, ask the user if questions arise.
-
20. End-to-end testing and polish
- Test complete user flows from list creation to task completion
- Verify PWA installation on iOS Safari
- Test offline functionality in real scenarios
- Check accessibility with screen readers
- Verify all requirements are met
- Requirements: All