(ctx context.Context, msg, attachPath string)
| 262 | } |
| 263 | |
| 264 | func (m *model) sendFirstMessage(ctx context.Context, msg, attachPath string) { |
| 265 | var atts []messages.Attachment |
| 266 | if attachPath != "" { |
| 267 | if abs, err := filepath.Abs(attachPath); err == nil { |
| 268 | atts = append(atts, messages.Attachment{Name: filepath.Base(abs), FilePath: abs}) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | trimmed := strings.TrimSpace(msg) |
| 273 | switch { |
| 274 | case trimmed != "": |
| 275 | m.addUserEcho(trimmed) |
| 276 | case len(atts) > 0: |
| 277 | m.addNotice("", "(attached "+atts[0].Name+")", stMuted()) |
| 278 | default: |
| 279 | return |
| 280 | } |
| 281 | |
| 282 | content := msg |
| 283 | if strings.HasPrefix(trimmed, "/") { |
| 284 | if resolved := m.app.ResolveInput(ctx, trimmed); resolved != "" { |
| 285 | content = resolved |
| 286 | } |
| 287 | } |
| 288 | m.startRun(ctx, content, atts) |
| 289 | } |
| 290 | |
| 291 | func (m *model) startRun(ctx context.Context, message string, attachments []messages.Attachment) { |
| 292 | runCtx, cancel := context.WithCancel(ctx) |
no test coverage detected