Skip to content

Commit c4e1364

Browse files
authored
Merge pull request #1808 from triggerdotdev/re2-queue-indexing
re2: Queue indexing, queue trigger changes
2 parents 49a3f72 + f1d5886 commit c4e1364

File tree

141 files changed

+5621
-1625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+5621
-1625
lines changed

.changeset/config.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
"access": "public",
1313
"baseBranch": "main",
1414
"updateInternalDependencies": "patch",
15-
"ignore": ["webapp", "supervisor", "coordinator", "docker-provider", "kubernetes-provider"],
15+
"ignore": [
16+
"webapp",
17+
"coordinator",
18+
"docker-provider",
19+
"kubernetes-provider",
20+
"supervisor"
21+
],
1622
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
1723
"onlyUpdatePeerDependentsWhenOutOfRange": true
1824
}

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: pnpm run generate
3939

4040
- name: 🧪 Run Webapp Unit Tests
41-
run: pnpm run test --filter webapp
41+
run: pnpm run test:webapp
4242
env:
4343
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
4444
DIRECT_URL: postgresql://postgres:postgres@localhost:5432/postgres
@@ -47,7 +47,7 @@ jobs:
4747
ENCRYPTION_KEY: "secret"
4848

4949
- name: 🧪 Run Package Unit Tests
50-
run: pnpm run test --filter "@trigger.dev/*"
50+
run: pnpm run test:packages
5151

