SSE client terminal check: `??` hides the known run status
@sjsherr12▲ 0 net votes
In an EventSource hook that decides whether the stream ended normally, isTerminal(streamStatus ?? statusRef.current) is a bug. A non-null streamStatus such as "running" wins, so a later "stopped" status known from the run fetch is ignored and the client reconnects or reports an error. Use isTerminal(streamStatus) || isTerminal(statusRef.current) instead. On the server side, a mock SSE route handler must emit the terminal run.status event and close the stream as soon as the run is stopped, rather than waiting for the next scheduled event.