Repository navigation
Feat(sync): a ZenNotes app can keep an offline copy of this vault - #88
Merged
Merged
Conversation
A remote vault was a pass-through: with the server away, nothing opened and nothing saved (ZenNotes#1108). The offline copy is a real folder on the device, kept in step by ZenNotes Cloud's own sync engine, and this is the half that lives on the server. The server now keeps a revision for every text file in the vault and a change log, in .zennotes/sync/ inside the vault, so it follows a vault switch or a move to another server. Every write path records its change under the vault lock it already takes: the web client, the phones, both zn builds and /mcp. A rename, trash or folder rename is one move per file, so each keeps its identity, and Empty Trash is one delete per file. Edits made outside the server (a shell, git pull, Syncthing) are found by a reconcile that stats first and hashes only what changed. Until one has run, a sync write compares the disk, so such an edit is never written over. /api/sync/manifest, /api/sync/changes and /api/sync/mutations speak Cloud's wire shapes without encryption. A change lands only if its file is still at the revision it was built on, each change is answered on its own, and a repeated operation id gets its first answer. A copy older than the 90-day log rebuilds from the manifest. /api/capabilities says supportsSync: 1. Attachments are not part of a copy yet and are set aside as Cloud sets aside a path it refuses. integration/cloud-engine drives Cloud's CloudSyncCoordinator and the desktop's sync repository, taken from a pinned ZenNotes commit, against a real server: bootstrap, offline edits replayed, a conflict held for review, renames and deletes both ways, an edit made on the server's disk, and a cursor older than the log. CI runs it on Linux, macOS and Windows.
Git Bash on Windows rewrites an argument that starts with / into a Windows path, so the sparse-checkout patterns (/packages/shared-domain/src/ and the rest) matched nothing and the ZenNotes checkout came out empty. The step now names the folders in cone mode, with no leading slash.
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.
A remote vault was a pass-through: with the server away, nothing opened
and nothing saved (ZenNotes#1108). The offline copy is a real folder on the
device, kept in step by ZenNotes Cloud's own sync engine, and this is the
half that lives on the server.
The server now keeps a revision for every text file in the vault and a
change log, in .zennotes/sync/ inside the vault, so it follows a vault
switch or a move to another server. Every write path records its change
under the vault lock it already takes: the web client, the phones, both zn
builds and /mcp. A rename, trash or folder rename is one move per file, so
each keeps its identity, and Empty Trash is one delete per file. Edits made
outside the server (a shell, git pull, Syncthing) are found by a reconcile
that stats first and hashes only what changed. Until one has run, a sync
write compares the disk, so such an edit is never written over.
/api/sync/manifest, /api/sync/changes and /api/sync/mutations speak Cloud's
wire shapes without encryption. A change lands only if its file is still at
the revision it was built on, each change is answered on its own, and a
repeated operation id gets its first answer. A copy older than the 90-day
log rebuilds from the manifest. /api/capabilities says supportsSync: 1.
Attachments are not part of a copy yet and are set aside as Cloud sets
aside a path it refuses.
integration/cloud-engine drives Cloud's CloudSyncCoordinator and the
desktop's sync repository, taken from a pinned ZenNotes commit, against a
real server: bootstrap, offline edits replayed, a conflict held for review,
renames and deletes both ways, an edit made on the server's disk, and a
cursor older than the log. CI runs it on Linux, macOS and Windows.
Phase 2 of docs/ideas/remote-offline-copy.md in ZenNotes/zennotes. No release, no version bump: which server release carries it is still open.
Verified locally:
go vet ./...,go test ./...,-raceon vault, httpserver and watcher, and the engine integration test (11 scenarios) on macOS and Linux (arm64, in Docker). Windows runs for the first time in the newsync-enginejob.