Skip to content

Conversation

@LukeTowers
Copy link
Member

@LukeTowers LukeTowers commented Jan 1, 2026

Related: wintercms/winter#801

Screenshot 2026-01-02 at 1 07 41 AM Screenshot 2026-01-02 at 1 08 19 AM Screenshot 2026-01-02 at 1 08 45 AM

Summary by CodeRabbit

  • New Features

    • Green visual indicators for newly added translation strings in the editor.
    • Improved AJAX handling so nested editor widgets in tabbed forms work reliably.
  • Style

    • Refreshed color and spacing tweaks across inspector, controls and hover/active states.
  • Refactor

    • Editor backend migrated to a new editor engine for better decorations and editing experience.
    • Migration generation streamlined to include explicit operation metadata and clearer script naming.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 1, 2026

Walkthrough

Migrates the in-browser editor from ACE to a Monaco wrapper, adds behavior-level AJAX reconstruction of nested FormWidgets for widget-scoped handlers, restructures migration code generation into up/down anonymous-class templates, and updates related CSS for new-translation highlights and minor UI tweaks.

Changes

Cohort / File(s) Summary
UI / CSS
assets/css/builder.css, assets/less/localization.less
Minor styling tweaks (colors, borders, padding, !important adjustments). Adds .builder-new-translation-line and .builder-new-translation-gutter for new-translation highlights (semi-transparent green).
Editor: ACE → Monaco migration
assets/js/build-min.js, assets/js/builder.index.entity.localization.js
getCodeEditor now returns the Monaco wrapper instead of .editor. Calls previously using ACE session (getSession().setValue, annotations) replaced with wrapper setValue and setDecorations using Monaco Ranges/decoration arrays. Variable renames to codeEditorWrapper.
FormWidget AJAX reconstruction framework
classes/IndexOperationsBehaviorBase.php, behaviors/IndexDatabaseTableOperations.php, behaviors/IndexLocalizationOperations.php, behaviors/IndexVersionsOperations.php
Adds constructor and handleFormWidgetAjax() in base behavior to intercept widget-scoped AJAX handlers and reconstruct missing nested FormWidgets. Each behavior implements reconstructFormWidget($alias) to rebuild form state from POST data (alias validation, plugin/language resolution, form creation and binding).
Migration object / filename and code wrapping
classes/DatabaseTableModel.php, classes/TableMigrationCodeGenerator.php
createMigrationObject signature extended to include $operation and $tableName; migration filenames incorporate operation/table and are made unique. wrapMigrationCode now accepts upCode and downCode; generateMigrationCode returns split up/down code.
Migration templates
classes/databasetablemodel/templates/full-migration-code.php.tpl, classes/databasetablemodel/templates/migration-code.php.tpl
Full migration template changed to return an anonymous class with explicit public function up(): void and public function down(): void containing {upCode}/{downCode}. migration-code.php.tpl contents removed (absorbed/removed).
Database table behavior helpers
behaviors/IndexDatabaseTableOperations.php, classes/DatabaseTableModel.php
onDatabaseTableMigrationApply now fills code from request and conditionally sets scriptFileName only when missing. makeMigrationFormWidget accepts optional $alias. New reconstructFormWidget added to support AJAX reconstruction for migration forms.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant IndexOpsBehavior as IndexOperationsBehaviorBase
    participant BehaviorImpl as ConcreteBehavior
    participant FormWidget
    participant CodeEditorWrapper

    Client->>Controller: AJAX widget-scoped request (handler + alias)
    Controller->>IndexOpsBehavior: handleFormWidgetAjax(handler)
    
    rect rgba(200,220,255,0.5)
    IndexOpsBehavior->>IndexOpsBehavior: parse widget alias from handler
    IndexOpsBehavior->>Controller: check widget registry for alias
    Controller-->>IndexOpsBehavior: widget not found
    end

    rect rgba(220,240,220,0.5)
    IndexOpsBehavior->>BehaviorImpl: reconstructFormWidget(alias)
    BehaviorImpl->>FormWidget: build FormWidget from POST data (fields, config, alias)
    FormWidget->>FormWidget: set context (language/version/etc.), bind to controller
    BehaviorImpl->>Controller: register reconstructed widget
    end

    IndexOpsBehavior->>Controller: resume handler execution
    Controller->>FormWidget: invoke widget AJAX action (e.g., save, diff)
    FormWidget->>CodeEditorWrapper: call setValue / setDecorations (Monaco)
    CodeEditorWrapper-->>FormWidget: success
    FormWidget-->>Client: AJAX response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.43% 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 'Support Monaco editor' directly and clearly identifies the main change across the entire changeset—migration from ACE to Monaco editor throughout multiple files.

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


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

coderabbitai[bot]

This comment was marked as resolved.

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