From Opaque Spinner to Live Progress
Staring at a single, uninformative generating spinner for an article queue was more frustrating than helpful. The interface admitted to one task, while behind the scenes, three separate drafts were undergoing research, generation, and verification. This disconnect between the user experience and the actual system state was a clear UX failure. The solution: replace the static spinner with a dynamic, real-time progress stream powered by Server-Sent Events (SSE).
The core issue was a lack of granular feedback. Users had no visibility into what was happening beyond a generic "generating" state. This opacity breeds user anxiety and distrust. By leveraging SSE, the system can now push granular updates directly to the client, transforming the user experience from passive waiting to active, informed observation.
Implementing Real-time Work Streaming
The backend endpoint POST /api/articles/drafts/queue was modified to stream progress events over SSE. Instead of a single, monolithic response, the server now sends discrete events for each stage of the article generation process. These events provide meaningful state information for each of the three available slots in the queue.
Each event carries a specific status, such as 'Researching', 'Generating', 'Verifying links', or 'Done'. This detailed information allows the frontend to render a much richer and more accurate representation of the system's activity. The dashboard component, named GenerationProgress, consumes these events to update the UI dynamically.
Consider the practical impact: instead of a user seeing a single spinner and wondering if the system is working, they can now observe distinct progress. They see source counts increasing during the 'Researching' phase, draft titles appearing as they are generated, and a 'Done' status only when the draft has been fully processed and saved. This granular feedback loop is crucial for maintaining user engagement and trust.

The Significance of 'slot_done'
The 'Done' event, specifically the slot_done event, carries particular importance. It is not merely a signal that a task has finished; it transmits the actual draft_id of the completed draft. This is critical because it signifies the completion of the entire pipeline for that specific draft, including the final verification steps. Firing this event only when the draft truly exists and is ready ensures that the UI accurately reflects the system's state and prevents users from attempting to access or interact with a draft that hasn't been finalized.
The architecture now supports a three-slot queue. This means that while one draft is being researched, another can be generating, and a third can be verifying links. SSE enables the UI to reflect this parallel processing. Each slot can independently report its status, providing a clear visual representation of the concurrent operations. This is a significant upgrade from the previous single-spinner model, which masked the true nature of the workload.
Technical Considerations and Benefits
Server-Sent Events are well-suited for this use case because they are designed for one-way communication from the server to the client. This is ideal for broadcasting progress updates without requiring the client to constantly poll the server. SSE uses standard HTTP, making it easier to implement and less prone to issues like connection timeouts that can plague other real-time technologies. The overhead is minimal, and the browser's native support for SSE simplifies client-side implementation.
The benefits extend beyond just a better UI. By providing real-time feedback, the system can also enable more sophisticated client-side logic. For example, if a verification step consistently fails for a particular type of article, the UI could proactively alert the user or even halt the process for that slot, providing immediate feedback rather than letting the user wait until the very end. Furthermore, the explicit reporting of states like 'Verifying links' allows for better debugging and monitoring on both the client and server sides. Developers can more easily identify bottlenecks or failures within the pipeline by observing the event stream.
This approach transforms the user experience from one of uncertainty to one of transparency. Users can now see the machinery at work, understand where their request is in the process, and anticipate completion with a much higher degree of confidence. It’s a prime example of how leveraging modern web technologies like SSE can significantly enhance the perceived performance and usability of complex backend processes.
