summaryrefslogtreecommitdiff
path: root/.agent/worklog.md
blob: 2d62bdb8f04d2a8efb82a2056320592800d4479c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# SESSION_STATE.md

## Backlog (fix later)

- **Pirate mode** — Re-introduce as an Easter egg / toggle, not the default voice. Long-press the trip report header (or a hidden gesture) flips the narrative into pirate dialect. Keep the seamanlike default; pirate is opt-in fun.

- **Tack detection is buggy, especially at low speed** — False positives at low SOG (GPS heading noise looks like tacks). Need minimum-SOG gate (e.g. skip detection when SOG < 1.5 kt) and review the stability window / MIN_DELTA thresholds against real tracks.

## Current Task Goal
Logbook + Trip Report Improvements — COMPLETE (2026-05-26)

Delivered:
- **Add notes/photos to finished track** — `+ Add note` button in `TrackDetailSheet` opens a dialog with text entry, camera, and gallery. Notes are saved with `timestampMs = track.endMs` so they fall within the track window and appear in `buildLogEvents()` automatically. The map is re-built via `logEventAdapter.update()` after save.
- **Trip report single Nav voice** — Removed `NarrativeStyle` enum and the 4-style ChipGroup. `generateNarrative(summary)` now emits a concise `PASSAGE` header with date/time range, stats, conditions, and a timestamped deck log. `fragment_trip_report.xml` no longer has the style picker.
- **Speed coloring fixed** — Replaced the broken `Expression.get("color")` (reads a string feature property, silently fails for `lineColor` on `LineLayer` in MapLibre Android 11.x) with `Expression.step(Expression.get("speed"), ...)` which maps the numeric `"speed"` property directly to color literals. `speedSegments()` no longer writes the unused `"color"` string property.

---

## Previous Task Goal
Instrument Sheet Visual Redesign — IN PROGRESS (2026-04-06)

**Plan:** `docs/superpowers/plans/2026-04-04-instrument-sheet-visual-redesign.md`
**Spec:** `docs/superpowers/specs/2026-04-04-instrument-sheet-visual-redesign.md`

### Progress
- [x] Task 1: Remove report buttons + fix touch-through — **DONE** (commit `2d86c0b`)
- [x] Task 2: Update typography styles — **DONE** (commit `e79b678`)
- [ ] Task 3: Create `DirectionArrowView` — pending
- [ ] Task 4: Create `WaveView` — pending
- [ ] Task 5: Restructure `layout_instruments_sheet.xml` — pending
- [ ] Task 6: Refactor `InstrumentHandler` — pending
- [ ] Task 7: Update `MainActivity` — wire new views and fix units — pending

### What's being built
A visual redesign of the instrument bottom sheet:
- Animated wave canvas divider (swell height/period + wind waves + whitecaps) replacing the plain divider between instruments and forecast
- Sky-blue gradient above wave, ocean blue below
- `DirectionArrowView`: 14dp inline chevron compass indicator in two palettes (SKY grey / OCEAN blue)
- Direction arrows inline with numeric values in all relevant cells
- `°` baked into HDG/COG values (not a separate unit label)
- Forecast cells: value on line 1, [arrow] bearing on line 2 (swell adds period)
- Imperial units: feet for depth, wave height, swell height (all converted from metres)
- Forecast labels: "Current" (not "Curr"), "Waves" (not "Wave"), no section header
- Touch-through prevention: clickable/focusable on root layout
- Reports section removed

### Key files
| File | Status |
|---|---|
| `layout_instruments_sheet.xml` | Partially done (Task 1 applied; full restructure in Task 5) |
| `DirectionArrowView.kt` | Not created yet |
| `WaveView.kt` | Not created yet |
| `InstrumentHandler.kt` | Not refactored yet |
| `MainActivity.kt` | Task 1 applied; Task 7 changes pending |
| `themes.xml` / `dimens.xml` | Done |

---

## Previous Task Goal
Section 7.4 Trip Reporting & Enhanced Tracks — COMPLETE (2026-04-04)

## Verified (2026-04-04)
- Build Successful: `android-app/gradlew assembleDebug` passed.
- UI Layout: `activity_main.xml` refactored to LinearLayout to prevent BottomNav overlap.
- Track Differentiation: Active (solid) vs Past (dotted) tracks verified in `MapHandler.kt`.
- Pre-Trip Logic: Sail suggestions reefing logic verified in `PreTripReportGenerator.kt`.

