Agent-Driven Chat Application Reconstruction: Engineering Practices and Acceptance Testing

    Rebuilding a chat web application with an AI agent requires more than visual similarity. This article explains how to define scope, turn product observations into traceable requirements, separate faithful reconstruction from UX improvements, integrate live services securely, manage streaming states, and verify delivery through functional, visual, security, and cross-environment testing. It also outlines how to evaluate agents under controlled conditions and support completion claims with evidence.

    1. From Generating a Web Page to Delivering a Complete System

    Asking an AI agent to build a chat application from an existing page may look like a frontend development task. In practice, it involves product analysis, interaction design, service integration, testing, and security governance. A screenshot captures a single visual state. It does not explain how conversations are saved, how generation stops, how errors are recovered from, or how access to shared content is controlled.

    The completion criterion should therefore be more than “the page opens.” The work should produce three distinct deliverables:

    1. Product analysis report: Document observed features, information architecture, interaction rules, error states, and questions that still need answers.
    2. Faithful reconstruction: With appropriate authorization, reproduce the reference page’s observable layout and behavior as closely as possible.
    3. UX improvement version: Propose and implement verifiable improvements based on identified problems and user needs.

    These deliverables answer different questions: What was understood? What was implemented? Why was it changed? Combining them can lead to discrepancies between the report and the code. It can also turn “optimization” into decorative additions that disrupt established workflows.

    This article presents a general engineering method, not a ranking of specific models or tools. Performance on one task does not establish a model’s reliability across all development scenarios.

    2. Define the Scope Before Filling in the Gaps

    Observation Does Not Confirm Internal Implementation

    Inspecting a logged-in chat application can reveal navigation, input methods, message presentation, and some interaction paths. It cannot establish the database schema, internal authorization rules, or server-side implementation.

    The product report should distinguish three categories:

    • Observed facts: Directly confirmed through interaction, such as a collapsible sidebar.
    • Reasonable inferences: Suggested by behavior but not verified, such as paginated history loading.
    • Implementation recommendations: Proposed designs for the reconstructed system, such as managing service credentials on the server.

    This distinction prevents an agent from presenting assumptions as product facts and helps developers prioritize uncertainty.

    Do Not Promise Unverifiable “Exact” Replication

    Visual reconstruction can be evaluated against layout, typography, colors, spacing, and responsive behavior. Functional reconstruction requires a defined result for each operation.

    Hidden features, unpublished rules, and states that cannot be accessed with the available permissions should not be included in an unconditional promise of identical behavior.

    Mark unobservable aspects as unverified, and use clear, explainable designs where implementation decisions are necessary. Auditable completeness is more valuable than an unsupported claim of perfect equivalence.

    Establish Authorization and Data Boundaries

    Reference-page inspection, screenshot capture, and automated interaction must remain within the authorized scope. Use dedicated test conversations wherever possible to avoid collecting sensitive content from real users.

    The reconstructed application should not copy unauthorized branding, assets, or proprietary content. It must not use a similar-looking page to persuade users to submit credentials for the original service. Technical reconstruction and impersonation are fundamentally different activities.

    3. Turn the Product Report into Development Input

    A product report should do more than list feature names. It should guide implementation, testing, and acceptance.

    Build a Feature Map

    A generic chat application can be organized as follows:

    1. Chat application
    2. ├─ Conversation management
    3. │ ├─ Create and switch
    4. │ ├─ History
    5. │ ├─ Rename and delete
    6. │ └─ Search and archive
    7. ├─ Message interaction
    8. │ ├─ Compose and send
    9. │ ├─ Streaming display
    10. │ ├─ Stop generation
    11. │ ├─ Retry and regenerate
    12. │ └─ Copy and feedback
    13. ├─ Content rendering
    14. │ ├─ Plain text
    15. │ ├─ Headings, lists, and tables
    16. │ └─ Code snippets
    17. ├─ Content sharing
    18. │ ├─ Create a share
    19. │ ├─ View shared content
    20. │ └─ Revoke a share
    21. └─ System safeguards
    22. ├─ Identity and authorization
    23. ├─ Error recovery
    24. ├─ Privacy protection
    25. └─ Logging and monitoring

    This is a candidate structure, not a claim that every reference application includes all these features. Label each item as confirmed by observation, within reconstruction scope, or added as an improvement. This prevents extensions from being misrepresented as original functionality.

    Define Four Dimensions for Each Feature

    For “stop generation,” the report should specify at least:

    • Trigger condition: The conversation has an unfinished generation request.
    • User action: The user clicks the stop button.
    • Visible result: Content already received is retained, and the message exits the generating state.
    • Exception handling: Late-arriving data must not continue updating the stopped message.

    Stopping reception on the client does not necessarily stop computation on the server. Whether the server-side task can actually be canceled depends on interface support, not on the button’s appearance.

    Maintain a Requirements Traceability Table

    Connect every requirement to its implementation concerns and test cases.

    Requirement Implementation concerns Acceptance method
    Switch between past conversations Conversation IDs, message loading, scroll restoration Switch repeatedly across several conversations
    Display streaming responses Chunk reception, message ownership, completion state Simulate latency and connection interruption
    Support mobile input Keyboard obstruction, safe areas, focus management Check multiple viewports and physical devices
    Access shared content Content snapshots, permissions, revocation Verify in an independent browsing environment

    Traceability reduces the risk of a comprehensive report paired with an incomplete implementation.

    4. Use Two Stages: Build the Structure, Then Connect Live Services

    A two-round task can serve as a useful engineering workflow, but staging alone does not guarantee fairness or quality.

    Stage One: Requirements Analysis and Local Implementation

    Before live service credentials are available, the agent can complete:

    • Page inspection and a feature inventory.
    • Application structure and component decomposition.
    • Mock messages and interaction states.
    • Faithful reconstruction and UX improvement versions.
    • Local testing and integration notes.

    The mock service should support normal responses, delays, empty content, errors, and interruptions. Its purpose is to validate UI behavior and state handling—not to simulate evidence of a real model’s capabilities.

    Stage Two: Live API Integration and Regression Testing

    Once credentials are available, the focus should move beyond replacing mock data to validating the complete request path:

    • Can the server initiate requests correctly?
    • Does the response use the expected data structure?
    • Are streaming chunk boundaries handled correctly?
    • Are timeouts, authorization failures, and service errors displayed appropriately?
    • Can concurrent conversations cause messages to be written to the wrong conversation?
    • Does the integration break existing functionality?

    Credentials must not appear in browser code, public repositories, screenshots, or routine logs. The recommended arrangement is for the server to read protected configuration and make upstream requests. The frontend communicates only with its own application service.

    5. Separate Architectural Responsibilities

    A maintainable reconstruction can use the following logical layers:

    1. Browser UI
    2. ↓
    3. Application service layer
    4. ├─ Identity and authorization checks
    5. ├─ Conversation and message management
    6. ├─ Request limits and cancellation handling
    7. └─ Model API adapter
    8. ↓
    9. External model service

    The browser handles presentation and interaction. It should not be responsible for protecting secrets or making final authorization decisions. The application service enforces business rules, while the model API adapter handles differences in response structures and error semantics.

    If conversation history is persisted, define the relationship between conversations and messages and assign stable identifiers to messages. Streaming updates should locate their target by message ID rather than modifying “the last message in the current list.”

    The latter approach may work in a single-conversation demo but can fail when users switch conversations, send repeatedly, or open multiple windows.

    6. Manage Streaming Interaction with an Explicit State Machine

    Coordinating request progress with UI state is one of the most error-prone parts of a chat application. Define the states explicitly:

    1. Idle → Submitting → Generating → Completed
    2. ├→ Stopped
    3. └→ Failed

    Bind each request to a conversation ID, message ID, and request ID. If the user switches conversations, the original response must still belong to its original conversation. A change in the active view must not redirect incoming content elsewhere.

    Stopping generation should include at least three actions:

    1. Send a cancellation signal where supported.
    2. Move the target message into the stopped state.
    3. Ignore subsequent data from that request that should no longer be processed.

    Retrying also requires more than making another call. Decide whether a retry replaces the failed message or creates a new one, and prevent duplicate copies of the user’s input. Operations with side effects need request deduplication rather than reliance on temporarily disabling a button.

    Streaming introduces rendering challenges as well. Code blocks and tables may be incomplete while content is arriving. The rendering layer should tolerate partial content and perform final formatting when generation ends.

    External content must not be inserted as executable page markup without appropriate processing, which could expose the application to script injection.

    7. Evaluate Faithful Reconstruction and UX Improvements Separately

    Faithful Reconstruction: Check Consistency

    Visual acceptance testing should use fixed viewport dimensions, zoom levels, page states, and test content. Check:

    • The proportions of navigation and content areas.
    • Input position, dimensions, and maximum height.
    • Message width, line height, and paragraph spacing.
    • Loading, empty, and error states.
    • Narrow-screen layouts and touch targets.
    • Scrolling behavior with long content.

    Screenshot comparisons can reveal visual differences, but they cannot prove functional correctness. Interaction tests cannot replace visual inspection either. Run both independently.

    UX Improvements: Check Whether They Solve a Problem

    The number of added features is not a useful measure of improvement. Each change should identify the problem, explain the design rationale, and define a validation method.

    Examples include:

    • Difficult navigation in long conversations: Add message search or navigation to specific sections.
    • Lost input: Provide draft recovery and explain where drafts are saved.
    • Unclear failures: Distinguish network interruptions, authorization failures, and service timeouts.
    • Sensitive shared content: Provide a preview before sharing and a way to revoke access.
    • Disruptive auto-scrolling: Stop forced scrolling when the user moves upward to read earlier content.

    Claims of improved efficiency should be validated through task completion time, number of actions, or error rates. Without measurement, describe the change as a design hypothesis rather than an established result.

    8. Test Across Environments and Failure Paths

    Clicking send once in a development environment only suggests that the happy path may work. Reliable acceptance testing needs at least four categories.

    Core Workflow Tests

    Verify creating conversations, sending messages, completing generation, switching history, renaming, and deleting. Check that data behaves as designed after a refresh.

    Failure Tests

    Cover network loss, timeouts, authorization failures, service errors, empty responses, and interrupted generation. Error messages should offer actionable recovery steps rather than a generic failure notice.

    Concurrency and Boundary Tests

    Test repeated send clicks, rapid conversation switching, deletion during generation, multiple windows, and the effects of long messages on layout and scrolling.

    Independent-Environment Tests

    Shared links require particular attention. Test them under different login states, in independent browsing environments, or on other devices. The creator’s authenticated session and local cache can conceal permission or content-loading problems.

    Verify normal access, access after revocation, and expired access. Also check whether the shared page exposes any content outside the intended sharing scope.

    9. Evaluate Agents Under Controlled Conditions and Preserve Evidence

    Agents working on the same requirements may use different planning, browsing, coding, and testing strategies. A final screenshot alone is not enough to assess their work, and the outcome of a single run should not be attributed entirely to the underlying model.

    A more useful evaluation standardizes:

    • Initial requirements and accessible reference materials.
    • Development environment and available tools.
    • Execution time and API call budget.
    • API permissions and network conditions.
    • Acceptance scripts and scoring criteria.

    Scoring should cover requirements accuracy, visual consistency, functional completeness, error recovery, security, code maintainability, and verification evidence. Where conditions permit, run the task multiple times and record variability instead of retaining only the best result.

    The agent’s completion report should list tests actually performed, failed checks, unimplemented items, and environmental limitations. A “fixed” claim requires a successful retest. A statement of completion is not a substitute for an acceptance record.

    10. Delivery Quality Depends on a Verifiable Engineering Loop

    Agent-driven chat application reconstruction tests the full engineering process, from understanding requirements to acting on validation feedback. Visual similarity is only the starting point. Reliable state management, secure service integration, traceable requirements, and thorough failure testing determine whether the application is usable.

    The most effective workflow begins by establishing facts and boundaries, then creating the product report and acceptance criteria. Build the faithful reconstruction and the improvement version separately, and run a full regression after connecting live services.

    The final delivery should include more than a working URL. It should contain code, documentation, test evidence, and known limitations.

    When every feature has a basis, every change has a rationale, and every completion claim has supporting evidence, an agent-generated page becomes more than a demo: it becomes a verifiable software engineering deliverable.