Read Healthy only for service DAGs

Merged
YO
8d ago
+663-158

Summary

Spec 100 already says that only a service DAG (restart_policy) reads Healthy, and that a running run of any other DAG with a continuous step reads Running. The UI still shows Healthy for every running run with a continuous step, whatever its DAG. This PR makes the run header and the run lists follow the spec.

Carved from #3813, #3829, #3830, #3831, #3835 (SCcagg5), as part of the re-slice tracked in #4002.

Changes

This PR changes the product on purpose. A cron or manual DAG with a continuous step no longer reads Healthy: it reads Running. The maintainer asked for this PR so that the change can be judged here.

  • Running run of a cron or manual DAG with a continuous step
    • Before: Healthy (green heart) in the run header, the step list, the history bars, the pop-out and the lists. The header shows the repeat count (×42) in place of the progress.
    • After: Running, as any running run. The header shows the step progress (0/1) and no repeat count.
  • Running run of a service DAG with no continuous step and no failed node
    • Before: Running, with the step progress.
    • After: Healthy. The header and the run details hide the progress, and the empty count slot leaves no gap.
  • Running run of a service DAG with a continuous step: Healthy, as before.
  • A failed or rejected node, a stopped continuous step or any status other than Running still shows the normal status.
  • The Kanban cards, the queue runs table and the run progress cards now use the same chip as the workflow and run lists. A running service run reads Healthy there too (before: Running). A run progress card reads its chip on the node of its run.
  • The lists decide "service DAG" from one GET /service-dags read shared by all rows, and read run details only for a running run of a service DAG, again every minute so that a failed step shows. Before, each running row read its run details.
  • Spec 083 states the service rule next to the rules that keep a failure visible.

Core change

runDisplayStatus takes what the caller knows about the workflow. A run reads Healthy only for a service DAG, while no node failed and, if it has a continuous step, that step runs or waits. The workspace passes isServiceDAG(dag) from the loaded definition. A list row cannot see the definition, so it reads the service DAG list once and matches the run by name.

ui/src/lib/runDisplayStatus.ts:80

export function runDisplayStatus(
  run: RunLike,
  { service }: RunDisplayContext
): RunDisplayStatus {
  if (!service || run.status !== Status.Running) return normal(run.status);
  const nodes = run.nodes ?? [];
  const failed = nodes.some(
    (n) => n.status === NodeStatus.Failed || n.status === NodeStatus.Rejected
  );
  if (failed) return normal(run.status);
  // A continuous step that repeats has the status Running between two runs.
  const continuous = nodes.filter((n) => isContinuousStep(n.step));
  const running =
    continuous.length === 0 ||
    continuous.some((n) => n.status === NodeStatus.Running);
  return running ? { status: run.status, ...HEALTHY } : normal(run.status);
}

ui/src/features/dag-runs/hooks/useListRunDisplay.ts:42

  const running = status === Status.Running && !!dagRunId;
  const services = useQuery(
    '/service-dags',
    running ? { params: { query: { remoteNode } } } : null,
    {
      revalidateOnFocus: false,
      revalidateOnReconnect: false,
      shouldRetryOnError: false,
      dedupingInterval: SERVICE_LIST_TTL_MS,
    }
  );
  const service = (services.data?.dags ?? []).some((dag) => dag.name === name);
  const enabled = running && service;

Review guide

The diff is about 710 handwritten lines, half of them tests.

  • Mechanical: the workspace call sites pass service (WorkflowBar, RunChip, RunDetailsParts, RunDetailsPopover, RunStepList, RunStepsNav, RunTimeline, PopoutBar, LogPopoutPage). KanbanCard, QueueRunsTable and RunProgressStack swap StatusChip for RunStatusChip.
  • Needs judgment:
    • the product change above, including Healthy for a service run with no continuous step;
    • the service list read in useListRunDisplay (one shared request, reused 5 minutes);
    • the hidden count slot of RunChip for a Healthy run with no continuous step;
    • the e2e change: the service DAG run is the one the scheduler starts.
flowchart LR
  Row[List row chip] -->|running| SL["GET /service-dags<br/>(changed: one shared read)"]
  SL -->|name listed| D["GET /dag-runs/{name}/{id}"]
  SL -->|not listed| Run[Running]
  D --> RDS["runDisplayStatus(run, {service})<br/>(changed)"]
  WS[Workspace views] -->|"isServiceDAG(dag) (new)"| RDS
  RDS -->|"service, no failed node,<br/>continuous step running or none"| H[Healthy]
  RDS -->|otherwise| N[API status]

In words: a list row of a running run reads the service DAG list (shared by all rows). Only when the list names its workflow does it read the run details. The workspace views already hold the definition and pass the service flag. runDisplayStatus then decides.

