Evaluating LLM-Assisted Desktop Tool Development: A Practical Case Study on Batch Media Transcoding

    This article explains how to evaluate code generated by large language models for a desktop application. Using a batch media transcoding tool as the example, it covers how to write verifiable requirements, separate the UI thread from worker threads, review generated code for edge cases, test the result, and plan the path to a maintainable application.

    1. Evaluation Goal: From “Runs” to “Deliverable”

    A batch media transcoding tool looks simple, but it includes many parts: importing files, choosing output formats, running tasks, reporting progress, showing errors, naming output files, scanning directories recursively, and detecting external transcoding components. If the prompt only asks for “a GUI,” a model can easily produce code that looks complete on the surface. Once non-functional requirements are added, such as “the interface must not freeze during conversion,” “errors must be reported,” or “existing output files must not be overwritten,” the quality gap becomes visible.

    When you evaluate code generated with an LLM, split the requirements into two groups:

    1. Functional requirements: import common video and audio files, select the output audio format, provide operations such as a file list, format settings, Start Conversion, and Exit, and display a progress bar and a status bar.
    2. Non-functional requirements: long-running transcoding must not block the UI, task failures must be traceable, output files must not be overwritten silently, directory scanning must be controllable, a missing external transcoding component must produce a clear message, and exiting or canceling must not leave tasks running in the background.

    The more verifiable a requirement is, the easier it is to review the generated code. For example, “a friendly interface” should be rewritten as “when the window is resized, the list and buttons remain laid out sensibly, long paths can be viewed, and errors are visible in both the status bar and a dialog box.” This helps the model understand the goal, and it makes the result easier to test.

    2. Key Architecture: Separate the UI Thread from Worker Threads

    A common problem with this type of tool is that the time-consuming conversion logic runs directly inside a UI event callback. The problem may not appear when testing a single file, but the interface stops responding as soon as a batch starts. The correct design keeps the main thread responsible only for rendering and user interaction. Worker threads handle directory scanning, calls to the external transcoding component, and writing output files. The two sides communicate through a thread-safe queue or an event mechanism.

    The following pseudocode illustrates the pattern:

    1. ui_queue = ThreadSafeQueue()
    2. def on_start_clicked():
    3. tasks = build_tasks_from_list()
    4. if tasks.is_empty():
    5. show_status("No files to convert")
    6. return
    7. disable_start_button()
    8. start_worker(tasks)
    9. def worker(tasks):
    10. for task in tasks:
    11. if cancel_requested():
    12. emit("cancelled")
    13. break
    14. try:
    15. emit("progress", task.index, 0)
    16. transcode(
    17. input_path=task.input,
    18. output_path=task.output,
    19. on_progress=lambda p: emit("progress", task.index, p)
    20. )
    21. emit("success", task.index)
    22. except ExternalComponentMissing:
    23. emit("error", "External transcoding component is unavailable. Check the installation and search path.")
    24. break
    25. except Exception as exc:
    26. emit("error", task.index, str(exc))
    27. emit("done")
    28. def ui_poll_queue():
    29. while not ui_queue.empty():
    30. event = ui_queue.pop()
    31. update_list_status(event)
    32. update_progress_bar(event)
    33. update_status_bar(event)
    34. schedule_next_poll()

    The important point is the division of responsibilities, not the code itself. Worker threads never modify UI controls directly. All UI updates return to the main thread. Progress events should be throttled so that frequent updates do not slow down the interface. Error events should include the task index and a readable reason. Cancellation should set a shared flag, and the worker should check that flag at task boundaries.

    3. Detailed Review: Does the Code Handle Real Edge Cases?

    A generated result may look complete, but you should check these details carefully:

    • External component detection: Before conversion starts, check whether the external transcoding component is available. This includes confirming that the executable is on the search path and that it can print version information. If the component is missing, report the problem before the batch starts, not after the first file fails.
    • Recursive directory scanning: When scanning directories recursively, avoid duplicate files, hidden files, and unreadable directories that could cause the whole scan to fail. Collect the full task list first, then run the tasks.
    • Preventing overwrites: If an output path already exists, either append a number automatically or ask the user. The numbering strategy should be stable, so repeated or concurrent runs do not conflict.
    • Format detection and filtering: The file list should exclude unsupported types. When the format settings change, the executable state of each item should update accordingly.
    • Error isolation: A failure in one file should not crash the whole batch. Record the error in the status bar or a log area, and let the user continue with the remaining tasks.
    • Exit and cancellation: When the program exits, it should stop accepting new tasks and wait for the current task to finish safely or cancel it. This prevents incomplete output files.

    These points are often missing from the original requirement text, but any deliverable software needs them. When you evaluate a model, check whether it adds reasonable engineering details on its own, instead of only satisfying the literal wording of the request.

    4. Verification: Static Checks, Runtime Tests, and Follow-up Questions

    After generating code, run at least three layers of verification:

    1. Static checks: Look for syntax errors, missing imports, undefined variables, obvious scope errors, and resources that are never released.
    2. Runtime tests: Test scenarios such as an empty list, a single file, multiple files, a corrupted file, an unreadable directory, an existing output file, and a long path.
    3. Follow-up questions: Ask about the default output directory, cancellation behavior, the message shown when a component is missing, and the frequency of progress updates. Check whether the answers match the code.

    For example, you could ask: “Is the default output directory the program’s directory? If the user does not select a directory, where does the code set the default value?” Questions like this test whether the generated code is internally consistent. If an answer contradicts the code, trust the code and the actual runtime results, and ask the model to identify the changes it would make.

    5. Engineering Recommendations

    Once the prototype runs, continue by adding configuration persistence, logging, a task queue, retry on failure, resource limits, and packaging for distribution. When calling an external component, pass arguments as a parameter list instead of building a command string, so special characters in file paths cannot cause command injection. Normalize and validate output paths to prevent path traversal. Clean up temporary files when an error occurs.

    If a single-machine batch tool later needs centralized processing, it can use general cloud services such as object storage, task queues, and log services. On Baidu AI Cloud, these general-purpose categories can carry input and output, task distribution, and auditing. The desktop client should still keep local component detection, fallback behavior, and error messages, so that it does not depend heavily on the network.

    6. Conclusion

    Evaluating desktop tools generated by an LLM should not stop at whether the code looks complete. A more reliable standard asks whether each requirement is covered, whether the UI and worker threads are separated, whether errors and cancellation are handled, whether a missing external component is reported, whether output naming and directory scanning are safe, and whether the answers to follow-up questions match the code. The batch media transcoding case shows that the user experience depends less on how fast code is generated than on whether the result passes engineering review and becomes maintainable.