MCPcopy
hub / github.com/docker/docker-agent / SendFirstMessage

Method SendFirstMessage

pkg/app/app.go:173–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171}
172
173func (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.
221func (a *App) CurrentAgentTools(ctx context.Context) ([]tools.Tool, error) {

Callers 1

initMethod · 0.80

Calls 3

PrepareUserMessageFunction · 0.92
AddAttachedFileMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected