Repository navigation
Conditional note writes and a watcher fix for vault switches - #85
Merged
Merged
Conversation
Startup seeds the watcher with the vault's systemFolderPaths (cmd/zennotes-server/main.go), but switchVaultRoot started its new watcher with none. Until the switched vault's vault.json next changed, the watcher sorted every change event into the default folder names, so a vault that keeps Trash in deleted/ reported a note trashed there as an ordinary note, and a client trusting the event's folder showed it in the wrong place. The switch now seeds the new watcher from the new vault's settings, the same way startup does. The folder rules themselves are untouched. The test selects a vault that maps Trash to deleted/, writes a note there and expects the event's folder to be trash; it reports inbox without the fix. Found while designing the offline copy for ZenNotes#1108.
A note write was last writer wins. A client that read a note, changed it and wrote it back wrote over anything another device saved during that round trip, and the desktop's retry after an outage (ZenNotes#1108) could only narrow that window with a read just before its write, never close it. A note read and a note write now answer with the `sha256` of the note's bytes on disk. A write may send it back as `baseSha256`: under the same vault lock as the write, the server hashes the file and refuses with 409, writing nothing, when the note is no longer that version or is gone. Clients never hash on their side; they echo what the server returned, so the value does not depend on what JSON did to the body (a stray non-UTF-8 byte reaches them as U+FFFD). A base that is not a hex SHA-256 is a 400, never compared and never dropped into an unconditional write. A write without one is unconditional, exactly as every older client sends it. Listings carry no hash, so they cost what they did. The capability is `supportsConditionalNoteWrites`. This is phase 1 of the offline-copy design in ZenNotes docs/ideas/remote-offline-copy.md. It keeps no state on the server: no revision index, no change log. Those come with the sync protocol in phase 2.
On Windows fsnotify sends change events and answers Add from the same goroutine. Start walked the vault and added every folder before anything read those events, so a change in a folder it had already added (the vault writing its own files as it opens is enough) left fsnotify waiting to hand over the event, and the next Add waited for fsnotify forever. The vault switch request never answered; the same walk runs at startup. The loop had the same trap when it added a newly made folder in the middle of a burst. The new vault switch test is what found it: it hung windows-latest for the full ten minutes. The watcher now starts a pump before its first Add. It reads fsnotify's events and errors as they come, queues the events, and hands them to the loop, so fsnotify is never left holding one. Linux and macOS answer Add on their own, so there the queue only moves the backlog from fsnotify to us. The new watcher test starts watching forty folders while a note in the vault root keeps changing, then makes a folder in the middle of it and expects to hear about it.
This was referenced Nov 23, 2026
Merged
renovate Bot
added a commit
to scottames/copr
that referenced
this pull request
Nov 23, 2026
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ZenNotes/zennotes](https://redirect.github.com/ZenNotes/zennotes) | minor | `2.90.0` → `2.91.0` | --- > [!WARNING] > Some dependencies could not be looked up. Check the [Dependency Dashboard](../issues/3) for more information. --- ### Release Notes <details> <summary>ZenNotes/zennotes</summary> ### [`v2.91.0`](https://redirect.github.com/ZenNotes/zennotes/releases/tag/v2.91.0): ZenNotes v2.91.0 [Compare Source](https://redirect.github.com/ZenNotes/zennotes/compare/v2.90.0...v2.91.0) ZenNotes 2.91.0 keeps your edits safe when a self-hosted server goes away: a note you change while the server is unreachable says Not saved, saves itself when the server is back, and never writes over a change another device made in the meantime. Install for OpenCode no longer rewrites your OpenCode settings, and a failed Connect to Remote Vault no longer locks the address field on Windows. Released from [`82360d73`](https://redirect.github.com/ZenNotes/zennotes/commit/82360d73b17c9e7b4f465761447d899842c04c3a) through [#​1110](https://redirect.github.com/ZenNotes/zennotes/pull/1110) on 2026-11-23. #### Fixes - **Edits made while your server is away are kept** ([#​1108](https://redirect.github.com/ZenNotes/zennotes/issues/1108), from a request by [@​dwnsdp](https://redirect.github.com/dwnsdp)). A remote vault keeps nothing on your computer, so while its server cannot be reached a save fails. Until now the note only kept the small unsaved dot every pending save shows, nothing tried again when the server came back, and quitting lost the edit. Now: - The note's header says **Not saved** (hover it for the reason), and a message stays on screen until the note is saved. - ZenNotes saves it by itself: a few seconds after the failure, then once a minute, and at once when the connection or the network comes back. - Nothing is overwritten. If someone changed the same note on the server in the meantime, their version is kept beside yours as **Note (server copy)**. With server 2.91.0 or later the server checks this itself in the same step as the write, so even a change that lands during the save is kept. - Quitting ZenNotes or closing a window while a note is not saved asks first. - **Install for OpenCode keeps the rest of your config** ([#​1104](https://redirect.github.com/ZenNotes/zennotes/issues/1104), reported by [@​coyotle](https://redirect.github.com/coyotle)). OpenCode allows comments and trailing commas in `opencode.json`. When the file had them, Install for OpenCode in Settings, MCP read it as empty and wrote back only its own entry, so providers, models and every other setting were gone. ZenNotes now reads the file the way OpenCode does and changes only its own `mcp.zennotes` entry, keeping your comments and formatting. A file it still cannot read is left untouched, and Settings shows the line and column of the problem. When you have only an `opencode.jsonc`, that file is edited instead of a second config being started beside it. - **A failed Connect to Remote Vault leaves the address field typeable on Windows** ([#​1106](https://redirect.github.com/ZenNotes/zennotes/issues/1106), reported by [@​medzsikmisi](https://redirect.github.com/medzsikmisi)). When a server turned the connection down, the error came in a native Windows message box, and after OK no text field took typing until ZenNotes restarted. The error now shows in the app's own dialog, without Electron's "Error invoking remote method" prefix, and Quick Connect remembers the address you last tried for the rest of the session. #### zn and the server - **The desktop app bundles zn 0.18.2**, whose terminal app autosave and CLI and MCP edits use the same server check, so they never overwrite a note another device just changed. - **Server 2.91.0** answers note reads and writes with the note's `sha256` and takes an optional `baseSha256` on writes, refusing with 409 when the note changed. It also fixes the file watcher after a vault switch, which sorted changes into the default folder names instead of the vault's own, and a hang that switch could cause on Windows ([ZenNotes/znserver#85](https://redirect.github.com/ZenNotes/znserver/pull/85)). #### For contributors - **The offline copy for remote vaults is designed**, not built: `docs/ideas/remote-offline-copy.md` describes a local copy kept in step with the server by the Cloud sync engine, with the decisions taken so far. Conditional writes are its phase 1. - **`supportsConditionalNoteWrites`** is the server capability the desktop retry, zn and the MCP server look for. Against an older server the desktop falls back to reading the note just before it writes, which narrows the window but cannot close it. - **`jsonc-parser`** is bundled into the desktop main process (not externalized), per the packaging rule for pure-ESM main dependencies. #### Verification How to test locally: 1. Run a ZenNotes server and connect to it with Connect to Remote Vault (command palette). 2. Open a note, stop the server, and type a line. Before: the note kept the unsaved dot and nothing else happened. After: the header says Not saved and a message stays up. 3. Start the server again. Within a few seconds the note saves and the message goes away. 4. Stop the server, type another line, then try to quit. Before: ZenNotes quit and the edit was gone. After: it asks first. 5. For a conflict: stop the server, edit a note, change the same note on the server from another device or with `zn`, then start the server. Your version is saved, and the server's is kept beside it as Note (server copy). 6. For OpenCode: put a `// comment` and a provider in `~/.config/opencode/opencode.json`, then Settings, MCP, Install for OpenCode. Before: the file held only the ZenNotes entry. After: your comment and provider are still there. 7. On Windows: Connect to Remote Vault to a server that refuses you (no token), click OK on the error, and type in the address field. Before: nothing typed. After: it types, and the address you tried is filled in. #### Distribution channels - **GitHub:** this release, latest, with all five update feeds. Every file they name was checked, and the app in both macOS DMGs is Notarized Developer ID and stapled. - **AUR:** `zennotes-bin 2.91.0-1`, pinned to the Linux tarball's SHA-256 `1d09d88b…31d6e46d`. - **Homebrew:** the `zennotes` cask in ZenNotes/homebrew-tap (`979d1c7`), and the `zn` formula on 0.18.2 (`d7d7449`). - **Nix:** `packaging/nix/release-data.json` (`a602e951`), built on `main` (run [`4525295`](https://redirect.github.com/ZenNotes/zennotes/commit/45252959098)). - **nixpkgs:** [NixOS/nixpkgs#590905](https://redirect.github.com/NixOS/nixpkgs/pull/590905), now `zennotes-desktop: 2.88.0 -> 2.91.0`, waiting for nixpkgs review. - **Self-hosted server:** [2.91.0](https://redirect.github.com/ZenNotes/znserver/releases/tag/v2.91.0), latest, with the 2.91.0 web client. Docker `adibhanna/zennotes` `2.91.0`, `2.91` and `latest` point at `sha256:81f2df1b…1fc978`. - **zn:** [0.18.2](https://redirect.github.com/ZenNotes/tui/releases/tag/v0.18.2), released first and bundled here. - **Phones:** unchanged. Nothing in this release changes them; iPhone 1.43.0 and Android 1.1.62 are current. - **Website:** the release page, zn 0.18.2 and server 2.91.0 on their tabs, and the docs for Not saved and the bundled CLI. #### Release validation - On `82360d73`: typecheck, every test suite uncached (shared-domain 2720, portable-vault 398, app-core 4969, quicklook 18, web 76, desktop 1977), `build:prod`, the packaged app (signed, launch check: page target, rendered, 2.91.0, bundled zn 0.18.2) and the three smoke suites. No hazards, no audit findings, no long dashes. Every CI job passed on the release pull request and on `main` before the tag. - The gate found one thing. On its first full run, two note tests failed once: a save-retry timer from an earlier test fired inside a later one. Users could not lose a write that way (the retry goes through the normal save, which respects renames and vault switches), but after a vault switch the old vault's "Couldn't save" message could stay on screen. Each retry now remembers the vault and connection it belongs to, with two new tests, and every check ran again. - The fixes were driven in the built app: the remote save retry and server copy over CDP against a real server, including a save landing in the middle of a retry; Install for OpenCode with a commented config; and the address field on the shipped Windows build in a Windows VM. - znserver 2.91.0: Go tests on Linux, macOS and Windows, the MCP contract, Docker and Nix passed; the binaries match `SHA256SUMS`, and an isolated run reports 2.91.0 and `supportsConditionalNoteWrites`. One MCP contract job failed on a GitHub 403 while cloning zn and passed on a re-run. - The macOS pack hit this Mac's code-signing timestamp failure; it was signed through Apple's timestamp server by its IPv4 address. CI builds are unaffected. - Not tested before release: the iPhone Cloud UI tests (waived: no phone change), and packaged Windows and Linux builds beyond CI. </details> --- ### Configuration 📅 **Schedule**: (in timezone America/Los_Angeles) - Branch creation - Every minute (`* * * * *`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/scottames/copr). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTcuMyIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Ny4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.
Two changes for the next server release, both found while designing the offline copy for remote vaults (ZenNotes/zennotes#1108, design in
docs/ideas/remote-offline-copy.mdon ZenNotes/zennotesv2.91.0).sha256of the note's bytes on disk. A write may send it back asbaseSha256; under the vault lock the server refuses with 409 and writes nothing when the note changed or is gone. A malformed base is a 400. A write without one is unconditional, as every older client sends it. Advertised assupportsConditionalNoteWrites. No new server state.switchVaultRootstarted the new watcher without the switched vault'ssystemFolderPaths, so change events were sorted into the default folder names until its vault.json next changed. The switch now seeds the watcher the way startup does. The folder rules are untouched.The desktop side is on ZenNotes/zennotes
v2.91.0(f7f585fc): its retry after an outage sendsbaseSha256when the server advertises the capability, so a save made meanwhile is kept as "(server copy)" instead of being overwritten. Against an older server it falls back to the 2.91.0 read-then-write check.Verification:
go vet ./...andgo test ./...green; the watcher test reports inbox without the fix; the desktop change was driven over CDP against a server built from this branch, with the mid-retry race kept as a server copy.