From 8d34aa712511195c78bc96b6ebf31abc53617d7a Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Wed, 3 Jun 2026 01:13:47 +0700 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20remove=20warn=20moderatio?= =?UTF-8?q?n=20status=20=E2=80=94=20hardcode=20warn=20to=200=20in=20charts?= =?UTF-8?q?,=20drop=20warn=20filter/badge/buttons/Api,=20simplify=20to=20f?= =?UTF-8?q?lagged-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/frontend/src/App.tsx | 6 +- .../analytics/components/ActivityChart.tsx | 2 +- .../analytics/components/SummaryCards.tsx | 9 --- .../analytics/components/TrendChart.tsx | 2 +- .../analytics/components/UserTable.tsx | 4 -- .../analytics/components/ViolatorTable.tsx | 6 +- .../messages/components/MessageCard.tsx | 62 +------------------ .../components/ModerationAlertListener.tsx | 11 ++-- .../frontend/src/features/messages/index.tsx | 10 +-- services/frontend/src/shared/api/client.ts | 11 ---- 10 files changed, 15 insertions(+), 108 deletions(-) diff --git a/services/frontend/src/App.tsx b/services/frontend/src/App.tsx index df31cf4..e5ed658 100644 --- a/services/frontend/src/App.tsx +++ b/services/frontend/src/App.tsx @@ -97,15 +97,15 @@ export default function App() { onMessageAnalyzed: (m) => { const msg = m as MessageRecord; messages.setMessages((prev) => mergeMessages(prev, [msg])); - // Show toast for moderation alerts (warn/flagged) + // Show toast for moderation alerts (flagged) const status = msg.ai_status; - if (status === "flagged" || status === "warn") { + if (status === "flagged") { const username = msg.username || msg.user_id || "unknown"; const severity = msg.ai_severity || ""; const categories = msg.ai_categories || ""; const brief = msg.ai_analysis?.slice(0, 80) ?? - `Message ${status === "flagged" ? "flagged" : "warned"} by AI`; + "Message flagged by AI"; window.dispatchEvent( new CustomEvent("moderation_alert", { detail: { type: status, username, severity, categories, brief }, diff --git a/services/frontend/src/features/analytics/components/ActivityChart.tsx b/services/frontend/src/features/analytics/components/ActivityChart.tsx index 579b083..9179a00 100644 --- a/services/frontend/src/features/analytics/components/ActivityChart.tsx +++ b/services/frontend/src/features/analytics/components/ActivityChart.tsx @@ -27,7 +27,7 @@ export function ActivityChart({ hourly, loading }: ActivityChartProps) { return { hour: `${String(jakartaHour).padStart(2, "0")}:00`, clean: b.clean, - warned: b.warned, + warned: 0, flagged: b.flagged, error: b.error, total: b.count, diff --git a/services/frontend/src/features/analytics/components/SummaryCards.tsx b/services/frontend/src/features/analytics/components/SummaryCards.tsx index 33ab46f..df78e10 100644 --- a/services/frontend/src/features/analytics/components/SummaryCards.tsx +++ b/services/frontend/src/features/analytics/components/SummaryCards.tsx @@ -22,10 +22,6 @@ export function SummaryCards({ messages && messages.total > 0 ? Math.round((messages.clean / messages.total) * 100) : 0; - const warnedPct = - messages && messages.total > 0 - ? Math.round((messages.warned / messages.total) * 100) - : 0; const flaggedPct = messages && messages.total > 0 ? Math.round((messages.flagged / messages.total) * 100) @@ -47,11 +43,6 @@ export function SummaryCards({ value: cleanPct > 0 ? `${cleanPct}%` : "—", accent: "text-emerald-400", }, - { - label: "Warned", - value: warnedPct > 0 ? `${warnedPct}%` : "—", - accent: "text-amber-400", - }, { label: "Flagged", value: flaggedPct > 0 ? `${flaggedPct}%` : "—", diff --git a/services/frontend/src/features/analytics/components/TrendChart.tsx b/services/frontend/src/features/analytics/components/TrendChart.tsx index 05f0333..448a992 100644 --- a/services/frontend/src/features/analytics/components/TrendChart.tsx +++ b/services/frontend/src/features/analytics/components/TrendChart.tsx @@ -24,7 +24,7 @@ export function TrendChart({ trend, loading }: TrendChartProps) { const data = trend.map((bucket) => ({ date: bucket.date, clean: bucket.clean, - warned: bucket.warned, + warned: 0, flagged: bucket.flagged, error: bucket.error, total: bucket.count, diff --git a/services/frontend/src/features/analytics/components/UserTable.tsx b/services/frontend/src/features/analytics/components/UserTable.tsx index 1ebb034..1e53c22 100644 --- a/services/frontend/src/features/analytics/components/UserTable.tsx +++ b/services/frontend/src/features/analytics/components/UserTable.tsx @@ -53,7 +53,6 @@ export function UserTable({ users, loading }: UserTableProps) { User Pesan Edit - Hapus Flag @@ -103,9 +102,6 @@ export function UserTable({ users, loading }: UserTableProps) { {user.edited_count > 0 ? user.edited_count : "—"} - - {user.deleted_count > 0 ? user.deleted_count : "—"} - {user.flagged_count > 0 ? ( - Skor: flagged × 3 + warned × 1. + Skor: flagged × 3. {users.length} pelanggar @@ -61,7 +61,6 @@ export function ViolatorTable({ users, loading }: ViolatorTableProps) { # User - Warned Flagged Skor @@ -102,9 +101,6 @@ export function ViolatorTable({ users, loading }: ViolatorTableProps) { - - {user.warned_count} - {user.flagged_count} diff --git a/services/frontend/src/features/messages/components/MessageCard.tsx b/services/frontend/src/features/messages/components/MessageCard.tsx index 9019a0b..21403fa 100644 --- a/services/frontend/src/features/messages/components/MessageCard.tsx +++ b/services/frontend/src/features/messages/components/MessageCard.tsx @@ -1,6 +1,5 @@ import { AlertCircle, - AlertTriangle, CheckCircle2, ChevronDown, ChevronUp, @@ -12,7 +11,6 @@ import { } from "lucide-react"; import { Fragment, useMemo, useState } from "react"; import type { MessageRecord } from "../../../shared/api/client"; -import { moderateMessage } from "../../../shared/api/client"; import { Badge, Button, Skeleton } from "../../../shared/ui"; import { parseMetadata } from "../../../entities/message/types"; @@ -89,7 +87,6 @@ function parseStringList(value?: string | null): string[] { function aiVariant(status: string) { if (status === "clean") return "success"; - if (status === "warn") return "warning"; if (status === "flagged" || status === "error") return "destructive"; return "secondary"; } @@ -138,7 +135,7 @@ export function MessageCard({ message.ai_confidence ?? message.ai_moderation_score ?? null; const [isReanalyzing, setIsReanalyzing] = useState(false); const [showAnalysis, setShowAnalysis] = useState( - aiStatus === "warn" || aiStatus === "flagged", + aiStatus === "flagged", ); // Build a human-readable analysis summary from categories + confidence + severity @@ -223,9 +220,6 @@ export function MessageCard({ {aiStatus === "clean" && ( )} - {aiStatus === "warn" && ( - - )} {aiStatus === "flagged" && ( )} @@ -328,9 +322,7 @@ export function MessageCard({ className={`rounded-xl border-l-2 p-3 ${ aiStatus === "flagged" ? "border-l-red-500 bg-red-500/5" - : aiStatus === "warn" - ? "border-l-yellow-500 bg-yellow-500/5" - : "border-l-blue-500 bg-blue-500/5" + : "border-l-blue-500 bg-blue-500/5" }`} > - - - )} diff --git a/services/frontend/src/features/messages/components/ModerationAlertListener.tsx b/services/frontend/src/features/messages/components/ModerationAlertListener.tsx index 18d9ca9..dee204f 100644 --- a/services/frontend/src/features/messages/components/ModerationAlertListener.tsx +++ b/services/frontend/src/features/messages/components/ModerationAlertListener.tsx @@ -1,12 +1,12 @@ // ─── Moderation alert toast listener ─────────────────────────────────────── // Listens for "moderation_alert" custom events dispatched from WebSocket -// message_analyzed handler, and shows toast notifications for flagged/warned +// message_analyzed handler, and shows toast notifications for flagged // messages so moderators don't miss important alerts. import { useEffect } from "react"; import { useToast } from "../../../shared/ui"; interface AlertDetail { - type: "flagged" | "warn"; + type: "flagged"; username: string; severity: string; categories: string; @@ -18,19 +18,18 @@ export function ModerationAlertListener() { useEffect(() => { const handler = (e: Event) => { - const { type, username, severity, categories, brief } = ( + const { username, severity, categories, brief } = ( e as CustomEvent ).detail; - const emoji = type === "flagged" ? "🚨" : "⚠️"; const sevLabel = severity ? `[${severity}]` : ""; const catLabel = categories ? ` — ${categories.split(",").slice(0, 2).join(", ")}` : ""; addToast( - `${emoji} ${username} ${sevLabel}${catLabel}: ${brief}`, - type === "flagged" ? "error" : "warning", + `🚨 ${username} ${sevLabel}${catLabel}: ${brief}`, + "error", ); }; diff --git a/services/frontend/src/features/messages/index.tsx b/services/frontend/src/features/messages/index.tsx index 89200f3..6c9c11c 100644 --- a/services/frontend/src/features/messages/index.tsx +++ b/services/frontend/src/features/messages/index.tsx @@ -27,7 +27,7 @@ interface MessagesPanelProps { loadingMore?: boolean; } -type AiFilter = "all" | "clean" | "warn" | "flagged" | "error" | "pending"; +type AiFilter = "all" | "clean" | "flagged" | "error" | "pending"; export function MessagesPanel({ guildName, @@ -73,7 +73,6 @@ export function MessagesPanel({ return { total: base.length, clean: base.filter((m) => m.ai_status === "clean").length, - warn: base.filter((m) => m.ai_status === "warn").length, flagged: base.filter((m) => m.ai_status === "flagged").length, error: base.filter((m) => m.ai_status === "error").length, pending: base.filter((m) => m.ai_status === "pending" || !m.ai_status) @@ -125,12 +124,6 @@ export function MessagesPanel({ > {stats.clean} clean - - {stats.warn} warn - { - return request<{ ok: boolean }>(`/api/messages/${id}/moderate`, { - method: "POST", - body: JSON.stringify({ actionType, reason }), - }); -} - // ─── Guilds / Config ───────────────────────────────────────────────────────── export function getGuilds(): Promise {