Engineering Methods and Acceptance Criteria for Rebuilding Conversational Web Apps with AI Coding
This article explains how to treat conversational webpage reconstruction as a deliverable system, not a static UI clone. It covers task modeling, state machines, security boundaries, staged validation with mocks and real APIs, streaming edge cases, evidence-based improvements, and a maintainable acceptance process.
From generating a page to delivering a system
Rebuilding a conversational webpage with AI coding looks like a frontend task. In practice it also involves product analysis, interaction design, API integration, security controls, and quality verification. If the only requirement is “make it look like the reference page,” the result is often a static layout: the input box renders and buttons click, but real conversations, failure recovery, session management, and data isolation may be incomplete.
A better definition of the work is: using authorized reference materials and API documentation, build a conversational system with a clear functional boundary, verifiable interaction behavior, and traceable service calls, then produce an evidence-based improvement plan.
The reference page should be used to understand common interaction patterns, not to copy brand marks, protected assets, or unauthorized data. Rebuilding the UI also does not mean replicating backend models, training methods, or service capabilities. Frontend appearance, application logic, and model capability are different layers and must be described separately.
This kind of work has three delivery goals:
- Product function documentation and system structure diagrams: what problem the system solves, which modules it includes, and how it is accepted.
- Baseline implementation: a functionally complete conversational webpage against confirmed requirements.
- Improved implementation: keep core behavior, improve usability, reliability, and maintenance cost, and provide verification evidence.
All three goals should share the same requirement IDs and acceptance criteria so documentation, implementation, and test results stay aligned.
Build a functional model before generating code
1. Break the page into user tasks
When analyzing a reference page, do not only record colors, spacing, and component positions. Identify the paths users take to complete tasks.
Typical conversational-web tasks include:
- creating a new session and submitting a question;
- watching response generation;
- stopping the current generation;
- switching among historical sessions;
- copying an answer or retrying a request;
- understanding a failure and choosing a recovery path.
If the target system also involves file input, search, or other helpers, confirm that the backend supports them. Do not assume an API has a capability just because the reference UI shows an entry point. Unconfirmed features should be marked as pending verification, not implemented as inert buttons.
2. Define inputs, states, and outcomes for each function
Function docs cannot stop at “supports sending messages.” For send-message, at least specify:
- whether empty input may be submitted;
- how over-limit input is surfaced;
- whether another submit is allowed while generation is in progress;
- whether input is kept after a failed request;
- how unfinished requests are handled when the user switches sessions;
- how already-displayed content is saved after the user stops generation.
Input limits, timeouts, and concurrency policy should follow real service constraints, not invented values.
A useful requirement structure:
Function: Send message
Preconditions: current session is available; input meets configured constraints
Normal outcome: the message is added to the session; the answer is shown in the way the service actually supports
Abnormal outcome: a understandable error is shown; necessary context is retained
Acceptance: repeated clicks do not create unexpected duplicate requests; responses are attributed correctly; the user can recover after failure
This form supports both development and conversion of natural-language requirements into automated checks.
3. Constrain interaction with a state machine
Conversational UI complexity comes from asynchronous state, not static layout. Distinguish states such as idle, request ready, waiting for response, receiving content, completed, stopped, and failed.
Each state needs explicit UI behavior. While waiting, show a loading indicator; do not fabricate answer text. Stopping generation should cancel further receipt and update the UI, not merely reset the button style.
Give every request a correlatable identifier so asynchronous responses can be tied to the right session and message. Otherwise, after a fast session switch, a late callback may write content into the wrong session.
System structure and security boundaries
A maintainable conversational system is typically layered as:
User interface├─ Session navigation├─ Message display├─ Input and actions└─ Status and error prompts│▼Application state and request management├─ Session state├─ Message state├─ Request cancellation└─ Response attribution checks│▼Server-side access layer├─ Identity verification├─ Parameter validation├─ Quotas and rate limiting├─ Error mapping└─ Logging│▼Model service APIs and necessary data storage
The central rule: service secrets must not be exposed in the browser.
Browser code, network requests, and local storage can be inspected. Confidential credentials belong on the server and should call model services through a controlled access layer. Even in prototypes, do not put real keys in page source, sample config, or commit history.
The access layer must not be an unrestricted proxy. It should authenticate callers, validate request structure, and apply access control. Logs may record request IDs, processing status, and error classes; they should not, by default, store full user input and model answers.
Session storage also needs a boundary. A single-machine demo may use local persistence, but users should be told data stays on the current device. Multi-user and cross-device sync require server persistence and per-user isolation. Knowing a session ID must not grant read access to that session.
Two acceptable delivery stages
Phased delivery reduces rework when API details are incomplete, but each stage needs a clear goal.
Stage 1: Structure and simulated interaction
Deliver function docs, structure diagrams, a baseline page, and an improved page. Validate UI states with simulated responses.
Mocks should not be a single successful answer. Cover:
- incremental (chunked) content;
- delayed first response;
- empty content;
- cancelled requests;
- service errors;
- disconnects mid-stream.
These scenarios validate page logic; they do not represent real service performance. Delivery notes must distinguish “verified with mock data” from “verified against the real API.”
Stage 2: Credentials and real calls
After authorized credentials are available, the work is more than swapping config. Check actual request structure, authentication, response format, and error handling against the API documentation.
Inject keys through a controlled configuration channel. Do not put real values in task prompts, screenshots, or test reports. If a credential appeared in a leak-prone record, revoke it and rotate it per process.
Real-API verification should at least cover:
- a normal request and answer display;
- invalid credentials or insufficient permission;
- rate limiting or temporary unavailability;
- user-initiated cancel;
- consecutive requests and session switching;
- state recovery after refresh;
- safe rendering of returned content.
If the service does not support streaming, show the full response as-is. Do not fake streaming with animation.
Streaming must handle boundaries, not only append text
Streaming can shorten perceived wait time, but it increases state and parsing complexity.
Network chunks are not necessarily complete events and may not align with character boundaries. The receive layer should decode incrementally, buffer, and parse events according to the real protocol, then hand valid content to the display layer. Parsing each network fragment independently often fails at split boundaries.
Stop must apply at both the request layer and the UI layer. After cancel, queued async callbacks may still run, so the UI should still check that the request is valid and belongs to the current target message before updating.
Partially completed answers can be marked “stopped” or “connection interrupted” so users know the result is incomplete. Connection close is not proof of successful generation; completeness follows the protocol and request state.
Retries can duplicate calls and extra cost. Before automatic retry, distinguish cases where the connection never established, the request may already have been accepted, or a partial answer already returned. Without confirmed idempotency, do not assume retry is safe; it is more robust to show a clear state and let the user request again.
Improvements need problem evidence and verification
An improved version is not a new palette, radius, or decoration. Each change should answer: what was the original problem, who is affected, what was done, and how effectiveness is judged.
1. Make status visible
Show states such as processing, generating, stopped, and request failed so users know whether the system is still working.
Verify by delaying responses or dropping the connection. Check that prompts stay consistent and that button state matches the real request.
2. Reduce cost in long sessions
Users may scroll back through old messages. Auto-scroll should respect whether the user is still at the bottom; do not yank them down while they read history.
A “new content” cue can let users jump when they choose. Acceptance should test both follow-the-bottom and history-reading paths.
3. Improve error recovery
Keeping input, naming the error class, and offering a reasonable recovery path is usually more useful than a generic “something went wrong.”
User-facing messages should not expose stacks, internal addresses, or sensitive config. Diagnostic detail and user copy should be separated.
4. Accessibility and content safety
Inputs need understandable labels, controls should be keyboard operable, and focus should be visible. Status changes should be perceivable by assistive technology, but do not announce every streaming fragment.
Model output is untrusted. Rich-text display needs appropriate sanitization, restricted dangerous URL schemes, and no execution of scripts or embedded content.
Evaluate delivery quality, not only screenshots
AI coding systems use different strategies: some stop after one successful call; others keep checking edge cases. A single observation describes that run; it does not prove a model or tool is more reliable in every scenario.
A more useful approach is shared acceptance conditions:
- the same requirement scope and authorized materials;
- the same runtime environment and resource limits;
- the same API access conditions;
- the same required test scenarios;
- savable operation records, test results, and known-issue lists.
Acceptance can cover requirement consistency, functional completeness, state correctness, security, maintainability, and test evidence. Screenshots prove a visual moment, not that cancel works, isolation is correct, or recovery is reliable.
Combine automation with human review. State transitions, request attribution, and error handling suit programmatic checks; reading experience, interaction rhythm, and copy need hands-on use. Real-service tests depend on network and service state; record those conditions and keep them separate from stable mock tests.
Make the delivery maintainable
A complete delivery includes not only page source but startup notes, a configuration inventory, API integration notes, a test report, known limits, and a follow-up improvement plan.
Baseline and improved implementations should share core request and session logic so two codebases do not drift. UI differences can live in components or controlled configuration, but the same feature must not have different security behavior across versions.
The engineering value of AI coding is not how much code appears quickly. It is a closed loop: requirements are traceable, state is explainable, credentials are bounded, failures are recoverable, tests are repeatable, and the product can be maintained.
Designing the task around these requirements turns conversational-page reconstruction from a visual demo into verifiable, iterable application development.
