Vibe Coding App That Rewrites Its Own UI in Real Time
Explore how a vibe coding app rewrites its UI in real time mid-conversation. See AI transform chat into dynamic forms and tables.
Every AI chat product ships with the same interface: a text box at the bottom, a scrolling column of messages above it. That layout was borrowed from SMS in the 1990s, and it has barely moved since. We kept running into its limits — asking a model to compare three options and getting a wall of text where a table should be, asking for a date and typing it out instead of tapping a calendar. So we built an experiment: a vibe coding app where the chat interface rewrites its own UI in real time, mid-conversation, based on what the conversation actually needs. This article is a case study of that build — what worked, what broke, and what the approach means if you are considering something similar for your own product.
What "Rewrites Its Own UI" Actually Means
Put simply: instead of the model answering only in text, it answers in interface. Ask it to plan a trip, and it does not describe a form — it renders one, with date pickers and a budget slider. Ask it to compare hosting providers, and a sortable comparison table appears inside the chat. Ask a yes/no question, and you get two buttons instead of an invitation to type "yes."
The term "vibe coding" was coined by Andrej Karpathy in a February 2025 post describing a style of building where you describe intent in natural language and let the model produce the implementation. A vibe coding app takes that loop and embeds it into the product itself: the end user's message is the prompt, and the interface is the output. The user never sees code — they see the screen reshaping itself around their request.
This is not science fiction infrastructure. Anthropic shipped a constrained version of the idea with Artifacts in June 2024 — a side panel where Claude renders working documents and components next to the conversation. Vercel's AI SDK supports generative user interfaces, where the model streams React components instead of markdown. The building blocks are public. What is missing from most write-ups is an honest account of the engineering and business trade-offs, which is what we focus on below.
Why Static Chat Interfaces Are a Business Problem
This matters beyond aesthetics, for three concrete reasons.
Text is a lossy format for structured decisions. When a user needs to pick one of five plans, a paragraph describing five plans forces them to hold the comparison in their head. A table with a highlight on the recommended row does the cognitive work for them. Every extra step between "user has a question" and "user makes a decision" is where funnels leak — this is the same logic that makes checkout flows shorter every year.
Typing is the slowest input method you can offer. A date typed as free text has to be parsed, validated, and often re-asked ("did you mean March 3rd or April 3rd?"). A date picker eliminates the entire error class. Multiply that across a conversation with a dozen inputs and the difference in completion time is significant — and abandoned conversations are abandoned revenue.
One fixed UI cannot serve every conversation. Traditional product design solves this by building separate screens for separate tasks: a booking screen, a comparison screen, a settings screen. Each screen is a design-develop-test cycle measured in weeks. A generative interface collapses those cycles: the "screen" is produced at runtime, shaped to the request. For products whose users arrive with unpredictable, open-ended tasks — assistants, internal tools, configurators — this is the difference between shipping ten hardcoded flows and supporting effectively unlimited ones.
How We Built It: Architecture of a Self-Rewriting Interface
The naive version of this idea is dangerous: let the model generate arbitrary code and execute it in the user's browser. We ruled that out on day one. Arbitrary generated code means arbitrary bugs, arbitrary security holes, and an interface that can break in ways no QA process can anticipate.
Here is what we recommend instead, and what we built: the model does not write code — it assembles LEGO.
A constrained component registry
We defined a fixed registry of vetted UI components: cards, tables, forms, selectors, sliders, charts, buttons. Each component is built, tested, and styled by humans, once. The model's job is to output a structured description — effectively a JSON document — saying which bricks to use, in what arrangement, with what data inside.
The LEGO analogy is precise here. A child with a LEGO set can build an unlimited number of castles, but every brick is factory-made and every connection point is standardized. The model gets the same deal: infinite compositions, zero ability to manufacture a defective brick. If it hallucinates a component that does not exist, schema validation rejects the output before anything renders, and the system falls back to plain text. The failure mode of the whole system is "boring chat message," not "broken screen."
Streaming, so the UI feels alive rather than laggy
Model output takes seconds; users forgive seconds only if something visible is happening. We stream the UI specification as it generates, rendering components progressively — the table skeleton appears first, rows fill in as they arrive. This is the same pattern Vercel's AI SDK uses for generative UI, and it converts dead waiting time into perceived responsiveness. The interface appears to build itself in front of the user, which — a side effect we did not plan for — reads as a feature rather than a loading state.
The interaction loop closes back into the conversation
The generated UI is not a dead end. When the user drags the budget slider or picks a date, that structured event goes back to the model as context. The next response already knows the budget is set — no re-asking, no parsing free text. This loop is the actual product: not "chat that shows widgets" but a conversation where both sides can speak in interface.
The safety rails
Three rules kept the experiment from becoming a liability:
- No arbitrary code execution. The model outputs data, never JavaScript. Rendering is done by our own trusted code interpreting that data.
- Validate everything, always. Every model output passes schema validation. Invalid output degrades to text. The user never sees an error caused by a hallucinated component.
- Deterministic actions. Buttons in generated UIs can only trigger actions from a whitelist we control. The model can propose a "Book now" button; it cannot invent what "Book now" does.
Alternatives and Trade-Offs: Do You Actually Need This?
Honest take: most products do not need a self-rewriting interface, and pretending otherwise would be selling you a solution in search of a problem. Here is the real decision space:
| Approach | Build cost | Flexibility | Reliability | Best for |
|---|---|---|---|---|
| Classic static UI | Low–medium | None at runtime | Highest | Known, stable user flows |
| Hardcoded rich chat (fixed widget set, rule-triggered) | Medium | Low | High | Support bots, narrow assistants |
| Generative UI (constrained registry — our approach) | Medium–high | High | High, if validated | Open-ended assistants, internal tools |
| Full runtime code generation | High | Maximum | Lowest | Prototypes, demos, developer tools |
The trade-offs that actually matter:
- Token cost is real and per-interaction. A static screen costs nothing to render the second time. A generated one invokes the model on every request. For high-traffic consumer products, that line item compounds; for internal tools or high-value B2B interactions, it is usually noise compared to the labor it replaces.
- Latency floor. However well you stream, a generated interface will never appear as fast as a precompiled one. If your flow is fixed and speed-critical — checkout, login — generate nothing. Hardcode it.
- Design control narrows, it does not disappear. With a constrained registry, your designers still control every pixel of every component. What they give up is control over composition — which components appear when. Brand-sensitive teams find this uncomfortable at first; in practice the registry constraint keeps output on-brand far better than expected.
- Testing changes shape. You can no longer test "the screen," because there is no fixed screen. You test the components (as always), the schema validation, and the fallback paths. Teams coming from traditional QA need to budget time for this mental shift.
There is also a wider strategic question: how much of this pattern survives once the hype cycle moves on. We have covered that separately in our analysis of what vibe coding actually is and which parts survive the hype — the short version is that constrained, validated generation has staying power precisely because it treats the model as an unreliable-but-creative junior, not as a trusted senior engineer. And if your organization is pushing AI-generated code on you faster than your safety rails can keep up, we have written about what to do when a vibe coding mandate lands on your team.
What This Means for Your Project
If you are evaluating whether a generative interface belongs in your product, three questions decide it:
- Are your users' tasks predictable? If 90% of sessions follow five known flows, build five great static screens. Generative UI earns its cost only when the task space is genuinely open-ended.
- Is each interaction valuable enough to pay per-render model costs? Internal tools, sales configurators, and expert assistants: usually yes. Free consumer chat at scale: run the numbers first.
- Can you commit to the constrained-registry discipline? The teams that get burned are the ones that let the model generate arbitrary code because it demos beautifully. The demo-to-production gap in that approach is where budgets go to die.
Here is what we recommend as a starting path: do not begin with the full self-rewriting interface. Begin with three components — a table, a form, an option selector — wired into your existing chat with schema validation and a text fallback. That is a scoped, low-risk build, and it will tell you within weeks whether your users actually engage with generated interfaces or ignore them. Expand the registry only where usage data says the interface is doing work that text was not.
Key Takeaway for Business
Key takeaway for business:
- A chat app that rewrites its own UI is not magic and not arbitrary code generation — done right, it is a model assembling pre-built, human-vetted components, like LEGO from a fixed brick set. That constraint is what makes it shippable rather than a permanent demo.
- The pattern pays off where user tasks are open-ended and each interaction carries real value; it loses to static screens wherever flows are fixed and speed-critical. Choosing wrong in either direction wastes budget.
- Start with a three-component pilot inside your existing chat, with validation and text fallback. It is the cheapest possible way to learn whether generative UI moves your metrics — and it leaves you with reusable components even if the answer is no.
This article is based on publicly available sources and may contain inaccuracies.


