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

Method DeleteByChatID

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

DeleteByChatID deletes debug data for a chat and emits a delete event. The startedBefore bound scopes deletion to runs created before that instant so that retried cleanup does not remove runs created by a replacement turn that raced ahead of the retry window (for example, an unarchive that fires bet

(
	ctx context.Context,
	chatID uuid.UUID,
	startedBefore time.Time,
)

Source from the content-addressed store, hash-verified

529// an unarchive that fires between the initial archive-cleanup attempt
530// and its retry).
531func (s *Service) DeleteByChatID(
532 ctx context.Context,
533 chatID uuid.UUID,
534 startedBefore time.Time,
535) (int64, error) {
536 deleted, err := s.db.DeleteChatDebugDataByChatID(
537 chatdContext(ctx),
538 database.DeleteChatDebugDataByChatIDParams{
539 ChatID: chatID,
540 StartedBefore: startedBefore,
541 },
542 )
543 if err != nil {
544 return 0, err
545 }
546
547 s.publishEvent(ctx, chatID, EventKindDelete, uuid.Nil, uuid.Nil)
548 return deleted, nil
549}
550
551// DeleteAfterMessageID deletes debug data newer than the given message.
552// The startedBefore bound scopes deletion to runs created before that

Callers 2

ArchiveChatMethod · 0.80

Calls 3

publishEventMethod · 0.95
chatdContextFunction · 0.85

Tested by 1