Skip to content

sideboard: stop projections sharing the automerge doc object - #78

Closed
paulsonnentag wants to merge 3 commits into
mainfrom
fix/folder-duplicate-rows
Closed

paulsonnentag wants to merge 3 commits into
mainfrom
fix/folder-duplicate-rows

Conversation

@paulsonnentag

Copy link
Copy Markdown
Contributor

A document created in a folder showed up three times in the sidebar until reload (#58). The folder doc itself was fine; the Solid store behind the list had three entries.

solid-automerge's makeDocumentProjection does createStore(handle.doc()), so the automerge document's own materialized object becomes the store's raw object and every patch is written into it in place. handle.doc() returns the same object for every handle of a document, and when a folder is open in the main pane several s each hold their own overlay handle for it (sidebar, the folder's own document list, the title bar). Each projection applied the same insert patch to the one shared array, so the row appeared once per projection. solid-automerge 2.0.1 is already the latest, so bumping it doesn't help.

Replace useDocument/makeDocumentProjection in the sideboard with a local version whose store starts from, and is only ever reconciled against, a structuredClone of the doc. It's still built on solid-automerge's useDocHandle and autoproduce; only the ownership of the store's raw object changes. Adds a unit test that fails against the upstream implementation.

A document created in a folder showed up three times in the sidebar until
reload (#58). The folder doc itself was
fine; the Solid store behind the list had three entries.

solid-automerge's makeDocumentProjection does createStore(handle.doc()),
so the automerge document's own materialized object becomes the store's
raw object and every patch is written into it in place. handle.doc()
returns the same object for every handle of a document, and when a
folder is open in the main pane several <patchwork-view>s each hold their
own overlay handle for it (sidebar, the folder's own document list, the
title bar). Each projection applied the same insert patch to the one
shared array, so the row appeared once per projection. solid-automerge
2.0.1 is already the latest, so bumping it doesn't help.

Replace useDocument/makeDocumentProjection in the sideboard with a local
version whose store starts from, and is only ever reconciled against, a
structuredClone of the doc. It's still built on solid-automerge's
useDocHandle and autoproduce; only the ownership of the store's raw
object changes. Adds a unit test that fails against the upstream
implementation.
@patchcrow

patchcrow commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

🪡 Patchwork preview

Torn down.

tldraw failed to load on fresh builds of the tools bundle:

  Failed to resolve module specifier
  "@automerge/automerge-repo-network-broadcastchannel"

Both tools took useDocument/useRepo/RepoContext and DocHandle/Repo types
from @automerge/react, which also re-exports every network adapter. The
bootloader pinned in their lockfiles (0.7.2) lists the broadcastchannel
adapter as an external, so esbuild left the re-export as a bare import;
but the deployed shell's import map is generated from an older bootloader
and has no entry for it, so the browser throws at import time.

Take the hooks from @automerge/automerge-repo-react-hooks (already a
dependency) and the types from @automerge/automerge-repo/slim, and drop
@automerge/react. The built tool.js no longer references the adapter at
all, so it loads regardless of which bootloader the shell was built with.
@chee

chee commented Oct 1, 2026

Copy link
Copy Markdown
Member

A document created in a folder showed up three times in the sidebar until reload (#58). The folder doc itself was fine; the Solid store behind the list had three entries.

solid-automerge's makeDocumentProjection does createStore(handle.doc()), so the automerge document's own materialized object becomes the store's raw object and every patch is written into it in place. handle.doc() returns the same object for every handle of a document, and when a folder is open in the main pane several s each hold their own overlay handle for it (sidebar, the folder's own document list, the title bar). Each projection applied the same insert patch to the one shared array, so the row appeared once per projection. solid-automerge 2.0.1 is already the latest, so bumping it doesn't help.

Replace useDocument/makeDocumentProjection in the sideboard with a local version whose store starts from, and is only ever reconciled against, a structuredClone of the doc. It's still built on solid-automerge's useDocHandle and autoproduce; only the ownership of the store's raw object changes. Adds a unit test that fails against the upstream implementation.

let me just do this upstream instead

@chee chee closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants