task-queue: unified task audit events, queue API, and bilingual split-view webui

This commit is contained in:
DBT
2026-02-28 02:41:05 +00:00
parent 4dfd6ce11f
commit f274acf818
4 changed files with 101 additions and 22 deletions

View File

@@ -16,6 +16,9 @@ const resources = {
taskAudit: 'Task Audit',
taskList: 'Task List',
taskDetail: 'Task Detail',
taskQueue: 'Task Queue',
taskLogs: 'Task Logs',
error: 'Error',
noTaskAudit: 'No task audit records',
selectTask: 'Select a task from the left list',
loading: 'Loading...',
@@ -165,6 +168,9 @@ const resources = {
taskAudit: '任务审计',
taskList: '任务列表',
taskDetail: '任务详情',
taskQueue: '任务队列',
taskLogs: '任务日志',
error: '错误',
noTaskAudit: '暂无任务审计记录',
selectTask: '请从左侧选择任务',
loading: '加载中...',

View File

@@ -11,8 +11,10 @@ type TaskAuditItem = {
sender_id?: string;
status?: string;
duration_ms?: number;
retry_count?: number;
error?: string;
input_preview?: string;
logs?: string[];
[key: string]: any;
};
@@ -26,13 +28,14 @@ const TaskAudit: React.FC = () => {
const fetchData = async () => {
setLoading(true);
try {
const url = `/webui/api/task_audit${q ? `${q}&limit=300` : '?limit=300'}`;
const url = `/webui/api/task_queue${q ? `${q}&limit=300` : '?limit=300'}`;
const r = await fetch(url);
if (!r.ok) throw new Error(await r.text());
const j = await r.json();
const arr = Array.isArray(j.items) ? j.items : [];
setItems(arr.reverse());
if (arr.length > 0) setSelected(arr[arr.length - 1]);
const sorted = arr.sort((a: any, b: any) => String(b.time || '').localeCompare(String(a.time || '')));
setItems(sorted);
if (sorted.length > 0) setSelected(sorted[0]);
} catch (e) {
console.error(e);
setItems([]);
@@ -55,7 +58,7 @@ const TaskAudit: React.FC = () => {
<div className="flex-1 min-h-0 grid grid-cols-1 lg:grid-cols-[360px_1fr] gap-4">
<div className="border border-zinc-800 rounded-xl bg-zinc-900/40 overflow-hidden flex flex-col min-h-0">
<div className="px-3 py-2 border-b border-zinc-800 text-xs text-zinc-400 uppercase tracking-wider">{t('taskList')}</div>
<div className="px-3 py-2 border-b border-zinc-800 text-xs text-zinc-400 uppercase tracking-wider">{t('taskQueue')}</div>
<div className="overflow-y-auto min-h-0">
{items.length === 0 ? (
<div className="p-4 text-sm text-zinc-500">{t('noTaskAudit')}</div>
@@ -68,7 +71,7 @@ const TaskAudit: React.FC = () => {
className={`w-full text-left px-3 py-2 border-b border-zinc-800/60 hover:bg-zinc-800/40 ${active ? 'bg-indigo-500/15' : ''}`}
>
<div className="text-sm font-medium text-zinc-100 truncate">{it.task_id || `task-${idx + 1}`}</div>
<div className="text-xs text-zinc-400 truncate">{it.channel} · {it.status} · {it.duration_ms || 0}ms</div>
<div className="text-xs text-zinc-400 truncate">{it.channel} · {it.status} · {it.duration_ms || 0}ms · retry:{it.retry_count || 0}</div>
<div className="text-[11px] text-zinc-500 truncate">{it.time}</div>
</button>
);
@@ -98,12 +101,17 @@ const TaskAudit: React.FC = () => {
</div>
<div>
<div className="text-zinc-500 text-xs mb-1">Error</div>
<div className="text-zinc-500 text-xs mb-1">{t('error')}</div>
<div className="p-2 rounded bg-zinc-950/60 border border-zinc-800 whitespace-pre-wrap text-red-300">{selected.error || '-'}</div>
</div>
<div>
<div className="text-zinc-500 text-xs mb-1">Raw JSON</div>
<div className="text-zinc-500 text-xs mb-1">{t('taskLogs')}</div>
<div className="p-2 rounded bg-zinc-950/60 border border-zinc-800 whitespace-pre-wrap text-zinc-200">{Array.isArray(selected.logs) && selected.logs.length ? selected.logs.join('\n') : '-'}</div>
</div>
<div>
<div className="text-zinc-500 text-xs mb-1">{t('rawJson')}</div>
<pre className="p-2 rounded bg-zinc-950/60 border border-zinc-800 text-xs overflow-auto">{selectedPretty}</pre>
</div>
</>