fix(server): close task event streams when the client only wants a replay

Interrupted runs often have no done event, so a refresh replay would otherwise hold the SSE connection open.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-21 06:21:09 +00:00
co-authored by Cursor
parent a236ddc0fa
commit cb1c378c5a
+4
View File
@@ -502,6 +502,10 @@ func (s *Server) handleTaskRunEvents(w http.ResponseWriter, r *http.Request) {
if err := writeStoredEvents(replay); err != nil {
return
}
// 刷新后只重放已落库事件,避免 interrupted 任务没有 done/error 时把连接挂住。
if r.URL.Query().Get("replay_only") == "1" {
return
}
for _, stored := range replay {
if stored.Event.Type == stream.EventDone || stored.Event.Type == stream.EventError {
return