| 293 | } |
| 294 | |
| 295 | func newCompactProgressWriter(ctx context.Context, p Platform, replyCtx any, agentName string, lang Language, transform func(string) string) *compactProgressWriter { |
| 296 | w := &compactProgressWriter{ |
| 297 | ctx: ctx, |
| 298 | platform: p, |
| 299 | replyCtx: replyCtx, |
| 300 | transform: transform, |
| 301 | style: progressStyleForTarget(p, replyCtx), |
| 302 | state: ProgressCardStateRunning, |
| 303 | agentName: normalizeProgressAgentLabel(agentName), |
| 304 | lang: lang, |
| 305 | maxEntries: 10, |
| 306 | } |
| 307 | if throttler, ok := p.(ProgressUpdateThrottler); ok { |
| 308 | w.minUpdateInterval = throttler.ProgressUpdateInterval() |
| 309 | } |
| 310 | if w.style != progressStyleCompact && w.style != progressStyleCard { |
| 311 | slog.Debug("progress writer disabled: unsupported style", "platform", p.Name(), "style", w.style) |
| 312 | return w |
| 313 | } |
| 314 | updater, ok := p.(MessageUpdater) |
| 315 | if !ok { |
| 316 | slog.Debug("progress writer disabled: platform has no MessageUpdater", "platform", p.Name(), "style", w.style) |
| 317 | return w |
| 318 | } |
| 319 | w.enabled = true |
| 320 | w.updater = updater |
| 321 | if starter, ok := p.(PreviewStarter); ok { |
| 322 | w.starter = starter |
| 323 | } |
| 324 | if w.style == progressStyleCard { |
| 325 | if progressCardPayloadForTarget(p, replyCtx) { |
| 326 | w.usePayload = true |
| 327 | } |
| 328 | } |
| 329 | slog.Debug("progress writer enabled", "platform", p.Name(), "style", w.style, "use_payload", w.usePayload) |
| 330 | return w |
| 331 | } |
| 332 | |
| 333 | func normalizeProgressAgentLabel(name string) string { |
| 334 | switch strings.ToLower(strings.TrimSpace(name)) { |