Skip to content

Commit 9dc7e9d

Browse files
authored
Merge branch 'main' into fix(webapp)-onboarding-fixes
2 parents e67a202 + e64b101 commit 9dc7e9d

File tree

12 files changed

+1255
-298
lines changed

12 files changed

+1255
-298
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: feature
4+
---
5+
6+
Add sidebar tabs (Options, AI, Schema) to the Test page for schemaTask payload generation and schema viewing.

apps/webapp/app/presenters/v3/TestTaskPresenter.server.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
type TaskRunTemplate,
77
PrismaClientOrTransaction,
88
} from "@trigger.dev/database";
9+
import { inferSchema } from "@jsonhero/schema-infer";
910
import parse from "parse-duration";
1011
import { type PrismaClient } from "~/db.server";
1112
import { RunsRepository } from "~/services/runsRepository/runsRepository.server";
@@ -34,6 +35,8 @@ type Task = {
3435
taskIdentifier: string;
3536
filePath: string;
3637
friendlyId: string;
38+
payloadSchema?: unknown;
39+
inferredPayloadSchema?: unknown;
3740
};
3841

3942
type Queue = {
@@ -244,11 +247,30 @@ export class TestTaskPresenter {
244247
},
245248
});
246249

250+
// Infer schema from existing run payloads when no explicit schema is defined
251+
let inferredPayloadSchema: unknown | undefined;
252+
if (!task.payloadSchema && latestRuns.length > 0 && task.triggerSource === "STANDARD") {
253+
let inference: ReturnType<typeof inferSchema> | undefined;
254+
for (const run of latestRuns) {
255+
try {
256+
const parsed = await parsePacket({ data: run.payload, dataType: run.payloadType });
257+
inference = inferSchema(parsed, inference);
258+
} catch {
259+
// Skip malformed runs — inference is best-effort
260+
}
261+
}
262+
if (inference) {
263+
inferredPayloadSchema = inference.toJSONSchema();
264+
}
265+
}
266+
247267
const taskWithEnvironment = {
248268
id: task.id,
249269
taskIdentifier: task.slug,
250270
filePath: task.filePath,
251271
friendlyId: task.friendlyId,
272+
payloadSchema: task.payloadSchema ?? undefined,
273+
inferredPayloadSchema,
252274
};
253275

254276
switch (task.triggerSource) {

0 commit comments

Comments
 (0)