πͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(blob-storage): add 'Running' status badge for export jobs (#14282)
Niklas Semmler446fe5525139
diff --git a/fern/apis/server/definition/blob-storage-integrations.yml b/fern/apis/server/definition/blob-storage-integrations.ymlindex 69b96fcf5b..e7f41fac66 100644--- a/fern/apis/server/definition/blob-storage-integrations.yml+++ b/fern/apis/server/definition/blob-storage-integrations.yml@@ -124,7 +124,7 @@ types:exportMode: BlobStorageExportModeexportStartDate:type: optional<datetime>- docs: Custom start date for exports (required when exportMode is FROM_CUSTOM_DATE)+ docs: Custom start date for exports (required when exportMode is FROM_CUSTOM_DATE). Must not be in the future (27 h tolerance for timezone differences).compressed:type: optional<boolean>docs: Enable gzip compression for exported files (.csv.gz, .json.gz, .jsonl.gz). Defaults to true.@@ -182,8 +182,9 @@ types:Sync status of the blob storage integration:- `disabled` β integration is not enabled- `error` β last export failed (see `lastError` for details)- - `idle` β enabled but has never exported yet+ - `running` β an export job is currently being processed- `queued` β next export is overdue (`nextSyncAt` is in the past) and waiting to be picked up by the worker+ - `idle` β enabled but has never exported yet and no export is queued- `up_to_date` β all available data has been exported; next export is scheduled for the future**ETL usage**: poll this endpoint and check for `up_to_date` status. Compare `lastSyncAt` against your@@ -191,6 +192,7 @@ types:so `lastSyncAt` will always be at least 20 minutes behind real-time.enum:- idle+ - running- queued- up_to_date- disableddiff --git a/packages/shared/prisma/migrations/20260616000000_add_blob_storage_run_started_at/migration.sql b/packages/shared/prisma/migrations/20260616000000_add_blob_storage_run_started_at/migration.sqlnew file mode 100644index 0000000000..adbf7b8d93--- /dev/null+++ b/packages/shared/prisma/migrations/20260616000000_add_blob_storage_run_started_at/migration.sql@@ -0,0 +1,2 @@+-- AlterTable+ALTER TABLE "blob_storage_integrations" ADD COLUMN "run_started_at" TIMESTAMP(3);diff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 0998beb236..b21e2a9204 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -1237,6 +1237,9 @@ model BlobStorageIntegration {// Shared with LFE-10394; extend the zod schema, do not duplicate the column.exportTuning Json? @map("export_tuning")+ // Run tracking+ runStartedAt DateTime? @map("run_started_at")+// Error trackinglastError String? @map("last_error")lastErrorAt DateTime? @map("last_error_at")diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.ymlindex 7f5a79f33a..d9b65253e0 100644--- a/web/public/generated/api/openapi.yml+++ b/web/public/generated/api/openapi.yml@@ -5642,7 +5642,19 @@ paths:security: *ref_0/api/public/sessions:get:- description: Get sessions+ description: >-+ Get sessions.+++ This legacy endpoint is not recommended for new data extraction+ workflows.++ Use the v2 observations endpoint with a bounded time range and group+ rows by++ `sessionId` instead:++ `GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to>`.operationId: sessions_listtags:- Sessions@@ -5730,9 +5742,18 @@ paths:/api/public/sessions/{sessionId}:get:description: >-- Get a session. Please note that `traces` on this endpoint are not- paginated, if you plan to fetch large sessions, consider `GET- /api/public/traces?sessionId=<sessionId>`+ Get a session.+++ Please note that `traces` on this endpoint are not paginated. For large++ sessions or new data extraction workflows, use the v2 observations+ endpoint++ with a URL-encoded `sessionId` filter and a bounded time range:++ `GET /api/public/v2/observations?filter=<sessionId+ filter>&fromStartTime=<from>&toStartTime=<to>`.operationId: sessions_gettags:- Sessions@@ -7398,7 +7419,8 @@ components:nullable: truedescription: >-Custom start date for exports (required when exportMode is- FROM_CUSTOM_DATE)+ FROM_CUSTOM_DATE). Must not be in the future (27 h tolerance for+ timezone differences).compressed:type: booleannullable: true@@ -7564,6 +7586,7 @@ components:type: stringenum:- idle+ - running- queued- up_to_date- disabled@@ -7575,11 +7598,13 @@ components:- `error` β last export failed (see `lastError` for details)- - `idle` β enabled but has never exported yet+ - `running` β an export job is currently being processed- `queued` β next export is overdue (`nextSyncAt` is in the past) andwaiting to be picked up by the worker+ - `idle` β enabled but has never exported yet and no export is queued+- `up_to_date` β all available data has been exported; next export isscheduled for the futurediff --git a/web/src/__tests__/server/blob-storage-integration-status-api.servertest.ts b/web/src/__tests__/server/blob-storage-integration-status-api.servertest.tsindex 8083339ebc..dd03db33d6 100644--- a/web/src/__tests__/server/blob-storage-integration-status-api.servertest.ts+++ b/web/src/__tests__/server/blob-storage-integration-status-api.servertest.ts@@ -14,7 +14,14 @@ const BlobStorageIntegrationStatusResponseSchema = z.object({id: z.string(),projectId: z.string(),- syncStatus: z.enum(["idle", "queued", "up_to_date", "disabled", "error"]),+ syncStatus: z.enum([+ "idle",+ "running",+ "queued",+ "up_to_date",+ "disabled",+ "error",+ ]),enabled: z.boolean(),lastSyncAt: z.coerce.date().nullable(),nextSyncAt: z.coerce.date().nullable(),@@ -29,6 +36,7 @@ const HOUR_AGO = new Date(NOW - 60 * 60 * 1000);const TWO_HOURS_AGO = new Date(NOW - 2 * 60 * 60 * 1000);const THIRTY_MIN_AGO = new Date(NOW - 30 * 60 * 1000);const TEN_MIN_AGO = new Date(NOW - 10 * 60 * 1000);+const THREE_HOURS_AGO = new Date(NOW - 3 * 60 * 60 * 1000);const TOMORROW = new Date(NOW + 24 * 60 * 60 * 1000);describe("Blob Storage Integration Status API - GET /api/public/integrations/blob-storage/{id}", () => {@@ -178,6 +186,7 @@ describe("Blob Storage Integration Status API - GET /api/public/integrations/blonextSyncAt: Date | null;lastError: string | null;lastErrorAt: Date | null;+ runStartedAt?: Date | null;expectedStatus: string;expectedFields?: Record<string, unknown>;}>([@@ -201,6 +210,35 @@ describe("Blob Storage Integration Status API - GET /api/public/integrations/bloexpectedStatus: "idle",expectedFields: { enabled: true, lastSyncAt: null },},+ {+ name: "queued (nextSyncAt past, lastSyncAt null β precedence: queued wins over idle)",+ enabled: true,+ lastSyncAt: null,+ nextSyncAt: TEN_MIN_AGO,+ lastError: null,+ lastErrorAt: null,+ expectedStatus: "queued",+ },+ {+ name: "running (runStartedAt set, never synced)",+ enabled: true,+ lastSyncAt: null,+ nextSyncAt: null,+ lastError: null,+ lastErrorAt: null,+ runStartedAt: TEN_MIN_AGO,+ expectedStatus: "running",+ },+ {+ name: "running (runStartedAt set, previously synced)",+ enabled: true,+ lastSyncAt: HOUR_AGO,+ nextSyncAt: TOMORROW,+ lastError: null,+ lastErrorAt: null,+ runStartedAt: TEN_MIN_AGO,+ expectedStatus: "running",+ },{name: "up_to_date (nextSyncAt in future)",enabled: true,@@ -251,6 +289,27 @@ describe("Blob Storage Integration Status API - GET /api/public/integrations/bloexpectedStatus: "disabled",expectedFields: { lastError: "Access Denied" },},+ {+ name: "stale runStartedAt (>2h fixed TTL, falls through to up_to_date)",+ enabled: true,+ lastSyncAt: HOUR_AGO,+ nextSyncAt: TOMORROW,+ lastError: null,+ lastErrorAt: null,+ runStartedAt: THREE_HOURS_AGO,+ expectedStatus: "up_to_date",+ },+ {+ name: "error > running (precedence: lastError wins over runStartedAt)",+ enabled: true,+ lastSyncAt: HOUR_AGO,+ nextSyncAt: TOMORROW,+ lastError: "Access Denied",+ lastErrorAt: THIRTY_MIN_AGO,+ runStartedAt: TEN_MIN_AGO,+ expectedStatus: "error",+ expectedFields: { lastError: "Access Denied" },+ },{name: "error > up_to_date (precedence: lastError wins over future nextSyncAt)",enabled: true,@@ -269,6 +328,7 @@ describe("Blob Storage Integration Status API - GET /api/public/integrations/blonextSyncAt,lastError,lastErrorAt,+ runStartedAt,expectedStatus,expectedFields,}) => {@@ -290,6 +350,7 @@ describe("Blob Storage Integration Status API - GET /api/public/integrations/blonextSyncAt,lastError,lastErrorAt,+ runStartedAt: runStartedAt ?? null,},});diff --git a/web/src/components/layouts/status-badge.tsx b/web/src/components/layouts/status-badge.tsxindex f6ef1a9a16..5d56dfbe0c 100644--- a/web/src/components/layouts/status-badge.tsx+++ b/web/src/components/layouts/status-badge.tsx@@ -3,7 +3,7 @@ import { type ReactNode } from "react";const statusCategories = {active: ["production", "live", "active", "public"],- pending: ["pending", "waiting", "queued"],+ pending: ["pending", "waiting", "queued", "running"],delayed: ["delayed"],inactive: ["disabled", "inactive"],paused: ["paused"],diff --git a/web/src/features/blobstorage-integration/README.md b/web/src/features/blobstorage-integration/README.mdnew file mode 100644index 0000000000..a6a186a896--- /dev/null+++ b/web/src/features/blobstorage-integration/README.md@@ -0,0 +1,110 @@+# Blob Storage Integration β Sync Status State Machine++The blob storage exporter's UI status is derived from five DB fields on+`BlobStorageIntegration`. No explicit `status` column exists β the status is+computed at read time by `deriveSyncStatus.ts`.++## DB fields (the state vector)++| Field | Type | Written by |+|---|---|---|+| `enabled` | boolean | Web (save) |+| `lastError` | string \| null | Worker (catch / success) |+| `lastSyncAt` | Date \| null | Worker (success) |+| `nextSyncAt` | Date \| null | Worker (success / empty-window), Web (save) |+| `runStartedAt` | Date \| null | Worker (start / end), Web (save clears it) |++## Derived states (precedence top-to-bottom)++```+disabled β enabled = false+error β lastError != null+running β runStartedAt != null AND age < 2h+queued β nextSyncAt <= now+idle β lastSyncAt = null (never exported)+up_to_date β fallthrough+```++## Transition diagram++```+ ββββββββββββββββββββββββββββββββββββββββββββ+ β User saves (web) β+ β runStartedAt = null β+ β if errored+enabled: nextSyncAt = now β+ β if mode changed: lastSyncAt = null, β+ β nextSyncAt = now β+ ββββββββββββββββββ¬ββββββββββββββββββββββββββ+ β+ ββββββββββββ βΌ+ β disabled ββββββ enabled = false (any state)+ ββββββββββββ+ β user enables+ βΌ+ ββββββββββββ nextSyncAt = null, lastSyncAt = null+ β idle ββββββ freshly created, never synced+ ββββββββββββ+ β save sets nextSyncAt = now (on mode change or save while errored)+ βΌ+ ββββββββββββ nextSyncAt <= now+ β queued ββββββ scheduler finds row (lastSyncAt=null OR nextSyncAt<=now)+ ββββββββββββ and enqueues a BullMQ job (no DB write)+ β+ β worker picks up job, sets runStartedAt = new Date()+ βΌ+ ββββββββββββ+ β running β runStartedAt set, age < 2h+ ββββββββββββ+ β± β²+ success failure+ β± β²+ βΌ βΌ+βββββββββββββ βββββββββ+β up_to_dateβ β error β+βββββββββββββ βββββββββ+```++## Transition detail++| From | Trigger | Writes | To |+|---|---|---|---|+| **any** | User saves with `enabled=false` | `runStartedAt=null` | **disabled** |+| **any** | User saves with `enabled=true` | `runStartedAt=null`; `nextSyncAt=now` if errored or mode changed | **idle**, **queued**, **up_to_date**, or stays **error** (`lastError` is not cleared by save) |+| **disabled** | User saves `enabled=true` | (as above) | **idle**, **queued**, **up_to_date**, or stays **error** |+| **idle** | Scheduler finds `lastSyncAt=null` | Enqueues BullMQ job (no DB write) | stays **idle** |+| **queued** | Scheduler finds `nextSyncAt<=now` | Enqueues BullMQ job (no DB write) | stays **queued** |+| **idle/queued** | Worker starts job | `runStartedAt=now` | **running** |+| **running** | Worker: integration disabled | `runStartedAt=null` | **disabled** |+| **running** | Worker: empty time window | `runStartedAt=null`, `nextSyncAt=now+frequency`, `lastError=null` | **up_to_date** (or **idle** if never synced) |+| **running** | Worker: export succeeds, caught up | `lastSyncAt=max`, `nextSyncAt=max+freq`, `lastError=null`, `runStartedAt=null` | **up_to_date** |+| **running** | Worker: export succeeds, not caught up | `lastSyncAt=max`, `nextSyncAt=now`, `lastError=null`, `runStartedAt=null` + re-enqueues job | **queued** (immediately) |+| **running** | Worker: export fails | `lastError=msg`, `lastErrorAt=now`, `runStartedAt=null` | **error** |+| **error** | User saves (enabled, same mode) | `runStartedAt=null`, `nextSyncAt=now` | stays **error** (`lastError` preserved; scheduler re-enqueues via `nextSyncAt`) |+| **error** | User clicks Run Now | Enqueues manual job (no DB write) | stays **error** until worker clears `lastError` (success or empty-window) |+| **running** | Stale `runStartedAt` > 2h | (no write β derived only) | falls through to **queued**, **idle**, or **up_to_date** |+| **up_to_date** | Clock passes `nextSyncAt` | (no write β derived only) | **queued** |++## Safety valve++If a worker crashes without clearing `runStartedAt`, the 2h TTL in+`deriveSyncStatus` lets the status fall through to whatever the underlying+fields indicate (typically **queued**, since the scheduler will re-enqueue on+the next tick). No explicit cleanup is needed.++## Run Now (manual trigger)++Run Now only enqueues a BullMQ job with a unique `manual-` jobId. It does not+write any DB state. The worker then follows the normal running β success/failure+path. The UI shows the current status (error/up_to_date/queued) until the+worker picks up the job and sets `runStartedAt`.++## Key files++| File | Role |+|---|---|+| `deriveSyncStatus.ts` | Derives display status from DB fields |+| `types.ts` | `BlobStorageSyncStatus` type |+| `service.ts` | Upsert logic (web save path) |+| `blobstorage-integration-router.ts` | tRPC router (save, runNow) |+| `worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts` | Worker job handler |+| `worker/src/features/blobstorage/handleBlobStorageIntegrationSchedule.ts` | Scheduler (enqueues due jobs) |diff --git a/web/src/features/blobstorage-integration/deriveSyncStatus.ts b/web/src/features/blobstorage-integration/deriveSyncStatus.tsindex c7da0b8b44..0b8500ad72 100644--- a/web/src/features/blobstorage-integration/deriveSyncStatus.ts+++ b/web/src/features/blobstorage-integration/deriveSyncStatus.ts@@ -1,19 +1,27 @@import type { BlobStorageSyncStatus } from "@/src/features/blobstorage-integration/types";+const MAX_RUN_AGE_MS = 2 * 60 * 60 * 1000;+export function deriveSyncStatus(integration: {enabled: boolean;lastError: string | null;lastSyncAt: Date | null;nextSyncAt: Date | null;+ runStartedAt: Date | null;}): BlobStorageSyncStatus {if (!integration.enabled) return "disabled";if (integration.lastError) return "error";- if (!integration.lastSyncAt) return "idle";+ if (integration.runStartedAt) {+ const ageMs = Date.now() - integration.runStartedAt.getTime();+ if (ageMs < MAX_RUN_AGE_MS) return "running";+ }const now = new Date();if (integration.nextSyncAt && integration.nextSyncAt <= now) {return "queued";}+ if (!integration.lastSyncAt) return "idle";+return "up_to_date";}diff --git a/web/src/features/blobstorage-integration/service.ts b/web/src/features/blobstorage-integration/service.tsindex 008552d768..a63dbca3f5 100644--- a/web/src/features/blobstorage-integration/service.ts+++ b/web/src/features/blobstorage-integration/service.ts@@ -119,7 +119,7 @@ export async function upsertBlobStorageIntegration(params: {return prisma.$transaction(async (tx) => {const existing = await tx.blobStorageIntegration.findUnique({where: { projectId },- select: { exportMode: true },+ select: { exportMode: true, lastError: true, runStartedAt: true },});// Require secret key for new integrations (unless using host credentials)@@ -164,10 +164,16 @@ export async function upsertBlobStorageIntegration(params: {// Only overwrite secretAccessKey when a new value is provided,// so partial updates don't wipe the existing encrypted secret....(encryptedSecret ? { secretAccessKey: encryptedSecret } : {}),+ // Schedule an immediate retry when saving an errored integration+ // so the scheduler picks it up via the nextSyncAt clause.+ ...(existing?.lastError && data.enabled && !modeChanged+ ? { nextSyncAt: new Date() }+ : {}),// Reset sync state when export mode changes so the new mode's// start-date logic takes effect instead of continuing from the// previous mode's lastSyncAt.- ...(modeChanged ? { lastSyncAt: null, nextSyncAt: null } : {}),+ ...(modeChanged ? { lastSyncAt: null, nextSyncAt: new Date() } : {}),+ runStartedAt: null,},});diff --git a/web/src/features/blobstorage-integration/types.ts b/web/src/features/blobstorage-integration/types.tsindex fdefe1ada9..a37a756381 100644--- a/web/src/features/blobstorage-integration/types.ts+++ b/web/src/features/blobstorage-integration/types.ts@@ -9,6 +9,8 @@ import {import {validateAzureContainerName,validateExportFieldGroups,+ exportStartDateNotInFuture,+ EXPORT_START_DATE_FUTURE_ERROR,} from "@/src/features/blobstorage-integration/validation";export const blobStorageIntegrationFormSchemaBase = z.object({@@ -34,7 +36,13 @@ export const blobStorageIntegrationFormSchemaBase = z.object({exportMode: z.enum(BlobStorageExportMode).default(BlobStorageExportMode.FULL_HISTORY),- exportStartDate: z.coerce.date().optional().nullable(),+ exportStartDate: z.coerce+ .date()+ .refine(exportStartDateNotInFuture, {+ message: EXPORT_START_DATE_FUTURE_ERROR,+ })+ .optional()+ .nullable(),exportSource: z.enum(AnalyticsIntegrationExportSource).default(AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),@@ -55,6 +63,7 @@ export type BlobStorageIntegrationFormSchema = z.infer<export type BlobStorageSyncStatus =| "idle"+ | "running"| "queued"| "up_to_date"| "disabled"diff --git a/web/src/features/blobstorage-integration/validation.ts b/web/src/features/blobstorage-integration/validation.tsindex 38e5187704..7e2ed6a68e 100644--- a/web/src/features/blobstorage-integration/validation.ts+++ b/web/src/features/blobstorage-integration/validation.ts@@ -1,5 +1,17 @@import type { z } from "zod";+// 27h covers all real-world TZ offsets (UTC-12 to UTC+14 = 26h span + 1h margin).+// The HTML date picker sends YYYY-MM-DD parsed as UTC midnight; on a UTC server,+// an east-of-UTC user's local today can be up to 14h ahead of server UTC.+export const MAX_EXPORT_START_DATE_FUTURE_MS = 27 * 60 * 60 * 1000;++export function exportStartDateNotInFuture(d: Date | null | undefined) {+ return !d || d.getTime() <= Date.now() + MAX_EXPORT_START_DATE_FUTURE_MS;+}++export const EXPORT_START_DATE_FUTURE_ERROR =+ "Export start date must not be in the future (27 h tolerance for timezone differences)";+export function validateExportFieldGroups(data: { exportFieldGroups: unknown[] },ctx: z.RefinementCtx,diff --git a/web/src/features/public-api/types/blob-storage-integrations.ts b/web/src/features/public-api/types/blob-storage-integrations.tsindex dbbf633d31..7170da24d7 100644--- a/web/src/features/public-api/types/blob-storage-integrations.ts+++ b/web/src/features/public-api/types/blob-storage-integrations.ts@@ -6,6 +6,8 @@ import {import {validateAzureContainerName,validateExportFieldGroups,+ exportStartDateNotInFuture,+ EXPORT_START_DATE_FUTURE_ERROR,} from "@/src/features/blobstorage-integration/validation";/**@@ -96,12 +98,18 @@ export const CreateBlobStorageIntegrationRequest = z(value) => value === "" || value.endsWith("/"),"Prefix must be empty or end with a forward slash",),- exportFrequency: z.string(),+ exportFrequency: z.enum(["every_20_minutes", "hourly", "daily", "weekly"]),enabled: z.boolean(),forcePathStyle: z.boolean(),fileType: BlobStorageIntegrationFileType,exportMode: BlobStorageExportMode,- exportStartDate: z.coerce.date().nullable().optional(),+ exportStartDate: z.coerce+ .date()+ .refine(exportStartDateNotInFuture, {+ message: EXPORT_START_DATE_FUTURE_ERROR,+ })+ .nullable()+ .optional(),compressed: z.boolean().optional().default(true),exportSource: BlobStorageExportSource.nullable().optional(),exportFieldGroups: z@@ -172,6 +180,7 @@ export type BlobStorageIntegrationResponseType = z.infer<export const BlobStorageSyncStatus = z.enum(["idle",+ "running","queued","up_to_date","disabled",diff --git a/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsx b/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsxindex 31632f7502..0ae8f5aa05 100644--- a/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsx+++ b/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsx@@ -41,7 +41,7 @@ import { zodResolver } from "@hookform/resolvers/zod";import { Card } from "@/src/components/ui/card";import Link from "next/link";import { useRouter } from "next/router";-import { useEffect, useMemo, useState } from "react";+import { useEffect, useMemo } from "react";import { useForm } from "react-hook-form";import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { showErrorToast } from "@/src/features/notifications/showErrorToast";@@ -81,6 +81,18 @@ export default function BlobStorageIntegrationSettings() {refetchOnWindowFocus: false,refetchOnReconnect: false,staleTime: 50 * 60 * 1000, // 50 minutes+ refetchInterval: (query) => {+ const cfg = query.state.data?.config;+ if (!cfg) return false;+ const status = deriveSyncStatus({+ enabled: cfg.enabled,+ lastError: cfg.lastError,+ lastSyncAt: cfg.lastSyncAt ? new Date(cfg.lastSyncAt) : null,+ nextSyncAt: cfg.nextSyncAt ? new Date(cfg.nextSyncAt) : null,+ runStartedAt: cfg.runStartedAt ? new Date(cfg.runStartedAt) : null,+ });+ return status === "running" || status === "queued" ? 5_000 : false;+ },},);@@ -96,10 +108,14 @@ export default function BlobStorageIntegrationSettings() {nextSyncAt: state.data.config.nextSyncAt? new Date(state.data.config.nextSyncAt): null,+ runStartedAt: state.data.config.runStartedAt+ ? new Date(state.data.config.runStartedAt)+ : null,});const syncStatusToBadge: Record<BlobStorageSyncStatus, string> = {up_to_date: "active",+ running: "running",queued: "queued",idle: "pending",disabled: "disabled",@@ -247,8 +263,6 @@ const BlobStorageIntegrationSettingsForm = ({const capture = usePostHogClientCapture();const { isLangfuseCloud } = useLangfuseCloudRegion();const { project } = useQueryProject();- const [integrationType, setIntegrationType] =- useState<BlobStorageIntegrationType>(BlobStorageIntegrationType.S3);// Check if this is a self-hosted instance (no cloud region set)const isSelfHosted = !isLangfuseCloud;@@ -318,34 +332,42 @@ const BlobStorageIntegrationSettingsForm = ({disabled: isLoading,});+ const integrationType =+ blobStorageForm.watch("type") ?? BlobStorageIntegrationType.S3;+useEffect(() => {- setIntegrationType(state?.type || BlobStorageIntegrationType.S3);- blobStorageForm.reset({- type: state?.type || BlobStorageIntegrationType.S3,- bucketName: state?.bucketName || "",- endpoint: state?.endpoint || null,- region: state?.region || "auto",- accessKeyId: state?.accessKeyId || "",- secretAccessKey: state?.secretAccessKey || null,- prefix: state?.prefix || "",- exportFrequency: (state?.exportFrequency || "daily") as- | "every_20_minutes"- | "daily"- | "weekly"- | "hourly",- enabled: state?.enabled || false,- forcePathStyle: state?.forcePathStyle || false,- fileType: state?.fileType || BlobStorageIntegrationFileType.JSONL,- exportMode: state?.exportMode || BlobStorageExportMode.FULL_HISTORY,- exportStartDate: state?.exportStartDate || null,- exportSource: getExportSourceFormValue(state?.exportSource, availability),- // Empty array in the DB means "export everything" (the worker falls back- // to all groups), so surface it as the full selection in the form.- exportFieldGroups: state?.exportFieldGroups?.length- ? (state.exportFieldGroups as ObservationFieldGroupFull[])- : [...OBSERVATION_FIELD_GROUPS_FULL],- compressed: state?.compressed ?? true,- });+ blobStorageForm.reset(+ {+ type: state?.type || BlobStorageIntegrationType.S3,+ bucketName: state?.bucketName || "",+ endpoint: state?.endpoint || null,+ region: state?.region || "auto",+ accessKeyId: state?.accessKeyId || "",+ secretAccessKey: state?.secretAccessKey || null,+ prefix: state?.prefix || "",+ exportFrequency: (state?.exportFrequency || "daily") as+ | "every_20_minutes"+ | "daily"+ | "weekly"+ | "hourly",+ enabled: state?.enabled || false,+ forcePathStyle: state?.forcePathStyle || false,+ fileType: state?.fileType || BlobStorageIntegrationFileType.JSONL,+ exportMode: state?.exportMode || BlobStorageExportMode.FULL_HISTORY,+ exportStartDate: state?.exportStartDate || null,+ exportSource: getExportSourceFormValue(+ state?.exportSource,+ availability,+ ),+ // Empty array in the DB means "export everything" (the worker falls back+ // to all groups), so surface it as the full selection in the form.+ exportFieldGroups: state?.exportFieldGroups?.length+ ? (state.exportFieldGroups as ObservationFieldGroupFull[])+ : [...OBSERVATION_FIELD_GROUPS_FULL],+ compressed: state?.compressed ?? true,+ },+ state ? { keepDirtyValues: true } : undefined,+ );// eslint-disable-next-line react-hooks/exhaustive-deps}, [state, availability]);@@ -413,8 +435,7 @@ const BlobStorageIntegrationSettingsForm = ({}const handleIntegrationTypeChange = (value: BlobStorageIntegrationType) => {- setIntegrationType(value);- blobStorageForm.setValue("type", value);+ blobStorageForm.setValue("type", value, { shouldDirty: true });};return (@@ -904,6 +925,10 @@ const BlobStorageIntegrationSettingsForm = ({<FormControl><Inputtype="date"+ max={(() => {+ const t = new Date();+ return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")}`;+ })()}value={field.value instanceof Date? field.value.toISOString().split("T")[0]diff --git a/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts b/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.tsindex 3fe4a6c607..1b97351acc 100644--- a/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts+++ b/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts@@ -923,9 +923,18 @@ export const handleBlobStorageIntegrationProjectJob = async (logger.info(`[BLOB INTEGRATION] Blob storage integration is disabled for project ${projectId}`,);+ await prisma.blobStorageIntegration.update({+ where: { projectId },+ data: { runStartedAt: null },+ });return;}+ await prisma.blobStorageIntegration.update({+ where: { projectId },+ data: { runStartedAt: new Date() },+ });+// Sync between lastSyncAt and now - 30 minutes// Cap the export to one frequency period to enable chunked historic exportsconst minTimestamp = await getMinTimestampForExport(@@ -965,6 +974,15 @@ export const handleBlobStorageIntegrationProjectJob = async (logger.info(`[BLOB INTEGRATION] Skipping export for project ${projectId}: time window is empty (min: ${minTimestamp.toISOString()}, max: ${maxTimestamp.toISOString()})`,);+ await prisma.blobStorageIntegration.update({+ where: { projectId },+ data: {+ runStartedAt: null,+ nextSyncAt: new Date(now.getTime() + frequencyIntervalMs),+ lastError: null,+ lastErrorAt: null,+ },+ });return;}@@ -1140,6 +1158,7 @@ export const handleBlobStorageIntegrationProjectJob = async (nextSyncAt,lastError: null,lastErrorAt: null,+ runStartedAt: null,},});@@ -1176,6 +1195,7 @@ export const handleBlobStorageIntegrationProjectJob = async (data: {lastError: errorMessage,lastErrorAt: new Date(),+ runStartedAt: null,},});} catch (persistError) {