feat: surface AI analysis duration across gateway, backend, and FE
Adds per-message AI moderation analysis time (ai_analysis_duration_ms) so operators can see how long the LLM took to moderate each message. Gateway: - messagesTable: new ai_analysis_duration_ms (bigint) column. - AIAnalysisUpdate + buildAIAnalysisSet: carry analysisDurationMs through both single and bulk update paths. - ai-analysis-worker: measure wall-clock time around runModerationAnalysis and attach it to every result in the batch. Backend: - Mirror schema column; messageMapper maps ai_analysis_duration_ms; moderation-types + MappedMessage expose it. Frontend: - message.ts type gains ai_analysis_duration_ms. - AiBadge (messages view) shows 'status · 1.2s' when duration is present; analysis view badge mirrors the same formatting. DB: - scripts/add-ai-analysis-duration.sql (idempotent ADD COLUMN IF NOT EXISTS). No behavior change for moderation logic; null until new gateway build records values.
This commit is contained in:
@@ -130,6 +130,7 @@ export interface MessageRecord {
|
||||
ai_recommended_action?: AiRecommendedAction | null;
|
||||
ai_error?: string | null;
|
||||
ai_analyzed_at?: number | null;
|
||||
ai_analysis_duration_ms?: number | null;
|
||||
/** Detail-only: number of past edits (message_edits snapshots) */
|
||||
edit_count?: number;
|
||||
/** Detail-only: previous content snapshots, newest first */
|
||||
|
||||
Reference in New Issue
Block a user