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

Function resolveDefaultAgentChat

coderd/workspaceagents.go:2706–2729  ·  view source on GitHub ↗
(chats []database.Chat)

Source from the content-addressed store, hash-verified

2704}
2705
2706func resolveDefaultAgentChat(chats []database.Chat) (database.Chat, error) {
2707 switch len(chats) {
2708 case 0:
2709 return database.Chat{}, errNoActiveChats
2710 case 1:
2711 return chats[0], nil
2712 }
2713
2714 var rootChat *database.Chat
2715 for i := range chats {
2716 chat := &chats[i]
2717 if chat.ParentChatID.Valid {
2718 continue
2719 }
2720 if rootChat != nil {
2721 return database.Chat{}, &multipleActiveChatsError{count: len(chats)}
2722 }
2723 rootChat = chat
2724 }
2725 if rootChat != nil {
2726 return *rootChat, nil
2727 }
2728 return database.Chat{}, &multipleActiveChatsError{count: len(chats)}
2729}
2730
2731// resolveAgentChat finds the target chat from either an explicit ID
2732// or auto-detection via the agent's active chats.

Callers 1

resolveAgentChatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected