From 0c06cdd117c897dcba5c56df08368802872003b0 Mon Sep 17 00:00:00 2001 From: Igor Loskutov Date: Mon, 9 Feb 2026 13:25:40 -0500 Subject: [PATCH] fix: consolidate DagTask types, fix REST fallback shape, fix lint noqa - Extract shared DagTask/DagTaskStatus types into www/app/lib/dagTypes.ts - Re-export from useWebSockets.ts and UserEventsProvider.tsx - Fix browse page REST fallback: dag_status is list[dict] directly, not {tasks: [...]} - Add missing # noqa: PLC0415 for fork-safe deferred imports --- server/reflector/hatchet/dag_progress.py | 6 +++--- .../browse/_components/TranscriptCards.tsx | 8 +++---- www/app/(app)/transcripts/useWebSockets.ts | 21 ++----------------- www/app/lib/UserEventsProvider.tsx | 21 ++----------------- www/app/lib/dagTypes.ts | 19 +++++++++++++++++ 5 files changed, 29 insertions(+), 46 deletions(-) create mode 100644 www/app/lib/dagTypes.ts diff --git a/server/reflector/hatchet/dag_progress.py b/server/reflector/hatchet/dag_progress.py index 97d29ef1..06ebfd1c 100644 --- a/server/reflector/hatchet/dag_progress.py +++ b/server/reflector/hatchet/dag_progress.py @@ -125,7 +125,7 @@ def extract_dag_tasks(details: V1WorkflowRunDetails) -> list[DagTask]: parents_by_step[child_id].append(step_to_name[s.step_id]) # Join tasks by step_id - from hatchet_sdk.clients.rest.models import V1TaskSummary + from hatchet_sdk.clients.rest.models import V1TaskSummary # noqa: PLC0415 task_by_step: dict[str, V1TaskSummary] = {} for t in tasks: @@ -199,9 +199,9 @@ async def broadcast_dag_status(transcript_id: str, workflow_run_id: str) -> None from reflector.db.transcripts import transcripts_controller # noqa: I001, PLC0415 from reflector.hatchet.broadcast import append_event_and_broadcast # noqa: PLC0415 from reflector.hatchet.client import HatchetClientManager # noqa: PLC0415 - from reflector.hatchet.workflows.daily_multitrack_pipeline import ( + from reflector.hatchet.workflows.daily_multitrack_pipeline import ( # noqa: PLC0415 fresh_db_connection, - ) # noqa: PLC0415 + ) from reflector.logger import logger # noqa: PLC0415 async with fresh_db_connection(): diff --git a/www/app/(app)/browse/_components/TranscriptCards.tsx b/www/app/(app)/browse/_components/TranscriptCards.tsx index 2b717301..c5626342 100644 --- a/www/app/(app)/browse/_components/TranscriptCards.tsx +++ b/www/app/(app)/browse/_components/TranscriptCards.tsx @@ -145,11 +145,9 @@ function TranscriptCard({ status={result.status} dagStatus={ dagStatusMap?.get(result.id) ?? - ( - (result as Record).dag_status as - | { tasks?: DagTask[] } - | undefined - )?.tasks ?? + ((result as Record).dag_status as + | DagTask[] + | null) ?? null } /> diff --git a/www/app/(app)/transcripts/useWebSockets.ts b/www/app/(app)/transcripts/useWebSockets.ts index ab05f59d..0de0dd1d 100644 --- a/www/app/(app)/transcripts/useWebSockets.ts +++ b/www/app/(app)/transcripts/useWebSockets.ts @@ -14,25 +14,8 @@ import { } from "../../lib/apiHooks"; import { NonEmptyString } from "../../lib/utils"; -export type DagTaskStatus = - | "queued" - | "running" - | "completed" - | "failed" - | "cancelled"; - -export type DagTask = { - name: string; - status: DagTaskStatus; - started_at: string | null; - finished_at: string | null; - duration_seconds: number | null; - parents: string[]; - error: string | null; - children_total: number | null; - children_completed: number | null; - progress_pct: number | null; -}; +import type { DagTask } from "../../lib/dagTypes"; +export type { DagTask, DagTaskStatus } from "../../lib/dagTypes"; export type UseWebSockets = { transcriptTextLive: string; diff --git a/www/app/lib/UserEventsProvider.tsx b/www/app/lib/UserEventsProvider.tsx index c733da44..1b58d3d2 100644 --- a/www/app/lib/UserEventsProvider.tsx +++ b/www/app/lib/UserEventsProvider.tsx @@ -7,25 +7,8 @@ import { useAuth } from "./AuthProvider"; import { z } from "zod"; import { invalidateTranscriptLists, TRANSCRIPT_SEARCH_URL } from "./apiHooks"; -export type DagTaskStatus = - | "queued" - | "running" - | "completed" - | "failed" - | "cancelled"; - -export type DagTask = { - name: string; - status: DagTaskStatus; - started_at: string | null; - finished_at: string | null; - duration_seconds: number | null; - parents: string[]; - error: string | null; - children_total: number | null; - children_completed: number | null; - progress_pct: number | null; -}; +import type { DagTask } from "./dagTypes"; +export type { DagTask, DagTaskStatus } from "./dagTypes"; const DagStatusContext = React.createContext>(new Map()); diff --git a/www/app/lib/dagTypes.ts b/www/app/lib/dagTypes.ts new file mode 100644 index 00000000..2d730da6 --- /dev/null +++ b/www/app/lib/dagTypes.ts @@ -0,0 +1,19 @@ +export type DagTaskStatus = + | "queued" + | "running" + | "completed" + | "failed" + | "cancelled"; + +export type DagTask = { + name: string; + status: DagTaskStatus; + started_at: string | null; + finished_at: string | null; + duration_seconds: number | null; + parents: string[]; + error: string | null; + children_total: number | null; + children_completed: number | null; + progress_pct: number | null; +};