Evaluating Interactive Front-End Generation by Large Language Models
Anonymous model demos often produce inconsistent interactive front ends. This article turns that experience into a reproducible evaluation practice for interactive UI code, covering controlled variables, a desktop window prototype, a real-time strategy prototype, blind testing, prompt iteration, and engineering checks for correctness, interaction, visuals, performance, and maintainability.
Evaluating Interactive Front-End Generation by Large Language Models
Many large language models first appear under anonymous codenames on general model aggregators or online experiment benches before they reach a formal product entry point. That pattern often sparks debate about large gaps between single trials: for the same class of task, one run may produce a complete structure and natural interaction, while another shows weak visual fidelity, missing logic, or slow responses. Rather than stopping at subjective impressions, it is more useful to turn “user experience” into an evaluation practice that can be reproduced, compared, and accepted. This article outlines a developer-oriented framework for interactive front-end code generation.
1. From Subjective Experience to Reproducible Evaluation
Front-end code generated by large language models is highly uncertain. A single result can be affected by context length, sampling parameters, system prompts, the toolchain, service load, and the number of generation rounds. An evaluation should at least control the following variables:
- The same prompt version and the same supplementary instructions
- The same runtime environment and browser size
- The same acceptance checklist and interaction script
- Pass rates across multiple samples, rather than a single result
- Five separate dimensions: functional correctness, interaction completeness, visual conformance, performance stability, and code maintainability
Anonymous blind testing reduces bias from brand expectations. Screenshots alone are not enough; the interaction process should also be recorded. Examples include whether window dragging tracks the pointer, whether layer switching works, whether a game loop stays stable, whether automatic target seeking freezes, and whether a speed control actually changes the simulation step. For each task, build an acceptance sheet that turns “it looks similar” into items that can be operated and verified.
2. Task Design: A Window System and a Real-Time Strategy Prototype
2.1 Desktop Window System Prototype
A typical task is to imitate a classic desktop window system: draggable windows, window stacking, minimize, maximize, and close buttons, plus a window-switching view with a sense of spatial depth. It looks like UI reproduction, but it actually tests the event model, coordinate transforms, an animation state machine, and layout constraints.
Dragging a window means recording the start point and offset with pointer events and clamping the position inside the viewport. Example:
function enableDrag(win, handle) {let startX = 0, startY = 0, originX = 0, originY = 0, dragging = false;handle.addEventListener('pointerdown', (e) => {dragging = true;startX = e.clientX;startY = e.clientY;const rect = win.getBoundingClientRect();originX = rect.left;originY = rect.top;handle.setPointerCapture(e.pointerId);});handle.addEventListener('pointermove', (e) => {if (!dragging) return;const x = originX + e.clientX - startX;const y = originY + e.clientY - startY;const maxX = innerWidth - win.offsetWidth;const maxY = innerHeight - win.offsetHeight;win.style.transform =`translate(${Math.max(0, Math.min(x, maxX))}px, ${Math.max(0, Math.min(y, maxY))}px)`;});handle.addEventListener('pointerup', (e) => {dragging = false;handle.releasePointerCapture(e.pointerId);});}
A 3D-style window switcher must maintain stacking order, rotation, scale, and opacity. Evaluation should focus on whether the transition can be interrupted, whether focus lands on the correct window, whether button clicks are blocked, and whether too many windows cause obvious frame drops. Visually, translucent glass, button feedback, and layered shadows can be required, but those requirements should become checkable CSS properties and interaction states rather than a vague request to “make it look a bit more like the original.”
2.2 Real-Time Strategy Game Prototype
Another high-value task is to turn turn-based strategy play into a real-time strategy (RTS) prototype. The defining traits of RTS are continuous time, fair time for both sides, and units that can keep acting, rather than waiting for the player to click “next turn.” The task asks the model to understand higher-level abstractions: a game main loop, resources and research, unit behavior, camera control, grid coordinates, and pathfinding.
Acceptance requirements include:
- A real-time main loop driven by
requestAnimationFrameor a fixed step. Pause and speed multipliers must not break time fairness. - An AI-assisted research tree that, when enabled, automatically picks research that resources allow and reports its status.
- Automatic target seeking that finds the nearest target with a grid or spatial index, then plans a path with a general algorithm such as A*.
- A speed slider from 1x to 10x. The multiplier must change the simulation step or accumulated time, not only the animation speed.
- A hexagonal grid with consistent axial-to-pixel conversion so selection, movement, and pathfinding do not drift apart.
- Keyboard camera control: arrow keys pan the view and stay inside the map bounds.
- An icon system in which cities, units, and resources use a shared icon set or emoji placeholders so the scene stays readable.
Example of hexagonal coordinate conversion:
// Convert axial coordinates to pixels; keep this consistent with the draw directionfunction axialToPixel(q, r, size) {const x = size * 1.5 * q;const y = size * Math.sqrt(3) * (r + q / 2);return { x, y };}
The RTS main loop can accumulate a fixed time step:
let acc = 0;let last = performance.now();let speed = 1;function loop(now) {const dt = Math.min(100, now - last);last = now;acc += dt * speed;const step = 50;while (acc >= step) {simulate(step / 1000);acc -= step;}render();requestAnimationFrame(loop);}
Automatic target seeking should not scan every unit on every frame. Grid buckets or a spatial hash can shrink the candidate set before pathfinding runs. During evaluation, watch for units that jitter, jam, pass through obstacles, or loop forever when no path exists.
3. Anonymous Blind Testing and Prompt Iteration
Differences between an anonymous build and the formal entry-point build are common. Causes can include sampling settings, system prompts, tool calls, context trimming, and service load. A practical approach is blind testing under the same environment, the same prompt, and multiple samples: hide the model identity and keep generation logs, screenshots, interaction recordings, and acceptance results. Do not compare only the final screenshot. Also compare intermediate artifacts such as code structure, state management, error handling, and maintainability.
Prompt iteration should be treated as engineering work. A useful sequence is:
- Feature list: state the features that must be implemented.
- Acceptance criteria: give operable checks for each feature.
- Prohibitions: do not use undeclared APIs, and do not omit core logic.
- Interaction details: specify button states, keyboard mappings, and boundary constraints.
- Failure handling: require fallback behavior when there is no path, resources are insufficient, or a window would leave the viewport.
For example: “Produce a single-page prototype with window dragging, layer switching, a speed slider, a hexagonal grid, and keyboard camera movement. Attach acceptance notes for each feature. Do not depend on undeclared external resources.” That is more effective than repeatedly asking the model to “make it look a bit more alike.”
4. Capability Breakdown and Engineering Advice
Interactive front-end generation mainly tests five capabilities: requirement abstraction, architecture planning, state synchronization, algorithm implementation, and visual reproduction. Abstraction decides whether the model can split “real-time strategy” into a main loop, resources, units, and a camera. Architecture decides whether the code is maintainable. State synchronization decides whether the UI matches the simulation. Algorithms decide whether pathfinding, target seeking, and grid conversion are correct. Visual reproduction affects usability, but it cannot replace functional correctness.
Slow generation may come from service queueing, an overly long context, or too many output tokens. Slow front-end runtime often comes from full redraws, frequent DOM updates, or full path searches on every frame. Useful directions include narrowing the generation scope, emitting code by module, batching rendering with requestAnimationFrame, caching paths, limiting the number of candidate units, and using event delegation for long lists. Record generation time and runtime separately so they are not treated as the same metric.
In practice, a small evaluation set and automated acceptance scripts can fix the prompt, fix the browser viewport, record interaction, compare screenshots, and log console errors. Generated prototypes can be deployed to general object storage and static website hosting on Baidu AI Cloud so several people can review them remotely. The environment should stay neutral, and the evaluation should not be locked to a single runtime. The goal is not one impressive generation. It is a reproducible, measurable, and continuously improvable process for model selection and prompt engineering.
