Skip to content

Extend frontend TriggerConfig types to match all backend trigger variants #1096

Description

@geoffjay

Summary

Expand the frontend TaskSourceConfig type in ui/src/types/orchestrator.ts to cover all 14+ backend TriggerConfig variants, and reconcile the field naming mismatch between frontend (source_config) and backend (trigger_config).

Context

The backend TriggerConfig enum (in crates/orchestrator/src/scheduler/types.rs) supports 14 trigger types:

  • github_issues, github_pull_requests
  • cron, delay
  • webhook, manual
  • linear_issues
  • agent_lifecycle, agent_idle
  • dispatch_result
  • composite
  • queue
  • ask_response

The frontend TaskSourceConfig type only covers github_issues and github_pull_requests. Additionally, the frontend uses the field name source_config while the backend API serializes as trigger_config - this mismatch needs reconciliation.

Implementation Details

1. Rename and expand the type

In ui/src/types/orchestrator.ts, replace TaskSourceConfig with TriggerConfig:

export type TriggerConfig =
  | { type: "github_issues"; owner: string; repo: string; labels: string[]; state: string }
  | { type: "github_pull_requests"; owner: string; repo: string; labels: string[]; state: string }
  | { type: "cron"; expression: string }
  | { type: "delay"; run_at: string }
  | { type: "webhook"; secret?: string; source: "github" | "linear" | "any" }
  | { type: "manual" }
  | { type: "linear_issues"; team_key?: string; project?: string; status?: string[]; labels: string[]; assignee?: string }
  | { type: "agent_lifecycle"; event: "session_start" | "session_end" | "context_clear" }
  | { type: "agent_idle"; idle_seconds: number }
  | { type: "dispatch_result"; source_workflow_id?: string; status?: DispatchStatus }
  | { type: "composite"; mode: "or" | "and"; triggers: TriggerConfig[]; correlation_window_secs?: number }
  | { type: "queue"; queue_name: string; poll_interval_secs?: number; visibility_timeout_secs?: number }
  | { type: "ask_response"; agent_id?: string; category?: string; response_pattern?: string };

2. Fix field naming

Update the Workflow interface to use trigger_config to match the backend JSON:

export interface Workflow {
  id: string;
  name: string;
  agent_id: string;
  trigger_config: TriggerConfig;  // was: source_config: TaskSourceConfig
  // ...
}

Similarly update CreateWorkflowRequest.

3. Add type guards and helpers

export type TriggerType = TriggerConfig["type"];

export function getTriggerLabel(type: TriggerType): string { /* human-readable labels */ }
export function getTriggerCategory(type: TriggerType): "external" | "schedule" | "event" | "internal" { /* categorization */ }
export function getDefaultTriggerConfig(type: TriggerType): TriggerConfig { /* defaults for each type */ }

4. Update all consumers

Update all components and hooks that reference source_config or TaskSourceConfig:

  • ui/src/components/workflows/WorkflowForm.tsx
  • ui/src/components/workflows/WorkflowTable.tsx
  • ui/src/pages/workflows/WorkflowDetail.tsx
  • ui/src/hooks/useWorkflows.ts
  • ui/src/services/orchestrator.ts

5. Keep backward compatibility

Add a deprecated alias if needed:

/** @deprecated Use TriggerConfig instead */
export type TaskSourceConfig = TriggerConfig;

Files to Modify

  • ui/src/types/orchestrator.ts - primary type changes
  • ui/src/components/workflows/WorkflowForm.tsx - update field references
  • ui/src/components/workflows/WorkflowTable.tsx - update source label logic
  • ui/src/pages/workflows/WorkflowDetail.tsx - update config display
  • ui/src/pages/workflows/WorkflowList.tsx - update if needed
  • ui/src/hooks/useWorkflows.ts - update type references
  • ui/src/services/orchestrator.ts - verify API mapping

Reference

Backend source of truth: crates/orchestrator/src/scheduler/types.rs (TriggerConfig enum)

Acceptance Criteria

  • TriggerConfig type covers all 14 backend trigger variants
  • Workflow interface uses trigger_config field name matching backend JSON
  • Type guards and helper functions for trigger type categorization
  • Default config factories for each trigger type
  • All existing workflow components updated to use new type/field names
  • Existing tests updated and passing
  • No TypeScript compilation errors

Stack Base

  • Stack on: feature/autonomous-pipeline
  • Parallel: no ordering constraint (can be implemented independently of canvas scaffold)

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity:mediumMedium scope: <200 lines, 1-2 filesenhancementNew feature or requestfrontendFrontend application codetriagedIssue has been triaged, ready for planning or implementationuiUser interface and frontend

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions