|
Bogdan Timofte
authored
2 weeks ago
|
1
|
# UI Alignment to API Documentation
|
|
|
2
|
|
|
|
3
|
Mapare UI ↔ Operații documentate. Status implementare şi TODO-uri pentru a alinia UI la documentație.
|
|
|
4
|
|
|
|
5
|
---
|
|
|
6
|
|
|
|
7
|
## 1. Charging Monitoring
|
|
|
8
|
|
|
|
9
|
**Documentație:** [ChargingMonitoring.md](./ChargingMonitoring.md)
|
|
|
10
|
|
|
|
11
|
### Responsabilități
|
|
|
12
|
- ✅ Start → record → end sesiune
|
|
|
13
|
- ✅ Colectare măsurători ~1Hz
|
|
|
14
|
- ✅ Calculul energiei totale
|
|
|
15
|
- ⚠️ Timeout logic (incomplete)
|
|
|
16
|
|
|
|
17
|
### UI Components
|
|
|
18
|
|
|
|
19
|
| File | Status | Alignment | TODO |
|
|
|
20
|
|---|---|---|---|
|
|
|
21
|
| `MeterChargeRecordTabView.swift` | ✅ Exists | Good | Document timeout handling |
|
|
|
22
|
| `ChargeRecordSheetView.swift` | ✅ Exists | Fair | Add measurement count UI |
|
|
|
23
|
| `ChargeSessionCompletionSheetView.swift` | ✅ Exists | Fair | Show isolation interval |
|
|
|
24
|
| `BatteryCheckpointEditorSheetView.swift` | ✅ Exists | Good | Add stdDev visualization |
|
|
|
25
|
|
|
|
26
|
### Current UI Flow
|
|
|
27
|
|
|
|
28
|
```
|
|
|
29
|
MeterChargeRecordTabView
|
|
|
30
|
├─ [Start recording button]
|
|
|
31
|
├─ [Live power graph]
|
|
|
32
|
├─ [Energy counter (Wh)]
|
|
|
33
|
├─ [Duration counter]
|
|
|
34
|
└─ [Stop recording button]
|
|
|
35
|
└─ ChargeRecordSheetView
|
|
|
36
|
├─ [Completion details]
|
|
|
37
|
├─ [Battery checkpoints]
|
|
|
38
|
├─ [Charger selection]
|
|
|
39
|
└─ [Save/discard]
|
|
|
40
|
```
|
|
|
41
|
|
|
|
42
|
### Needed Alignments
|
|
|
43
|
|
|
|
44
|
1. **Invariant validation display**
|
|
|
45
|
- MUST show error if start without device
|
|
|
46
|
- SHOULD show warning if session > 24h
|
|
|
47
|
- SHOULD show warning if measurement gap > 5min
|
|
|
48
|
|
|
|
49
|
2. **Measurement monitoring**
|
|
|
50
|
- SHOULD display sample count (ex: "324 samples")
|
|
|
51
|
- SHOULD show last update time
|
|
|
52
|
- MAY show power trend (trending up/down/stable)
|
|
|
53
|
|
|
|
54
|
3. **Isolation visualization**
|
|
|
55
|
- After stop, show isolated interval on curve
|
|
|
56
|
- Highlight [real_start, real_end]
|
|
|
57
|
- Show pre/post noise regions
|
|
|
58
|
|
|
|
59
|
---
|
|
|
60
|
|
|
|
61
|
## 2. Capacity Measurement
|
|
|
62
|
|
|
|
63
|
**Documentație:** [CapacityMeasurement.md](./CapacityMeasurement.md)
|
|
|
64
|
|
|
|
65
|
### Responsabilități
|
|
|
66
|
- ✅ Learning din discharge sessions
|
|
|
67
|
- ⚠️ Health tracking (not visible in UI)
|
|
|
68
|
- ⚠️ Weighted average (calculated, not displayed)
|
|
|
69
|
|
|
|
70
|
### UI Components
|
|
|
71
|
|
|
|
72
|
| File | Status | Alignment | TODO |
|
|
|
73
|
|---|---|---|---|
|
|
|
74
|
| `ChargeSessionDetailView.swift` | ✅ Exists | Poor | Add capacity learning |
|
|
|
75
|
| `ChargedDeviceSettingsView.swift` | ✅ Exists | Poor | Show measured vs rated capacity |
|
|
|
76
|
| — | ❌ Missing | — | Battery health indicator |
|
|
|
77
|
| — | ❌ Missing | — | Capacity trend graph |
|
|
|
78
|
|
|
|
79
|
### Current UI
|
|
|
80
|
|
|
|
81
|
```
|
|
|
82
|
ChargeSessionDetailView
|
|
|
83
|
├─ [Session info: date, duration, energy]
|
|
|
84
|
├─ [Device/charger info]
|
|
|
85
|
└─ [Checkpoint list]
|
|
|
86
|
```
|
|
|
87
|
|
|
|
88
|
### Needed Alignments
|
|
|
89
|
|
|
|
90
|
1. **Capacity learning indicator**
|
|
|
91
|
- IF session = complete discharge (0% → 100%)
|
|
|
92
|
- Show: "Capacity learning: 2950 mAh ✓"
|
|
|
93
|
- ELSE
|
|
|
94
|
- Show: "Partial discharge (15%), no capacity learning"
|
|
|
95
|
|
|
|
96
|
2. **Battery health display**
|
|
|
97
|
- NEW section: "Battery Health"
|
|
|
98
|
```
|
|
|
99
|
Measured capacity: 2950 mAh
|
|
|
100
|
Rated capacity: 3000 mAh
|
|
|
101
|
Health: 98% ✓
|
|
|
102
|
```
|
|
|
103
|
- IF health < 80%: Show warning "Aged battery"
|
|
|
104
|
|
|
|
105
|
3. **Multiple measurement history**
|
|
|
106
|
- NEW tab: "Capacity History"
|
|
|
107
|
- Show last 5 discharge cycles
|
|
|
108
|
- Chart: capacity over time
|
|
|
109
|
- Show trend: "Stable" / "Degrading" / "Improving"
|
|
|
110
|
|
|
|
111
|
---
|
|
|
112
|
|
|
|
113
|
## 3. Charge Curve Isolation
|
|
|
114
|
|
|
|
115
|
**Documentație:** [ChargeCurveIsolation.md](./ChargeCurveIsolation.md)
|
|
|
116
|
|
|
|
117
|
### Responsabilități
|
|
|
118
|
- ✅ Detect start (power threshold)
|
|
|
119
|
- ✅ Detect end (trickle charge)
|
|
|
120
|
- ⚠️ Visual feedback (weak)
|
|
|
121
|
|
|
|
122
|
### UI Components
|
|
|
123
|
|
|
|
124
|
| File | Status | Alignment | TODO |
|
|
|
125
|
|---|---|---|---|
|
|
|
126
|
| `ChargeRecordSheetView.swift` | ✅ Exists | Fair | Add isolation visualization |
|
|
|
127
|
| `TimeSeriesChart.swift` | ✅ Exists | Good | Highlight isolated region |
|
|
|
128
|
|
|
|
129
|
### Current UI
|
|
|
130
|
|
|
|
131
|
```
|
|
|
132
|
ChargeRecordSheetView
|
|
|
133
|
├─ [Total energy]
|
|
|
134
|
├─ [Duration]
|
|
|
135
|
└─ [Checkpoints]
|
|
|
136
|
```
|
|
|
137
|
|
|
|
138
|
### Needed Alignments
|
|
|
139
|
|
|
|
140
|
1. **Isolated interval visualization**
|
|
|
141
|
- After completion, show original curve with:
|
|
|
142
|
```
|
|
|
143
|
Power (W)
|
|
|
144
|
20├──────────────────────
|
|
|
145
|
│ NOISE (discarded)
|
|
|
146
|
10├──────┐
|
|
|
147
|
│ ISOLATED REGION ████████
|
|
|
148
|
5├──────┘
|
|
|
149
|
│ NOISE (discarded)
|
|
|
150
|
0└──────────────────────
|
|
|
151
|
```
|
|
|
152
|
|
|
|
153
|
2. **Detection feedback**
|
|
|
154
|
- Show: "Auto-isolated [10:15–10:45] (30 min)"
|
|
|
155
|
- If manual override: "Custom selection [10:16–10:43]"
|
|
|
156
|
|
|
|
157
|
3. **Noise estimation**
|
|
|
158
|
- Show: "Pre-charge noise: 15% of total"
|
|
|
159
|
- Show: "Post-charge noise: 5% of total"
|
|
|
160
|
|
|
|
161
|
---
|
|
|
162
|
|
|
|
163
|
## 4. Charge Curve Storage
|
|
|
164
|
|
|
|
165
|
**Documentație:** [ChargeCurveStorage.md](./ChargeCurveStorage.md)
|
|
|
166
|
|
|
|
167
|
### Responsabilități
|
|
|
168
|
- ✅ Persist to Core Data
|
|
|
169
|
- ✅ CloudKit sync
|
|
|
170
|
- ⚠️ Compression visible to user
|
|
|
171
|
|
|
|
172
|
### UI Components
|
|
|
173
|
|
|
|
174
|
| File | Status | Alignment | TODO |
|
|
|
175
|
|---|---|---|---|
|
|
|
176
|
| `ChargedDeviceSessionsView.swift` | ✅ Exists | Good | Show compression status |
|
|
|
177
|
| `ChargeSessionDetailView.swift` | ✅ Exists | Good | Show sample count |
|
|
|
178
|
|
|
|
179
|
### Current UI
|
|
|
180
|
|
|
|
181
|
```
|
|
|
182
|
ChargedDeviceSessionsView
|
|
|
183
|
├─ [Session list (sorted by date)]
|
|
|
184
|
└─ [Each row: date, duration, energy]
|
|
|
185
|
```
|
|
|
186
|
|
|
|
187
|
### Needed Alignments
|
|
|
188
|
|
|
|
189
|
1. **Compression indicator**
|
|
|
190
|
- IF session < 7 days: "Full resolution (3600 samples)"
|
|
|
191
|
- ELSE IF session < 365 days: "Downsampled (360 samples)"
|
|
|
192
|
- ELSE: "Archived (metadata only)"
|
|
|
193
|
|
|
|
194
|
2. **Sync status**
|
|
|
195
|
- NEW badge: ☁️ (synced) / ⏳ (pending) / ⚠️ (conflict)
|
|
|
196
|
|
|
|
197
|
3. **Storage estimate**
|
|
|
198
|
- Footer: "Storage: 2.4 MB (on device) + 1.2 MB (iCloud)"
|
|
|
199
|
|
|
|
200
|
---
|
|
|
201
|
|
|
|
202
|
## 5. Consumption Measurement
|
|
|
203
|
|
|
|
204
|
**Documentație:** [ConsumptionMeasurement.md](./ConsumptionMeasurement.md)
|
|
|
205
|
|
|
|
206
|
### Responsabilități
|
|
|
207
|
- ✅ Select arbitrary interval
|
|
|
208
|
- ✅ Tail trimming (graph selection)
|
|
|
209
|
- ✅ Display statistics
|
|
|
210
|
- ⚠️ Predictions (weak implementation)
|
|
|
211
|
- ✅ Discard measurements
|
|
|
212
|
|
|
|
213
|
### UI Components
|
|
|
214
|
|
|
|
215
|
| File | Status | Alignment | TODO |
|
|
|
216
|
|---|---|---|---|
|
|
|
217
|
| `ConsumptionMonitorView.swift` | ✅ Exists | Good | Strengthen predictions |
|
|
|
218
|
| `TimeSeriesChart.swift` | ✅ Exists | Good | Add interval selection |
|
|
|
219
|
|
|
|
220
|
### Current UI
|
|
|
221
|
|
|
|
222
|
```
|
|
|
223
|
ConsumptionMonitorView
|
|
|
224
|
├─ [Meter selection]
|
|
|
225
|
├─ [Active session card]
|
|
|
226
|
├─ [Live metrics (Power, Energy, Time)]
|
|
|
227
|
├─ [Aggregation duration selector (300s default)]
|
|
|
228
|
├─ [Inventory list]
|
|
|
229
|
└─ [Saved sessions]
|
|
|
230
|
```
|
|
|
231
|
|
|
|
232
|
### Needed Alignments
|
|
|
233
|
|
|
|
234
|
1. **Tail trimming improvements**
|
|
|
235
|
- Current: "Stop" button
|
|
|
236
|
- NEW: Interactive graph with draggable endpoints
|
|
|
237
|
```
|
|
|
238
|
Power (W)
|
|
|
239
|
20├──────────────────
|
|
|
240
|
│ ◄─ drag start
|
|
|
241
|
│ [selected region]
|
|
|
242
|
10├──────────────────► drag end
|
|
|
243
|
│
|
|
|
244
|
0 └──────────────────
|
|
|
245
|
10:00 10:30 11:00
|
|
|
246
|
```
|
|
|
247
|
|
|
|
248
|
2. **Prediction display**
|
|
|
249
|
- Current: Only shows "Aggregation duration" selector
|
|
|
250
|
- NEW: Add prediction section
|
|
|
251
|
```
|
|
|
252
|
Measured (10:00–10:30): 12.5W avg
|
|
|
253
|
Predict next 30 min: 12.5Wh ±2.5Wh (80% confidence)
|
|
|
254
|
Predict next 24h: 300Wh ±120Wh (40% confidence ⚠️)
|
|
|
255
|
```
|
|
|
256
|
|
|
|
257
|
3. **Statistics card**
|
|
|
258
|
- Current: Only total energy + duration
|
|
|
259
|
- NEW: Add table
|
|
|
260
|
```
|
|
|
261
|
Total Energy: 12.5 Wh
|
|
|
262
|
Avg Power: 25 W
|
|
|
263
|
Peak Power: 32 W
|
|
|
264
|
Min Power: 15 W
|
|
|
265
|
Variance (σ): ±3.2 W
|
|
|
266
|
Measurement #: 1800 samples
|
|
|
267
|
```
|
|
|
268
|
|
|
|
269
|
4. **Measurement discard confirmation**
|
|
|
270
|
- Current: ✓ (button exists)
|
|
|
271
|
- NEW: Show "Discarding measurements, keeping stats..."
|
|
|
272
|
|
|
|
273
|
---
|
|
|
274
|
|
|
|
275
|
## 6. Idle Consumption Measurement
|
|
|
276
|
|
|
|
277
|
**Documentație:** [IdleConsumptionMeasurement.md](./IdleConsumptionMeasurement.md)
|
|
|
278
|
|
|
|
279
|
### Responsabilități
|
|
|
280
|
- ❌ NOT implemented in UI
|
|
|
281
|
- ❌ NO idle detection
|
|
|
282
|
- ❌ NO idle profiles
|
|
|
283
|
|
|
|
284
|
### Current State
|
|
|
285
|
|
|
|
286
|
```
|
|
|
287
|
Status: ❌ MISSING
|
|
|
288
|
```
|
|
|
289
|
|
|
|
290
|
### Required Implementation
|
|
|
291
|
|
|
|
292
|
#### New Views
|
|
|
293
|
|
|
|
294
|
1. **IdleConsumptionSetupView**
|
|
|
295
|
```
|
|
|
296
|
┌─────────────────────────────┐
|
|
|
297
|
│ Measure Idle Consumption │
|
|
|
298
|
├─────────────────────────────┤
|
|
|
299
|
│ Device: [iPhone 15 ▼] │
|
|
|
300
|
│ Charger: [USB-C 20W ▼] │
|
|
|
301
|
│ Battery: [100% ✓] │
|
|
|
302
|
├─────────────────────────────┤
|
|
|
303
|
│ [Start measurement] │
|
|
|
304
|
└─────────────────────────────┘
|
|
|
305
|
```
|
|
|
306
|
|
|
|
307
|
2. **IdleConsumptionMonitorView**
|
|
|
308
|
```
|
|
|
309
|
┌──────────────────────────────┐
|
|
|
310
|
│ Recording idle consumption...│
|
|
|
311
|
├──────────────────────────────┤
|
|
|
312
|
│ Power (W) 5 W │
|
|
|
313
|
│ Trend: ↘ (stabilizing) │
|
|
|
314
|
│ │
|
|
|
315
|
│ Time elapsed: 00:15:32 │
|
|
|
316
|
│ │
|
|
|
317
|
│ Status: ✓ Idle detected │
|
|
|
318
|
│ (power < 5W, stable) │
|
|
|
319
|
│ │
|
|
|
320
|
│ [Confirm] [Discard] │
|
|
|
321
|
└──────────────────────────────┘
|
|
|
322
|
```
|
|
|
323
|
|
|
|
324
|
3. **IdleConsumptionReviewView**
|
|
|
325
|
```
|
|
|
326
|
┌──────────────────────────────┐
|
|
|
327
|
│ Idle Profile (Adjust) │
|
|
|
328
|
├──────────────────────────────┤
|
|
|
329
|
│ Power (W) │
|
|
|
330
|
│ 5 ├───────────────── │
|
|
|
331
|
│ │ ◄─ slide to adjust │
|
|
|
332
|
│ 0 │ ████████████► idle │
|
|
|
333
|
│ └──────────────────── │
|
|
|
334
|
│ 10:15 10:45 │
|
|
|
335
|
│ │
|
|
|
336
|
│ Idle Power: 0.25 W │
|
|
|
337
|
│ Duration: 30 min │
|
|
|
338
|
│ Confidence: 85% ✓ │
|
|
|
339
|
│ │
|
|
|
340
|
│ [Save profile] [Retry] │
|
|
|
341
|
└──────────────────────────────┘
|
|
|
342
|
```
|
|
|
343
|
|
|
|
344
|
4. **DeviceIdleProfilesView**
|
|
|
345
|
```
|
|
|
346
|
┌──────────────────────────────┐
|
|
|
347
|
│ Idle Profiles │
|
|
|
348
|
├──────────────────────────────┤
|
|
|
349
|
│ iPhone 15: │
|
|
|
350
|
│ └─ USB-C 20W: 0.25 W │
|
|
|
351
|
│ └─ MagSafe: 0.20 W │
|
|
|
352
|
│ │
|
|
|
353
|
│ iPad Pro: │
|
|
|
354
|
│ └─ USB-C 30W: 0.45 W │
|
|
|
355
|
│ │
|
|
|
356
|
│ [Measure new] [Edit] │
|
|
|
357
|
└──────────────────────────────┘
|
|
|
358
|
```
|
|
|
359
|
|
|
|
360
|
#### Integration Points
|
|
|
361
|
|
|
|
362
|
1. **ChargeSessionCompletionSheetView**
|
|
|
363
|
- Add row: "Auto-terminate when: [idle power + 50%]"
|
|
|
364
|
- When user selects idle profile, pre-fill
|
|
|
365
|
|
|
|
366
|
2. **MeterChargeRecordTabView**
|
|
|
367
|
- Show idle indicator when power drops below threshold
|
|
|
368
|
- "Idle detected, session can auto-terminate"
|
|
|
369
|
|
|
|
370
|
3. **ChargedDeviceSettingsView**
|
|
|
371
|
- NEW section: "Idle Consumption Profile"
|
|
|
372
|
- Show measured idle power per charger
|
|
|
373
|
- Link to "Measure idle..."
|
|
|
374
|
|
|
|
375
|
---
|
|
|
376
|
|
|
|
377
|
## 7. System Core Operations
|
|
|
378
|
|
|
|
379
|
**Documentație:**
|
|
|
380
|
- [Operations.md](./Operations.md)
|
|
|
381
|
- [CloudKitSync.md](./CloudKitSync.md)
|
|
|
382
|
- [BluetoothDiscovery.md](./BluetoothDiscovery.md)
|
|
|
383
|
|
|
|
384
|
### Status: ✅ Mostly implemented
|
|
|
385
|
|
|
|
386
|
| Component | UI File | Status |
|
|
|
387
|
|---|---|---|
|
|
|
388
|
| BT Discovery | `SidebarMeterCardView.swift` | ✅ Good |
|
|
|
389
|
| Connection | `MeterHomeTabView.swift` | ✅ Good |
|
|
|
390
|
| CloudKit sync | (implicit) | ✅ Good |
|
|
|
391
|
|
|
|
392
|
### Needed Alignments
|
|
|
393
|
|
|
|
394
|
1. **CloudKit sync status display**
|
|
|
395
|
- Current: No visible indicator
|
|
|
396
|
- NEW: Badge in meter card "☁️ synced @ 10:45"
|
|
|
397
|
|
|
|
398
|
2. **Connection retry display**
|
|
|
399
|
- Current: Just shows "Offline"
|
|
|
400
|
- NEW: "Offline (retry in 8s...)" or "Reconnecting..."
|
|
|
401
|
|
|
|
402
|
3. **Discovery throttling indicator**
|
|
|
403
|
- MAY: Show "Last scan: 45s ago" in debug view
|
|
|
404
|
|
|
|
405
|
---
|
|
|
406
|
|
|
|
407
|
## Summary Table
|
|
|
408
|
|
|
|
409
|
| Operation | Documentație | UI Status | Alignment | Priority |
|
|
|
410
|
|---|---|---|---|---|
|
|
|
411
|
| Charging Monitoring | ✅ | ✅ Impl | Fair | Medium |
|
|
|
412
|
| Capacity Learning | ✅ | ⚠️ Partial | Poor | High |
|
|
|
413
|
| Curve Isolation | ✅ | ✅ Impl | Fair | Medium |
|
|
|
414
|
| Curve Storage | ✅ | ✅ Impl | Good | Low |
|
|
|
415
|
| Consumption Meas. | ✅ | ✅ Impl | Good | Low |
|
|
|
416
|
| **Idle Consumption** | ✅ | ❌ Missing | — | **High** |
|
|
|
417
|
| Cloud Sync | ✅ | ✅ Impl | Good | Low |
|
|
|
418
|
| BT Discovery | ✅ | ✅ Impl | Good | Low |
|
|
|
419
|
|
|
|
420
|
---
|
|
|
421
|
|
|
|
422
|
## Alignment Checklist
|
|
|
423
|
|
|
|
424
|
### High Priority (implement next)
|
|
|
425
|
|
|
|
426
|
- [ ] Idle Consumption Measurement (all 4 new views)
|
|
|
427
|
- [ ] Capacity Learning display in ChargeSessionDetailView
|
|
|
428
|
- [ ] Battery Health section in ChargedDeviceSettingsView
|
|
|
429
|
- [ ] Curve Isolation visualization in ChargeRecordSheetView
|
|
|
430
|
|
|
|
431
|
### Medium Priority (refine)
|
|
|
432
|
|
|
|
433
|
- [ ] Consumption prediction UI (confidence bounds)
|
|
|
434
|
- [ ] Measurement validation warnings
|
|
|
435
|
- [ ] Compression status indicators
|
|
|
436
|
|
|
|
437
|
### Low Priority (nice-to-have)
|
|
|
438
|
|
|
|
439
|
- [ ] Discovery throttling display
|
|
|
440
|
- [ ] Retry countdown in connection status
|
|
|
441
|
- [ ] Storage estimate footer
|
|
|
442
|
|
|
|
443
|
---
|
|
|
444
|
|
|
|
445
|
## Implementation Guide
|
|
|
446
|
|
|
|
447
|
### For each operation:
|
|
|
448
|
|
|
|
449
|
1. **Read documentation** (`ChargingMonitoring.md`, etc.)
|
|
|
450
|
2. **Identify required UI** (sections above)
|
|
|
451
|
3. **Check invariants** (MUST/SHOULD/MAY)
|
|
|
452
|
4. **Implement/update views**
|
|
|
453
|
5. **Add validation errors**
|
|
|
454
|
6. **Test with unit tests**
|
|
|
455
|
7. **Link to documentation in comments**
|
|
|
456
|
|
|
|
457
|
Example comment in code:
|
|
|
458
|
```swift
|
|
|
459
|
// See: Documentation/API Reference/ChargingMonitoring.md
|
|
|
460
|
// MUST: recordMeasurement fails if sessionState < active
|
|
|
461
|
if !session.isActive {
|
|
|
462
|
throw SessionError.invalidState
|
|
|
463
|
}
|
|
|
464
|
```
|
|
|
465
|
|
|
|
466
|
---
|
|
|
467
|
|
|
|
468
|
## Notes
|
|
|
469
|
|
|
|
470
|
- This document is a living checklist
|
|
|
471
|
- Update as UI aligns with docs
|
|
|
472
|
- Link each UI file to relevant docs
|
|
|
473
|
- Mark `// DOCUMENTED` in code for traced invariants
|