feat(webapp): the hub can write the document back to the file - #243
Merged
Merged
Conversation
"Whoever stops typing last writes the file" is what a relay leaves you with: the document lives only between browsers, so the only machine that can save it is one of the browsers. Close every laptop at once and whatever had not reached the 700ms idle save is gone. The hub holds the document now, so it can write it. On the last peer leaving and on the room being unloaded, the text goes back to the file. A SAFETY NET, not a replacement. The browser still saves on idle exactly as it did, and that is not double-writing: identical content journals nothing (#238), so whichever write lands second is free. What this adds is the case no client can cover. Two things it is careful about. Attribution. A version whose author is "the server" is a regression in History even when the server is holding the pen, so the snapshot is written AS the human who was editing — recorded when their connection was authorized — and a room that nobody with write access ever joined writes nothing at all rather than guessing. The route in. It re-enters the API instead of calling the uploader directly, so quota, folder permissions, the no-op check, journaling and the change frame are the same code every other write goes through. A second path into the file would be a second set of rules to keep in agreement, and they would not stay agreed. Seeding moves from the persistence adapter to OnLoadDocument while here, which hands over the actual document rather than encoded bytes — one fewer encode/decode round trip on every room that opens. Stage 3 of docs/collab-provider-prd.md. Full module: 12 packages ok. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.
TL;DR
What this actually adds
Not fewer versions — #238 already delivered that by making duplicate writes free. Durability. The one case no client can cover is every client going away at once, and until now that lost whatever hadn't reached the 700 ms idle save.
Two things it's careful about
Attribution. A version whose author is "the server" is a regression in History even when the server is holding the pen. The writer is recorded when their connection is authorized, and a room that nobody with write access ever joined writes nothing at all rather than guessing. Both pinned by tests.
The route in. The snapshot re-enters the API rather than calling the uploader directly, so quota, folder permissions, the no-op check, journaling and the change frame are all the same code every other write goes through. A second path into the file would be a second set of rules to keep in agreement — and they wouldn't stay agreed.
Also
Seeding moves from the persistence adapter to
OnLoadDocument, which hands over the actual*crdt.Docinstead of encoded bytes — one fewer encode/decode round trip per room opened.Tests
Full module: 12 packages ok, zero failures.
🤖 Generated with Claude Code