|
| 1 | +# ADR 0012: Planned-Stop WorkPeriods Are Not "Live" for the Tracking Bar |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Accepted |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +ADR 0009 classifies a WorkPeriod whose `end` is a future HH:MM as a |
| 10 | +Planned-Stop WorkPeriod, and states it "is treated as live-tracked until |
| 11 | +`end` passes". `findActiveTracking` (`src/features/day/dayStreamModel.ts`) |
| 12 | +implemented this literally: it fell back to `findActivePeriod`, which |
| 13 | +returns a Planned-Stop WorkPeriod when there is no fully open one. |
| 14 | + |
| 15 | +A future `end` can be written in two ways that are indistinguishable |
| 16 | +afterward: pressing "Stop work" with a custom future time in |
| 17 | +`TimeNowField`, or editing an open period's times directly and setting its |
| 18 | +end to a future value. Either way, the tracking bar (`ActiveTrackingRow`) |
| 19 | +stayed visible with "■ Stop work" and "▶ Start subtask" — because the |
| 20 | +period still looked "live" by ADR 0009's rule. For the Stop-button case in |
| 21 | +particular this reads as a bug: the user just pressed Stop, there is no |
| 22 | +open WorkPeriod (`end !== null`), yet the UI still offers to stop tracking. |
| 23 | + |
| 24 | +There is no data-model hook to tell the two paths apart after the fact — |
| 25 | +both just leave a WorkPeriod with a future `end`. Fixing the Stop-button |
| 26 | +case without also changing the edit-times case is not possible without a |
| 27 | +new field (the Option A that ADR 0009 already rejected), so both now |
| 28 | +behave the same way. |
| 29 | + |
| 30 | +## Decision |
| 31 | + |
| 32 | +`findActiveTracking` now only treats a fully open WorkPeriod (`end === |
| 33 | +null`) as the currently-tracked session. A Planned-Stop WorkPeriod no |
| 34 | +longer counts as active for this purpose. Once any WorkPeriod's `end` is |
| 35 | +set — whether by pressing Stop or by editing times to declare a future |
| 36 | +end — the tracking bar falls back to `NotTrackingRow`/`LogPastWorkRow` |
| 37 | +immediately, even if that end is still in the future. |
| 38 | + |
| 39 | +This only changes what counts as "active tracking" for the bar and for |
| 40 | +`DayStats.runningSince`/`lastStop`. It does not touch `isPlannedStop`, |
| 41 | +`findPlannedStopPeriod`, `findActivePeriod`, or `derivePlannedStopState` in |
| 42 | +`src/shared/worktime.ts` — the countdown-to-planned-stop badge/tray display |
| 43 | +and the projected-worked-hours totals (`BalanceRows`, `OvertimeBar`, |
| 44 | +`MonthProgressMeter`, `DayTotalsPanel`) still treat a declared future stop |
| 45 | +as something to project towards. Those features describe what the rest of |
| 46 | +the day is expected to look like; they don't need the Stop/Start-subtask |
| 47 | +controls to stay on screen to do that. |
| 48 | + |
| 49 | +## Consequences |
| 50 | + |
| 51 | +- ✅ Pressing Stop, or editing times to declare a future end, ends live |
| 52 | + tracking in the UI, matching the invariant that no open WorkPeriod means |
| 53 | + no "what's running" bar. |
| 54 | +- ❌ There is no way, with today's data model, to keep the bar live for "I'm |
| 55 | + still working, planning to leave later" while hiding it for "I already |
| 56 | + stopped, with a future timestamp" — both produce the same `end` value. |
| 57 | + Reintroducing the former would need a separate field (ADR 0009's Option |
| 58 | + A). |
| 59 | +- ✅ Countdown and projected-total features (ADR 0009) are unaffected — they |
| 60 | + read `end` directly via `worktime.ts`, not through `findActiveTracking`. |
| 61 | +- ❌ ADR 0009's "treated as live-tracked" language no longer holds for the |
| 62 | + tracking bar specifically; it now only describes the projection-facing |
| 63 | + helpers in `worktime.ts`. Readers of ADR 0009 should cross-reference this |
| 64 | + ADR for that narrower scope. |
0 commit comments