Skip to content

Commit ec0ac4a

Browse files
committed
Merge remote-tracking branch 'origin/staging' into feat/docs-academy
2 parents 5a5c7a7 + 707c3cc commit ec0ac4a

31 files changed

Lines changed: 878 additions & 23 deletions

File tree

apps/sim/app/_shell/providers/session-provider.test.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,18 @@ function renderProvider(): Harness {
107107
}
108108
}
109109

110-
/** Flush pending microtasks inside an act() boundary. */
110+
/**
111+
* Flush pending work inside an act() boundary. Drains the microtask queue and
112+
* then yields one macrotask tick, so React Query's notifyManager (which can
113+
* schedule observer notifications on a timer) and any deferred renders settle
114+
* deterministically — microtask-only flushing raced the query→render update.
115+
*/
111116
async function flush() {
112117
await act(async () => {
113118
await Promise.resolve()
114119
await Promise.resolve()
115120
await Promise.resolve()
121+
await new Promise<void>((resolve) => setTimeout(resolve, 0))
116122
})
117123
}
118124

apps/sim/app/api/table/[tableId]/delete-async/route.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ vi.mock('@/lib/core/config/env-flags', () => ({
3939
},
4040
}))
4141
vi.mock('@/background/table-delete', () => ({ tableDeleteTask: { id: 'table-delete' } }))
42+
vi.mock('@/lib/core/async-jobs/region', () => ({
43+
resolveTriggerRegion: vi.fn().mockResolvedValue('us-east-1'),
44+
}))
4245
vi.mock('@trigger.dev/sdk', () => ({
4346
tasks: { trigger: mockTasksTrigger },
4447
task: (config: unknown) => config,
@@ -196,7 +199,7 @@ describe('POST /api/table/[tableId]/delete-async', () => {
196199
excludeRowIds: ['row_keep'],
197200
cutoff: expect.any(String),
198201
}),
199-
{ tags: ['tableId:tbl_1', 'jobId:job-id-xyz'] }
202+
{ tags: ['tableId:tbl_1', 'jobId:job-id-xyz'], region: 'us-east-1' }
200203
)
201204
})
202205

