Show per-case agent status instead of global — fix Hebrew translation of "running"
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m41s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m41s
Agent status widget now checks heartbeat_runs + wakeup_requests to determine if an agent is running on *this* case. Agents running on other cases show as idle. Added "running" to STATUS_DOT/STATUS_LABEL maps so it displays in Hebrew. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -408,6 +408,43 @@ async def get_agents_for_company(company_id: str) -> list[dict]:
|
||||
await conn.close()
|
||||
|
||||
|
||||
async def get_agents_for_case(company_id: str, issue_ids: list[str]) -> list[dict]:
|
||||
"""Get agents with per-case status (running on *this* case vs globally)."""
|
||||
conn = await asyncpg.connect(PAPERCLIP_DB_URL)
|
||||
try:
|
||||
rows = await conn.fetch(
|
||||
"""SELECT a.id, a.name, a.role, a.title, a.icon,
|
||||
a.status AS global_status, a.last_heartbeat_at,
|
||||
EXISTS(
|
||||
SELECT 1 FROM heartbeat_runs hr
|
||||
JOIN agent_wakeup_requests wr ON hr.wakeup_request_id = wr.id
|
||||
WHERE hr.agent_id = a.id
|
||||
AND hr.status = 'running'
|
||||
AND wr.payload->>'issueId' = ANY($2::text[])
|
||||
) AS active_on_case
|
||||
FROM agents a
|
||||
WHERE a.company_id = $1::uuid
|
||||
ORDER BY a.role, a.name""",
|
||||
company_id, issue_ids,
|
||||
)
|
||||
return [
|
||||
{
|
||||
"id": str(r["id"]),
|
||||
"name": r["name"],
|
||||
"role": r["role"],
|
||||
"title": r["title"],
|
||||
"status": "running" if r["active_on_case"] else (
|
||||
"idle" if r["global_status"] == "running" else r["global_status"]
|
||||
),
|
||||
"icon": r["icon"],
|
||||
"last_heartbeat_at": r["last_heartbeat_at"].isoformat() if r["last_heartbeat_at"] else None,
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
finally:
|
||||
await conn.close()
|
||||
|
||||
|
||||
async def post_comment(issue_id: str, company_id: str, body: str) -> dict:
|
||||
"""Post a comment on a Paperclip issue.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user