# Reading, editing and history

| Action | Behaviour |
| --- | --- |
| Open | A topic or Core source record shows rendered Markdown, with its footnotes and links. Controls: Preview, Edit, History. |
| Edit | Source text. No Save button. |
| Save | Each edit goes straight to local draft storage and through a writer serialized per file. A reply never marks newer typing as saved. |
| Undo, redo | Individual edits, across automatic saves |
| History | Newest first, 50 at a time, with local date and time and commit message. Older entries load on demand. |
| Select a revision | Lines added and removed against its parent |
| Restore this version | Commits the current state, then a new commit with the chosen document. History is kept. |

## Git checkpoints

Manual edits are grouped into five-minute checkpoints. The first edit commits `memory: before manual editing` and records a durable deadline, so the pre-edit state survives even if it was written outside the UI. A server-owned task checks the deadline every 15 seconds and commits `memory: manual editing checkpoint`, also when the page has closed. Restarts resume pending deadlines.

## Data and failure handling

| Case | Behaviour |
| --- | --- |
| Write path | Staged write: validates references, rebuilds derived views, commits Git history, renders Markdown as before. Source validation is unchanged. |
| Stale edit | Submitted `base_content` is compared under the write lock; a mismatch is rejected and the draft kept with an error. |
| Normalization | The reply returns canonical saved text, because normalization may alter source. |
| Headings only | Kept as saved: a person's save never prunes a Topic, and an uncited paragraph a person writes gets a block ID like any other. |
| Status shown | Errors and warnings inline only (a failed Git commit); no saving or saved indicator. The preview puts a Nova badge "Added by you" after each paragraph a person added without a citation, and a file written outside OpenProgram gets one badge by its title, "Written outside OpenProgram · read only to memory". |
| Navigation, reload | Drafts survive locally. |
| Access | Owner-authorized endpoints read bounded Git history restricted to topic Markdown. Path and revision inputs cannot escape Memory; a revision must be a full commit id. |

## Source links and sidebar

| Item | Behaviour |
| --- | --- |
| Archived session | Hidden, with no expiry or capacity deletion |
| Deleted session | Its links are unavailable and labelled Original session deleted; no extra source copy is made. The memory remains. |
| Source content | Existing Memory source storage is checked before exposing it. |
| Memory navigation, refresh | Reuse the primary sidebar row and icon-button styles. |

**References**

| Reference | Adopted | Boundary |
| --- | --- | --- |
| [HackMD versions](https://hackmd.io/@hackmd-blog/hackmd-versions-api-2026) | Version list and visible differences | No collaborative editing or named versions |
| [Obsidian history](https://obsidian.md/help/sync/version-history) | Automatic persistence and accessible history | Local Git; no sync service |

## Implementation status

Implemented. Route tests cover deferred Git commits, restoration and deleted-source access; controller tests cover serialized writes and undo and redo; archive tests cover retention across restart.
