AI Coding in Practice: A Pitfall Guide for Desktop Tool Development

    This article reports a hands-on test of AI coding tools on a real desktop application: a batch audio-video extraction utility. It explains why generating code is not the same as delivering software, proposes a four-dimension evaluation framework (requirement coverage, runtime correctness, concurrency and responsiveness, robustness and UX details), and details the correct GUI structure for avoiding freezes through separation of main, worker, and message-passing roles. It also shares a reusable five-part prompt template, acceptance criteria, and post-delivery recommendations covering security review, dependency governance, and observability.

    1. The Problem: “It Generates Code” Is Not “It Ships Software”

    Over the past year, the capability boundary of AI coding tools has been pushed higher and higher, and pass rates in public benchmarks keep looking better. But for frontline developers, there is only one real acceptance criterion: can the generated code run directly, and does it stay stable, responsive, and free of data loss in real usage scenarios?

    One typical test makes the point. The requirement was to build a batch audio-video extraction tool that accepts common video formats as input, exports to two mainstream audio formats, provides a file list and format settings, offers complete interactions such as import, execute, and exit, includes a progress bar and status bar, shows errors when they occur, and “the interface must not freeze.” This kind of requirement looks ordinary, but it is a touchstone for the engineering maturity of a generative model.

    The reason is that the first few items belong to “functional completeness,” which a model has a high probability of getting right. “No freezing,” however, belongs to “concurrency correctness”: it requires the model to realize on its own that long-running tasks must not occupy the UI main thread. A large number of lazy solutions write the transcoding loop directly inside the button callback. It compiles, the interface renders, but the moment you click “Start,” the app hangs. This kind of defect never surfaces during syntax checking; it only appears at runtime.

    2. Evaluation Framework: Four Dimensions of Real Model Capability

    Breaking the subjective “is the experience good” into four verifiable dimensions makes the evaluation engineering-actionable.

    1. Requirement coverage. Compare against the constraint list item by item and check for omissions or unauthorized cuts. Excellent behavior is catching everything and filling in common-sense gaps, such as recursively scanning subdirectories, completing common container and audio codec suffixes, and automatically appending a sequence number to duplicate output names to prevent overwriting.
    2. Runtime correctness. Does it pass syntax and import checks on the first try; does it probe external dependencies up front, for example checking at startup whether the system has the required media processing components, and giving clear guidance when they are missing instead of crashing with a stack trace.
    3. Concurrency and responsiveness. Are long-running operations moved off the main thread, is progress feedback sent back in a thread-safe way, and does it exit cleanly when canceling or closing the window.
    4. Robustness and UX details. Are exceptions caught by category and turned into human-readable messages; are edge cases handled, such as paths with spaces, Chinese characters, or overly long file names; does the layout scale reasonably with the window.

    3. Key Technique: The Right Way to Keep a GUI from Freezing

    The root cause of a desktop program “hanging” is almost always the same: the main thread carries both the event loop and blocking computation. The event loop of mainstream GUI frameworks is a single-threaded model, and any prolonged occupation makes repaint and click events queue up and wait.

    The correct structure can be summarized as “three-role separation”:

    • Main thread: responsible only for rendering and event dispatch, never executing transcoding.
    • Worker thread: processes the task queue serially or in parallel and performs the actual media processing calls.
    • Return channel: uses the framework-provided thread-safe queue to send progress, logs, and results from the worker thread back to the main thread to refresh widgets.

    The illustrative code below focuses on structure rather than a specific implementation:

    1. import queue
    2. import threading
    3. # The main thread polls the message queue on a timer to avoid touching UI widgets across threads
    4. msg_queue = queue.Queue()
    5. def worker(task_queue, msg_queue):
    6. while True:
    7. item = task_queue.get()
    8. if item is None:
    9. break
    10. try:
    11. # Call the external media processing component to do the extraction; the long-running work happens in this thread
    12. do_convert(item, progress_cb=lambda p: msg_queue.put(("progress", p)))
    13. msg_queue.put(("done", item))
    14. except Exception as e:
    15. msg_queue.put(("error", (item, str(e))))
    16. finally:
    17. task_queue.task_done()
    18. def poll_messages(root, bar, status):
    19. while not msg_queue.empty():
    20. kind, payload = msg_queue.get_nowait()
    21. if kind == "progress":
    22. bar["value"] = payload
    23. elif kind == "status":
    24. status["text"] = payload
    25. # Remaining branches update the status bar or show a prompt
    26. root.after(80, poll_messages, root, bar, status)

    Three easily overlooked engineering constraints are worth emphasizing. First, UI widgets may only be updated in the thread that created them. Second, progress reporting must be throttled, or high-frequency messages will flood the event queue and cause the very freezing you were avoiding. Third, on exit you must post an end marker to the task queue and wait for the worker threads to wind down, preventing leftover processes from holding file handles.

    4. Prompt Writing: Turning “Tedious Requirements” into an Acceptance Checklist

    What actually made the difference in testing was not luck but how the prompt was organized. A reusable template has five parts:

    1. Role and goal: specify “senior desktop developer” and describe the form of the deliverable.
    2. Technical constraints: language, GUI framework, external dependencies, and their detection strategy.
    3. Feature list: numbered items, each a verifiable action, easy to check off one by one.
    4. Non-functional requirements: responsiveness, error message tone, layout adaptivity, and log retention.
    5. Acceptance criteria: require a syntax and import self-check first, then output usage instructions and known limitations.

    Rewriting vague statements like “friendly interface, smooth operation” into “after clicking Start the main thread must not block, progress refreshes as a percentage, and failed items are summarized in the status bar with reasons” noticeably improves the model’s implementation quality. Only verifiable constraints are effective constraints.

    5. Retrospective and Recommendations for Adoption

    A complete delivery in ten minutes with very low resource consumption shows that current mainstream models can already cover the development range of small and medium internal tools. But treating the output as “maintainable production code” still requires human gatekeeping, and three closing steps are recommended:

    • Security review: external command invocation must avoid concatenating user input and should uniformly use argument arrays; validate target directory permissions before writing files.
    • Dependency governance: list the external media processing component as an optional dependency, probe for it at startup, and give installation guidance; pin versions in container platforms or virtual environments to reduce environment drift.
    • Observability: emit structured logs for batch tasks and connect them to a general logging service and monitoring/alerting categories, making it easy to track failure rates and average duration.

    To productize this kind of tool, you can also use object storage to archive inputs and outputs, a message queue to smooth task peaks, and container platforms to scale stateless executors, forming a stable pipeline of “interface submission - queue scheduling - parallel processing - result return.”

    The conclusion is straightforward: to evaluate AI coding capability, do not look only at benchmark scores; stress-test with a “hard requirement” that includes concurrency and exception constraints. A model that runs through on the first try, keeps the interface responsive, and explains errors is the one with real engineering value. And writing requirements clearly and moving acceptance criteria to the front is the ability developers should practice most right now.