Skip to main content

Research Synthesizer

A research tool with a multi-stage workflow: collect sources, analyze each in parallel, synthesize findings, and wait for human approval before finalizing. The number of analysis streams is determined at runtime based on how many sources the user adds.

Server Code

Key Patterns

Dynamic stream arrays: Each source contains its own analysis stream. When you push a source to the array, the stream syncs to clients. During analysis, each stream updates in parallel. Human-in-the-loop: After synthesis, set approval = { pending: true } and return. The Durable Object can hibernate. When the user responds, the approve action continues the workflow. This approval state persists across browser sessions.

Client Code

Running the Example

Add 2-3 sources, then click “Analyze Sources.” Watch each source’s analysis stream in parallel. When synthesis finishes, the approval dialog appears. Approve to complete, or reject to return to collection. Key behaviors to notice:
  • Dynamic streams: Add 5 sources and 5 parallel streams appear
  • Workflow stages: The stage field drives which UI renders
  • Persistent approval: Close your browser, return later—the approval dialog is still waiting
  • Clean rejection loop: Rejecting resets to collection stage for iteration