Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 6 .server-changes/test-page-sidebar-tabs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: feature
---

Add sidebar tabs (Options, AI, Schema) to the Test page for schemaTask payload generation and schema viewing.
22 changes: 22 additions & 0 deletions 22 apps/webapp/app/presenters/v3/TestTaskPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type TaskRunTemplate,
PrismaClientOrTransaction,
} from "@trigger.dev/database";
import { inferSchema } from "@jsonhero/schema-infer";
import parse from "parse-duration";
import { type PrismaClient } from "~/db.server";
import { RunsRepository } from "~/services/runsRepository/runsRepository.server";
Expand Down Expand Up @@ -34,6 +35,8 @@ type Task = {
taskIdentifier: string;
filePath: string;
friendlyId: string;
payloadSchema?: unknown;
inferredPayloadSchema?: unknown;
};

type Queue = {
Expand Down Expand Up @@ -244,11 +247,30 @@ export class TestTaskPresenter {
},
});

// Infer schema from existing run payloads when no explicit schema is defined
let inferredPayloadSchema: unknown | undefined;
if (!task.payloadSchema && latestRuns.length > 0 && task.triggerSource === "STANDARD") {
Comment thread
ericallam marked this conversation as resolved.
let inference: ReturnType<typeof inferSchema> | undefined;
for (const run of latestRuns) {
try {
const parsed = await parsePacket({ data: run.payload, dataType: run.payloadType });
inference = inferSchema(parsed, inference);
} catch {
// Skip malformed runs — inference is best-effort
}
}
if (inference) {
inferredPayloadSchema = inference.toJSONSchema();
}
}
Comment thread
ericallam marked this conversation as resolved.

const taskWithEnvironment = {
id: task.id,
taskIdentifier: task.slug,
filePath: task.filePath,
friendlyId: task.friendlyId,
payloadSchema: task.payloadSchema ?? undefined,
inferredPayloadSchema,
};

switch (task.triggerSource) {
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.