Skip to content

Commit 712bd5c

Browse files
committed
Add machine preset to the run options list
1 parent 0cb381b commit 712bd5c

File tree

3 files changed

+62
-21
lines changed

3 files changed

+62
-21
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/route.tsx

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ export default function Page() {
196196
}
197197

198198
const startingJson = "{\n\n}";
199+
const machinePresets = [
200+
"micro",
201+
"small-1x",
202+
"small-2x",
203+
"medium-1x",
204+
"medium-2x",
205+
"large-1x",
206+
"large-2x",
207+
];
199208

200209
function StandardTaskForm({
201210
task,
@@ -247,6 +256,9 @@ function StandardTaskForm({
247256
selectedCodeSample?.concurrencyKey
248257
);
249258
const [queueValue, setQueueValue] = useState<string | undefined>(selectedCodeSample?.queue);
259+
const [machineValue, setMachineValue] = useState<string | undefined>(
260+
selectedCodeSample?.machinePreset
261+
);
250262
const [maxAttemptsValue, setMaxAttemptsValue] = useState<number | undefined>(
251263
selectedCodeSample?.maxAttempts
252264
);
@@ -315,6 +327,7 @@ function StandardTaskForm({
315327
triggerSource,
316328
tags,
317329
version,
330+
machine,
318331
},
319332
] = useForm({
320333
id: "test-task",
@@ -401,6 +414,7 @@ function StandardTaskForm({
401414
setMaxDurationValue(run.maxDurationInSeconds);
402415
setTagsValue(run.runTags ?? []);
403416
setQueueValue(run.queue);
417+
setMachineValue(run.machinePreset);
404418
}}
405419
className="flex w-full items-center gap-2 rounded-sm px-2 py-2 outline-none transition-colors focus-custom hover:bg-charcoal-900 "
406420
>
@@ -576,27 +590,6 @@ function StandardTaskForm({
576590
/>
577591
<FormError id={maxDurationSeconds.errorId}>{maxDurationSeconds.error}</FormError>
578592
</InputGroup>
579-
<InputGroup>
580-
<Label htmlFor={version.id}>Version</Label>
581-
<Select
582-
{...conform.select(version)}
583-
defaultValue="latest"
584-
variant="tertiary/small"
585-
placeholder="Select version"
586-
dropdownIcon
587-
disabled={disableVersionSelection}
588-
>
589-
{versions.map((version, i) => (
590-
<SelectItem key={version} value={i === 0 ? "latest" : version}>
591-
{version} {i === 0 && "(latest)"}
592-
</SelectItem>
593-
))}
594-
</Select>
595-
{disableVersionSelection && (
596-
<Hint>Only the latest version is available in the development environment.</Hint>
597-
)}
598-
<FormError id={version.errorId}>{version.error}</FormError>
599-
</InputGroup>
600593
<InputGroup>
601594
<Label htmlFor={idempotencyKey.id}>Idempotency key</Label>
602595
<Input {...conform.input(idempotencyKey, { type: "text" })} variant="small" />
@@ -631,6 +624,51 @@ function StandardTaskForm({
631624
</Hint>
632625
<FormError id={concurrencyKey.errorId}>{concurrencyKey.error}</FormError>
633626
</InputGroup>
627+
<InputGroup>
628+
<Label htmlFor={machine.id}>Machine</Label>
629+
<Select
630+
{...conform.select(machine)}
631+
variant="tertiary/small"
632+
placeholder="Select machine type"
633+
dropdownIcon
634+
items={machinePresets}
635+
defaultValue={undefined}
636+
value={machineValue}
637+
setValue={(e) => {
638+
if (Array.isArray(e)) return;
639+
setMachineValue(e);
640+
}}
641+
>
642+
{machinePresets.map((machine) => (
643+
<SelectItem key={machine} value={machine}>
644+
{machine}
645+
</SelectItem>
646+
))}
647+
</Select>
648+
<Hint>This lets you override the machine preset specified in the task.</Hint>
649+
<FormError id={machine.errorId}>{machine.error}</FormError>
650+
</InputGroup>
651+
<InputGroup>
652+
<Label htmlFor={version.id}>Version</Label>
653+
<Select
654+
{...conform.select(version)}
655+
defaultValue="latest"
656+
variant="tertiary/small"
657+
placeholder="Select version"
658+
dropdownIcon
659+
disabled={disableVersionSelection}
660+
>
661+
{versions.map((version, i) => (
662+
<SelectItem key={version} value={i === 0 ? "latest" : version}>
663+
{version} {i === 0 && "(latest)"}
664+
</SelectItem>
665+
))}
666+
</Select>
667+
{disableVersionSelection && (
668+
<Hint>Only the latest version is available in the development environment.</Hint>
669+
)}
670+
<FormError id={version.errorId}>{version.error}</FormError>
671+
</InputGroup>
634672
<FormError>{form.error}</FormError>
635673
</Fieldset>
636674
</div>

apps/webapp/app/v3/services/testTask.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class TestTaskService extends BaseService {
2626
maxAttempts: data.maxAttempts,
2727
maxDuration: data.maxDurationSeconds,
2828
tags: data.tags,
29+
machine: data.machine,
2930
lockToVersion: data.version === "latest" ? undefined : data.version,
3031
},
3132
});

apps/webapp/app/v3/testTask.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { z } from "zod";
2+
import { MachinePresetName } from "@trigger.dev/core/v3/schemas";
23

34
export const TestTaskData = z
45
.discriminatedUnion("triggerSource", [
@@ -75,6 +76,7 @@ export const TestTaskData = z
7576
queue: z.string().optional(),
7677
concurrencyKey: z.string().optional(),
7778
maxAttempts: z.number().min(1).optional(),
79+
machine: MachinePresetName.optional(),
7880
maxDurationSeconds: z
7981
.number()
8082
.min(0)

0 commit comments

Comments
 (0)