fix(kanban): synchronize real Gitea issues & PRs with Whiteboard Kanban columns

This commit is contained in:
2026-10-03 21:18:02 +02:00
parent b545fa8920
commit f011461229
2 changed files with 109 additions and 36 deletions
+48 -6
View File
@@ -149,11 +149,12 @@ class RealtimeRPGHandler(http.server.SimpleHTTPRequestHandler):
status["gitea"]["active_ci_jobs"] = len(ci_containers)
status["gitea"]["ci_status"] = "BUILDING" if len(ci_containers) > 0 else "PASSING"
req = urllib.request.Request(
# Fetch Open Pull Requests
req_prs = urllib.request.Request(
f"{GITEA_BASE_URL}/repos/openclaw/{target_project}/pulls?state=open",
headers={'Authorization': f'token {GITEA_TOKEN}'}
)
with urllib.request.urlopen(req, timeout=2) as resp:
with urllib.request.urlopen(req_prs, timeout=2) as resp:
prs = json.loads(resp.read().decode())
status["gitea"]["open_prs_count"] = len(prs)
for p in prs:
@@ -163,10 +164,51 @@ class RealtimeRPGHandler(http.server.SimpleHTTPRequestHandler):
"user": p.get("user", {}).get("username"),
"created_at": p.get("created_at")
})
status["gitea"]["kanban_columns"]["review"] = len(prs)
status["gitea"]["kanban_columns"]["ready"] = max(1, len(prs))
status["gitea"]["kanban_columns"]["planned"] = 3
status["gitea"]["kanban_columns"]["done"] = 12
# Fetch All Issues for Real Kanban Board Sync
req_issues = urllib.request.Request(
f"{GITEA_BASE_URL}/repos/openclaw/{target_project}/issues?state=all&limit=50",
headers={'Authorization': f'token {GITEA_TOKEN}'}
)
with urllib.request.urlopen(req_issues, timeout=2) as resp:
issues = json.loads(resp.read().decode())
kanban = {"planned": 0, "ready": 0, "in_progress": 0, "review": 0, "done": 0}
kanban_items = {"planned": [], "ready": [], "in_progress": [], "review": [], "done": []}
for iss in issues:
labels = [l.get("name", "").lower() for l in iss.get("labels", [])]
is_closed = iss.get("state") == "closed"
is_pr = bool(iss.get("pull_request"))
item_meta = {
"number": iss.get("number"),
"title": iss.get("title"),
"is_pr": is_pr,
"state": iss.get("state")
}
if is_closed:
kanban["done"] += 1
if len(kanban_items["done"]) < 5: kanban_items["done"].append(item_meta)
elif any("review" in l for l in labels) or is_pr:
kanban["review"] += 1
if len(kanban_items["review"]) < 5: kanban_items["review"].append(item_meta)
elif any("in-progress" in l or "in_progress" in l for l in labels) or ("coder-tasks" in latest_active_tasks):
kanban["in_progress"] += 1
if len(kanban_items["in_progress"]) < 5: kanban_items["in_progress"].append(item_meta)
elif any("ready" in l or "board/active" in l for l in labels):
kanban["ready"] += 1
if len(kanban_items["ready"]) < 5: kanban_items["ready"].append(item_meta)
else:
kanban["planned"] += 1
if len(kanban_items["planned"]) < 5: kanban_items["planned"].append(item_meta)
# Ensure active BullMQ coder task reflects in Kanban WIP if not already
if status["bullmq"]["total_active"] > 0 and kanban["in_progress"] == 0:
kanban["in_progress"] = status["bullmq"]["total_active"]
status["gitea"]["kanban_columns"] = kanban
status["gitea"]["kanban_items"] = kanban_items
except Exception as e:
status["gitea"]["connected"] = False
status["gitea"]["error"] = str(e)