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

Method IsEnabled

coderd/x/chatd/chatdebug/service.go:219–271  ·  view source on GitHub ↗

IsEnabled returns whether debug logging is enabled for the given chat.

(
	ctx context.Context,
	chatID uuid.UUID,
	ownerID uuid.UUID,
)

Source from the content-addressed store, hash-verified

217
218// IsEnabled returns whether debug logging is enabled for the given chat.
219func (s *Service) IsEnabled(
220 ctx context.Context,
221 chatID uuid.UUID,
222 ownerID uuid.UUID,
223) bool {
224 if s == nil {
225 return false
226 }
227 if s.alwaysEnable {
228 return true
229 }
230 if s.db == nil {
231 return false
232 }
233
234 authCtx := chatdContext(ctx)
235
236 allowUsers, err := s.db.GetChatDebugLoggingAllowUsers(authCtx)
237 if err != nil {
238 if errors.Is(err, sql.ErrNoRows) {
239 return false
240 }
241 s.log.Warn(ctx, "failed to load runtime admin chat debug logging setting",
242 slog.Error(err),
243 )
244 return false
245 }
246 if !allowUsers {
247 return false
248 }
249
250 if ownerID == uuid.Nil {
251 s.log.Warn(ctx, "missing chat owner for debug logging enablement check",
252 slog.F("chat_id", chatID),
253 )
254 return false
255 }
256
257 enabled, err := s.db.GetUserChatDebugLoggingEnabled(authCtx, ownerID)
258 if err == nil {
259 return enabled
260 }
261 if errors.Is(err, sql.ErrNoRows) {
262 return false
263 }
264
265 s.log.Warn(ctx, "failed to load user chat debug logging setting",
266 slog.Error(err),
267 slog.F("chat_id", chatID),
268 slog.F("owner_id", ownerID),
269 )
270 return false
271}
272
273// CreateRun inserts a new debug run and emits a run update event.
274func (s *Service) CreateRun(

Callers 8

TestService_IsEnabledFunction · 0.95
newDebugAwareModelMethod · 0.80
beginStepFunction · 0.80

Calls 5

chatdContextFunction · 0.85
IsMethod · 0.45
ErrorMethod · 0.45