fix: heartbeat 500 error, timezone to Beijing, tasks guide collapse

- fix(api): heartbeat endpoint no longer requires request body, fix spa_fallback
  404 handler causing 500 on API routes, add db.refresh() in agent update/heartbeat
- feat(time): unify all frontend time display to Beijing time (Asia/Shanghai)
  via new beijing() utility; backend alert messages also use BJT
- feat(ui): collapse AI agent instruction panel on Tasks page by default
- chore: add backend/app/utils.py and frontend/src/utils/time.js
This commit is contained in:
Steven
2026-06-15 03:29:07 +08:00
parent cd41e59afc
commit 6f64eecb43
12 changed files with 445 additions and 130 deletions
+2
View File
@@ -38,6 +38,7 @@ class AgentService:
if v is not None and hasattr(agent, k):
setattr(agent, k, v)
await self.db.flush()
await self.db.refresh(agent)
return agent
async def heartbeat(self, agent_id: int) -> Agent | None:
@@ -46,6 +47,7 @@ class AgentService:
if agent:
agent.last_heartbeat_at = datetime.utcnow()
await self.db.flush()
await self.db.refresh(agent)
return agent
async def get_task_count(self, agent_id: int) -> int:
+3 -2
View File
@@ -10,6 +10,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.config import settings
from app.database import async_session_factory
from app.models import ScheduledTask, Alert, AlertRule, NotificationChannel
from app.utils import fmt_bj
logger = logging.getLogger("taskpulse.scheduler")
@@ -66,9 +67,9 @@ class SchedulerService:
alert_type="missed_run",
message=(
f"任务 [{task.name}](ID={task.id}) 超过预定时间未执行。\n"
f"预期执行时间: {task.next_run_at}\n"
f"预期执行时间: {fmt_bj(task.next_run_at)}\n"
f"容忍窗口: {task.grace_period}s\n"
f"当前时间: {now}"
f"当前时间: {fmt_bj(now)}"
),
status="pending",
)