## Completed Items

### [APPROVED] Trip Narrative Generator + Multi-Style AI (2026-04-04)
- `android-app/app/src/main/kotlin/org/terst/nav/tripreport/TripReportGenerator.kt`: Logic for distance, speed, and stylized narratives (Professional, Adventurous, Journal, Pirate).
- `android-app/app/src/main/kotlin/org/terst/nav/tripreport/TripReportViewModel.kt`: State management for narrative generation.
- `android-app/app/src/main/kotlin/org/terst/nav/tripreport/TripReportFragment.kt`: UI for viewing and selecting narrative styles.

### [APPROVED] Pre-Trip Planning & Sail Suggestions (2026-04-04)
- `android-app/app/src/main/kotlin/org/terst/nav/tripreport/PreTripReportGenerator.kt`: Routing and reefing suggestions based on wind/waves.
- `android-app/app/src/main/kotlin/org/terst/nav/tripreport/PreTripModels.kt`: Domain models for boat profiles and suggestions.
- `android-app/app/src/main/kotlin/org/terst/nav/tripreport/PreTripReportFragment.kt`: UI for generating and viewing pre-trip plans.

### [APPROVED] Enhanced Map & Track Visualization (2026-04-04)
- `android-app/app/src/main/kotlin/org/terst/nav/ui/MapHandler.kt`: `updateTrackLayer` now supports active and past tracks with distinct styles.
- `android-app/app/src/main/res/layout/activity_main.xml`: Refactored to vertical LinearLayout root to stabilize BottomNav and FAB placement.
- `android-app/app/src/main/res/layout/layout_instruments_sheet.xml`: Added "TRIP REPORTS & PLANNING" section for direct access from main view.
- `android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt`: Wired Pre-Trip and Trip Report buttons from instrument sheet; added `showReport` navigation helper.
- `android-app/app/src/main/kotlin/org/terst/nav/track/TrackRepository.kt`: Added `pastTracks` storage.
- `test-runner/src/main/kotlin/org/terst/nav/track/TrackRepository.kt`: Synchronized with main app implementation.

### [APPROVED] GpsPosition data class (2026-03-15)
- File: `app/src/main/kotlin/org/terst/nav/gps/GpsPosition.kt`
- Fields: latitude, longitude, sog (knots), cog (degrees true), timestampMs

### [APPROVED] DeviceGpsProvider (2026-03-15)
- Wraps `LocationManager` with `GPS_PROVIDER`
- Fix-lost timer: fires `onFixLost()` after 10s with no update

### [APPROVED] NmeaParser — RMC parser (2026-03-15)
- Parses any `*RMC` sentence (GP, GN, etc.)
- HHMMSS + DDMMYY → Unix epoch millis UTC

### [APPROVED] AIS Integration (2026-03-15)
- `AisVdmParser.kt`: Parses !AIVDM/!AIVDO (Types 1, 2, 3, 5).
- `AisRepository.kt`: Upserts vessels and merges static data.
- `AisHubSource.kt`: Integration with AISHub REST API.
- `MapFragment`: GeoJSON layer for AIS vessels with rotation and labels.

### [APPROVED] Track Recording (2026-03-25)
- `MainViewModel`: TrackRepository wired; `addGpsPoint` enriches with environmental data.
- `MainActivity`: FAB for toggling recording; MapHandler for rendering.

### [APPROVED] TrackRepository (2026-03-25)
- `android-app/app/src/main/kotlin/org/terst/nav/track/TrackRepository.kt`
- `test-runner/src/main/kotlin/org/terst/nav/track/TrackRepository.kt`
- `isRecording` flag; `startTrack()` clears + starts; `stopTrack()`; `addPoint()` guards on isRecording; `getPoints()` returns snapshot
- 8 tests — all GREEN (`TrackRepositoryTest`)

