MessageCard:
- Add sticker image preview (renders actual sticker from URL, not just text name)
- Show attachment thumbnails inline (up to 4 with overflow counter)
- Remove dead columns (ai_policy_version, ai_evidence) from UI
- Add severity color coding (critical=red, high=orange, medium=yellow, low=blue)
- Add relative time display ('2h ago' instead of full datetime)
- Better hover effects and visual hierarchy
MessagesPanel:
- Add stats bar showing total/clean/warn/flagged/error/pending/deleted/edited counts
- Add AI status filter buttons (all, clean, warn, flagged, error, pending)
- Improve search UX with inline search icon and clear button
- Show filtered count in tab labels
ImageGrid:
- Include sticker images (was only attachments + embeds before)
- Add kind badge overlay (sticker/attachment/embed)
- Show user avatar next to image caption
- Better sticker rendering (object-contain with padding)
Header:
- Add shield icon per tab
- Improve tab titles and add descriptive subtitles
API client:
- Remove dead fields from MessageRecord (ai_moderation_raw, ai_policy_version, ai_evidence)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
108 lines
2.7 KiB
TypeScript
108 lines
2.7 KiB
TypeScript
export type AIStatus = "pending" | "clean" | "warn" | "flagged" | "error";
|
|
export type AISeverity = "none" | "low" | "medium" | "high" | "critical";
|
|
export type AIRecommendedAction =
|
|
| "none"
|
|
| "monitor"
|
|
| "warn"
|
|
| "review"
|
|
| "delete"
|
|
| "escalate";
|
|
|
|
export interface MessageRecord {
|
|
id: string;
|
|
guild_id: string;
|
|
channel_id: string;
|
|
thread_id: string | null;
|
|
user_id: string;
|
|
username: string;
|
|
avatar_url: string | null;
|
|
content: string;
|
|
edited_content: string | null;
|
|
created_at: number;
|
|
edited_at: number | null;
|
|
deleted_at: number | null;
|
|
type: "text" | "edited" | "deleted";
|
|
metadata: string | null;
|
|
ai_status?: AIStatus | null;
|
|
ai_moderation_flags?: string | null;
|
|
ai_moderation_score?: number | null;
|
|
ai_analysis?: string | null;
|
|
ai_categories?: string | null;
|
|
ai_severity?: AISeverity | null;
|
|
ai_confidence?: number | null;
|
|
ai_recommended_action?: AIRecommendedAction | null;
|
|
ai_analyzed_at?: number | null;
|
|
ai_error?: string | null;
|
|
}
|
|
|
|
export interface PageResult<T> {
|
|
data: T[];
|
|
nextCursor: string | null;
|
|
}
|
|
|
|
export type DashboardMessage = MessageRecord;
|
|
|
|
export interface Guild {
|
|
id: string;
|
|
name: string;
|
|
icon: string | null;
|
|
}
|
|
|
|
class ApiError extends Error {
|
|
code: string;
|
|
statusCode: number;
|
|
|
|
constructor(code: string, message: string, statusCode: number) {
|
|
super(message);
|
|
this.name = "ApiError";
|
|
this.code = code;
|
|
this.statusCode = statusCode;
|
|
}
|
|
}
|
|
|
|
export async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
|
const password = localStorage.getItem("admin-password");
|
|
const res = await fetch(path, {
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...(password ? { "X-Admin-Password": password } : {}),
|
|
},
|
|
...init,
|
|
});
|
|
|
|
if (!res.ok) {
|
|
let message = res.statusText;
|
|
let code = "REQUEST_FAILED";
|
|
try {
|
|
const body = (await res.json()) as { error?: string; message?: string };
|
|
if (body.message) message = body.message;
|
|
if (body.error) code = body.error;
|
|
} catch {
|
|
// ignore parse errors
|
|
}
|
|
throw new ApiError(code, message, res.status);
|
|
}
|
|
|
|
return res.json() as Promise<T>;
|
|
}
|
|
|
|
export async function listMessages(
|
|
params: URLSearchParams,
|
|
): Promise<PageResult<MessageRecord>> {
|
|
return request<PageResult<MessageRecord>>(`/api/messages?${params}`);
|
|
}
|
|
|
|
export async function listReview(
|
|
params: URLSearchParams,
|
|
): Promise<PageResult<MessageRecord>> {
|
|
return request<PageResult<MessageRecord>>(`/api/review?${params}`);
|
|
}
|
|
|
|
export async function reanalyzeMessage(id: string): Promise<void> {
|
|
await request<void>(`/api/messages/${id}/reanalyze`, { method: "POST" });
|
|
}
|
|
|
|
export async function getGuilds(): Promise<Guild[]> {
|
|
return request<Guild[]>("/api/guilds");
|
|
}
|