| 1 | package cli |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "reasonix/internal/event" |
| 6 | "time" |
| 7 | ) |
| 8 | |
| 9 | func (m *chatTUI) waitingRecoveryLine() (string, bool) { |
| 10 | if m.recovery == nil || !m.recovery.Waiting { |
| 11 | return "", false |
| 12 | } |
| 13 | return fmt.Sprintf(" %s waiting for provider (%s), retry in %ds — Esc to stop", m.spinner.View(), m.recovery.Phase, max(0, (m.recovery.NextAttemptAt-time.Now().UnixMilli()+999)/1000)), true |
| 14 | } |
| 15 | func (m *chatTUI) setRecoveryStatus(e event.Event) { |
| 16 | m.retryAttempt = e.RetryAttempt |
| 17 | m.retryMax = e.RetryMax |
| 18 | m.recovery = e.Recovery |
| 19 | } |
| 20 | func (m *chatTUI) clearRecoveryStatus() { m.retryAttempt = 0; m.retryMax = 0; m.recovery = nil } |
| 21 | |
| 22 | func (m *chatTUI) recordRecoveryDiscard(reason string) { |
| 23 | if reason == "headers" || reason == "connect" { |
| 24 | return |
| 25 | } |
| 26 | m.commitLine(dim(" ↻ stream interrupted — reconnecting…")) |
| 27 | } |
| 28 |