Repository navigation
Integrate Phase 2 batch 2: #125, #123, #127, #124 - #129
Merged
Merged
Conversation
WriteGate filters every local transaction that changes the document while canWrite() is false, appended ones included, so read-only never makes a Yjs update that would later have to be dropped (details spec §1 rules 1-2). Changes from Yjs and meta-only transactions pass. The decoration host generalises the action-preview stub (rule 6): each declared layer is one plugin holding a DecorationSet, set by the meta-only setDecorationLayer command and mapped or cleared on document changes, so comments and Find add no eager plugin of their own.
tsconfig.desktop-node.json covers desktop/{storage,main,build} with Node
types and no Bun types, so a Bun-only API fails the typecheck in code that
runs inside Electron (desktop architecture §3.2). The root project excludes
those folders.
The SQLite engine behind the desktop library (plan P2.6), behind a SqliteDriver seam so the same code runs on node:sqlite in the Electron storage worker and on bun:sqlite in tests: - format-1 schema: docs (lineage, link_key minted at insert, kind and the list columns), folders, tags, doc_tags, doc_view, import_sources, snapshots and updates with an AUTOINCREMENT seq - open order: cloud-folder refusal, library.lock, WAL and synchronous=FULL (fullfsync on macOS), then the format_version guard before any write; quick_check after an unclean exit - format migrations with a pre-migration VACUUM INTO (keeps 2), one transaction per step, read-only on failure - append and renderer-driven compaction in one transaction each, with stale and future upToSeq guards - the one-window registry: already_open, forbidden, document_open - documents, folders, tags, Trash and the sidebar snapshot, with rev - daily VACUUM INTO copies after 30 s idle, keeping 7 - shutdown: checkpoint, clear unclean_exit, release the lock
lib/doc-migrations/ holds the pure Yjs forward migrations that local-session runs after hydrate and before the editor binds, and that import runs on .tinydoc and web downloads (desktop architecture §5.1, D-A5). The list starts empty, so DOC_SCHEMA is 0. checkImport refuses a state that is too large, isn't Yjs, or carries a node, mark or root this build doesn't know, before it reaches the library. The legacy link and code marks pass: the import migrations rename them.
The worker accepted appends and compactions from any window when no window held the document. It now requires the writer's own hold, as desktop architecture §7 requires of main, and adds claim() so main can replay its registry after a worker restart. Compaction is bounded by the document's own last row instead of the library-wide sequence.
worker.ts runs the engine on node:sqlite in a worker_thread (D-A1) and answers one request at a time, so flush and shutdown run after every write sent before them. Replies are Result envelopes and bytes are transferred. Idle jobs run between requests, and index writes emit index_changed. StorageClient starts the worker, waits for ready, rejects pending calls with worker_restarting if the worker dies, and ends with the quit flush's shutdown (terminated after 2 s). createRpcDocStore turns those replies into the DocStore port, for IpcDocStore and the tests. Engine DocStore cases run in-process on bun:sqlite and, framework-free, in Electron.
The first rows of desktop architecture §3.3's import-boundaries test: the
engine imports no electron, node:*, bun:*, React or Tiptap and stays in
its folder; the worker reaches lib/ only through the allowlist and never
bun:*; lib/platform/desktop never imports desktop/{main,preload,storage}.
Audit of today's bubble, Insert, "/" and phone surfaces with screenshots, research across eight editors and the platform guidance, and a design for owner review: owner decisions O1-O12, the bubble without registerPlugin, the "/" menu amendments and a phased plan.
A clickable throwaway prototype with a switch for each owner decision, theme, RTL, reduced motion and device, plus its screenshots.
DocumentEditor now takes the session's Awareness and a provider that may be null (desktop P2.2). The caret is configured with that Awareness, and the extensions memo depends on it rather than on the provider, so attaching a provider later never calls setOptions. The connection chip renders only with a provider: its connection state creates the shared socket. UniqueID finds the caret's provider option and waits for its "synced" event, so on and off forward to the provider of the moment through a ref; the web behaves as before. WriteGate and an empty decoration host join the extensions. The new readOnly prop drives the gate and setEditable; the web never sets it.
The budget was 23.5 KB of growth (contract A12); main is at +15,691 B. D23 lowers it to main plus the 1,580 B ledger, +17,271 B, so unrelated work cannot spend the ledger's bytes. The report prints exact bytes.
…or-no-provider-a52225 # Conflicts: # CHANGELOG.md
#118 landed first: main is at +15,674 B, so the fence is +17,254 B (main plus the 1,580 B ledger). P2.2 measures 294 B on the merged tree.
Copy diagnostics and soak T3 read back journal_mode, synchronous, fullfsync, checkpoint_fullfsync and foreign_keys as the library runs.
tests/load/desktop-durability-soak.ts launches the real storage worker inside a windowless Electron (desktop/storage-harness, its own lockfile on Electron 45.3.2), kills it during appends, compactions and format migrations, quits it with edits in flight, opens a newer library with it, and runs a year of editing over 1,000 documents before timing startup to sidebar rows. Every library is verified by reopening it with the engine on bun:sqlite. T7 is the web library's. desktop-storage-soak.yml runs it on macOS, Windows and Linux: 20 kills per case on pull requests that touch storage, 200 nightly and on demand.
A pull request labelled storage-soak-full runs 200 kills per case, as the nightly does; workflow_dispatch only works once the file is on main.
The architecture spec now lists where the engine, client and soak harness live, the open order as built, the worker-side registry check and claim, the compaction guards, the import guard, the lib/schema-names.ts boundary allowance, and that T7 belongs to the web library.
A person whose user name is box or dropbox had their library refused as a cloud folder. The check now skips the home folder's own segments.
Appends change a document's title, snippet and modified time, but did not move rev, and opening a document or the idle Trash purge moved rev without an event. The library now records each changed row, appends bump rev in their transaction, and the worker sends index_changed with the rev and the changed rows after every request and idle pass (architecture §7, §8.1). A failed daily copy is kept for stats instead of dropped.
T8 now gates sidebar rows against architecture §10 from process start, reports worker ready against its own row, runs one startup after an unclean exit to time quick_check, sends realistic snippets, and records how long each daily VACUUM INTO blocks the worker. Temp-folder cleanup retries and never fails a case.
Bun's close() leaves a connection whose statements are still live open as a zombie, holding the library's file handles. On Windows the soak could not delete a library the verifier had closed (EBUSY). The driver now finalizes its cached statements first.
…into claude/feat-p2-6-storage-worker # Conflicts: # CHANGELOG.md
createDoc takes the document's schema (DOC_SCHEMA for a new document, the file's on import) and accepts any id that is safe in SQL, paths and logs. Main's IPC guard still lets only UUIDs through; tests and imports use other ids.
The shared contract now runs on the engine over bun:sqlite under bun test, and over node:sqlite in the real storage worker in the soak's contract case. It replaces the interim engine cases.
… takes it DOC_MIGRATIONS now plugs into LocalSessionOptions without an adapter. runDocMigrations stays for import, where a file migrates all or nothing.
…into claude/feat-p2-6-storage-worker
bun run build:desktop writes the static export to out/ with NEXT_PUBLIC_APP_TARGET=desktop. Web-only route handlers become route.web.ts(x), which the desktop page extensions skip. The five web metadata files and the /privacy and /offline pages are parked in the checkout for the build and put back: Turbopack ignores pageExtensions for metadata files, and a page.web.tsx loses the root layout's font preload on the web. next.config.ts refuses a web build while anything is parked. The export fails if a web-only route, a web metadata tag or the Windows segment layout reaches out/. icon.tsx is force-static.
The worker precaches web-only pages (SHELL_PATHS has /privacy) and the desktop renderer loads from disk, so the target flag now turns registration off, as NEXT_PUBLIC_SERVICE_WORKER=0 does.
desktop/shared/export-paths.ts holds the app:// protocol handler's path rules for the shell to reuse: pages to .html, RSC payloads under their exported names, the extension-less icon as image/png, unknown types and traversal refused. scripts/serve-desktop-export.ts serves out/ with them, the desktop project checks that every request the renderer makes is answered, and nightly runs it on Linux.
After a next dev run, .next/dev/types imports the /privacy and /offline pages, which the export parks, so the export failed its type check. bun run typecheck already checks every file, desktop ones included.
expectSavedToServer (#116) read isSynced from the caret's provider option, which P2.2 made the editor's Awareness holder, so it never saw the server ack and the perf and collab runs timed out. filter.spec's copy saw undefined and stopped waiting at all. The caret option's on returns the provider's on, which returns the provider, so the helper asks it; filter.spec now uses the same helper. A unit test pins it.
…or-no-provider-a52225 # Conflicts: # CHANGELOG.md
#126 landed first: main is at +15,284 B, so the fence is +16,864 B (main plus the 1,580 B ledger). P2.2 still measures 294 B on the merged tree (+15,578 B).
…son-26e90f # Conflicts: # CHANGELOG.md
…ert-design # Conflicts: # CHANGELOG.md
Under a desktop-target next dev the web metadata files aren't parked, and output: "export" made each of them a 500 that every page links. The config is now a phase function; the web config object is unchanged.
… into integrate/phase-2-batch-2
…der-a52225' into integrate/phase-2-batch-2 # Conflicts: # CHANGELOG.md
… into integrate/phase-2-batch-2 # Conflicts: # CHANGELOG.md # tsconfig.json
… into integrate/phase-2-batch-2 # Conflicts: # CHANGELOG.md
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.
This merges reviewed PRs so CI runs once against the current
main(08b7663). GitHub marks each of them merged when this lands.DocStorecontract passes onbun:sqliteand onnode:sqlitein Electron.WriteGateand the decoration host.isSyncedfrom the caret's option, now an Awareness holder. No app code reads that option.bun run build:desktopwrites the desktop static export. The web build output is unchanged apart from the/iconhash, and thedesktopproject runs nightly.action-previewtable-header case, which passes onmainat the same code.Merging:
CHANGELOG.mdconflicts were resolved by keeping every entry.tsconfig.json'sexcludeis the union of feat(desktop): add the library storage worker (P2.6) #125's and build(desktop): static export of the desktop renderer (P2.4a) #127's lists.Checked locally: Biome shows only the 7 warnings already on
main, andbun run testpasses 1,839 tests. Local typecheck tripped only on a stale.next/typesfile from an earlier local build; CI's fresh checkout settles it.Deploy: nothing for the operator to do. The web editor gains P2.2's provider-optional seam, with web behaviour unchanged.
🤖 Generated with Claude Code