Skip to content

Refactor block event handling and add load_model gizmo support#467

Open
tracygardner wants to merge 1 commit intomainfrom
claude/model-block-live-updates-awzHi
Open

Refactor block event handling and add load_model gizmo support#467
tracygardner wants to merge 1 commit intomainfrom
claude/model-block-live-updates-awzHi

Conversation

@tracygardner
Copy link
Contributor

Summary

This PR improves the event handling logic in block models and extends gizmo support to include the load_model type.

Key Changes

  • Refactored block event handling in blocks/models.js:

    • Reorganized the conditional logic for processing block change events to be more explicit and maintainable
    • Moved handleMeshLifecycleChange check to execute first when the event targets this block or represents a block creation
    • Consolidated handleParentLinkedUpdate and handleFieldOrChildChange checks into a single conditional block
    • Removed the inverted logic condition that was checking this.id !== changeEvent.blockId && changeEvent.type !== Blockly.Events.BLOCK_CHANGE && !isThisBlockCreated
  • Added load_model gizmo case in ui/gizmos.js:

    • Extended the gizmo toggle switch statement to handle the load_model case alongside existing model loading cases (load_multi_object, load_object, load_character)

Implementation Details

The refactoring in blocks/models.js improves code clarity by:

  1. First handling mesh lifecycle changes for directly targeted blocks
  2. Then handling parent-linked updates and field/child changes
  3. Using positive conditions instead of negated logic, making the flow easier to follow and maintain

https://claude.ai/code/session_01CVKFvSifik74xZnSM6Fdwp

- Add load_model to scale gizmo switch case in gizmos.js so dragging
  the scale gizmo creates/updates a resize block in the DO section,
  consistent with load_character/load_object/load_multi_object
- Update load_model block handler to use handleParentLinkedUpdate
  alongside handleFieldOrChildChange, matching the load_multi_object
  pattern so BLOCK_CREATE events on value-input children (e.g.
  connecting a number block to X/Y/Z/SCALE) also trigger mesh updates

https://claude.ai/code/session_01CVKFvSifik74xZnSM6Fdwp
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 773389f6-56f4-46c0-91e5-b2ccf25f581a

📥 Commits

Reviewing files that changed from the base of the PR and between 7fcba7a and e70f4a8.

📒 Files selected for processing (2)
  • blocks/models.js
  • ui/gizmos.js

📝 Walkthrough

Walkthrough

The load_model block's event-handling pipeline was refactored to prioritize mesh lifecycle changes and consolidate parent-linked and field-update handling logic. Additionally, gizmo scale-resize functionality was extended to support load_model blocks alongside similar block types.

Changes

Cohort / File(s) Summary
Event Handler Refactoring
blocks/models.js
Reorganized event-processing control flow in the load_model block handler to prioritize mesh lifecycle event handling earlier, then consolidated parent-linked and field/child update checks into a single early-return condition.
Gizmo Scale Support
ui/gizmos.js
Added missing case "load_model": to the scale gizmo's onDragEndObservable switch statement to handle resize/DO-section updates for load_model blocks alongside load_multi_object, load_object, and load_character blocks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

Poem

🐰 Hops through the event stream with glee,
Mesh lifecycles handled first, you see!
Then gizmos fall into place—
Load_model finds its space!
A pipeline reordered, logic in harmony~

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes: refactoring block event handling in blocks/models.js and adding load_model gizmo support in ui/gizmos.js.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/model-block-live-updates-awzHi

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants