mirror of
https://github.com/outline/outline.git
synced 2026-11-24 23:00:18 +03:00
* fix: Reduce peak memory when duplicating large document trees, stabilize useActionContext identity Two regressions found via automated review of PRs merged in the last 24 hours: - documentDuplicator (#13270) now assigns ids across a whole document tree before writing any duplicates, but the planning pass eagerly loaded every descendant's full content, holding the entire tree's content in memory at once for large trees. Content is now fetched lazily, immediately before each document is written, bounding peak memory to roughly one document at a time. Fixes #13296. - useActionContext returned a freshly spread object on every render when overrides were passed, which DropdownMenu's new isEmpty check (#13292) depends on — this broke memoization and caused every action's visible() callback to be re-resolved on every render of every DropdownMenu on the page, even while closed. The hook now returns a referentially stable object as long as its shallow contents haven't changed. Fixes #13297. * fix: Correct shallowEqual false positive for differing key sets shallowEqual only iterated a's keys and never checked they existed on b, so objects with entirely different keys (e.g. {a: undefined} vs {b: undefined}) could compare equal whenever the mismatched key happened to read back the same value on both sides. Also adds the suggested a === b fast path. Addresses Copilot review comments on #13298. * refactor: Simplify content-loaded check, use es-toolkit's isEqualWith for shallowEqual - Drop the hasContent field/plumbing through DuplicateItem and buildItem; check dataValues.content directly instead (direct property access throws under sequelize-strict-attributes when the column was excluded from the query, so the check has to read dataValues, which bypasses the guard). - Replace the hand-rolled shallowEqual with a one-level-deep comparison built on es-toolkit/compat's isEqualWith, already used elsewhere in the app, instead of maintaining bespoke key-set comparison logic. - Trim comments per review feedback. Addresses review comments from tommoor on #13298. * refactor: Inline isEqualWith directly in useStableValue Drop the standalone shallowEqual wrapper and its dedicated test file; useStableValue now calls es-toolkit/compat's isEqualWith directly. Addresses review feedback from tommoor on #13298. --------- Co-authored-by: Claude <noreply@anthropic.com>