### [APPROVED] Track ViewModel + Map overlay + Record FAB (2026-03-25)
- `MainViewModel`: TrackRepository wired in; exposes `isRecording: StateFlow<Boolean>`, `trackPoints: StateFlow<List<TrackPoint>>`; `startTrack()`, `stopTrack()`, `addGpsPoint(lat, lon, sogKnots, cogDeg)`
- `MapHandler.updateTrackLayer(style, points)`: lazy LineLayer init; red (#E53935) 3dp polyline from List<TrackPoint>
- `MainActivity`: stores `loadedStyle`; GPS flow feeds `viewModel.addGpsPoint()` (m/s→knots); observes `trackPoints` → `mapHandler.updateTrackLayer()`; observes `isRecording` → FAB icon toggle (ic_track_record / ic_close)
- `activity_main.xml`: `fab_record_track` FAB anchored top|end of bottom nav
- `drawable/ic_track_record.xml`: red dot record icon

### [APPROVED] Vessel Registry + Crew Management (2026-04-22)
- `android-app/app/src/main/kotlin/org/terst/nav/vessel/Vessel.kt` — data class: name, MMSI, callsign, flag, homePort, hullType, LOA, beam, draft, displacement, engineHp, notes, isOwnVessel
- `android-app/app/src/main/kotlin/org/terst/nav/vessel/CrewMember.kt` — data class: name, role (SKIPPER/FIRST_MATE/WATCH_CAPTAIN/CREW/GUEST), emergencyContact, emergencyPhone, certifications, notes
- `android-app/app/src/main/kotlin/org/terst/nav/vessel/VesselRepository.kt` — in-memory CRUD for vessels and crew; addVessel, updateVessel, removeVessel, getOwnVessel, addCrewMember, updateCrewMember, removeCrewMember, getSkipper, getCrewByRole
- `android-app/app/src/main/res/layout/fragment_vessel_registry.xml` — NestedScrollView with own vessel card, crew list, and known vessels list; + ADD buttons for crew and fleet
- `android-app/app/src/main/kotlin/org/terst/nav/ui/vessel/VesselRegistryFragment.kt` — fragment with AlertDialog editors for vessels and crew; long-press to delete
- `android-app/app/src/main/res/menu/bottom_nav_menu.xml` — added `nav_vessel` 5th tab with `ic_vessel` icon
- `android-app/app/src/main/res/drawable/ic_vessel.xml` — sailboat silhouette vector icon
- `MainViewModel.kt` — added `vesselRepository` property (public, for fragment access)
- `MainActivity.kt` — `R.id.nav_vessel` case loads `VesselRegistryFragment`
- Mirror classes in `test-runner/src/main/kotlin/org/terst/nav/vessel/`
- 18 tests in `test-runner/src/test/kotlin/org/terst/nav/vessel/VesselRepositoryTest.kt` — all GREEN

### [APPROVED] Thermal Alarm (2026-04-22)
- `android-app/app/src/main/kotlin/org/terst/nav/thermal/ThermalMonitor.kt` — `thermalFlow(context)` as Kotlin Flow using `Intent.ACTION_BATTERY_CHANGED` for battery temperature; `PowerManager.addThermalStatusListener` on API 29+ for supplemental state; emits distinct `ThermalReading` only on state change
- `ThermalState` enum: OK (<40°C), WARM (40–45°C), HOT (45–50°C), CRITICAL (>50°C)
- `MainViewModel.kt` — `thermalState: StateFlow<ThermalState>`, `thermalReading: StateFlow<ThermalReading?>`, `onThermalReading()` entry point
- `MainActivity.kt` — `startThermalMonitoring()` called from `observeDataSources()`; HOT triggers Toast + alarm sound (reuses `R.raw.mob_alarm`); CRITICAL triggers urgent Toast + alarm; OK/WARM stops alarm; alarm released in `onDestroy()`

## Next 3 Specific Steps
1. **Unit Tests for Trip Generators** — Add JVM tests in `test-runner` for `TripReportGenerator` and `PreTripReportGenerator`.
2. **Persist track to Room** — Replace in-memory `pastTracks` with a Room database for persistence across sessions.
3. **AnchorWatchHandler UI** — Re-integrate `AnchorWatchHandler` UI into `activity_main.xml` and wire it to the Safety Dashboard.

## Scripts Added
- `test-runner/` — standalone Kotlin/JVM Gradle project for fast test cycles.

## Process Improvements
- Stabilized UI layout by moving navigation out of the `CoordinatorLayout`.
- Duplicated core logic into `test-runner` to bypass Android SDK requirements for logic testing.