#541 Hold ongoing durations in desktop files, ending at the app's clock (#537, stage 3)
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#541
- pull request
- state:merged
Stage 3 of #537: the desktop's SQLite store and `och-convert` hold ongoing durations. This PR is stacked on #540, which is stacked on #539. I'll retarget it as those merge. ## Storage - **The ongoing end.** It is stored as neither a time nor a moment, so the `durations` CHECK becomes "at most one" for an end. A start still needs exactly one, and an ongoing start is refused. - **Older files.** Their `durations` table requires an end time or moment. The first ongoing duration saved into one copies the table into the new schema (`allow_ongoing`). Files that never hold an ongoing duration are left alone, and earlier app versions cannot open a file that does. - **The interval tree.** It holds an ongoing duration as a point at its start, like the server's, with `end_json` = `{"ongoing":true}`. A new partial index, `duration_intervals_ongoing`, finds those rows. - **Validation.** An ongoing end on a timeline without the Gregorian display is refused, matching `validateDocument`. ## Queries The desktop store has no clock of its own, so the app passes `now` with each query. - **Lists and pages** (`durations`, overlapping or keyset) read `duration_intervals` with ongoing rows resolved in SQL (`resolved_intervals`). Their filters, sort orders and offsets are therefore exact. - **Overviews** return the ongoing durations resolved at `now`. The app merges them with `frameWithOngoing`. - **The server** now answers windows with `frameWithOngoing` too, replacing the merge #540 added. The server and the desktop share one merge, which: 1. takes each placeholder out of the summary holding its start; 2. adds the resolved band, or adds it to the summaries when it collapses. ## Tests - **Rust:** new tests for windows, lists, pages, sparse close and reopen, the calendar and start rules, and migrating an old `durations` table. All 35 native tests pass, and `cargo fmt` and `clippy` are clean. - **Unit:** a new test joins a placeholder window with its ongoing durations. Over four windows, including truncated and collapsed ones, it matches what the browser index draws. - **`och-convert`:** round-trips an ongoing end, and refuses one without a calendar. - **PostgreSQL**, after the server refactor: `ongoing-durations-postgres`, `durations-postgres`, `summaries-postgres` and `views-postgres` all pass locally. - **`npm test`:** passes apart from `contents.test.mjs`, which fails locally with git `ENOBUFS`. I haven't run the desktop app itself. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/pull/541
Related
- #537 Ongoing durations: an end that is "now"
- #539 Let a duration end "now", while it is ongoing (#537, stage 1)
- #540 Save ongoing durations on the server and resolve them at its clock (#537, stage 2)
- #542 Mirror GitHub issues and pull requests into timelines (#538)
- Merge pull request #541 from openchronology/feature/ongoing-durations-native