feat: add durable document sessions and workspace polish - #25
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 82 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
| Filename | Overview |
|---|---|
| docmostly/Features/Editor/DocumentSession.swift | New durable session layer: handles open/restore/retain-draft/compact/publish lifecycle. isCompacting guard is racy across await suspension points (benign due to CRDT idempotency). |
| docmostly/Persistence/DocumentLocalPersistencePeer.swift | SwiftData-backed actor for sequenced updates, snapshots, and legacy migration. Silent try? for retained-draft decode risks silently losing unsynchronised user edits. |
| docmostly/Features/Editor/DocumentSessionRegistry.swift | Session-per-key registry with generation-based invalidation and deduplication of concurrent creation tasks; logic looks correct. |
| docmostly/Persistence/DocumentStoreState.swift | Four related value types grouped in one file, against project convention. |
| docmostly/App/AppState+OfflineQueue.swift | Offline replay refactored: body mutations route through synchronizeQueuedDocument, title changes via replayPageMetadata with correct title==baseTitle short-circuit. |
| docmostly/App/AppState+EditorPersistence.swift | updateCollaborativePageTitle now queues only metadata mutations; offline document body persistence delegated to the session layer. |
| Tools/CRDTRuntime/src/docmostly-crdt-runtime.js | Adds validateUpdate and currentSnapshot; enqueueSnapshot title changed to null to align with session-owned title model. |
| docmostly/Features/Editor/NativeEditorCRDTSyncCoordinator.swift | Coordinator now owns the committed-update stream with persistence-before-publish ordering guarantee. |
| docmostly/Features/PageReader/EmojiCatalog.swift | Lazy static catalog parsed from bundled emoji-16.0.txt; tab-delimited parsing with group-header detection looks correct. |
| docmostly/Features/Spaces/SidebarRootView.swift | Sidebar restructured with page browser section; task key correctly invalidates on space, scope, discovery, and favorite revision changes. |
| docmostlyTests/Persistence/DocumentSessionArchitectureTests.swift | Comprehensive session-architecture tests covering ordering, deduplication, compaction, reconnect, two-window identity, and migration. |
Sequence Diagram
sequenceDiagram
participant VM as NativeRichEditorViewModel
participant Reg as DocumentSessionRegistry
participant Sess as DocumentSession
participant Coord as NativeEditorCRDTSyncCoordinator
participant Peer as DocumentLocalPersistencePeer
participant Engine as NativeEditorCRDTDocumentEngine
VM->>Reg: session(for:title:document:)
Reg->>Engine: makeDocumentEngine(pageID:title:document:)
Engine-->>Reg: engine
Reg->>Sess: open(title:)
Sess->>Peer: legacyMigrationCandidate(key)
Peer-->>Sess: candidate?
Sess->>Peer: commitLegacyMigration
Sess->>Peer: load(key)
Peer-->>Sess: DocumentStoredState
Sess->>Engine: apply(snapshot)
Sess->>Engine: apply(update) [per pending update]
Engine-->>Sess: NativeEditorCRDTDocumentSnapshot
Sess-->>Reg: session (open)
Reg-->>VM: DocumentSession
VM->>Sess: configureDocumentSession
Note over VM,Coord: Normal edit cycle
VM->>Coord: integrateLocalChange
Coord->>Engine: integrateLocalChangeForCommit
Engine-->>Coord: updates
Coord->>Peer: append(update, origin:.local, key:)
Peer-->>Coord: CommittedDocumentUpdate
Coord->>VM: yield snapshot
Coord->>Peer: "metrics -> compact if needed"
Note over VM,Peer: Remote update
Coord->>Engine: validate(update)
Coord->>Peer: append(update, origin:.remote)
Coord->>Engine: apply(update)
Coord->>VM: publish(snapshot)
Reviews (2): Last reviewed commit: "test: cover unavailable CRDT attachment" | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18b76e15ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
I love free runners |
There was a problem hiding this comment.
All reported issues were addressed across 39 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 21 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
What changed
Checks