apps/sim/app/api/table/[tableId]/delete-async/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro
8686
// Trigger.dev runs the delete outside the web container (survives deploys) and retries —
8787
// safe: the keyset + cutoff walk just deletes whatever remains.
8888
try {
89-
const [{ tableDeleteTask }, { tasks }] = await Promise.all([
89+
const [{ tableDeleteTask }, { tasks }, { resolveTriggerRegion }] = await Promise.all([
9090
import('@/background/table-delete'),
9191
import('@trigger.dev/sdk'),
92+
import('@/lib/core/async-jobs/region'),
9293
])
9394
await tasks.trigger<typeof tableDeleteTask>(
9495
'table-delete',
9596
{ jobId, tableId, workspaceId, filter, excludeRowIds, cutoff: cutoff.toISOString() },
96-
{ tags: [`tableId:${tableId}`, `jobId:${jobId}`] }
97+
{ tags: [`tableId:${tableId}`, `jobId:${jobId}`], region: await resolveTriggerRegion() }
9798
)
9899
} catch (error) {
99100
// A failed dispatch must not leave a ghost `running` job holding the

apps/sim/app/api/table/[tableId]/export-async/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro
6161
const payload: TableExportPayload = { jobId, tableId, workspaceId, format }
6262
if (isTriggerDevEnabled) {
6363
try {
64-
const [{ tableExportTask }, { tasks }] = await Promise.all([
64+
const [{ tableExportTask }, { tasks }, { resolveTriggerRegion }] = await Promise.all([
6565
import('@/background/table-export'),
6666
import('@trigger.dev/sdk'),
67+
import('@/lib/core/async-jobs/region'),
6768
])
6869
await tasks.trigger<typeof tableExportTask>('table-export', payload, {
6970
tags: [`tableId:${tableId}`, `jobId:${jobId}`],
71+
region: await resolveTriggerRegion(),
7072
})
7173
} catch (error) {
7274
// A failed dispatch must not leave a ghost `running` job holding the

apps/sim/app/api/table/[tableId]/import-async/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro
8383
if (isTriggerDevEnabled) {
8484
// Trigger.dev runs the import outside the web container, so it survives app deploys.
8585
try {
86-
const [{ tableImportTask }, { tasks }] = await Promise.all([
86+
const [{ tableImportTask }, { tasks }, { resolveTriggerRegion }] = await Promise.all([
8787
import('@/background/table-import'),
8888
import('@trigger.dev/sdk'),
89+
import('@/lib/core/async-jobs/region'),
8990
])
9091
await tasks.trigger<typeof tableImportTask>('table-import', importPayload, {
9192
tags: [`tableId:${tableId}`, `jobId:${importId}`],
93+
region: await resolveTriggerRegion(),
9294
})
9395
} catch (error) {
9496
// A failed dispatch must not leave a ghost `running` job holding the

apps/sim/app/api/table/import-async/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
115115
if (isTriggerDevEnabled) {
116116
// Trigger.dev runs the import outside the web container, so it survives app deploys.
117117
try {
118-
const [{ tableImportTask }, { tasks }] = await Promise.all([
118+
const [{ tableImportTask }, { tasks }, { resolveTriggerRegion }] = await Promise.all([
119119
import('@/background/table-import'),
120120
import('@trigger.dev/sdk'),
121+
import('@/lib/core/async-jobs/region'),
121122
])
122123
await tasks.trigger<typeof tableImportTask>('table-import', importPayload, {
123124
tags: [`tableId:${table.id}`, `jobId:${importId}`],
125+
region: await resolveTriggerRegion(),
124126
})
125127
} catch (error) {
126128
// A failed dispatch must not leave a ghost `running` job holding the

apps/sim/app/api/webhooks/agentmail/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
agentMailMessageSchema,
2020
webhookSvixHeadersSchema,
2121
} from '@/lib/api/contracts/webhooks'
22+
import { resolveTriggerRegion } from '@/lib/core/async-jobs/region'
2223
import { isTriggerDevEnabled } from '@/lib/core/config/env-flags'
2324
import {
2425
assertContentLengthWithinLimit,
@@ -234,6 +235,7 @@ export const POST = withRouteHandler(async (req: Request) => {
234235
{ taskId },
235236
{
236237
tags: [`workspaceId:${result.id}`, `taskId:${taskId}`],
238+
region: await resolveTriggerRegion(),
237239
}
238240
)
239241
await db

apps/sim/components/icons.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3439,6 +3439,16 @@ export const DeepseekIcon = (props: SVGProps<SVGSVGElement>) => (
34393439
</svg>
34403440
)
34413441

3442+
export const SakanaIcon = (props: SVGProps<SVGSVGElement>) => (
3443+
<svg {...props} height='1em' viewBox='152 5 38 30' width='1em' xmlns='http://www.w3.org/2000/svg'>
3444+
<title>Sakana AI</title>
3445+
<path
3446+
d='m187.2 7.8-2.5-0.7c-6.3-1.8-12.7-1.2-18 1.5l-10.2 5.7c-1.2 0.7-0.2 2.5 1 1.8l7.6-4.4c0.8 1.7 1.5 4 1.1 7.7-1.4-0.3-6-1.4-10.9 1.5-0.6 0.3-0.8 1.1-0.3 1.7 0.5 0.5 1.2 0.3 1.3 0.2 2.2-1.3 5.6-2.4 9.6-1.4-0.7 2.5-2.5 5.6-6 7.8-1.5 0.7-0.4 2.3 0.7 1.8 1.8-1 5.3-3.4 6.9-9 2.1 0.9 4.2 2.4 5.9 4.6l-7.2 4.1c-1.2 0.6-0.3 2.4 1.1 1.7l9-5c4.6-2.7 8.3-7.5 10.1-13.1l1.3-5.3c0.4-0.4 0-1.1-0.5-1.2zm-11.5 17.5-0.6 0.4c-2-2.6-4.5-4.7-7.5-5.7 0.5-3.8-0.3-6.8-1.2-9.1l1.1-0.6c4.8-2 9.8-2.7 16.2-0.9l1.6 0.4-0.8 2.7c-1.5 4.9-4.5 9.6-8.8 12.8z'
3447+
fill='#E60000'
3448+
/>
3449+
</svg>
3450+
)
3451+
34423452
export function GeminiIcon(props: SVGProps<SVGSVGElement>) {
34433453
const id = useId()
34443454
const gradientId = `gemini_gradient_${id}`

apps/sim/lib/a2a/push-notifications.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,15 @@ export async function notifyTaskStateChange(taskId: string, state: TaskState): P
111111

112112
if (isTriggerDevEnabled) {
113113
try {
114-
const { a2aPushNotificationTask } = await import(
115-
'@/background/a2a-push-notification-delivery'
116-
)
114+
const [{ a2aPushNotificationTask }, { resolveTriggerRegion }] = await Promise.all([
115+
import('@/background/a2a-push-notification-delivery'),
116+
import('@/lib/core/async-jobs/region'),
117+
])
117118
await a2aPushNotificationTask.trigger(
118119
{ taskId, state },
119120
{
120121
tags: [`taskId:${taskId}`],
122+
region: await resolveTriggerRegion(),
121123
}
122124
)
123125
logger.info('Push notification queued to trigger.dev', { taskId, state })

apps/sim/lib/billing/cleanup-dispatcher.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getPlanType, type PlanCategory } from '@/lib/billing/plan-helpers'
1010
import { chunkArray } from '@/lib/cleanup/batch-delete'
1111
import { getJobQueue } from '@/lib/core/async-jobs'
1212
import { shouldExecuteInline } from '@/lib/core/async-jobs/config'
13+
import { resolveTriggerRegion } from '@/lib/core/async-jobs/region'
1314
import type { EnqueueOptions } from '@/lib/core/async-jobs/types'
1415
import { isTriggerAvailable } from '@/lib/knowledge/documents/service'
1516
import { isOrganizationWorkspace, WORKSPACE_MODE } from '@/lib/workspaces/policy'
@@ -314,13 +315,15 @@ export async function dispatchCleanupJobs(jobType: CleanupJobType): Promise<{
314315
if (batch.length === 0) return
315316
const currentBatch = batch
316317
batch = []
318+
const region = await resolveTriggerRegion()
317319
const batchResult = await tasks.batchTrigger(
318320
jobType,
319321
currentBatch.map((payload) => ({
320322
payload,
321323
options: {
322324
tags: [`plan:${payload.plan}`, `jobType:${jobType}`],
323325
concurrencyKey: getCleanupConcurrencyKey(jobType),
326+
region,
324327
},
325328
}))
326329
)

0 commit comments

Comments
 (0)