Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Margin previously stored one global workspace in localStorage. Switching documents cleared or conflated editorial state, so findings, discussions, sources, reviews, brief corrections, proposals, and assets could not compound reliably.
What changed
Architecture
Persistence now lives under margin/src/persistence with pure normalization and sanitization helpers, a versioned IndexedDB schema, legacy migration, and a document-session API. App initializes asynchronously and remounts its document workspace by stable document ID, which keeps transient UI state from leaking across documents.
Migration / compatibility
The legacy localStorage workspace is imported once and is not deleted or rewritten. DocumentRecord includes a local Markdown working snapshot because browsers cannot reliably restore external file handles after reload. The snapshot restores the editing session; ordinary Markdown remains the portable authored artifact and external files are only written through explicit Save or Export actions.
Tests
Screenshots or UX notes
The document menu now includes recent Margin documents, and startup has an explicit local-library loading boundary. Manual browser acceptance could not be run in this Codex session because the browser controller reported that no browser was available. The persistence paths are covered by focused fake-IndexedDB integration tests, but this PR remains draft until the following UI scenario is exercised:
Documentation
Risks / follow-ups
Closes #2