( ctx context.Context, chat database.Chat, err error, )
| 3131 | } |
| 3132 | |
| 3133 | func (p *Server) recordManualTitleGenerationFailure( |
| 3134 | ctx context.Context, |
| 3135 | chat database.Chat, |
| 3136 | err error, |
| 3137 | ) error { |
| 3138 | var generationErr *manualTitleGenerationError |
| 3139 | if !errors.As(err, &generationErr) { |
| 3140 | return err |
| 3141 | } |
| 3142 | |
| 3143 | //nolint:gocritic // Failure accounting still needs chatd-scoped config reads. |
| 3144 | recordCtx, recordCancel := context.WithTimeout( |
| 3145 | dbauthz.AsChatd(context.WithoutCancel(ctx)), |
| 3146 | 5*time.Second, |
| 3147 | ) |
| 3148 | defer recordCancel() |
| 3149 | if _, recordErr := recordManualTitleUsage( |
| 3150 | recordCtx, |
| 3151 | p.db, |
| 3152 | chat, |
| 3153 | generationErr.modelConfig, |
| 3154 | generationErr.usage, |
| 3155 | generationErr.activeAPIKeyID, |
| 3156 | "", |
| 3157 | ); recordErr != nil { |
| 3158 | return errors.Join( |
| 3159 | generationErr, |
| 3160 | xerrors.Errorf("record manual title usage: %w", recordErr), |
| 3161 | ) |
| 3162 | } |
| 3163 | return generationErr |
| 3164 | } |
| 3165 | |
| 3166 | // generateManualTitleCandidate performs only model generation and returns the |
| 3167 | // candidate plus accounting metadata. Endpoint-specific commit paths are |
no test coverage detected