5252
- name: 🧪 Run Internal Unit Tests
53-
run: pnpm run test --filter "@internal/*"
53+
run: pnpm run test:internal

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ export function SideMenu({
175175
to={v3EnvironmentPath(organization, project, environment)}
176176
data-action="tasks"
177177
/>
178+
<SideMenuItem
179+
name="Runs"
180+
icon={RunsIcon}
181+
activeIconColor="text-teal-500"
182+
to={v3RunsPath(organization, project, environment)}
183+
/>
178184
<SideMenuItem
179185
name="Batches"
180186
icon={Squares2X2Icon}
@@ -212,22 +218,6 @@ export function SideMenu({
212218
/>
213219
</div>
214220

215-
<SideMenuSection title="Observability">
216-
<SideMenuItem
217-
name="Runs"
218-
icon={RunsIcon}
219-
activeIconColor="text-teal-500"
220-
to={v3RunsPath(organization, project, environment)}
221-
/>
222-
<SideMenuItem
223-
name="Alerts"
224-
icon={BellAlertIcon}
225-
activeIconColor="text-red-500"
226-
to={v3ProjectAlertsPath(organization, project, environment)}
227-
data-action="alerts"
228-
/>
229-
</SideMenuSection>
230-
231221
<SideMenuSection title="Manage">
232222
<SideMenuItem
233223
name="API keys"
@@ -243,6 +233,13 @@ export function SideMenu({
243233
to={v3EnvironmentVariablesPath(organization, project, environment)}
244234
data-action="environment variables"
245235
/>
236+
<SideMenuItem
237+
name="Alerts"
238+
icon={BellAlertIcon}
239+
activeIconColor="text-red-500"
240+
to={v3ProjectAlertsPath(organization, project, environment)}
241+
data-action="alerts"
242+
/>
246243
<SideMenuItem
247244
name="Project settings"
248245
icon={Cog8ToothIcon}

apps/webapp/app/components/primitives/Table.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ export const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellP
161161
{hiddenLabel ? (
162162
<span className="sr-only">{children}</span>
163163
) : tooltip ? (
164-
<div className="flex items-center gap-1">
164+
<div
165+
className={cn("flex items-center gap-1", {
166+
"justify-center": alignment === "center",
167+
"justify-end": alignment === "right",
168+
})}
169+
>
165170
{children}
166171
<InfoIconTooltip content={tooltip} contentClassName="normal-case tracking-normal" />
167172
</div>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ export function TaskPath({ filePath, functionName, className }: TaskPathProps) {
1919
);
2020
}
2121

22-
type TaskFunctionNameProps = {
23-
functionName: string;
22+
type TaskFileNameProps = {
23+
fileName: string;
2424
variant?: InlineCodeVariant;
2525
className?: string;
2626
};
2727

28-
export function TaskFunctionName({ variant, functionName, className }: TaskFunctionNameProps) {
28+
export function TaskFileName({ variant, fileName, className }: TaskFileNameProps) {
2929
return (
3030
<InlineCode variant={variant} className={cn("text-text-dimmed", className)}>
31-
{`${functionName}()`}
31+
{`${fileName}`}
3232
</InlineCode>
3333
);
3434
}

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

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import { type TaskRunStatus } from "@trigger.dev/database";
1515
import assertNever from "assert-never";
1616
import { HourglassIcon } from "lucide-react";
1717
import { TimedOutIcon } from "~/assets/icons/TimedOutIcon";
18+
import { Callout } from "~/components/primitives/Callout";
1819
import { Spinner } from "~/components/primitives/Spinner";
1920
import { cn } from "~/utils/cn";
2021

2122
export const allTaskRunStatuses = [
2223
"DELAYED",
2324
"WAITING_FOR_DEPLOY",
25+
"PENDING_VERSION",
2426
"PENDING",
2527
"EXECUTING",
2628
"RETRYING_AFTER_FAILURE",
@@ -37,7 +39,7 @@ export const allTaskRunStatuses = [
3739
] as const satisfies Readonly<Array<TaskRunStatus>>;
3840

3941
export const filterableTaskRunStatuses = [
40-
"WAITING_FOR_DEPLOY",
42+
"PENDING_VERSION",
4143
"DELAYED",
4244
"PENDING",
4345
"WAITING_TO_RESUME",
@@ -56,7 +58,8 @@ export const filterableTaskRunStatuses = [
5658
const taskRunStatusDescriptions: Record<TaskRunStatus, string> = {
5759
DELAYED: "Task has been delayed and is waiting to be executed.",
5860
PENDING: "Task is waiting to be executed.",
59-
WAITING_FOR_DEPLOY: "Task needs to be deployed first to start executing.",
61+
PENDING_VERSION: "Run cannot execute until a version includes the task and queue.",
62+
WAITING_FOR_DEPLOY: "Run cannot execute until a version includes the task and queue.",
6063
EXECUTING: "Task is currently being executed.",
6164
RETRYING_AFTER_FAILURE: "Task is being reattempted after a failure.",
6265
WAITING_TO_RESUME: `You have used a "wait" function. When the wait is complete, the task will resume execution.`,
@@ -73,6 +76,7 @@ const taskRunStatusDescriptions: Record<TaskRunStatus, string> = {
7376

7477
export const QUEUED_STATUSES = [
7578
"PENDING",
79+
"PENDING_VERSION",
7680
"WAITING_FOR_DEPLOY",
7781
"DELAYED",
7882
] satisfies TaskRunStatus[];
@@ -104,6 +108,43 @@ export function TaskRunStatusCombo({
104108
);
105109
}
106110

111+
const statusReasonsToDescription: Record<string, string> = {
112+
NO_DEPLOYMENT: "No deployment or deployment image reference found for deployed run",
113+
NO_WORKER: "No worker found for run",
114+
TASK_NEVER_REGISTERED: "Task never registered",
115+
QUEUE_NOT_FOUND: "Queue not found",
116+
TASK_NOT_IN_LATEST: "Task not in latest version",
117+
BACKGROUND_WORKER_MISMATCH: "Background worker mismatch",
118+
};
119+
120+
export function TaskRunStatusReason({
121+
status,
122+
statusReason,
123+
}: {
124+
status: TaskRunStatus;
125+
statusReason?: string;
126+
}) {
127+
if (status !== "PENDING_VERSION") {
128+
return null;
129+
}
130+
131+
if (!statusReason) {
132+
return null;
133+
}
134+
135+
const description = statusReasonsToDescription[statusReason];
136+
137+
if (!description) {
138+
return null;
139+
}
140+
141+
return (
142+
<Callout to="https://trigger.dev/docs" variant="warning" className="text-sm">
143+
{description}
144+
</Callout>
145+
);
146+
}
147+
107148
export function TaskRunStatusLabel({ status }: { status: TaskRunStatus }) {
108149
return <span className={runStatusClassNameColor(status)}>{runStatusTitle(status)}</span>;
109150
}
@@ -120,6 +161,7 @@ export function TaskRunStatusIcon({
120161
return <ClockIcon className={cn(runStatusClassNameColor(status), className)} />;
121162
case "PENDING":
122163
return <RectangleStackIcon className={cn(runStatusClassNameColor(status), className)} />;
164+
case "PENDING_VERSION":
123165
case "WAITING_FOR_DEPLOY":
124166
return <RectangleStackIcon className={cn(runStatusClassNameColor(status), className)} />;
125167
case "EXECUTING":
@@ -158,6 +200,7 @@ export function runStatusClassNameColor(status: TaskRunStatus): string {
158200
case "PENDING":
159201
case "DELAYED":
160202
return "text-charcoal-500";
203+
case "PENDING_VERSION":
161204
case "WAITING_FOR_DEPLOY":
162205
return "text-amber-500";
163206
case "EXECUTING":
@@ -194,8 +237,9 @@ export function runStatusTitle(status: TaskRunStatus): string {
194237
return "Delayed";
195238
case "PENDING":
196239
return "Queued";
240+
case "PENDING_VERSION":
197241
case "WAITING_FOR_DEPLOY":
198-
return "Waiting for deploy";
242+
return "Pending version";
199243
case "EXECUTING":
200244
return "Executing";
201245
case "WAITING_TO_RESUME":

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ export function TaskRunsTable({
330330
<TableCell to={path} className="w-[1%]" actionClassName="pr-0 tabular-nums">
331331
<div className="flex items-center gap-1">
332332
<RectangleStackIcon className="size-4 text-text-dimmed" />
333-
{run.startedAt ? (
333+
{run.isPending ? (
334+
"–"
335+
) : run.startedAt ? (
334336
formatDuration(new Date(run.createdAt), new Date(run.startedAt), {
335337
style: "short",
336338
})

apps/webapp/app/database-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const TaskRunAttemptStatus = {
2929

3030
export const TaskRunStatus = {
3131
PENDING: "PENDING",
32+
PENDING_VERSION: "PENDING_VERSION",
3233
WAITING_FOR_DEPLOY: "WAITING_FOR_DEPLOY",
3334
EXECUTING: "EXECUTING",
3435
WAITING_TO_RESUME: "WAITING_TO_RESUME",

apps/webapp/app/hooks/useFilterTasks.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ type Task = {
44
id: string;
55
friendlyId: string;
66
taskIdentifier: string;
7-
exportName: string;
87
filePath: string;
98
triggerSource: string;
109
};
@@ -17,10 +16,6 @@ export function useFilterTasks<T extends Task>({ tasks }: { tasks: T[] }) {
1716
return true;
1817
}
1918

20-
if (task.exportName.toLowerCase().includes(text.toLowerCase())) {
21-
return true;
22-
}
23-
2419
if (task.filePath.toLowerCase().includes(text.toLowerCase())) {
2520
return true;
2621
}

apps/webapp/app/models/runtimeEnvironment.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AuthenticatedEnvironment } from "@internal/testcontainers";
1+
import type { AuthenticatedEnvironment } from "@internal/run-engine";
22
import type { Prisma, PrismaClientOrTransaction, RuntimeEnvironment } from "@trigger.dev/database";
33
import { prisma } from "~/db.server";
44
import { getUsername } from "~/utils/username";

apps/webapp/app/models/taskQueue.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QueueOptions } from "@trigger.dev/core/v3/schemas";
1+
import { QueueManifest } from "@trigger.dev/core/v3/schemas";
22
import { TaskQueue } from "@trigger.dev/database";
33
import { prisma } from "~/db.server";
44

@@ -35,7 +35,7 @@ export async function findQueueInEnvironment(
3535
return;
3636
}
3737

38-
const queueConfig = QueueOptions.safeParse(task.queueConfig);
38+
const queueConfig = QueueManifest.safeParse(task.queueConfig);
3939

4040
if (queueConfig.success) {
4141
const taskQueueName = queueConfig.data.name

apps/webapp/app/models/taskRun.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function batchTaskRunItemStatusForRunStatus(
125125
case TaskRunStatus.TIMED_OUT:
126126
return BatchTaskRunItemStatus.FAILED;
127127
case TaskRunStatus.PENDING:
128+
case TaskRunStatus.PENDING_VERSION:
128129
case TaskRunStatus.WAITING_FOR_DEPLOY:
129130
case TaskRunStatus.WAITING_TO_RESUME:
130131
case TaskRunStatus.RETRYING_AFTER_FAILURE:

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ export class ApiRetrieveRunPresenter extends BasePresenter {
204204
case "DELAYED": {
205205
return "DELAYED";
206206
}
207+
case "PENDING_VERSION": {
208+
return "PENDING_VERSION";
209+
}
207210
case "WAITING_FOR_DEPLOY": {
208211
return "WAITING_FOR_DEPLOY";
209212
}
@@ -257,7 +260,11 @@ export class ApiRetrieveRunPresenter extends BasePresenter {
257260
}
258261

259262
static apiBooleanHelpersFromRunStatus(status: RunStatus) {
260-
const isQueued = status === "QUEUED" || status === "WAITING_FOR_DEPLOY" || status === "DELAYED";
263+
const isQueued =
264+
status === "QUEUED" ||
265+
status === "WAITING_FOR_DEPLOY" ||
266+
status === "DELAYED" ||
267+
status === "PENDING_VERSION";
261268
const isExecuting = status === "EXECUTING" || status === "REATTEMPTING" || status === "FROZEN";
262269
const isCompleted =
263270
status === "COMPLETED" ||

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ export class ApiRunListPresenter extends BasePresenter {
280280
switch (status) {
281281
case "DELAYED":
282282
return "DELAYED";
283+
case "PENDING_VERSION": {
284+
return "PENDING_VERSION";
285+
}
283286
case "WAITING_FOR_DEPLOY": {
284287
return "WAITING_FOR_DEPLOY";
285288
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,10 @@ export class DeploymentPresenter {
108108
tasks: {
109109
select: {
110110
slug: true,
111-
exportName: true,
112111
filePath: true,
113112
},
114113
orderBy: {
115-
exportName: "asc",
114+
slug: "asc",
116115
},
117116
},
118117
sdkVersion: true,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ export class QueueListPresenter extends BasePresenter {
5656
const queues = await this._replica.taskQueue.findMany({
5757
where: {
5858
runtimeEnvironmentId: environment.id,
59+
version: "V2",
5960
},
6061
select: {
6162
friendlyId: true,
6263
name: true,
64+
orderableName: true,
6365
concurrencyLimit: true,
6466
type: true,
6567
paused: true,
68+
releaseConcurrencyOnWaitpoint: true,
6669
},
6770
orderBy: {
68-
name: "asc",
71+
orderableName: "asc",
6972
},
7073
skip: (page - 1) * this.perPage,
7174
take: this.perPage,
@@ -92,6 +95,7 @@ export class QueueListPresenter extends BasePresenter {
9295
queued: results[0][queue.name] ?? 0,
9396
concurrencyLimit: queue.concurrencyLimit ?? null,
9497
paused: queue.paused,
98+
releaseConcurrencyOnWaitpoint: queue.releaseConcurrencyOnWaitpoint,
9599
})
96100
);
97101
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export class QueueRetrievePresenter extends BasePresenter {
7676
queued: results[0]?.[queue.name] ?? 0,
7777
concurrencyLimit: queue.concurrencyLimit ?? null,
7878
paused: queue.paused,
79+
releaseConcurrencyOnWaitpoint: queue.releaseConcurrencyOnWaitpoint,
7980
}),
8081
};
8182
}
@@ -105,6 +106,7 @@ export function toQueueItem(data: {
105106
queued: number;
106107
concurrencyLimit: number | null;
107108
paused: boolean;
109+
releaseConcurrencyOnWaitpoint: boolean;
108110
}): QueueItem {
109111
return {
110112
id: data.friendlyId,
@@ -115,5 +117,6 @@ export function toQueueItem(data: {
115117
queued: data.queued,
116118
concurrencyLimit: data.concurrencyLimit,
117119
paused: data.paused,
120+
releaseConcurrencyOnWaitpoint: data.releaseConcurrencyOnWaitpoint,
118121
};
119122
}

0 commit comments

Comments
 (0)