Tasks: Rework Found Campsites UI
Input: Design documents from docs/specs/033-found-campsites-ui/
Prerequisites: plan.md, spec.md, research.md, data-model.md, contracts/ui-contract.md, quickstart.md
Tests: Included per Camply Constitution Principle V (Automated Verification) and Test-First Mentality. Write test tasks first within each phase and verify they fail before implementing.
Organization: Tasks are grouped by user story (US1–US4) so each story is independently implementable and testable.
Format: [ID] [P?] [Story] Description
- [P]: Can run in parallel (different files, no dependency on incomplete tasks)
- [Story]: Maps task to a specific user story from
spec.md([US1],[US2],[US3],[US4]) - Exact file paths are included in every task description
Path Conventions
- Frontend source & colocated unit tests:
src/frontend/ - Visual snapshot tooling & baselines:
src/frontend/tooling/run-snapshots.ts,tests/frontend/snapshots/baselines/ - Architecture & checklist documentation:
docs/
Phase 1: Setup (Shared Infrastructure)
Purpose: Confirm baseline health and prepare the subcomponent directory structure
- [x] T001 Confirm existing frontend baseline passes by running
pnpm exec vitest run src/frontend/components/FoundCampsites.test.tsx src/frontend/pages/ScanDetail.test.tsxand create thesrc/frontend/components/found-campsites/directory for modular UI components
Phase 2: Foundational (Blocking Prerequisites)
Purpose: Build and thoroughly verify the pure TypeScript availability, calendar, filtering, sorting, and grid-window domain module that all user stories depend on
⚠️ CRITICAL: Complete this phase before starting User Stories 1–4.
- [x] T002 Write failing unit tests in
src/frontend/lib/availability.test.tscovering: maximal consecutiveAvailableStayblocks (stay.nights >= scan.min_stay_length, exclusive check-outend = addDays(lastNight, 1), non-combining across campsites/campgrounds);NormalizedFoundSitededuplication by${providerId}:${campgroundId}:${campsiteId}and fallbackdisplayName("Campsite ${campsiteId}");applyCalendarDayClickstate transitions (single-night select, same-day clear, forward range, reverse-click auto-normalization, restart after active range);stayMatchesSelection(stay.start <= start && start < stay.endfor single night,stay.start <= start && stay.end >= endfor continuous range);buildCalendarMonth(soonest-opening default month withscan.start_datefallback when empty, scan-window clamping,scan.end_datecheckout-boundary selectability only whenselection?.end === null, Friday/SaturdayisWeekendNightflags, per-night uniqueavailableSiteCountcomputed from search-filtered sites);filterAndSortSitesacrosssoonest,longest,most_nights, andname(evaluating matching stays forsoonest/longestwhendateSelectionis active); and 14-daybuildGridWindowclamping and pagination helpers - [x] T003 Implement pure domain types and helpers (
AvailableStay,NormalizedFoundSite,DateSelection,CalendarDayCell,CalendarMonth,FoundViewMode,FoundSortMode,GridWindow,SelectedGridStay,normalizeFoundSites,applyCalendarDayClick,stayMatchesSelection,getInitialCalendarMonth,getCalendarMonthBounds,buildCalendarMonth,filterAndSortSites,buildGridWindow,formatStayRangeDate) insrc/frontend/lib/availability.tsso all tests insrc/frontend/lib/availability.test.tspass
Checkpoint: pnpm exec vitest run src/frontend/lib/availability.test.ts passes cleanly; all user story UI phases can proceed.
Phase 3: User Story 1 - Explore openings visually with an interactive availability calendar (Priority: P1) 🎯 MVP
Goal: Provide an interactive monthly availability calendar scoped to the scan window that shows opening counts and weekend cues at a glance and filters found campsites by single night or check-in → check-out range.
Independent Test: Render a scan spanning multiple months with overlapping openings; verify the calendar opens on the month of the soonest qualifying opening, bounds month navigation to the scan window, shows per-night site counts and weekend cues, filters overlapping sites accurately on single-night click and two-date check-in → check-out selection (including reverse order and scan.end_date checkout boundary), and clears cleanly in one click.
Tests for User Story 1 ⚠️
- [x] T004 [P] [US1] Write failing component tests in
src/frontend/components/found-campsites/AvailabilityCalendar.test.tsxverifying: initial month opens to soonest qualifying opening (orscan.start_datewhen empty);"Previous month"/"Next month"buttons clamp to[monthOf(scan.start_date), monthOf(scan.end_date)]; day cells expose descriptivearia-label(date + available site count) andaria-pressed; single-night selection, same-day toggle-off, check-in → check-out range selection (forward and reverse),scan.end_datecheckout-boundary enablement only whenselection?.end === null, hover range preview, active filter summary pill, and"Clear dates"button
Implementation for User Story 1
- [x] T005 [US1] Implement
AvailabilityCalendarinsrc/frontend/components/found-campsites/AvailabilityCalendar.tsxusingbuildCalendarMonth,getCalendarMonthBounds, andapplyCalendarDayClickfromsrc/frontend/lib/availability.ts, rendering Sun–Sat month grid, per-night site count cues, Fri/Sat weekend-night styling, out-of-window disabled cells, hover range preview, keyboard navigation, active selection badge, and"Clear dates"action - [x] T006 [US1] Integrate
AvailabilityCalendarstate (dateSelection,visibleMonth, automatic reset/preservation across scan changes and live refreshes) intosrc/frontend/components/FoundCampsites.tsxso calendar day counts reflect the current search-filtered qualifying sites and clicking dates immediately filters displayed results and updates therole="status"summary count
Checkpoint: User Story 1 calendar browsing and date-range filtering work and pass AvailabilityCalendar.test.tsx.
Phase 4: User Story 2 - Browse scannable, deduplicated campsite cards (Priority: P1)
Goal: Render each unique qualifying campsite once as a clean, scannable card with campground attribution, structured capability badges, readable check-in → check-out stay chips (highlighting matches to any active calendar selection and expanding inline when >4 stays exist), full-result search, 4-mode sorting, bounded pagination (SITES_PER_PAGE = 10), and prominent booking CTAs.
Independent Test: Render a scan containing a campsite with 5+ separate stay windows, rich capabilities, an unnamed campsite, a stale recreation-area observation, and 12+ sites across pages; verify each unique (provider, campground, campsite) appears once, stay chips expand inline beyond 4, active calendar filters highlight matching stay chips, search and sort (soonest, longest, most_nights, name) evaluate all pages and reset to page 1, pagination clamps on result shrinkage, and booking links carry accessible site + campground labels.
Tests for User Story 2 ⚠️
- [x] T007 [P] [US2] Update and expand component tests in
src/frontend/components/FoundCampsites.test.tsxto test: deduplicated site cards (site with multiple stays rendered once), fallbackCampsite <id>label, campground attribution + stale badge on multi-campground/stale sites, structured capability badges (campsite_type,Electric hookup,Accessible,Up to N ft,permitted_equipment) omitting unknown fields, stay-chip capping at4with inline"+N more stays"/"Show fewer stays"toggle, stay-chip highlighting when a calendar date/range filter is active, full-result search ("Search found campsites"), sort selector ("Sort campsites"withsoonest,longest,most_nights,name), pagination (SITES_PER_PAGE = 10,"Previous campsites"/"Next campsites", clamping on live refresh shrinkage), single concise disclaimer, and filter-empty reset states ("Clear filters"/"Clear search"/"Clear dates")
Implementation for User Story 2
- [x] T008 [P] [US2] Implement
CampsiteCardListinsrc/frontend/components/found-campsites/CampsiteCardList.tsxdisplaying deduplicatedNormalizedFoundSitecards with campground eyebrow (when present), stale badge with relative freshness context, icon-backed capability badges, formattedCheck-in → Check-out · N nightsstay chips (capped at4prioritizing matching stays, inline"+N more stays"/"Show fewer stays"toggle, year shown when crossing New Year's Day), visual highlight for stays matchingdateSelection, prominent external booking CTA (target="_blank" rel="noopener noreferrer", accessiblearia-label="View <name> on provider website"plus(<campground>)), and<nav aria-label="Campsite pages">pagination (SITES_PER_PAGE = 10) - [x] T009 [US2] Rework
src/frontend/components/FoundCampsites.tsxto replace the legacy exact-date-range<details>accordions with the desktop split / mobile stackedAvailabilityCalendar+CampsiteCardListlayout, clean toolbar ("Search found campsites","Sort campsites"), accurate liverole="status"counts (N sites · M openings), distinct waiting/active-empty/paused-empty/partial-coverage-empty/filter-empty states, single concise provider disclaimer, and#resultsanchor scrolling
Checkpoint: User Stories 1 and 2 together deliver the complete P1 MVP; pnpm exec vitest run src/frontend/components/FoundCampsites.test.tsx src/frontend/components/found-campsites/AvailabilityCalendar.test.tsx passes cleanly.
Phase 5: User Story 3 - Switch between Cards and Availability Grid views (Priority: P2)
Goal: Add a segmented view switcher (Cards | Grid) that lets users inspect night-by-night availability in a 14-day Sites × Dates matrix with a sticky campsite column, weekend cues, date-window navigation, inline stay inspection and booking CTA, and zero horizontal viewport overflow.
Independent Test: Render a multi-week scan with multiple campsites, switch to Grid view, verify rows/columns and weekend cues, step date windows forward/backward, click an available night cell to open the inline stay inspector and verify the booking link, dismiss via Escape/close, switch back to Cards view, and verify search, sort, date filter, and view mode persist across switches and live data refreshes.
Tests for User Story 3 ⚠️
- [x] T010 [P] [US3] Write failing component tests in
src/frontend/components/found-campsites/AvailabilityGrid.test.tsxverifying: matrix renders matching campsites as rows (with sticky identity column and campground label) and up to 14 consecutive dates as columns;"Previous dates"/"Next dates"controls step within[scan.start_date, scan.end_date); clicking or keyboard-activating an available cell togglesaria-pressedand opens the inline stay inspector showingCheck-in → Check-out, night count, capabilities, stale indicator (if applicable), and provider booking link; closing via close button orEscapedismisses the inspector; and stale/removed selected stays auto-clear when results refresh - [x] T011 [US3] Add view-switcher interaction and state-persistence tests in
src/frontend/components/FoundCampsites.test.tsx(afterT007) verifying toggling"Results view"("Cards"↔"Grid"), preserving search query, sort order, and activedateSelectionacross switches and live refreshes, and aligning the grid window to an active calendar date filter
Implementation for User Story 3
- [x] T012 [P] [US3] Implement
AvailabilityGridinsrc/frontend/components/found-campsites/AvailabilityGrid.tsxwith bounded 14-day window navigation (buildGridWindow), inneroverflow-x-autocontainer with sticky left site column (preventing document horizontal overflow), weekend column tinting, accessible available night buttons (aria-labelwith site, night, and full stay range;aria-pressed), inline stay inspector panel with capabilities, staleness context, external booking CTA (target="_blank" rel="noopener noreferrer",aria-label="View <name> on provider website"plus(<campground>)), close button, andEscapekey handler, plus<nav aria-label="Campsite pages">row pagination (SITES_PER_PAGE = 10) - [x] T013 [US3] Add the
"Results view"segmented switcher ("Cards"|"Grid") to the toolbar insrc/frontend/components/FoundCampsites.tsx, wireviewModeandgridStartDatestate (synced withdateSelectionand preserved across live refreshes), and ensure compact date-filter summary/clear controls remain visible when browsing Grid view
Checkpoint: User Stories 1, 2, and 3 all work seamlessly and pass all component tests.
Phase 6: User Story 4 - Navigate a cohesive scan detail header and recreation-area coverage summary (Priority: P2)
Goal: Clean up ScanDetail.tsx with a single cohesive header (eliminating the duplicate Scan overview card and repeated freshness/criteria blocks) and replace raw recreation-area coverage text and ISO timestamps with a structured, expandable CoverageSummary component.
Independent Test: Render both a single-campground scan and a partial-coverage recreation-area scan in ScanDetail; verify scan status (Monitoring/Paused/Ended), criteria, freshness, creation time, external provider link, and edit action appear once in the cohesive header with no duplicate Scan overview card; verify recreation-area coverage displays structured counts, a partial-coverage warning, and an expandable breakdown with human-readable relative timestamps (zero raw ISO timestamps); and verify catalog-error resilience, refresh-error retry with cached results, and #results anchor behavior.
Tests for User Story 4 ⚠️
- [x] T014 [P] [US4] Write failing component tests in
src/frontend/components/found-campsites/CoverageSummary.test.tsxverifying:<section aria-label="Campground coverage">renders coverage mode (All campgrounds/Selected campgrounds), eligible/unavailable and checked/pending/failed counts, partial-coverage warning whencoverage_status !== "complete", expandable per-campground breakdown with status badges,unavailable_reason, and human-readableformatRelativeTimelabels (never raw ISO timestamp strings) - [x] T015 [P] [US4] Update integration tests in
src/frontend/pages/ScanDetail.test.tsxto match the reworkedFoundCampsitesand consolidatedScanDetailUI: verify single cohesive header with saved criteria/status/freshness/created metadata (no duplicateScan overviewaccordion or duplicate disclaimer),CoverageSummaryintegration for recreation-area scans, calendar filtering + Cards/Grid view flows, live-refresh state preservation (view mode, search, date filter, pagination clamping), paused/waiting/empty/partial-coverage states, cached-results retry on refresh failure, and graceful fallback when destination metadata fails to load
Implementation for User Story 4
- [x] T016 [P] [US4] Implement
CoverageSummaryinsrc/frontend/components/found-campsites/CoverageSummary.tsxpreserving<section aria-label="Campground coverage">, showing compact coverage mode and status counts, clear amber partial/failed warning callout whencoverage_status !== "complete", and an expandable<details>list of member campgrounds with status badges (Checked,Pending,Failed,Unavailable),unavailable_reason, and human-readableformatRelativeTime(member.last_checked_at)timestamps - [x] T017 [US4] Refactor
src/frontend/pages/ScanDetail.tsxto widen the container tomax-w-5xl, consolidate destination title, parent recreation area, external provider link, status badges (Monitoring/Paused/Ended),Last checked,Created, saved criteria pills, andScanFormedit button into one cohesive header, replace raw coverage<p>lines with<CoverageSummary scan={scan} />, and remove the redundant bottomScan overview<details>card
Checkpoint: All 4 user stories are complete and independently verified; pnpm exec vitest run src/frontend/lib/availability.test.ts src/frontend/components/FoundCampsites.test.tsx src/frontend/components/found-campsites/ src/frontend/pages/ScanDetail.test.tsx passes cleanly.
Phase 7: Polish & Cross-Cutting Concerns
Purpose: Visual regression coverage (desktop/mobile, light/dark), documentation alignment, and full project quality gates
- [x] T018 Update existing
scan-detail-*,scan-detail-paginated-*, andarea-scan-detail-*scenarios and add Grid-view / calendar-filter visual snapshot scenarios insrc/frontend/tooling/run-snapshots.ts(asserting zero viewport horizontal overflow on desktop1280×800and mobile375×812/390×844in both light and dark themes) - [ ] T019 Run
task frontend:snapshot:updateandtask frontend:snapshot:checkto capture and verify updated visual baselines intests/frontend/snapshots/baselines/and inspecttmp/snapshots/report.htmlfor visual polish across desktop/mobile and light/dark modes (blocked in this Linux container: Chromium requires OSlibglib-2.0.so.0; runtask frontend:snapshot:update -- --filter scan-detailon a machine/CI runner with Chromium system deps) - [x] T020 [P] Update
docs/architecture/DESIGN_FRONTEND.mdto document the reworked Found Campsites calendar + deduplicated cards + availability grid UX and consolidated Scan Detail header - [x] T021 [P] Update
docs/CHECKLIST.mdto reflect completion of the Found Campsites UI rework - [x] T022 Run full validation pipeline per
docs/specs/033-found-campsites-ui/quickstart.md:task frontend:fix && task frontend:check && task frontend:lint && task frontend:testand confirm zero errors, zero warnings, and 100% passing tests
Dependencies & Execution Order
Phase Dependencies
- Phase 1 (Setup): No dependencies — start immediately.
- Phase 2 (Foundational): Depends on Phase 1 — blocks all user stories (
US1–US4) becausesrc/frontend/lib/availability.tsdefines the shared view models and pure calculations. - Phase 3 (
US1— Interactive Calendar): Depends on Phase 2. - Phase 4 (
US2— Deduplicated Campsite Cards): Depends on Phase 2; integrates cleanly withUS1insideFoundCampsites.tsx(T008can be authored in parallel withUS1, then integrated inT009). - Phase 5 (
US3— Cards ↔ Grid View Switcher): Depends on Phase 2 (T010,T012can be authored in parallel withUS1/US2; toolbar wiringT013followsT009). - Phase 6 (
US4— Cohesive Scan Detail & Coverage Summary): Depends on Phase 2 (T014,T016have zero dependency onUS1–US3and can run in parallel;T015/T017integrate withFoundCampsites). - Phase 7 (Polish & Cross-Cutting): Depends on Phases 3–6 completing.
Parallel Opportunities
# Once Phase 2 (src/frontend/lib/availability.ts) passes, independent subcomponents & tests can be authored in parallel:
Task: "T004 [P] [US1] AvailabilityCalendar.test.tsx"
Task: "T008 [P] [US2] CampsiteCardList.tsx"
Task: "T010 [P] [US3] AvailabilityGrid.test.tsx"
Task: "T012 [P] [US3] AvailabilityGrid.tsx"
Task: "T014 [P] [US4] CoverageSummary.test.tsx"
Task: "T016 [P] [US4] CoverageSummary.tsx"
# In Phase 7, documentation updates can run in parallel:
Task: "T020 [P] Update docs/architecture/DESIGN_FRONTEND.md"
Task: "T021 [P] Update docs/CHECKLIST.md"Implementation Strategy
MVP First (Phase 1 + Phase 2 + User Stories 1 & 2)
- Complete Phase 1 (Setup) and Phase 2 (
src/frontend/lib/availability.ts+ unit tests). - Implement Phase 3 (
US1— Interactive Availability Calendar) and Phase 4 (US2— Deduplicated Campsite Cards + refactoredFoundCampsites.tsx). - Checkpoint: Validate calendar date/range filtering, deduplicated cards, search, sort, pagination, and empty states independently.
Incremental Delivery
- Add Phase 5 (
US3— Availability Grid + Cards ↔ Grid view switcher) → verify matrix interactions, stay inspector, and mobile scroll behavior. - Add Phase 6 (
US4—CoverageSummary+ cohesiveScanDetail.tsxheader cleanup) → verify full page integration and refresh/error resilience. - Complete Phase 7 (Playwright visual snapshots across desktop/mobile & light/dark, docs updates, and full
task frontend:check && task frontend:lint && task frontend:testgate).
Phase 8: Convergence
- [ ] T023 Capture and verify refreshed Playwright visual snapshot baselines (
scan-detail-*,scan-detail-grid-*,scan-detail-paginated-*,area-scan-detail-*) intests/frontend/snapshots/baselines/viatask frontend:snapshot:update -- --filter scan-detailandtask frontend:snapshot:checkon an environment with Chromium system libraries (libglib-2.0.so.0) per SC-006 (missing) - [x] T024 Add automated tests in
src/frontend/components/FoundCampsites.test.tsxandsrc/frontend/pages/ScanDetail.test.tsxcovering partial-coverage recreation-area empty state, checked paused-scan empty state, active-scan empty state, and date-filter-only / combined search+date-filter empty reset (Clear dates/Clear filters) per FR-015 (partial) - [x] T025 Re-anchor
gridStartDateinsrc/frontend/components/FoundCampsites.tsxwhen initial openings arrive after a waiting/empty mount or when saved scan dates change (without overriding manual user grid navigation) and add a regression test insrc/frontend/components/FoundCampsites.test.tsxper FR-008 / FR-012 (partial) - [x] T026 Align the Found campsites UI rework entry in
docs/CHECKLIST.mdso Playwright visual baseline status accurately reflects whetherT023has completed per plan: Documentation (partial)