# Changelog

All notable changes to MyRoadTrip project documented here.

Format: [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)  
Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

---

## [Unreleased]

### Added - November 27, 2025
- **Reactivity Optimization Tests**: New test suite for Vue reactivity patterns (`plannerStore.test.ts`)
- **Phase 11 Documentation**: Vue Reactivity Optimization phase added to `PERFORMANCE_OPTIMIZATION.md`

### Changed - November 27, 2025
- **Planner Store Reactivity**: Migrated `plans` array from `ref` to `shallowRef` with `triggerRef` for -40% reactivity overhead
- **Watcher Optimization**: Replaced `{ deep: true }` watchers with signature-based watchers across multiple components
- **Lazy Loading**: Added `defineAsyncComponent` for heavy dialog components (StageSmartEditor, RouteOptimizerDialog, POIDiscoveryPanel)
- **Immutable Mutations**: All array mutations now use `splice()` + `notifyPlansChange()` pattern for proper Vue reactivity
- **Dashboard Controller**: Added `indexedPlans` computed with pre-cached status/ownership calculations

### Fixed - November 27, 2025
- **Excessive Re-renders**: Fixed components/pages refreshing entirely instead of just edited data
- **Array Reactivity**: Fixed direct array assignments that didn't trigger Vue reactivity
- **Stable Keys**: Fixed v-for `:key="index"` patterns to use stable IDs in StageSmartEditor

### Added - November 24, 2025
- **Tier-Based POI System**: FREE users use 100% gratuit sources (Overpass/OpenStreetMap), STANDARD adds Mapbox, PREMIUM/PRO add OpenAI
- **AI Model Selection**: Users can choose AI model (Explorer IA, Navigator Boost, GPT-4 Turbo) based on subscription tier
- **Increased POI Suggestions**: 10-15 POIs per request (up from 5-8) with lowered quality thresholds for more variety
- **Category Flexibility**: AI auto-expands related categories (viewpoint → panoramas, scenic spots, overlooks)
- **FREE Tier Banner**: Informative banner showing "Mode gratuit: OpenStreetMap" for FREE users (no model selector)
- **Tier Strategy Documentation**: Complete cost analysis and source selection strategy (TIER_STRATEGY_COMPLETE.md)

### Fixed - November 24, 2025
- **Gulf of Guinea Bug**: Fixed POIs appearing at coordinates 0,0 (Atlantic Ocean) instead of actual location
  - Added multi-layer coordinate validation (±0.01° tolerance)
  - Source-level filtering (Overpass, Mapbox, OpenAI)
  - Proximity validation (coordinates must be near search center)
  - Enhanced OpenAI prompt to return absolute GPS coordinates (not relative offsets)
- **Firestore Undefined Values**: Fixed analytics save failures due to undefined values in nested objects
  - Added `removeUndefined()` recursive cleaning before Firestore save
  - Prevents "Cannot use undefined as Firestore value" errors

### Changed - November 24, 2025
- **AI Suggestion Quality**: Lowered thresholds for more results (uniqueness 30 from 50, confidence 50% from 70%)
- **OpenAI Tokens**: Increased max_tokens from 900 to 1800 to support 10-15 POIs
- **OpenAI Temperature**: Kept at 0.45 for balanced creativity/accuracy
- **Rejection Criteria**: Relaxed to accept local viewpoints, landmarks, natural sites (not just verified establishments)
- **System Prompt**: Changed from "Quality over quantity" to "Quantity and diversity"

### Added - Previous
- **AI Diagnostics**: Comprehensive POI diagnostic system showing WHY searches fail (filtering stats, actionable suggestions).
- **Auto-trigger Removal**: Removed automatic POI search on template selection for cost control.

### Fixed - Previous
- **Web Layout**: Fixed "double scrollbar" issue on Planner and Dashboard pages using dynamic height calculation.
- **Mobile Layout**: Fixed scrolling issues on Planner and Dashboard pages (content cut-off).
- **Mobile Planner**: Refactored tabs (removed Overview, modernized Config).
- **Code Quality**: Resolved linting errors and cognitive complexity in Dashboard components.
- **AI Tests**: Fixed `injectServices` import path and added verification mocks (38 tests passing).

### Changed - Previous
- **AI Metadata**: `generatePOISuggestions` now returns metadata with diagnostic info.
- **POI Processing**: Returns `success: false` with diagnostic instead of throwing error on empty results.
- Documented the Mapbox environment variable rename (`VITE_MAPBOX_TOKEN` / `MAPBOX_ACCESS_TOKEN`) so local setups stay in sync with the codebase.

---

## [0.9.3-alpha] - 2025-10-30

