--- phase: 06-task-history plan: 01 subsystem: database, ui tags: [drift, flutter, riverpod, go_router, intl, bottom-sheet, stream] # Dependency graph requires: - phase: 05-calendar-strip provides: CalendarTaskRow widget and CalendarDayList that render tasks in the home screen provides: - watchCompletionsForTask(taskId) DAO stream on TasksDao — sorted newest-first - task_history_sheet.dart with showTaskHistorySheet() function - Verlauf ListTile in TaskFormScreen (edit mode) opening history bottom sheet - CalendarTaskRow onTap navigation to TaskFormScreen for the tapped task affects: [07-task-sorting, future-phases-using-TaskFormScreen] # Tech tracking tech-stack: added: [] patterns: - "Bottom sheet follows icon_picker_sheet pattern: showModalBottomSheet with isScrollControlled, ConsumerWidget inside, SafeArea > Padding > Column(mainAxisSize.min)" - "StreamBuilder on DAO stream directly accessed via ref.read(appDatabaseProvider).tasksDao.methodName (no separate Riverpod provider for one-shot modals)" - "TDD: RED test commit followed by GREEN implementation commit" key-files: created: - lib/features/tasks/presentation/task_history_sheet.dart - test/features/tasks/data/task_history_dao_test.dart modified: - lib/features/tasks/data/tasks_dao.dart - lib/features/tasks/data/tasks_dao.g.dart - lib/features/tasks/presentation/task_form_screen.dart - lib/features/home/presentation/calendar_task_row.dart - lib/l10n/app_de.arb - lib/l10n/app_localizations.dart - lib/l10n/app_localizations_de.dart key-decisions: - "No separate Riverpod provider for history sheet — ref.read(appDatabaseProvider) directly in ConsumerWidget keeps it simple for a one-shot modal" - "CalendarTaskRow onTap routes to /rooms/:roomId/tasks/:taskId so history is always one tap away from the home screen" - "Count summary line shown above list when completions > 0; not shown for empty state" patterns-established: - "History sheet: showModalBottomSheet returning Future, ConsumerWidget sheet with StreamBuilder on DAO stream" - "Edit-mode-only ListTile pattern: if (widget.isEditing) [...] in TaskFormScreen ListView children" requirements-completed: [HIST-01, HIST-02] # Metrics duration: 5min completed: 2026-03-16 --- # Phase 6 Plan 1: Task History Summary **Drift DAO stream for task completion history, bottom sheet with reverse-chronological German-formatted dates, wired from CalendarTaskRow tap through TaskFormScreen Verlauf button** ## Performance - **Duration:** 5 min - **Started:** 2026-03-16T20:52:49Z - **Completed:** 2026-03-16T20:57:19Z - **Tasks:** 2 (Task 1 TDD: RED + GREEN + localization; Task 2: sheet + wiring + navigation) - **Files modified:** 9 ## Accomplishments - `watchCompletionsForTask(int taskId)` added to TasksDao: returns `Stream>` sorted by completedAt DESC - Task history bottom sheet (`task_history_sheet.dart`) with StreamBuilder, empty state, German date/time formatting via intl - Verlauf ListTile added to TaskFormScreen edit mode, opens history sheet on tap - CalendarTaskRow gains `onTap` that navigates via GoRouter to the task edit form, making history one tap away from the calendar ## Task Commits Each task was committed atomically: 1. **RED - Failing DAO tests** - `2687f5e` (test) 2. **Task 1: DAO method, localization** - `ceae7d7` (feat) 3. **Task 2: History sheet, form wiring, navigation** - `9f902ff` (feat) **Plan metadata:** (docs commit — see below) _Note: TDD tasks have separate RED (test) and GREEN (feat) commits_ ## Files Created/Modified - `lib/features/tasks/data/tasks_dao.dart` - Added watchCompletionsForTask stream method - `lib/features/tasks/data/tasks_dao.g.dart` - Regenerated by build_runner - `lib/features/tasks/presentation/task_history_sheet.dart` - New: bottom sheet with StreamBuilder, empty state, completion list - `lib/features/tasks/presentation/task_form_screen.dart` - Added Verlauf ListTile in edit mode - `lib/features/home/presentation/calendar_task_row.dart` - Added onTap navigation to task edit form - `lib/l10n/app_de.arb` - Added taskHistoryTitle, taskHistoryEmpty, taskHistoryCount strings - `lib/l10n/app_localizations.dart` - Regenerated (abstract class updated) - `lib/l10n/app_localizations_de.dart` - Regenerated (German implementation updated) - `test/features/tasks/data/task_history_dao_test.dart` - New: 5 tests covering empty state, single/multiple completions, task isolation, stream reactivity ## Decisions Made - No separate Riverpod provider for history sheet: `ref.read(appDatabaseProvider).tasksDao.watchCompletionsForTask(taskId)` directly in the ConsumerWidget. One-shot modals do not need a dedicated provider. - CalendarTaskRow navigation uses `context.go('/rooms/.../tasks/...')` consistent with existing GoRouter route patterns. - Removed unused `import 'package:drift/drift.dart'` from test file (Rule 1 auto-fix during GREEN verification). ## Deviations from Plan ### Auto-fixed Issues **1. [Rule 1 - Bug] Removed unused import from test file** - **Found during:** Task 1 (GREEN phase, flutter analyze) - **Issue:** `import 'package:drift/drift.dart'` was copied from the existing tasks_dao_test.dart pattern but not needed in the new history test file (no `Value()` usage) - **Fix:** Removed the unused import line - **Files modified:** test/features/tasks/data/task_history_dao_test.dart - **Verification:** flutter analyze reports zero issues - **Committed in:** ceae7d7 (Task 1 feat commit) --- **Total deviations:** 1 auto-fixed (1 bug — unused import) **Impact on plan:** Trivial cleanup. No scope creep. ## Issues Encountered None — plan executed smoothly. All 106 tests pass (101 pre-existing + 5 new DAO tests), zero analyze issues. ## User Setup Required None - no external service configuration required. ## Next Phase Readiness - Phase 6 Plan 1 complete. Task history is fully functional. - Phase 7 (task sorting) can proceed independently. - No blockers. --- *Phase: 06-task-history* *Completed: 2026-03-16*