Skip to content

Commit 7e150eb

Browse files
Reuse code, add view log inline in table view
1 parent e5de72a commit 7e150eb

10 files changed

Lines changed: 513 additions & 427 deletions

File tree

apps/sim/app/api/table/[tableId]/cancel-runs/route.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,8 @@ interface RouteParams {
2222
/**
2323
* POST /api/table/[tableId]/cancel-runs
2424
*
25-
* Cancels in-flight and queued workflow-column runs for this table.
26-
*
27-
* Scopes:
28-
* - `all`: every running/queued cell in the table
29-
* - `row`: every running/queued cell for the given `rowId`
30-
*
31-
* Current implementation is a stub: it authorizes the request and returns success.
32-
* Real cancellation requires a Redis pubsub signal plus a DB-backed "cancel requested"
33-
* flag so multi-replica deploys can abort AbortControllers held on any instance.
25+
* Cancels in-flight and pending workflow-column runs for this table. Scopes:
26+
* `all` (every cell) or `row` (every cell for `rowId`).
3427
*/
3528
export const POST = withRouteHandler(async (request: NextRequest, { params }: RouteParams) => {
3629
const requestId = generateRequestId()

apps/sim/app/api/table/[tableId]/rows/[rowId]/run-workflow-column/route.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { type NextRequest, NextResponse } from 'next/server'
44
import { z } from 'zod'
55
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
66
import { generateRequestId } from '@/lib/core/utils/request'
7+
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
78
import { getRowById, updateRow } from '@/lib/table'
89
import type { RowData, WorkflowCellValue } from '@/lib/table'
910
import { accessError, checkAccess } from '@/app/api/table/utils'
@@ -21,11 +22,11 @@ interface RouteParams {
2122

2223
/**
2324
* POST /api/table/[tableId]/rows/[rowId]/run-workflow-column
24-
* Manually (re-)runs a workflow column for a specific row. Bypasses the scheduler's
25-
* eligibility predicate — `runWorkflowColumn` writes the cell to `running` as its first
26-
* step, clearing any prior output/error state.
25+
* Manually (re-)runs a workflow column for a specific row by force-resetting
26+
* the cell to `pending`. The `updateRow` call fires the scheduler which
27+
* enqueues the cell job.
2728
*/
28-
export async function POST(request: NextRequest, { params }: RouteParams) {
29+
export const POST = withRouteHandler(async (request: NextRequest, { params }: RouteParams) => {
2930
const requestId = generateRequestId()
3031
const { tableId, rowId } = await params
3132

@@ -60,16 +61,10 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
6061
}
6162

6263
const executionId = generateId()
63-
const workflowId = column.workflowConfig.workflowId
64-
65-
// Force the cell back to a non-terminal state so the scheduler's
66-
// eligibility check picks it up. Calling `updateRow` here also fires
67-
// `scheduleWorkflowColumnRuns(table, [row])` from inside the service,
68-
// which enqueues a `workflow-column-execution` job for this cell.
6964
const pendingCell: WorkflowCellValue = {
7065
executionId,
7166
jobId: null,
72-
workflowId,
67+
workflowId: column.workflowConfig.workflowId,
7368
status: 'pending',
7469
output: null,
7570
error: null,
@@ -92,7 +87,7 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
9287
{ status: 400 }
9388
)
9489
}
95-
logger.error(`[${requestId}] run-workflow-column failed for ${tableId}/${rowId}:`, error)
90+
logger.error(`run-workflow-column failed for ${tableId}/${rowId}:`, error)
9691
return NextResponse.json({ error: 'Failed to run workflow column' }, { status: 500 })
9792
}
98-
}
93+
})

0 commit comments

Comments
 (0)