Manuscript Offprint

arXiv:2611.01383

Toward Executable Multi-framework Front-end Code Generation with Self-Correction

Linxiao Li, Haoran Ma, Chenyue Wang, Jiaye Lin, Haochen Sui, Jiechao Gao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Generating codes from UI screenshots has recently benefited from MLLMs, yet existing methods centered on HTML targets and transfer poorly to multi-frameworks such as React, Vue, and Angular. However, unlike HTML, which does not entail compilation issues, generating executable code in multi-framework settings is more challenging due to framework-specific differences in syntax and failure modes, as well as the need to maintain global consistency across files. To address this problem, we study executable multi-framework front-end code generation and propose MESCoder, a tree-structured self-corrective generation framework. Our method first extracts a structural scaffold from the screenshot and then constructs sub-trees and assembly relations step by step, transforming large project generation into a sequence of localized decisions. On top of this scaffold, we introduce a unified Project Agent that continuously revises its own partial project under runtime sandbox feedback and dynamically chooses between local repair and cluster level repair. For training, we adopt a two-stage strategy that first initializes the policy offline to learn basic multi-framework generation and repair priors, and then refines it with online reinforcement learning to optimize long horizon executability and final page quality. The resulting framework models multi-framework executability as a conditioned project state transition process and improves the stability and quality of complex front end generation through self correction. Experiments show that our method improves executability, while narrowing the visual-fidelity gap to HTML-based generation. Codes are available at: Link.

1 Introduction

Recent advances in MLLMs have substantially improved the ability to generate front-end code directly from UI screenshots [27, 16, 34, 31]. This task requires models to jointly perform visual understanding, structural abstraction, and front-end implementation. As a result, generation quality depends not only on recognizing local UI elements, but also on whether the model can transform hierarchical layout and spatial organization into a coherent implementation [30, 20].

Existing work has made clear progress on this problem, yet the dominant formulation remains largely HTML-centered. Recent efforts have scaled HTML-screenshot training corpora [16, 34, 9] and established benchmarks for measuring how faithfully a generated page reproduces its reference [27]. On the method side, divide-and-conquer decomposition [29], layout-guided prompting [30], and structure-aware fine-tuning [20] further improve element recall and spatial fidelity. Common to all of these efforts, however, is a shared assumption: the generation target is a single self-contained HTML file that renders without compilation and without cross-file reasoning—an assumption that

*Equal contribution.

†Corresponding author: jiechao@stanford.edu.

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

Figure

Figure 1: Compilation failure rates of six state-of-the-art MLLMs under one-shot generation on React, Vue, and Angular. Failures are decomposed into local errors and cluster errors.

does not hold in real front-end development, where production interfaces are assembled from multiple files within framework-specific project structures and become visible only after the entire project successfully compiles and runs.

However, extending screenshot-to-code generation from HTML to multi-frameworks such as React, Vue, and Angular is not merely a matter of changing prompts or rewriting syntax. Unlike HTML, multi-framework front-end generation requires models to produce an executable project within the framework-specific program space, where correctness depends not only on surface syntax but also on component boundaries, cross-file dependencies, parent-child assembly, and runtime consistency. Existing analysis shows that straightforward prompt transfer across frameworks causes a substantial drop in compilation success and is accompanied by highly framework-specific error modes [33]. In stricter frameworks, failures are often no longer limited to local token- or template-level mistakes, but instead emerge as engineering-level inconsistencies involving import/export relations, bindings, assembly, and project-level coherence. Meanwhile, one-shot screenshot-to-project generation entangles local implementation, global composition, and framework constraints in a single decoding process, making intermediate errors difficult to localize and even harder to correct reliably.

To address these challenges, we study executable multi-framework front-end code generation and propose MESCoder, a tree-structured self-corrective generation framework. Our key idea is to first extract a structural scaffold from the input screenshot, converting large project generation into a sequence of localized subtree expansion and assembly decisions, and then introduce a unified Project Agent that continuously revises its own partial project under runtime sandbox feedback. Rather than treating correction as a post-hoc repair stage, MESCoder integrates self-correction into the generation loop itself, enabling the model to dynamically decide whether to continue construction, perform local repair, or escalate to cluster-level repair when local edits become insufficient. To stably learn this behavior, we further adopt a two-stage training strategy: we first initialize the policy offline to acquire basic multi-framework generation and repair priors, and then refine it with online reinforcement learning to optimize long-horizon executability and final page quality. In this way, we formulate multi-framework front-end generation as a framework-conditioned project state transition process, with self-correction serving as the key mechanism for improving cross-framework executability and the stability of complex front-end generation.

Our contributions are summarized as follows:

  • We propose MESCoder, a tree-structured self-corrective generation framework that decomposes project construction into localized subtree and assembly decisions and equips a unified Project Agent with runtime-feedback-driven self-correction.

  • We develop a two-stage training strategy that combines offline policy initialization with online reinforcement learning, enabling to optimize long-horizon executability and generation quality.

  • Extensive experiments demonstrate that MESCoder improves code executability across multiple frameworks while narrowing visual similarity comparable to HTML-based generation.

References (32)