Testing

None of these tests were run locally. CI runs them; the e2e specs run with the full-ci label.

  • ui/src/lib/__tests__/runDisplayStatus.test.ts: Healthy only with service: true; a service run with no continuous step reads Healthy; a failed or rejected node, a stopped continuous step and other statuses keep the normal status; summaryDisplayStatus reads Healthy for any running run of a service DAG.
  • ui/src/features/dag-runs/hooks/__tests__/useListRunDisplay.test.tsx (new): the rows of three workflows share one service list request, reused for 5 minutes; Healthy only when the list names the workflow; no run details read otherwise; a service run with no continuous step turns Running when a later read shows a failed step.
  • ui/src/features/dag-runs/components/common/__tests__/RunStatusChip.test.tsx: Running for a workflow that is not a service DAG; no run details read while the service list loads, fails, or does not name the workflow; nothing read for a run that is not running.
  • ui/src/features/workflow-workspace/bar/__tests__/RunChip.test.tsx: Running and the progress for a continuous step of a non-service DAG; the repeat count for a service DAG; the empty count slot kept before the first repeat; no count slot for a Healthy run with no continuous step.
  • ui/src/features/workflow-workspace/bar/__tests__/RunDetailsPopover.test.tsx: Healthy or Running by the service flag.
  • ui/src/features/dags/components/dag-execution/__tests__/RunProgressStack.test.tsx: the chip of a progress card reads the node of its run, not the node of the app bar.
  • ui/e2e/workspace/run-header.spec.ts: "keeps Running for a run that never ends in a workflow that is not a service DAG, and keeps a failure visible"; "keeps the slots of the chip in place in every state of a run", now with a service DAG.

Performance

The list chips make fewer requests than before. Nothing is stored, and there is no index change or migration.

  • Removed: each running row of the workflow and run lists read its run details, and again every minute when it had a continuous step. A row of a DAG that is not a service DAG now reads nothing.
  • Added: one GET /service-dags per tab, only while a list shows a running run. All rows and lists share it (one SWR key), and it is reused for 5 minutes. It has no polling, no focus or reconnect refetch, and no retry. Server cost: one DAG list read, and one latest-status read and process probe for each service DAG. It does not grow with stored runs. Response: about 0.5 KB per service DAG.
  • Kept: a running run of a service DAG reads its details once, and again every minute while it runs, also with no continuous step, so that a failed step shows. A service DAG has one run at a time, so this is at most one row per service DAG. It stops when the run is no longer Running, and SWR does not refresh in a hidden tab.
  • New on the Kanban, queue and progress lists: the shared service list read above, plus the details read of each running service run.
  • The workspace views make no request: they use the loaded definition.

Out of scope

  • The Activity page keeps its plain status chip, although the carved branch switched it. The page leaves out the runs of service DAGs, so its lists never hold a run that can read Healthy, and the chip would only add requests. Its one exception, the item of a service DAG that keeps failing, would read Healthy next to its failures while a new run is up.

Known limits

  • The service list is reused for 5 minutes. A DAG that gains or loses restart_policy keeps its old chip in the lists until the next read. The workspace views follow the loaded definition.
  • The current definition decides, also for a run that started before restart_policy changed.
  • A remote node without GET /service-dags answers an error: its runs read Running in the lists.
  • The RunChip test of the hidden count slot checks the hidden class: jsdom applies no Tailwind styles.

Agent

Claude Code, claude-opus-5-5, xhigh


Summary by cubic

Aligns the run status display with the spec: only a service DAG (restart_policy) reads Healthy, while any other running DAG with a continuous step reads Running.

  • A running cron or manual DAG with a continuous step now reads Running with the step progress, instead of Healthy with a repeat count.
  • A running service DAG with no failed node now reads Healthy, also when it has no continuous step; the header hides the progress and leaves no count slot.
  • A failed or rejected node, a stopped continuous step, or any non-Running status still shows the normal status.
  • Kanban cards, the queue runs table, and run progress cards now use the same status chip as the workflow and run lists. A progress card reads the chip on the node that started the run.
  • Lists decide "service DAG" from one shared GET /service-dags read (reused for 5 minutes) and read run details only for running service runs, once a minute, replacing per-row detail reads.
  • Spec 083 now states the service rule next to the rules that keep a failure visible.

Summary by CodeRabbit

  • New Features
    • Running service workflows can display Healthy when they have no failed or rejected steps and any continuous step is running.
    • Status labels are consistent across run lists, workflow views, timelines, and popouts.
  • Bug Fixes
    • Running cron and manual workflows now display Running, even when they include continuous steps. Stopped continuous steps, failed or rejected steps, and non-running workflows retain their normal status.
    • Healthy service runs without continuous steps no longer show a repeat-count badge.