Stream exported timelines and saved revisions
- github
- github/openchronology/timeline-app
- commit
- main
- github/athanclark
Exporting a timeline (GET /api/timelines/:id/document) and reading a saved revision (GET /api/timelines/:id/history/:saved) built the whole document in the server's memory: about 1.1 GB at a million moments. Both now read the moments, durations and relationships through cursors a page at a time from one read-only snapshot, in the orders their indexes give, and send the JSON as it is read (server/document-stream.mjs): about 0.1 GB at any size, with the first part after 0.2 s. ?download=1 sends the document as an .ochx file. The Next.js route hands such a response a stream it pulls from, so a client that stops reading closes the cursors and gives the connection back. The saved revision page links to the download instead of handing the browser the whole document, and shows the document inline only for timelines of up to 5,000 moments. Streamed documents list the same entities as before in another order: moments by ID, durations by start, relationships by key (sorting a large timeline's moments by time would take longer than a statement may). Relationships read whole now come in a document's order, so exports are deterministic. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/commit/a7fd446100f2e9817911e27cfec720d798b35594
Open Stream exported timelines and saved revisions in the timeline