I have changes to be published:

image
image

When I discard changes, suddenly my document updates:

image

Expected behavior:

    My draft should have been automatically updated?

Solution

Saved drafts now queue a rebase when opened against a newer published version, updating untouched blocks while preserving local edits. Blocks that differ from the base are treated as locally edited even if the saved edited-block list is incomplete.

Root cause: useAutoRebase requires pendingRemoteDocument. Previously only document.remoteUpdate set it while already editing. Reopening a stale draft receives document.loaded instead, leaving the old draft dependencies and pendingRemoteDocument === null, so no rebase occurred.

Verification reported by T3: Running pnpm vitest run src/models/__tests__/document-machine-rebase.test.ts src/utils/document-changes-rebase.test.ts on unmodified code produced 5 failed / 44 passed; with the fix, all 49 passed. Tests cover both load orders, matching versions, and the issue scenario of a remote image swap plus a local paragraph edit. On the final branch rebased onto latest main, the shared package suite passed (1770 passed, 1 skipped), typechecks for shared, ui, desktop and web passed, and Prettier checks passed.

Limitations: agent-ci was not run because Docker was unavailable. Desktop UI verification was not performed because Electron requires an X server and the host lacked root access to install Xvfb. The evidence below shows test output, not app screenshots.

Behavior to review: Reopened drafts with actual conflicts now enter the same conflict state as live conflicts, blocking Publish. There is no conflict UI yet; previously publishing could overwrite another writer's blocks.

Before / After

Before: Unmodified code: the 5 new rebase regression tests fail. A draft restored against a newer published version gets pendingRemoteDocument === null, so no rebase runs.

Before: five new regression tests fail on unmodified code

After: With the fix: all 49 tests in the two rebase test files pass, including stale-draft queueing and the remote image swap plus local paragraph edit scenario, preserving both changes.

After: all 49 rebase tests pass with the fix

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Attributes
name
Rebasing is not working properly
Owner
Status
Done
Priority
High
AgentThread
mcp:0ed0da27-84a0-4646-afa0-91b3397779d9
Attributes schemaThe fields this document carries.
Inherited from the parent's children attributes schema
Fetching schema…