Recreating and Optimizing a Conversational Web UI with LLM Assistance
This article presents a practical methodology for recreating a conversational web application with the assistance of large language models. It outlines a complete workflow—from requirement documentation and structure mapping to page implementation, acceptance testing, and iterative optimization—with a focus on handling edge cases, designing effective prompt rounds, and verifying visual and interaction fidelity.
Why Recreate a Conversational Page
Conversational web applications have become a standard entry point for many products. Users type a question into an input box, the service streams text back, and the page simultaneously manages conversation history, session lists, and settings. The functionality may seem simple on the surface, but the details are numerous: the input box must auto-resize based on content, Enter and Shift+Enter need distinct behavior, a stop button must appear during generation, auto-scroll handling is required for long outputs, and code blocks need copy and highlight support. Each detail affects the user experience.
For developers, recreating a mature page offers two direct benefits. First, deconstructing well-designed interactions builds reusable component knowledge. Second, it tests the boundaries of LLM-assisted development with a realistic task—whether the model can interpret requirements accurately, produce runnable code, and proactively identify flaws in its own implementation.
This article does not evaluate any particular product. Instead, it offers a general method covering the full pipeline: requirement documentation, structure diagrams, page implementation, testing, and optimization.
Three Types of Deliverables
A complete page recreation typically produces three types of outcomes:
- Product functional documentation and structure diagrams: Describes the page modules, the function and state of each module, and the relationships between them.
- A runnable recreation: Matches the reference page in functionality and visuals as closely as possible, used to verify that the requirements were fully understood.
- An optimized version: Fixes interaction issues found in the recreation and adds general capabilities such as error retry, conversation search, and local persistence.
These three deliverables have clear sequential dependencies. The functional document serves as the input for the recreation, and the recreation serves as the baseline for the optimized version. If you skip the documentation and start coding directly, the model often implements only the visible interface, missing hidden features in dropdown menus, hover states, or error branches.
Mapping the Functional Structure
A conversational page can generally be divided into three main sections—sidebar, conversation area, and input area—plus settings and auxiliary features.
- Sidebar: New conversation, session list grouped by time, search entry, account and settings entries.
- Conversation area: Message list, distinct styling for user and assistant messages, message actions (copy, regenerate, feedback).
- Input area: Multi-line text box, send and stop buttons, attachment entry, feature toggles.
- Settings and auxiliary features: Theme switching, language switching, keyboard shortcut help.
A tree structure is recommended for the diagram so that developers and testers can check against it easily:
Conversational App├── Sidebar│ ├── New Conversation│ ├── Session List (grouped by time)│ ├── Search│ └── User and Settings├── Conversation Area│ ├── Message List│ │ ├── User Messages│ │ └── Assistant Messages (streaming output, Markdown rendering)│ └── Message Actions (copy, regenerate)└── Input Area├── Multi-line Input Box├── Send / Stop└── Feature Toggles
For each feature listed in the documentation, it is recommended to specify the trigger condition, the expected result, and the error result. Documentation that only covers the happy path will not be sufficient to support later testing.
Designing Multi-Round Prompts
Splitting the task into two prompt rounds is more stable than issuing all requirements at once.
Round one: Provide only the requirements and deliverables, ask for documentation first, and explicitly forbid code. The documentation should specify the page modules, the states of each module, error scenarios, and the required API capabilities. At this stage, the cost of correcting any misunderstanding on the model’s part is at its lowest.
Round two: Implement the page based on the documentation, and provide API access information. Access credentials should be injected through environment variables—never written into the code or exposed in logs. The second round must also specify the testing scope explicitly; otherwise, the model tends to perform only minimal verification, such as confirming the page loads and that sending a message returns a reply.
Example:
Round One:You are a senior product manager. Based on the given page, produce a functional specification document and a structure diagram.The document must include: module list, interaction flows, error states, open questions.Do not write code in this round.Round Two:Implement the front-end page based on the documentation from the previous round.API credentials must be read from the environment variable LLM_API_KEY and must not appear in the code.After implementation, test each of the following items: normal conversation, streaming interruption, oversized input, API error, network disconnect.List any issues found and fix them. Output a fix log.
The more specific the test scope, the more issues the model will surface. Writing the test checklist directly into the prompt is the most direct way to control verification depth.
Verifying Recreation Fidelity
“Consistent with the reference page” requires testable criteria. A verification checklist is recommended, with items checked one by one:
- Layout: Module positions, spacing, sidebar width, and breakpoint behavior at different screen widths.
- Dimensions: Minimum and maximum height of the input box, button sizes, font sizes, and line heights.
- States: Empty conversation, loading, generating, generation complete, error, offline.
- Interaction: Enter to send, Shift+Enter for line breaks, scroll following, content retained after stopping generation.
- Responsive behavior: How the sidebar collapses and expands when switching between desktop and mobile.
Dimension-related metrics can be measured directly from the DOM instead of relying on visual judgment alone:
const rect = document.querySelector('#chat-input').getBoundingClientRect();console.log({ width: rect.width, height: rect.height, top: rect.top });
Comparisons must be performed at the same viewport size. If the viewport differs, any size discrepancy cannot be attributed to the implementation itself. Screenshot comparison is effective for spotting visual deviations, while numerical measurement is better for layout deviations—combining both yields the best results.
