Repository navigation
fix(blocks): trigger onChange for insertMany - #3050
Merged
Merged
Conversation
ZainnQureshii
requested review from
TatianaFomina,
gohabereg,
ilyamore88 and
neSpecc
as code owners
November 14, 2026 13:00
Contributor
There was a problem hiding this comment.
🟢 Approved
No active review issues remain for the change adding insertMany() mutation notifications while keeping initialization silent.
No open issues 🎉
What changed in this PR
Fixes #2874 by making blocks.insertMany() report mutations through onChange, consistent with other block operations, while keeping initial document loading silent.
Changes:
- Emit a
block-addedevent with the correct index for each inserted block. - Start mutation notifications disabled until initialization completes.
- Add regression coverage for batched events, block IDs and indices, and silent initialization; document the fix.
| File | Description |
|---|---|
test/cypress/tests/onchange.cy.ts |
Tests batched insertion events and silent initialization. |
src/components/modules/modificationsObserver.ts |
Starts change notifications disabled. |
src/components/modules/blockManager.ts |
Emits indexed block-added events for bulk insertions. |
docs/CHANGELOG.md |
Records the insertMany() notification fix. |
Review effort: Balanced
neSpecc
reviewed
Nov 14, 2026
Emit a block-added mutation for each block inserted by BlockManager.insertMany and keep the modifications observer disabled until the initial render finishes, so loading a document stays silent. Fixes codex-team#2874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ZainnQureshii
force-pushed
the
fix/insertmany-onchange
branch
from
November 16, 2026 10:24
9c1ba74 to
861a3fa
Compare
neSpecc
approved these changes
Nov 16, 2026
neSpecc
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2874
blocks.insertMany()inserted the blocks but never reported them, soonChangestayed silent whileinsert,deleteandmoveall fire it.BlockManager.insertManynow emits ablock-addedevent for each inserted block, with its own index, and the observer batches them into oneonChangecall as it does for other mutations.The renderer also loads the initial document through
BlockManager.insertMany, socore.tsnow callsModificationsObserver.disable()right before the initial render and keeps the existingenable()after it, the same wayblocks.render()and the read-only toggle already wrap their re-renders.ModificationsObserverkeeps its default (disabled = false), so loading a document stays silent without changing the observer's starting state.Changes:
src/components/modules/blockManager.ts: emitblock-addedfor each block ininsertMany.src/components/core.ts: disable the observer explicitly around the initial render.test/cypress/tests/onchange.cy.ts: regression test for one batched call with both inserted blocks, their ids and indices 1 and 2, and no call on initialization.docs/CHANGELOG.md: oneFixline under 2.32.0.How it was checked:
next;yarn lint(0 errors) andyarn buildpass.yarn test:e2e --spec test/cypress/tests/onchange.cy.ts: 31 of 31 pass.disable()call removed fromcore.ts, the same spec fails 25 of 31, since every editor created with initial blocks then firesonChangeon load, so the "should not be called on initialization" assertions cover the explicit disable.insertManytest fails onnextand passes with the change.Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.
🤖 Generated with Claude Code