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

Method releaseManualTitleLock

coderd/x/chatd/chatd.go:3010–3041  ·  view source on GitHub ↗
(ctx context.Context, chatID uuid.UUID)

Source from the content-addressed store, hash-verified

3008}
3009
3010func (p *Server) releaseManualTitleLock(ctx context.Context, chatID uuid.UUID) {
3011 cleanupCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
3012 defer cancel()
3013
3014 err := p.db.InTx(func(tx database.Store) error {
3015 lockedChat, err := tx.GetChatByIDForUpdate(cleanupCtx, chatID)
3016 if err != nil {
3017 return xerrors.Errorf("lock chat to release manual title regeneration: %w", err)
3018 }
3019 if !lockedChat.WorkerID.Valid || lockedChat.WorkerID.UUID != manualTitleLockWorkerID {
3020 return nil
3021 }
3022 _, err = updateChatStatusPreserveUpdatedAt(
3023 cleanupCtx,
3024 tx,
3025 lockedChat,
3026 uuid.NullUUID{},
3027 sql.NullTime{},
3028 sql.NullTime{},
3029 )
3030 if err != nil {
3031 return xerrors.Errorf("clear manual title regeneration marker: %w", err)
3032 }
3033 return nil
3034 }, database.DefaultTXOptions().WithID("chat_title_regenerate_unlock"))
3035 if err != nil {
3036 p.logger.Warn(cleanupCtx, "failed to release manual title regeneration marker",
3037 slog.F("chat_id", chatID),
3038 slog.Error(err),
3039 )
3040 }
3041}
3042
3043// RegenerateChatTitle regenerates a chat title from the chat's visible
3044// messages, persists it when it changes, and broadcasts the update.

Callers 3

RegenerateChatTitleMethod · 0.95
RenameChatTitleMethod · 0.95
ProposeChatTitleMethod · 0.95

Calls 7

DefaultTXOptionsFunction · 0.92
InTxMethod · 0.65
GetChatByIDForUpdateMethod · 0.65
ErrorfMethod · 0.45
WithIDMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected