#457 Moments and durations link to entities on other timelines, or to other timelines (#422)
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#457
- pull request
- state:merged
Closes #422. Implements the design in [the issue comment](https://github.com/openchronology/timeline-app/issues/422#issuecomment-6661346387), plus links to whole timelines and search-engine backlinks. ## What links do - **Ends:** a moment or duration on a server timeline links to a moment or duration on another timeline, or to another timeline as a whole. - **Editor:** **Related to** gains **On other timelines**. **Link to another timeline** searches the timelines you can edit (a new `writable` search scope), then offers **Link to the whole timeline** or a search of that timeline's events. - **Permissions:** linking and unlinking need write access to both timelines. A link is shown only to readers of both, and nothing reveals a link to a timeline you can't read. - **Comparisons:** - Links between compared timelines are arcs: S-curves between stacked tracks, ordinary arcs when combined, following each track's alignment. - They're read for a window three views wide and redrawn on the live `links` event. - **Behaviour change:** comparisons now also draw each timeline's own relationships on its track. - **Not content:** links are not in history, undo, forks, pull requests or exports. They live in `oc_timeline_links`. ## Deletion and limits - **Saves:** a save that deletes an entity deletes its links before committing, including saves on a fork that reads through to its source. - Sparse saves check only the entities they removed. - Whole rebuilds and imports check every link of the timeline. - Reads also look up both ends, so a stale link is never shown. - **Timeline deletion:** deleting a timeline cascades to its links. - **Limit:** `TIMELINE_LINK_LIMIT`, 10,000 per timeline by default, counting both ends. - Creating a link locks both timelines in a fixed order, so concurrent links can't overshoot. - The admin page shows each timeline's count. - **Rate limit:** linking and unlinking allow 60 per minute per account. ## Search engines - **Entity pages:** moment and duration pages list their links to other timelines, linked to the other entity's page or timeline. Both ends list the link, so they back-link each other. - **Timeline pages:** list under **Linked from** the entities that link to that timeline as a whole. - **IndexNow:** sends both ends' pages when a link is added or removed, read from `oc_link_changes`. ## API - `GET`, `POST` and `DELETE /api/timelines/{id}/links`. - `POST /api/timelines/links/query` for a comparison's arcs. - `links` on `/revision`. - All in the OpenAPI description. ## Benchmarks `bench/links.mjs`, results in `docs/benchmarks.md`. At 10,000 links: | Operation | Time | | --- | ---: | | A comparison over the whole span (stops at 256 arcs) | 25 ms | | A comparison over 1% of the span (grows about 0.02 ms per link) | 217 ms | | A page of Related to (constant) | 14–20 ms | | A sparse save deleting linked moments | Same as a save without links | | Deleting a linked timeline | 270 ms | ## Tests - **New, both in CI:** - `test/timeline-links-postgres.mjs`: API, permissions, privacy, arcs, pruning (sparse, whole, fork), cascade, limit, paging, whole-timeline links. - `test/timeline-links-live-postgres.mjs`: editor UI on desktop and phone, comparison arcs stacked and combined, and the server-rendered pages both ways. - **Extended:** `test/indexnow-postgres.mjs` covers link changes; `test/limits.test.mjs` covers `TIMELINE_LINK_LIMIT`. - **Run locally, all passing:** - unit tests; - the browser suite; - PostgreSQL tests: relationships, fork read-through, index versions, retention, time mapping, merges, limits, OpenAPI, administration, related timelines; - live browser tests: sharing, labels, default view, moment links. - **Not run locally:** the main `test/postgres.mjs` passes everything up to the file-exchange step, which needs an `och-convert` binary this machine doesn't have. CI runs it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/cod……
Related
- #422 foreign references
- #458 The editor lists what links to a timeline as a whole
- #459 Search every timeline, moment and duration from Explore
- #460 Explore searches every timeline, moment and duration, with the words highlighted (#459)
- Merge pull request #457 from openchronology/feature/422-cross-timeline-links