feat(doubao): implement challenge handling and monitoring improvements
Desktop Client Build / Resolve Build Metadata (push) Successful in 26s
Frontend CI / Frontend (push) Successful in 3m12s
Backend CI / Backend (push) Failing after 10m8s
Desktop Client Build / Build Desktop Client (push) Successful in 23m53s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 26s

- Added classification for `doubao_challenge_required` as a challenge in platform-auth-adapters.
- Enhanced account action summaries to include specific messages for Doubao human verification.
- Introduced monitoring functions to filter out blocked platforms based on account health.
- Updated task leasing to support platform-specific filtering for monitor tasks.
- Refined issue aggregation in HomeView to consolidate Doubao challenge failures into a single actionable item.
- Improved backend logic to handle platform IDs in task leasing requests and responses.
- Added tests for new functionality, ensuring proper handling of Doubao challenges and task leasing logic.
This commit is contained in:
Xu Liang
2026-06-24 02:31:35 +08:00
parent a406971187
commit 0afd082d96
11 changed files with 2456 additions and 272 deletions
@@ -103,8 +103,9 @@ type DesktopTaskView struct {
}
type LeaseDesktopTaskRequest struct {
TaskID *string `json:"task_id"`
Kind *string `json:"kind" binding:"omitempty,oneof=publish monitor"`
TaskID *string `json:"task_id"`
Kind *string `json:"kind" binding:"omitempty,oneof=publish monitor"`
PlatformIDs []string `json:"platform_ids"`
}
type LeaseDesktopTaskResponse struct {
@@ -213,6 +214,7 @@ func (s *DesktopTaskService) Lease(ctx context.Context, client *repository.Deskt
AttemptID: attemptID,
LeaseTokenHash: tokenHash,
}
eligiblePlatformIDs := normalizeDesktopTaskLeasePlatformIDs(req.PlatformIDs)
if s.logger != nil {
fields := []zap.Field{
@@ -232,7 +234,7 @@ func (s *DesktopTaskService) Lease(ctx context.Context, client *repository.Deskt
case taskID != nil:
task, err = s.leaseQueuedDesktopTaskByID(ctx, client, *taskID, leaseParams)
case req.Kind != nil && strings.TrimSpace(*req.Kind) == "monitor":
task, err = s.leaseNextQueuedMonitorTask(ctx, client, leaseParams)
task, err = s.leaseNextQueuedMonitorTask(ctx, client, leaseParams, eligiblePlatformIDs)
case req.Kind != nil && strings.TrimSpace(*req.Kind) == "publish":
task, err = s.leaseNextQueuedPublishTask(ctx, client, leaseParams)
default:
@@ -519,6 +521,7 @@ func (s *DesktopTaskService) leaseNextQueuedMonitorTask(
ctx context.Context,
client *repository.DesktopClient,
params repository.DesktopTaskLeaseParams,
eligiblePlatformIDs []string,
) (*repository.DesktopTask, error) {
tx, err := beginDesktopMonitorLeaseTx(ctx, s.pool, client.ID)
if err != nil {
@@ -533,6 +536,7 @@ func (s *DesktopTaskService) leaseNextQueuedMonitorTask(
params.AttemptID,
params.LeaseTokenHash,
maxConcurrentMonitorPlatformsPerDesktopClient,
eligiblePlatformIDs,
)
task, err := scanRepositoryDesktopTask(row)
if err != nil {
@@ -577,6 +581,10 @@ func leaseNextQueuedMonitorTaskSQL() string {
AND dt.platform_id = ca.platform_id
AND dt.kind = 'monitor'
AND dt.status = 'queued'
AND (
COALESCE(array_length($7::text[], 1), 0) = 0
OR dt.platform_id = ANY($7::text[])
)
WHERE NOT EXISTS (
SELECT 1
FROM desktop_tasks AS active
@@ -668,6 +676,30 @@ func leaseNextQueuedMonitorTaskSQL() string {
RETURNING ` + desktopTaskRepositoryReturningColumns
}
func normalizeDesktopTaskLeasePlatformIDs(values []string) []string {
if len(values) == 0 {
return nil
}
result := make([]string, 0, len(values))
seen := make(map[string]struct{}, len(values))
for _, value := range values {
platformID := strings.ToLower(strings.TrimSpace(value))
if platformID == "" {
continue
}
if _, ok := seen[platformID]; ok {
continue
}
seen[platformID] = struct{}{}
result = append(result, platformID)
}
if len(result) == 0 {
return nil
}
return result
}
func monitorAccountLeaseLockSQL(alias string) string {
return fmt.Sprintf(`hashtextextended(
concat_ws(