X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/fc0503be49438775c5d08499046852df59bd7377..d7bc0a6ac452bfc646610fdfd7c8eccb5c55218f:/turn.go?ds=sidebyside diff --git a/turn.go b/turn.go index c08e94a..01d6b7b 100644 --- a/turn.go +++ b/turn.go @@ -16,7 +16,9 @@ import ( // run. ID is the ID of a logged message. Source names the client that sent a // user message, such as terminal or telegram, so that each client can show the // messages of the others, or the subagent of a report. Status tells how the run -// of a report ended: finished, stopped, or failed. +// of a report ended: finished, stopped, or failed. A private notify receipt +// uses ID for its queue sequence and Status for accepted or duplicate, not +// processed. type Event struct { Kind string `json:"kind"` ID int `json:"id,omitempty"` @@ -296,12 +298,23 @@ func (l *TurnLoop) Run(ctx context.Context) error { } for { - for ctx.Err() == nil && l.waiting() { + for ctx.Err() == nil { err := l.failed() if err != nil { return fmt.Errorf("check turn loop failure: %w", err) } + if l.messages != nil { + err = l.messages.Notifications(l) + if err != nil { + return fmt.Errorf("prepare external events: %w", err) + } + } + + if !l.waiting() { + break + } + err = l.turn(ctx) if err != nil { return fmt.Errorf("run turn: %w", err)