feat(desktop): auto-recover in-progress desktop tasks on client lifecycle events

- reset stale in_progress tasks owned by a client on startup, offline, and lease expiry
- monitor tasks re-queue for another pick; publish tasks move to unknown for manual reconcile
- send startup=true flag on first heartbeat so the server can trigger recovery
- finalize the linked desktop task when a phase2 monitor callback arrives via desktop_tasks path
- short-circuit the desktop monitor attempt write after the callback already finalized it

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 09:11:23 +08:00
parent f91d2645d3
commit ce028c56bf
6 changed files with 491 additions and 38 deletions
@@ -15,11 +15,17 @@ type DesktopClientHandler struct {
}
func NewDesktopClientHandler(a *bootstrap.App) *DesktopClientHandler {
taskSvc := app.NewDesktopTaskService(
a.DB,
a.MonitoringDB,
a.RabbitMQ,
a.Logger,
).WithCache(a.Cache)
return &DesktopClientHandler{
svc: app.NewDesktopClientService(
repository.NewDesktopClientRepository(a.DB),
a.Redis,
),
).WithTaskService(taskSvc),
}
}