hasPersistedInstructionFiles reports whether messages include a persisted context-file part that should suppress another baseline instruction-file lookup. The workspace-agent skill-only sentinel is ignored so default instructions still load on fresh chats.
( messages []database.ChatMessage, )
| 133 | // instruction-file lookup. The workspace-agent skill-only sentinel is |
| 134 | // ignored so default instructions still load on fresh chats. |
| 135 | func hasPersistedInstructionFiles( |
| 136 | messages []database.ChatMessage, |
| 137 | ) bool { |
| 138 | for _, msg := range messages { |
| 139 | if !msg.Content.Valid || |
| 140 | !bytes.Contains(msg.Content.RawMessage, []byte(`"context-file"`)) { |
| 141 | continue |
| 142 | } |
| 143 | var parts []codersdk.ChatMessagePart |
| 144 | if err := json.Unmarshal(msg.Content.RawMessage, &parts); err != nil { |
| 145 | continue |
| 146 | } |
| 147 | for _, part := range parts { |
| 148 | if part.Type != codersdk.ChatMessagePartTypeContextFile || |
| 149 | !part.ContextFileAgentID.Valid || |
| 150 | part.ContextFilePath == AgentChatContextSentinelPath { |
| 151 | continue |
| 152 | } |
| 153 | return true |
| 154 | } |
| 155 | } |
| 156 | return false |
| 157 | } |
| 158 | |
| 159 | func mergeSkillMetas( |
| 160 | persisted []chattool.SkillMeta, |