### Added
- **Billing Module**: Complete subscription management UI with plan comparison, billing history, payment methods (+1,288 LOC)
- **Admin Dashboard**: Enhanced login analytics, user growth charts, system health monitoring (+536 LOC)
- **Map Controls**: Redesigned map experience with layered controls, POI management, responsive sidebar (+853 LOC net)
- **Planner Command Center**: New planner UI with AI integration, drag-drop stages, enhanced plan management (+1,112 LOC net)
- **Profile Redesign**: Dynamic stats cards, achievements grid, responsive mobile UX (+492 LOC net)
- **Navbar Enhancements**: Animated badges, haptic feedback, smart FAB, auto-hide on scroll (+316 LOC)
- **Documentation**: Complete commit history documentation (COMMITS_OCT_30_2025.md)

### Changed
- **Map Architecture**: Refactored to use shared Mapbox composable for code reuse (-79 LOC duplication)
- **Profile Service**: Now uses stored stage data instead of recalculation for accurate metrics (+136 LOC)
- **User Profiles**: Improved defaults with email/'User' fallback if displayName missing
- **Gamification**: Enhanced error handling for empty achievements collections

### Fixed
- **Profile Metrics**: Fixed incorrect plan metrics calculation (commits 913ab46e, c75aa827)
- **Map Cleanup**: Resolved runtime errors in map cleanup by ensuring safe removal
- **Gamification Errors**: Handle empty achievements collections gracefully without crashes
- **Type Safety**: Removed unused user fields (bio, plan, subscriptionStatus, preferences)

### Documentation
- Created `docs/COMMITS_OCT_30_2025.md` with complete commit analysis (20 commits)
- Created `docs/archive/BUGFIX_RUNTIME_ERRORS_2025-10-30.md` (255 lines)
- Created `docs/archive/NAVBAR_IMPROVEMENTS_2025-10-30.md` (239 lines)
- Created `docs/archive/NAVBAR_VISUAL_GUIDE.md` (257 lines)
- Updated `docs/DOC_INDEX.md` with new documentation entries
- Updated `docs/CURRENT_STATE.md` to version 0.9.3-alpha

---

## [0.9.2-alpha] - 2025-10-29

### Added
- AI plan generation endpoint (`/api/planner/plans/generate`)
- Redis optimization with compression (90% memory reduction)
- Complete persistence architecture documentation

### Changed
- Improved CRDT sync flow documentation
- Enhanced type safety protocol

### Fixed
- Auth0 user sync to Firestore immediately after login
- TypeScript compilation errors (now 0 errors)

### Documentation
- Created `docs/modules/PLANNER.md` with AI generation flow
- Updated `docs/REFERENCE.md` with new endpoints
- Created `docs/PERSISTENCE_ARCHITECTURE.md`
- Created `docs/REDIS_OPTIMIZATION_GUIDE.md`

---

## [0.9.1-alpha] - 2025-10-28

### Added
- Complete gamification module (points, badges, leaderboard)
- PWA offline-first architecture with IndexedDB
- CRDT collaboration with Yjs
- Admin dashboard with moderation tools

### Changed
- Migrated from WebSocket to HTTP polling (mobile optimization)
- Refactored all modules to use domain isolation pattern

### Fixed
- Mobile disconnection handling at 130km/h
- Offline sync queue with exponential backoff

---

## [0.9.0-alpha] - 2025-10-25

### Added
- Initial monorepo setup with Turborepo
- Vue 3 + Quasar frontend
- Fastify backend
- Firebase Authentication (Auth0)
- Firestore database
- Redis cache
- Mapbox integration
- AI POI suggestions (OpenAI)

### Modules Implemented
- ✅ planner (CRUD plans/stages)
- ✅ ai (POI suggestions)
- ✅ collab (CRDT sync)
- ✅ offline (PWA + IndexedDB)
- ✅ gamification (points/badges)
- ✅ map (Mapbox GL)
- ✅ auth (Auth0)
- ✅ sharing (public/private)
- ✅ search (discovery)
- ✅ admin (moderation)

---

## Version History

| Version | Date | Status | Highlights |
|---------|------|--------|------------|
| 0.9.3-alpha | 2025-10-30 | Current | UI redesigns, bugfixes, documentation |
| 0.9.2-alpha | 2025-10-29 | Released | Redis optimization, AI generation |
| 0.9.1-alpha | 2025-10-28 | Released | Gamification, offline-first |
| 0.9.0-alpha | 2025-10-25 | Released | Initial monorepo setup |

---

## Upcoming (0.9.4-alpha)

### Planned
- [ ] E2E tests for redesigned pages
- [ ] Performance audit (pages >1000 LOC)
- [ ] Zod schemas for new endpoints
- [ ] Mobile haptic feedback testing
- [ ] Storybook component updates

### In Discussion
- [ ] Dark mode support
- [ ] Multi-language support (i18n)
- [ ] Export plans to PDF
- [ ] Social sharing features

---

**Generated:** October 30, 2025  
**Compliance:** FOCUS.instructions.md (tables only, compressed info)  
**Source:** `docs/COMMITS_OCT_30_2025.md`
