Skip to content

Conversation

@DJJones66
Copy link
Contributor

🔧 PR: Reduce Render Bounce & Clean Up Debug Noise

Summary

This PR addresses a critical issue with layout render bounce and also improves maintainability by cleaning up excessive debug logging in the unified layout system. It consists of a multi-phase implementation that introduces a versioned layout controller, bounce detection, and patch clean-up for consistent UI rendering in Plugin Studio.


✅ Key Improvements

1. Debug Logging Cleanup

  • Removed console.log and other dev-only debug statements from:

    • DynamicPluginRenderer.tsx
    • PluginModuleRenderer.tsx
    • LegacyModuleAdapter.tsx
    • LayoutEngine.tsx
    • useLayout.ts
    • layoutChangeManager.ts
  • Logging was previously overwhelming and made it harder to isolate real issues.

2. Bounce Detection Logic (Phase 1 & 2)

  • Introduced bounce suppression via:

    • previousPositionsRef and intendedPositionsRef in LayoutEngine.tsx
    • Blocking of suspicious layout changes that revert shortly after drag or resize.
    • Early rejection of known bounces during layout change detection.

3. Versioned Layout Controller (Phase A/B)

  • Added state machine (idle, resizing, dragging, grace, commit) to control layout state flow.

  • Introduced:

    • workingLayoutsRef and canonicalLayoutsRef
    • lastVersionRef to track update versions
  • Prevented layout flicker and unnecessary renders when changes re-apply old state.

4. Debounced Commit System (Phase C)

  • Layout changes now commit with a debounce and skip redundant updates.
  • Optimized for better UX during resizing and dragging.

5. Plugin Studio Adapter Compatibility

  • Updates to PluginStudioAdapter.tsx and layout flush logic ensure:

    • Layouts committed before saving.
    • Accurate and stable serialization of layout data (minimizing layout drift).
  • New ref: unifiedLayoutStateRef enables flush + snapshot.

6. Visual Debug Badge

  • LayoutCommitBadge.tsx displays version/hash and whether layout changes are pending.
  • Helpful for confirming that layout commits completed before saving.

7. Dev Mode Testing Tools

  • Adds test_phase1.sh to walk through dev testing scenarios.

  • Logging chain includes:

    • [LayoutEngine] Commit
    • [UnifiedLayoutState] Persist
    • [PluginStudioAdapter] Convert
    • [useLayout] Apply
    • [savePage] Serialize

@DJJones66 DJJones66 merged commit 811fc13 into main Sep 4, 2025
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