parseDynamicToolNames unmarshals the dynamic tools JSON column and returns a map of tool names. This centralizes the repeated pattern of deserializing DynamicTools into a name set.
(raw pqtype.NullRawMessage)
| 9588 | // and returns a map of tool names. This centralizes the repeated |
| 9589 | // pattern of deserializing DynamicTools into a name set. |
| 9590 | func parseDynamicToolNames(raw pqtype.NullRawMessage) (map[string]bool, error) { |
| 9591 | if !raw.Valid || len(raw.RawMessage) == 0 { |
| 9592 | return make(map[string]bool), nil |
| 9593 | } |
| 9594 | var tools []codersdk.DynamicTool |
| 9595 | if err := json.Unmarshal(raw.RawMessage, &tools); err != nil { |
| 9596 | return nil, xerrors.Errorf("unmarshal dynamic tools: %w", err) |
| 9597 | } |
| 9598 | names := make(map[string]bool, len(tools)) |
| 9599 | for _, t := range tools { |
| 9600 | names[t.Name] = true |
| 9601 | } |
| 9602 | return names, nil |
| 9603 | } |
| 9604 | |
| 9605 | // maybeFinalizeTurnStatusLabelAndPush updates the cached turn status label |
| 9606 | // for parent chats and optionally sends a web push notification. |
no test coverage detected