New builds a Client governed by the caller's context, not http.Client.Timeout. That timeout is end-to-end (it covers body reads) and would kill a slow but legitimate SSE stream mid-flight on slow local backends. tui.Model's turnCtx is the single cancellation source; connect-level safety (DNS/TCP) is
(base, model, token string)
| 236 | // enough that a proxy hiccup heals invisibly, and a *permanently* failing |
| 237 | // request (e.g. a genuinely wrong model name 404ing forever) still surfaces |
| 238 | // after ~22s total instead of minutes. |
| 239 | var defaultRetryBackoff = []time.Duration{2 * time.Second, 5 * time.Second, 15 * time.Second} |
| 240 | |
| 241 | type Client struct { |
| 242 | BaseURL string |
| 243 | Model string |
| 244 | Token string // optional; empty = no Authorization header |
| 245 | HTTP *http.Client |
| 246 | // IdleTimeout caps the wait for the next SSE frame (see streamIdleTimeout). |
| 247 | // A field, not a bare const, only so tests can shorten it; New sets the |
| 248 | // default and nothing else writes it. |
| 249 | IdleTimeout time.Duration |