Skip to content

Commit fe5178f

Browse files
authored
feat(webapp): add priority to task test and replay options (#2936)
Closes #2934 ## ✅ Checklist - [x] I have followed every step in the [contributing guide](https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md) - [x] The PR title follows the convention. - [x] I ran and tested the code works --- ## Testing _[Describe the steps you took to test this change]_ 1. make sure there are no worker connected or the queue is paused. 2. run hello world tasks and assign priority 3. notice the priority value in task context. 4. try running a replay for task with priority 5. notice the context priority --- ## Changelog _[Short description of what has changed]_ Added option to set priority on task test and replay dialog --- ## Screenshots _[Screenshots]_ <img width="953" height="804" alt="image" src="https://github.com/user-attachments/assets/d452b872-6c05-4a9e-a1e3-f6a283bb363d" /> <img width="958" height="886" alt="image" src="https://github.com/user-attachments/assets/8f9f3096-da99-4d81-a9c5-2f3004b89ceb" /> <img width="1022" height="736" alt="image" src="https://github.com/user-attachments/assets/233e01ac-a42b-4b4f-ac3e-e9b18638b971" /> 💯 <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/2936"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
1 parent a3f1eb2 commit fe5178f

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

apps/webapp/app/components/runs/v3/ReplayRunDialog.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ function ReplayForm({
201201
tags,
202202
version,
203203
machine,
204+
prioritySeconds,
204205
},
205206
] = useForm({
206207
id: "replay-task",
@@ -499,6 +500,12 @@ function ReplayForm({
499500
<Hint>Delays run by a specific duration.</Hint>
500501
<FormError id={delaySeconds.errorId}>{delaySeconds.error}</FormError>
501502
</InputGroup>
503+
<InputGroup>
504+
<Label variant="small">Priority</Label>
505+
<DurationPicker name={prioritySeconds.name} id={prioritySeconds.id} />
506+
<Hint>Sets the priority of the run. Higher values mean higher priority.</Hint>
507+
<FormError id={prioritySeconds.errorId}>{prioritySeconds.error}</FormError>
508+
</InputGroup>
502509
<InputGroup>
503510
<Label variant="small">TTL</Label>
504511
<DurationPicker

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ function StandardTaskForm({
409409
tags,
410410
version,
411411
machine,
412+
prioritySeconds,
412413
},
413414
] = useForm({
414415
id: "test-task",
@@ -730,6 +731,12 @@ function StandardTaskForm({
730731
<Hint>Delays run by a specific duration.</Hint>
731732
<FormError id={delaySeconds.errorId}>{delaySeconds.error}</FormError>
732733
</InputGroup>
734+
<InputGroup>
735+
<Label variant="small">Priority</Label>
736+
<DurationPicker name={prioritySeconds.name} id={prioritySeconds.id} />
737+
<Hint>Sets the priority of the run. Higher values mean higher priority.</Hint>
738+
<FormError id={prioritySeconds.errorId}>{prioritySeconds.error}</FormError>
739+
</InputGroup>
733740
<InputGroup>
734741
<Label variant="small">TTL</Label>
735742
<DurationPicker
@@ -872,6 +879,7 @@ function ScheduledTaskForm({
872879
tags,
873880
version,
874881
machine,
882+
prioritySeconds,
875883
},
876884
] = useForm({
877885
id: "test-task-scheduled",
@@ -1237,6 +1245,14 @@ function ScheduledTaskForm({
12371245
<Hint>Limits concurrency by creating a separate queue for each value of the key.</Hint>
12381246
<FormError id={concurrencyKey.errorId}>{concurrencyKey.error}</FormError>
12391247
</InputGroup>
1248+
<InputGroup>
1249+
<Label htmlFor={prioritySeconds.id} variant="small">
1250+
Priority
1251+
</Label>
1252+
<DurationPicker name={prioritySeconds.name} id={prioritySeconds.id} />
1253+
<Hint>Sets the priority of the run. Higher values mean higher priority.</Hint>
1254+
<FormError id={prioritySeconds.errorId}>{prioritySeconds.error}</FormError>
1255+
</InputGroup>
12401256
<InputGroup>
12411257
<Label htmlFor={ttlSeconds.id} variant="small">
12421258
TTL

apps/webapp/app/routes/resources.taskruns.$runParam.replay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export const action: ActionFunction = async ({ request, params }) => {
199199
idempotencyKeyTTLSeconds: submission.value.idempotencyKeyTTLSeconds,
200200
ttlSeconds: submission.value.ttlSeconds,
201201
version: submission.value.version,
202+
prioritySeconds: submission.value.prioritySeconds,
202203
});
203204

204205
if (!newRun) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class ReplayTaskRunService extends BaseService {
110110
overrideOptions.version === "latest" ? undefined : overrideOptions.version,
111111
bulkActionId: overrideOptions?.bulkActionId,
112112
region,
113+
priority: overrideOptions.prioritySeconds,
113114
},
114115
},
115116
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class TestTaskService extends BaseService {
2929
tags: data.tags,
3030
machine: data.machine,
3131
lockToVersion: data.version === "latest" ? undefined : data.version,
32+
priority: data.prioritySeconds,
3233
},
3334
});
3435

@@ -66,6 +67,7 @@ export class TestTaskService extends BaseService {
6667
tags: data.tags,
6768
machine: data.machine,
6869
lockToVersion: data.version === "latest" ? undefined : data.version,
70+
priority: data.prioritySeconds,
6971
},
7072
},
7173
{ customIcon: "scheduled" }

apps/webapp/app/v3/testTask.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export const RunOptionsData = z.object({
4646
message: "Each tag must be at most 128 characters long",
4747
}),
4848
version: z.string().optional(),
49+
prioritySeconds: z
50+
.number()
51+
.min(0)
52+
.optional()
53+
.transform((val) => (val === 0 ? undefined : val)),
4954
});
5055

5156
export type RunOptionsData = z.infer<typeof RunOptionsData>;

0 commit comments

Comments
 (0)