super-productivity/packages/plugin-dev/document-mode
Johannes Millan 492f3710d8 perf(plugins): skip no-op doc-mode saves via lastSeenDocBytes equality
Closes #7815.

flushSave and flushSaveSync now compute the would-be-written raw bytes
first and short-circuit when they equal lastSeenDocBytes — a typed-then-
reverted cycle inside the 30s throttle window no longer produces a
postMessage round-trip, an IDB transaction, or an op-log entry.

The baseline is intentionally NOT updated on a skip: it already equals
these bytes, so the self-echo invariant for PERSISTED_DATA_CHANGED
(#7752) is preserved.

Drive-by: added the isDocCorrupt guard to flushSave for symmetry with
flushSaveSync / scheduleSave. The schedule gate normally prevents
flushSave from firing on a corrupt doc, but corruption can be set
between schedule and fire (e.g. a remote-update reload turning up an
unparseable blob), so the explicit guard is cheaper than reasoning
about that invariant.

Persistence rename: saveContextDoc → persistContextDocRaw. The caller
now owns serialisation (via serializeContextDoc) so the byte-compare
can run before the persist dispatch. Three persistence.spec.ts tests
replace the dropped saveContextDoc test: exact-raw write, encoder
determinism (the premise the byte-compare relies on), and
write-idempotence (which proves the skip loses no information).
2026-05-27 15:43:21 +02:00
..
scripts feat(document-mode): add TipTap-based document-mode plugin 2026-05-22 17:33:22 +02:00
src perf(plugins): skip no-op doc-mode saves via lastSeenDocBytes equality 2026-05-27 15:43:21 +02:00
.gitignore feat(document-mode): add TipTap-based document-mode plugin 2026-05-22 17:33:22 +02:00
package-lock.json feat(document-mode): add TipTap-based document-mode plugin 2026-05-22 17:33:22 +02:00
package.json feat(document-mode): add TipTap-based document-mode plugin 2026-05-22 17:33:22 +02:00
tsconfig.json feat(document-mode): add TipTap-based document-mode plugin 2026-05-22 17:33:22 +02:00