From 071125b5a7cc3ddf0bf480127acf9dae24048644 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Mon, 14 Sep 2026 03:05:41 -0600 Subject: [PATCH] refactor(jobs): give RunJobResult one definition in jobs/store.ts (#tech-debt) The POST /api/v1/jobs/run response type was declared twice: once in apps/server/src/jobs/service.ts and once as a hand-copied duplicate in apps/web/src/hooks/use-jobs.ts. Web could not type-import it from service.ts without dragging the server graph into its TS program. Move the declaration verbatim into jobs/store.ts next to the job wire types web already type-imports, import it in service.ts, and delete the web copy in favour of the store.ts import. Co-Authored-By: Claude Opus 5 (1M context) --- apps/server/src/jobs/service.ts | 9 +-------- apps/server/src/jobs/store.ts | 14 +++++++++++--- apps/web/src/hooks/use-jobs.ts | 9 +-------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/apps/server/src/jobs/service.ts b/apps/server/src/jobs/service.ts index ee3f735b0..9cbef5dd6 100644 --- a/apps/server/src/jobs/service.ts +++ b/apps/server/src/jobs/service.ts @@ -26,6 +26,7 @@ import { type JobRunConfig, type JobRunRecord, type JobWithLatestRun, + type RunJobResult, } from "./store.js"; import { TemplateStore, @@ -54,14 +55,6 @@ type RunJobInput = { export type { AddJobInput } from "./store.js"; -export type RunJobResult = { - jobId: string; - runId: string; - agentId: string; - status: JobRunRecord["status"]; - report: JobRunRecord["report"]; -}; - const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000; const DEFAULT_NEEDS_INPUT_TIMEOUT_MS = 24 * 60 * 60 * 1000; const TERMINAL_STATUSES = new Set([ diff --git a/apps/server/src/jobs/store.ts b/apps/server/src/jobs/store.ts index b32cea44c..1edf0f2a8 100644 --- a/apps/server/src/jobs/store.ts +++ b/apps/server/src/jobs/store.ts @@ -13,9 +13,9 @@ import { } from "./report.js"; // The job wire types below (JobNotifyConfig, JobRunStatus, JobAgentType, -// JobRecord, JobRunRecord, JobWithLatestRun, AddJobInput) are imported -// type-only by the web client (apps/web/src/hooks/use-jobs.ts) so both sides -// of the API agree on one definition. +// JobRecord, JobRunRecord, RunJobResult, JobWithLatestRun, AddJobInput) are +// imported type-only by the web client (apps/web/src/hooks/use-jobs.ts) so +// both sides of the API agree on one definition. export type JobNotifyConfig = { onComplete: string[]; onError: string[]; @@ -84,6 +84,14 @@ export type JobRunRecord = { continuationRetries: number; }; +export type RunJobResult = { + jobId: string; + runId: string; + agentId: string; + status: JobRunRecord["status"]; + report: JobRunRecord["report"]; +}; + export type ContinuationStatus = { action: "default" | "continue" | "pause" | "finish"; phase?: string; diff --git a/apps/web/src/hooks/use-jobs.ts b/apps/web/src/hooks/use-jobs.ts index a0dd723be..10360ac60 100644 --- a/apps/web/src/hooks/use-jobs.ts +++ b/apps/web/src/hooks/use-jobs.ts @@ -9,6 +9,7 @@ import type { JobRunRecord, JobRunStatus, JobWithLatestRun, + RunJobResult, } from "../../../server/src/jobs/store"; export type { JobAgentType, JobNotifyConfig, JobReport, JobRunStatus }; @@ -19,14 +20,6 @@ export type JobRun = JobRunRecord; export type AddJobConfig = AddJobInput; -export type RunJobResult = { - jobId: string; - runId: string; - agentId: string; - status: JobRunStatus; - report: JobReport | null; -}; - type JobIdentity = Pick; export function useJobs(enabled = true) {