Engineering an AI-Assisted Chat Page Rebuild: From Prompt to Verifiable Delivery

    Rebuilding a conversational web page with an AI coding system is more than a visual task—it is a software engineering exercise spanning requirements specification, state management, service integration, security, and layered acceptance testing. This article explains how to structure the work in three deliverables (functional spec, baseline build, improved build), split the process into a two-phase workflow, understand the execution boundaries of AI coding systems, and validate outcomes with traceable acceptance criteria so that generated pages become reliable, maintainable software rather than one-off demos.

    1. From Page Rebuild to Engineering Delivery

    Asking an AI coding system to rebuild a conversational web page looks like a front-end task on the surface, but it actually involves requirements analysis, interaction modeling, API integration, state management, testing, and security design. A page that opens is not a finished application; buttons that can be clicked do not mean the business flow is reliable.

    When reference pages, design assets, or source code are available, developers must first confirm licensing. Publicly accessible does not mean free to copy, and open-source code does not mean the logos, images, and other assets in it carry the same license. Engineering practice should use legally obtained materials and extract generic interaction patterns, rather than mechanically reproducing identifiable elements of a specific product.

    For tasks like this, the more valuable questions are not “which system produced the most pixel-accurate page,” but:

    • Have the requirements been converted into executable, acceptable specifications?
    • Do page behavior and real service calls form a complete loop?
    • Can the system proactively discover failure paths and fix them?
    • Is the deliverable easy for other developers to maintain?
    • Do claimed experience improvements have clear goals and verification evidence?

    These questions turn a one-off page-generation exercise into a repeatable engineering practice.

    2. Define Three Deliverables Before Implementation Begins

    To keep implementation from being driven purely by visual details, split the work into three deliverables, each with its own acceptance criteria.

    2.1 Functional documentation and structure diagram

    Functional documentation should not merely list feature names like “supports chat” and “supports history.” It should describe user actions, system responses, state transitions, and exception handling.

    Taking message sending as an example, a complete specification must state at minimum:

    • Whether submission is allowed when the input is empty;
    • Whether the input area remains editable after a request is sent;
    • Whether parallel requests are allowed within the same conversation;
    • How progress is displayed while a reply is being generated;
    • Whether the original input is preserved when a request fails;
    • How an unfinished reply is presented after the user cancels;
    • Which data is restored after a page refresh.

    The structure diagram should express module relationships, not just page blocks. A generic application structure can be represented as:

    1. Conversation page
    2. ├── Session navigation
    3. │ ├── New session
    4. │ ├── History session list
    5. │ └── Session switching and deletion
    6. ├── Message display
    7. │ ├── User messages
    8. │ ├── Reply content
    9. │ └── Loading and error indicators
    10. ├── Input area
    11. │ ├── Text editing
    12. │ ├── Send action
    13. │ └── Cancel action
    14. └── Application service layer
    15. ├── Request lifecycle management
    16. ├── Session data management
    17. ├── Service invocation and response transformation
    18. └── Logging and exception handling

    This structure helps clarify boundaries: page components handle presentation and interaction, the application service layer coordinates requests and state, and the server side is responsible for protecting credentials and controlling access to external capabilities.

    2.2 Baseline rebuild version

    The baseline should preserve the core layout and interaction logic of the reference task, but it does not need to be a pixel-perfect copy. A better goal is a complete minimal usable loop:

    The user sends a message, the system makes a request, the page displays the reply, conversation records update correctly, and failures produce understandable feedback.

    If real services are not yet integrated, clearly labeled mock data can validate interactions—but mock replies must not be treated as evidence of successful integration. Delivery notes should distinguish explicitly between “UI complete,” “mock chain verified,” and “real calls verified.”

    2.3 Improved experience version

    The improved version must establish goals independent of the baseline; it cannot justify itself with extra decoration or color changes.

    Examples:

    • For long replies, provide clear paragraph spacing and readable line width;
    • For request failures, preserve the input and offer a conditional retry entry;
    • For mobile, prevent the input area from being obscured by the soft keyboard;
    • For long history lists, reduce unnecessary repeated rendering;
    • For assistive-technology users, add control labels and status announcements.

    Each improvement should state the problem, the solution, and the verification method. Only then can you judge whether the change actually reduces user effort rather than introducing new complexity.

    3. Turn Two Rounds of Prompts into a Two-Phase Engineering Process

    Two interaction rounds can map to two distinct engineering phases: first establish the specification and structure, then complete real integration and regression verification.

    Phase 1: Requirements clarification and a runnable skeleton

    In the first phase, provide the task scope, delivery checklist, reference materials, and acceptance criteria. Require the AI coding system to list its key assumptions before starting implementation.

    Recommended constraints:

    1. Do not present unconfirmed capabilities as supported features.
    2. Do not hide errors to make a demo pass.
    3. The baseline and improved versions must be separately identifiable.
    4. Unfinished items must be recorded with reasons and impact.
    5. All test conclusions must state their verification scope.

    This phase should produce functional documentation, a structure diagram, a page skeleton, mocked interactions, and a preliminary test checklist. The goal is to validate the structure, not to spend excessive time fine-tuning visual details.

    Phase 2: Configuration integration and real-chain verification

    In the second phase, supply the service endpoint, authorization method, and necessary configuration so the system can make real calls.

    One common practice needs adjustment here: do not paste long-lived production credentials into prompts, source code, or page configuration. A safer approach is to inject test credentials into a controlled server-side environment and tell the system where and how to read the configuration, rather than exposing the credential values.

    Integration must not stop at “the request succeeded.” More complete requirements include:

    • Verify normal responses;
    • Verify authorization failures and service unavailability;
    • Check that timeouts and cancellation work;
    • Check page data state after a refresh;
    • Check for cross-session content leakage when switching conversations;
    • Update run instructions and known limitations.

    Given the same supplementary instructions, different execution systems may adopt different strategies. Some only confirm one successful request; others probe failure paths. These differences cannot be attributed solely to the underlying model—they also depend on the execution framework, tool permissions, test feedback, and stopping conditions.

    4. Understand the Execution Boundaries of AI Coding Systems

    An AI coding system is usually not a single model but a combination of a model, an execution framework, and an environment.

    The execution framework organizes tool calls, file modifications, command execution, test feedback, and context management. It affects whether the system can obtain sufficient information, and when it considers the task complete.

    Therefore, an engineering retrospective should record at least:

    • Which input materials were used;
    • Which files the system could read and modify;
    • Whether it was allowed to run tests and start the application;
    • Whether it had page interaction inspection capabilities;
    • Whether there were limits on execution duration or call counts;
    • Whether a human provided additional explanations midway;
    • Whether the final conclusion came from actual runs or static judgment.

    Multi-agent collaboration does not automatically mean higher quality. If multiple execution units modify the same module simultaneously, the result can be inconsistent interfaces, duplicated implementations, or overwrites. A safer division is to assign distinct responsibilities to requirements analysis, implementation, and review, and designate a single unified integration step.

    Long context is likewise only one condition. Being able to read more material does not mean the system can identify the most important constraints. Well-organized requirements, clear module boundaries, and feedback mechanisms matter more than dumping a large amount of unstructured information in one go.

    5. The Key Difficulty for Conversational Apps: State Consistency

    The most common defects in conversation pages are usually not styling errors but asynchronous state confusion.

    Suppose the user sends a message in conversation A and then switches to conversation B. When the reply for A arrives, if the code simply appends the content to the “current conversation,” the response leaks into the wrong conversation.

    To solve this, pin the conversation ID and request ID when the request is created, and verify ownership when the response arrives. Here is language-agnostic pseudo-logic:

    1. Send message:
    2. Validate input
    3. Record target conversation ID
    4. Create a unique request ID
    5. Set request state to in progress
    6. Initiate the service call
    7. Receive response:
    8. Look up the request record by request ID
    9. Check whether the request was cancelled or invalidated
    10. Write the result to the original target conversation
    11. Update the request's completion state
    12. On error:
    13. Preserve the user's original input
    14. Record the error category
    15. Set the request state to failed
    16. Show a message matching the error category

    If the service supports streaming, you must also handle accumulated partial content, connection interruption, and completion confirmation. Response formats may differ across services; do not assume every data chunk is a complete message, and do not treat a closed connection as proof of business success.

    Cancellation should also distinguish two levels: stopping the page from receiving further results, and attempting to terminate the underlying request. Whether the latter can abort server-side computation depends on the actual API capability—do not promise it without verification.

    6. Credential Security and Data Handling Must Be Part of Acceptance

    Once the interface works, security problems are easily masked by a successful demo.

    Long-lived credentials must not appear in front-end code, browser persistent storage, or public build artifacts. A common architecture is for the front end to call a controlled server, which reads secure configuration and calls the external service.

    The server should also perform necessary request validation, access control, rate limiting, and log sanitization. Merely moving credentials to the server does not automatically solve unauthorized access or resource abuse.

    For conversation records, define the retention policy explicitly:

    • Whether they are kept only for the current page lifetime;
    • Whether they are written to local storage;
    • Whether they are synced to the server;
    • How users can delete history content;
    • Whether logs contain full conversations;
    • How retention periods are determined.

    Requirements differ across businesses, but these choices must be documented. Developers should not log full user inputs and replies by default—especially in scenarios that may contain personal information, internal materials, or access credentials.

    7. Build Layered Acceptance Instead of a Single Demo

    One successful send only proves a single path under specific conditions. Complete acceptance should cover multiple layers.

    7.1 Documentation and static checks

    Verify that feature lists, structure diagrams, and the actual implementation are consistent. Check for undisclosed dependencies, hardcoded configuration, unreachable branches, and obvious sensitive information.

    Every “supported” item in the documentation must map to actual behavior; unverified features should be marked as unverified, not silently treated as passing.

    7.2 Component and state tests

    Focus on input validation, message appending, session switching, failure recovery, and state changes after cancellation. This layer does not necessarily need real services; controlled responses can validate state logic.

    For example, when the send action is triggered twice in quick succession, confirm whether the app forbids concurrent sends, queues them, or allows parallelism—and check that the implementation matches the documentation.

    7.3 Service integration tests

    Verify authorization, request transformation, response parsing, timeout handling, and error classification. When the service returns an error, the page must not remain in a loading state indefinitely, nor append the error text as if it were a normal reply.

    Be cautious with automatic retries. Repeated requests can cause duplicate replies or extra resource consumption; whether a retry is safe depends on service semantics and request design.

    7.4 Full interaction testing

    Cover continuous operations such as creating a session, sending a message, waiting for the reply, switching sessions, refreshing the page, and restoring data. Also check narrow-screen layout, keyboard operation, and assistive-technology cues.

    Full interaction testing is valuable because it reveals cross-module problems: individual components passing tests does not guarantee the combined user flow is correct.

    8. How to Produce a Trustworthy Delivery Report

    An acceptance report need not be elaborate, but it must be traceable. Every check should include at least the operating conditions, expected result, actual result, and remaining risk.

    A usable format:

    1. Check item: Switching conversations while a reply is being generated
    2. Preconditions: Two independent sessions exist
    3. Operation: Send a message in the first session, then immediately switch to the second session
    4. Expected: The reply is written back to the first session; the second session's content is unchanged
    5. Actual: Fill in observed results
    6. Result: Pass / Fail / Not verified
    7. Evidence: Test record, screenshot, or sanitized log

    When comparing different execution approaches, keep the task input, runtime environment, and acceptance criteria identical, and record differences observed during execution. A single successful task cannot establish a stability advantage, and generation speed is not a substitute for security and maintainability evaluation.

    Importantly, unfinished items are themselves delivery information. Explicitly writing “streaming interruption recovery is not yet verified” is more valuable engineering-wise than covering the risk with “overall it runs normally.”

    9. Conclusion: Put Generative Capability into a Verifiable Loop

    Rebuilding a conversation page can be a good starting point for AI-assisted coding practice, but it should not end at visual reproduction. The genuinely valuable process starts from requirements specifications, establishes clear module boundaries, integrates services securely, and then uses layered testing to prove that both the main paths and failure paths behave as expected.

    What developers need to focus on is not how much code the system can generate, but whether it can state its assumptions, identify failures, provide evidence, and leave behind maintainable deliverables. Only by front-loading these requirements can page generation move from a demo to reliable software engineering.