Files
pad/internal
xarmian aa8975710d fix(store): a body rewritten without a version rebases the newest version's patch, so History stays exact (BUG-3745) (#2139)
* fix(store): a body rewritten without a version rebases the newest version's patch, so History stays exact (BUG-3745)

Versions are reverse patches resolved backwards from the row's body, and
diff.ApplyPatch does not check that a patch's base matches. A throttled
same-writer edit replaced the body without a version, leaving the newest
version's patch made against a body that no longer existed: History
resolved it against the new body, the hunks still applied, and the old
version picked up text written after it, which a restore then put back
into the live document.

rebaseNewestVersionPatch materializes the newest version's body from the
body its patch was made against, and stores it again against the new
body (as a patch when smaller, else in full). It runs on the throttled
branch of UpdateItem when Content moves the row, and, from a class
sweep of every writer of items.content, on the two system rewrites that
write no version: the wiki title cascade and the attachment remap.

Claude-Session: https://claude.ai/code/session_01Q9WssCjFuHjSfLABoW4tmS

* fix(store): a rebased version's line counts describe the change it now covers (BUG-3745)

Codex: the rebase moved the newest version's "after" body to the new row
body but left lines_added/lines_removed as they were, so History's counts
no longer described the version. They are recomputed from the version's
body to the new body, the same pair an update version records.

Claude-Session: https://claude.ai/code/session_01Q9WssCjFuHjSfLABoW4tmS

* fix(store): a full-body newest version's line counts follow an unversioned write too (BUG-3745)

Codex: a newest version stored in full needs no rebase, but its
lines_added/lines_removed still described the change before the
throttled write extended it. They are now recomputed for it as well.

Claude-Session: https://claude.ai/code/session_01Q9WssCjFuHjSfLABoW4tmS
2026-10-13 18:30:38 -04:00
..