Skip to content

fix(vm): silence reconcile log on sprite-import / backpack-paste#556

Merged
cwillisf merged 1 commit intohotfix/scratch-blocks-release-triagefrom
fix/silence-reconcile-log-on-sprite-import
Apr 30, 2026
Merged

fix(vm): silence reconcile log on sprite-import / backpack-paste#556
cwillisf merged 1 commit intohotfix/scratch-blocks-release-triagefrom
fix/silence-reconcile-log-on-sprite-import

Conversation

@cwillisf
Copy link
Copy Markdown
Contributor

Resolves

Follow-up to #555: the load-time-repair helper's log.warn was firing on every sprite-import / backpack-paste that referenced a broadcast not defined in the destination project. The text reads as a corruption alert ("Reconciled dangling reference") but the case is mundane — broadcasts live on the stage and naturally aren't carried with a backpacked sprite, so reconcile must create one in the new project's stage.

Confirmed via Playwright on scratch.ly:

  • Drag sprite-with-broadcast into backpack
  • New project, drag sprite back from backpack
  • Console shows: Reconciled dangling reference on 'Sprite2': created stage variable 'S9YSR/)K(PHVjM-/xQTU' (name 'awefawef', type 'broadcast_msg').

Proposed Changes

  • Target.reconcileVariableReferences accepts a {logRepairs} option (default false). All four log.warn call sites are gated on the option.
  • VirtualMachine.installTargets passes {logRepairs: true} only on the whole-project branch — where a dangling reference signals corruption from the missing-definitions bug.
  • Internal Target.fixUpVariableReferences (used for sprite import + backpack paste) calls reconcileVariableReferences() without options, so it stays silent.

Reason for Changes

fixUpVariableReferences calls reconcileVariableReferences as its missing-definitions phase, so once #555 added logging there, every sprite-import path inherited the log. The warning's wording and severity are correct for project-load repair — those projects really are corrupted — but wrong for backpack-paste, which is normal cross-target reference reconciliation.

The fix keeps all logging in exactly one entry point (installTargets whole-project) and leaves the sprite-import path silent, matching pre-#555 behavior on that path.

Test Coverage

  • New: reconcileVariableReferences without {logRepairs} is silent even when it repairs
  • New: fixUpVariableReferences does not log on sprite-import path
  • New: installTargets does not log on sprite import that creates a stage broadcast
  • New: installTargets logs on whole-project repair
  • Updated existing reconcile log assertions to pass {logRepairs: true} so they continue to assert the documented behavior of the load-repair entry point.
  • Full scratch-vm tap suite: 3770/3770.

Related

@cwillisf cwillisf requested a review from a team as a code owner April 30, 2026 23:06
@cwillisf cwillisf requested a review from Copilot April 30, 2026 23:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines scratch-vm’s “dangling reference reconciliation” logging so warnings only appear during whole-project load repair (where dangling refs indicate corruption), while keeping sprite import/backpack paste quiet (where creating stage broadcasts/vars is expected).

Changes:

  • Add a {logRepairs} option to Target.reconcileVariableReferences and gate all log.warn repair messages behind it.
  • Enable repair logging only for whole-project loads via VirtualMachine.installTargets(..., wholeProject=true).
  • Add/adjust unit tests to assert the new logging behavior across sprite import vs. whole-project load paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/scratch-vm/src/engine/target.js Adds {logRepairs} option and gates reconciliation warnings behind it.
packages/scratch-vm/src/virtual-machine.js Passes {logRepairs: true} only on whole-project installs; keeps sprite import path silent.
packages/scratch-vm/test/unit/engine_target.js Updates/extends tests to cover silent default and logging when {logRepairs: true}.
packages/scratch-vm/test/unit/virtual-machine.js Adds VM-level tests asserting no warn on sprite import and warn on whole-project repair.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/scratch-vm/src/engine/target.js Outdated
Comment thread packages/scratch-vm/src/engine/target.js Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

Test Results

    4 files   -   4    993 suites   - 118   10m 46s ⏱️ - 2m 55s
2 471 tests  - 370  2 463 ✅  - 370   8 💤 ±0  0 ❌ ±0 
5 877 runs   - 587  5 839 ✅  - 586  38 💤  - 1  0 ❌ ±0 

Results for commit 5da2332. ± Comparison against base commit b437181.

♻️ This comment has been updated with latest results.

reconcileVariableReferences was emitting log.warn whenever a sprite
imported via addSprite (the backpack-restore code path) referenced a
broadcast that wasn't defined in the new project. The text reads as a
corruption alert ("Reconciled dangling reference") but the case is
mundane: broadcasts live on the stage and naturally aren't carried with
a backpacked sprite, so reconcile must create one. The warning is
useful for the load-time-repair entry point added in #555 — where a
dangling reference does signal a corrupted saved project — but is
noise on import paths.

Add an opt-in {logRepairs} parameter, default false; only the
installTargets whole-project branch passes true. Behavior unchanged;
log emits in exactly one entry point now.
@cwillisf cwillisf force-pushed the fix/silence-reconcile-log-on-sprite-import branch from d703483 to 5da2332 Compare April 30, 2026 23:31
@cwillisf cwillisf requested a review from Copilot April 30, 2026 23:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cwillisf cwillisf merged commit ea94b90 into hotfix/scratch-blocks-release-triage Apr 30, 2026
17 checks passed
@cwillisf cwillisf deleted the fix/silence-reconcile-log-on-sprite-import branch April 30, 2026 23:55
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants