Command Palette

Search for a command to run...

Hectal
Phase 14: Agents in the UI
AI Frontend · Exercise 4 of 5 PreviousNext
Advanced

Stop a Run Half Way

A run has three steps of 120 ms. The server sends a data-step part ({ id, state: "done" }) when each step finishes. When #start is clicked, send Refund ORD-1042.

Show #progress as N of 3 where N is the number of data-step parts received (count them in onData). Add a #stop button that is enabled only while a run is going (status is submitted or streaming) and calls stop(). After a stop, show Stopped after N of 3 steps in #status. After a run that finishes, show Finished.

What Check tests

  1. #stop is disabled before a run
  2. Stopping after the first step says Stopped after 1 of 3 steps
  3. #stop is disabled again after the stop
  4. A run left alone finishes with all 3 steps

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.