mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 12:07:28 +08:00
daily summary ui/api: add task daily summary endpoint and dashboard card in task audit
This commit is contained in:
@@ -92,6 +92,7 @@ func (s *RegistryServer) Start(ctx context.Context) error {
|
||||
mux.HandleFunc("/webui/api/task_audit", s.handleWebUITaskAudit)
|
||||
mux.HandleFunc("/webui/api/task_queue", s.handleWebUITaskQueue)
|
||||
mux.HandleFunc("/webui/api/tasks", s.handleWebUITasks)
|
||||
mux.HandleFunc("/webui/api/task_daily_summary", s.handleWebUITaskDailySummary)
|
||||
mux.HandleFunc("/webui/api/exec_approvals", s.handleWebUIExecApprovals)
|
||||
mux.HandleFunc("/webui/api/logs/stream", s.handleWebUILogsStream)
|
||||
mux.HandleFunc("/webui/api/logs/recent", s.handleWebUILogsRecent)
|
||||
@@ -1559,6 +1560,38 @@ func (s *RegistryServer) handleWebUITaskQueue(w http.ResponseWriter, r *http.Req
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "running": running, "items": items, "stats": stats})
|
||||
}
|
||||
|
||||
func (s *RegistryServer) handleWebUITaskDailySummary(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.checkAuth(r) {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
date := r.URL.Query().Get("date")
|
||||
if date == "" {
|
||||
date = time.Now().UTC().Format("2006-01-02")
|
||||
}
|
||||
path := filepath.Join(strings.TrimSpace(s.workspacePath), "memory", date+".md")
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "date": date, "report": ""})
|
||||
return
|
||||
}
|
||||
text := string(b)
|
||||
marker := "## Autonomy Daily Report (" + date + ")"
|
||||
idx := strings.Index(text, marker)
|
||||
report := ""
|
||||
if idx >= 0 {
|
||||
report = text[idx:]
|
||||
if n := strings.Index(report[len(marker):], "\n## "); n > 0 {
|
||||
report = report[:len(marker)+n]
|
||||
}
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "date": date, "report": report})
|
||||
}
|
||||
|
||||
func (s *RegistryServer) handleWebUITasks(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.checkAuth(r) {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
|
||||
@@ -31,6 +31,8 @@ const resources = {
|
||||
createTask: 'Create',
|
||||
updateTask: 'Update',
|
||||
deleteTask: 'Delete',
|
||||
dailySummary: 'Daily Summary',
|
||||
noDailySummary: 'No autonomy daily summary yet.',
|
||||
error: 'Error',
|
||||
noTaskAudit: 'No task audit records',
|
||||
selectTask: 'Select a task from the left list',
|
||||
@@ -196,6 +198,8 @@ const resources = {
|
||||
createTask: '新建',
|
||||
updateTask: '更新',
|
||||
deleteTask: '删除',
|
||||
dailySummary: '日报摘要',
|
||||
noDailySummary: '暂无自治日报。',
|
||||
error: '错误',
|
||||
noTaskAudit: '暂无任务审计记录',
|
||||
selectTask: '请从左侧选择任务',
|
||||
|
||||
@@ -33,6 +33,7 @@ const TaskAudit: React.FC = () => {
|
||||
const [sourceFilter, setSourceFilter] = useState('all');
|
||||
const [statusFilter, setStatusFilter] = useState('all');
|
||||
const [draft, setDraft] = useState<any>({ id: '', content: '', priority: 'normal', status: 'todo', source: 'manual', due_at: '' });
|
||||
const [dailyReport, setDailyReport] = useState<string>('');
|
||||
|
||||
const fetchData = async () => {
|
||||
setLoading(true);
|
||||
@@ -45,6 +46,13 @@ const TaskAudit: React.FC = () => {
|
||||
const sorted = arr.sort((a: any, b: any) => String(b.time || '').localeCompare(String(a.time || '')));
|
||||
setItems(sorted);
|
||||
if (sorted.length > 0) setSelected(sorted[0]);
|
||||
const dr = await fetch(`/webui/api/task_daily_summary${q}`);
|
||||
if (dr.ok) {
|
||||
const dj = await dr.json();
|
||||
setDailyReport(String(dj.report || ''));
|
||||
} else {
|
||||
setDailyReport('');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setItems([]);
|
||||
@@ -116,6 +124,11 @@ const TaskAudit: React.FC = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="border border-zinc-800 rounded-xl bg-zinc-900/40 p-3 text-sm">
|
||||
<div className="text-xs text-zinc-400 uppercase tracking-wider mb-2">{t('dailySummary')}</div>
|
||||
<div className="whitespace-pre-wrap text-zinc-200">{dailyReport || t('noDailySummary')}</div>
|
||||
</div>
|
||||
|
||||
<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('taskQueue')}</div>
|
||||
|
||||
Reference in New Issue
Block a user