()
| 171 | } |
| 172 | |
| 173 | func (a *App) SendFirstMessage() tea.Cmd { |
| 174 | if a.firstMessage == nil { |
| 175 | return nil |
| 176 | } |
| 177 | |
| 178 | cmds := []tea.Cmd{ |
| 179 | func() tea.Msg { |
| 180 | // Use the shared PrepareUserMessage function for consistent attachment handling |
| 181 | userMsg, attachedPath, err := cli.PrepareUserMessage(a.ctx(), a.runtime, *a.firstMessage, a.firstMessageAttach) |
| 182 | if err != nil { |
| 183 | slog.Error("Failed to prepare first message", "error", err) |
| 184 | return nil |
| 185 | } |
| 186 | if userMsg == nil { |
| 187 | // Agent-only command with no content - agent switched but no message to send |
| 188 | return nil |
| 189 | } |
| 190 | // Inherit the attachment in any sub-session created by this turn. |
| 191 | a.session.AddAttachedFile(attachedPath) |
| 192 | |
| 193 | // If the message has multi-content (attachments), we need to handle it specially |
| 194 | if len(userMsg.Message.MultiContent) > 0 { |
| 195 | return messages.SendAttachmentMsg{ |
| 196 | Content: userMsg, |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | return messages.SendMsg{ |
| 201 | Content: userMsg.Message.Content, |
| 202 | } |
| 203 | }, |
| 204 | } |
| 205 | |
| 206 | // Queue additional messages to be sent after the first one. |
| 207 | // The TUI's message queue will hold them until the agent finishes |
| 208 | // processing the previous message. |
| 209 | for _, msg := range a.queuedMessages { |
| 210 | cmds = append(cmds, func() tea.Msg { |
| 211 | return messages.SendMsg{ |
| 212 | Content: msg, |
| 213 | } |
| 214 | }) |
| 215 | } |
| 216 | |
| 217 | return tea.Sequence(cmds...) |
| 218 | } |
| 219 | |
| 220 | // CurrentAgentTools returns the tools available to the current agent. |
| 221 | func (a *App) CurrentAgentTools(ctx context.Context) ([]tools.Tool, error) { |
no test coverage detected