MCPcopy Index your code
hub / github.com/coder/coder / startReporter

Method startReporter

cli/exp_mcp.go:594–622  ·  view source on GitHub ↗
(ctx context.Context, inv *serpent.Invocation)

Source from the content-addressed store, hash-verified

592}
593
594func (s *mcpServer) startReporter(ctx context.Context, inv *serpent.Invocation) {
595 go func() {
596 for {
597 // TODO: Even with the queue, there is still the potential that a message
598 // from the screen watcher and a message from the AI agent could arrive
599 // out of order if the timing is just right. We might want to wait a bit,
600 // then check if the status has changed before committing.
601 item, ok := s.queue.Pop()
602 if !ok {
603 return
604 }
605
606 req, err := agentsdk.ProtoFromPatchAppStatus(agentsdk.PatchAppStatus{
607 AppSlug: s.appStatusSlug,
608 Message: item.summary,
609 URI: item.link,
610 State: item.state,
611 })
612 if err != nil {
613 cliui.Warnf(inv.Stderr, "Failed to convert task status: %s", err)
614 continue
615 }
616 _, err = s.socketClient.UpdateAppStatus(ctx, req)
617 if err != nil && !errors.Is(err, context.Canceled) {
618 cliui.Warnf(inv.Stderr, "Failed to report task status: %s", err)
619 }
620 }
621 }()
622}
623
624func (s *mcpServer) startWatcher(ctx context.Context, inv *serpent.Invocation) {
625 go func() {

Callers 1

mcpServerMethod · 0.95

Calls 5

ProtoFromPatchAppStatusFunction · 0.92
WarnfFunction · 0.92
UpdateAppStatusMethod · 0.65
PopMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected