Skip to content

Commit aecc236

Browse files
fix(enrichment): show Cancelled in details panel for aborted runs
1 parent f2dc7f7 commit aecc236

6 files changed

Lines changed: 19 additions & 6 deletions

File tree

apps/sim/app/api/table/[tableId]/rows/[rowId]/enrichment/[groupId]/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const detail: EnrichmentRunDetail = {
5555
durationMs: 1000,
5656
totalCost: 0.05,
5757
matchedProvider: 'hunter',
58+
aborted: false,
5859
providers: [
5960
{
6061
id: 'hunter',

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichment-details/enrichment-details.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { MAX_LOG_DETAILS_WIDTH_RATIO, MIN_LOG_DETAILS_WIDTH } from '@/stores/log
1919

2020
type EnrichmentDetailsTab = 'result' | 'cascade'
2121

22-
type ResultStatus = 'matched' | 'no_match' | 'error' | 'not_run'
22+
type ResultStatus = 'matched' | 'no_match' | 'error' | 'not_run' | 'cancelled'
2323

2424
const RESULT_STATUS_CONFIG: Record<
2525
ResultStatus,
@@ -29,6 +29,7 @@ const RESULT_STATUS_CONFIG: Record<
2929
no_match: { variant: 'gray', label: 'No match' },
3030
error: { variant: 'red', label: 'Error' },
3131
not_run: { variant: 'gray', label: 'Not run' },
32+
cancelled: { variant: 'orange', label: 'Cancelled' },
3233
}
3334

3435
/** Minimum bar width so a sub-millisecond provider still shows on the timeline. */
@@ -76,11 +77,13 @@ function didRun(p: EnrichmentProviderOutcome): boolean {
7677
}
7778

7879
/**
79-
* Derives the cell-level outcome from the cascade — mirrors the executor: a run
80-
* is `error` only when every provider that ran errored; `not_run` when nothing
81-
* executed (missing inputs / cancelled early); otherwise a clean `no_match`.
80+
* Derives the cell-level outcome from the cascade — mirrors the executor: a
81+
* cancelled run is `cancelled` regardless of how far the cascade got; otherwise
82+
* `error` only when every provider that ran errored, `not_run` when nothing
83+
* executed (missing inputs), else a clean `no_match`.
8284
*/
8385
function deriveResultStatus(detail: EnrichmentRunDetail): ResultStatus {
86+
if (detail.aborted) return 'cancelled'
8487
if (detail.matchedProvider) return 'matched'
8588
const ran = detail.providers.filter(didRun)
8689
if (ran.length === 0) return 'not_run'

apps/sim/background/workflow-column-execution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ async function runWorkflowAndWriteTerminal(
335335
jobId: null,
336336
workflowId: statusId,
337337
error: 'Cancelled',
338-
enrichmentDetails: skippedEnrichmentDetail(enrichment),
338+
enrichmentDetails: skippedEnrichmentDetail(enrichment, { aborted: true }),
339339
})
340340
return 'error'
341341
}

apps/sim/enrichments/run.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ describe('runEnrichment cascade detail', () => {
137137
}
138138
)
139139
expect(mockExecuteTool).not.toHaveBeenCalled()
140+
expect(outcome.detail.aborted).toBe(true)
140141
expect(outcome.detail.providers.map((p) => p.status)).toEqual(['not_run', 'not_run'])
141142
})
142143

apps/sim/enrichments/run.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ export interface EnrichmentRunOutcome {
3030
* marked `skipped` so the details panel stays informative (shows the configured
3131
* cascade) instead of empty.
3232
*/
33-
export function skippedEnrichmentDetail(enrichment: EnrichmentConfig): EnrichmentRunDetail {
33+
export function skippedEnrichmentDetail(
34+
enrichment: EnrichmentConfig,
35+
opts: { aborted?: boolean } = {}
36+
): EnrichmentRunDetail {
3437
const now = new Date().toISOString()
3538
return {
3639
startedAt: now,
3740
completedAt: now,
3841
durationMs: 0,
3942
totalCost: 0,
4043
matchedProvider: null,
44+
aborted: opts.aborted ?? false,
4145
providers: enrichment.providers.map((provider) => ({
4246
id: provider.id,
4347
label: provider.label,
@@ -204,6 +208,7 @@ export async function runEnrichment(
204208
durationMs: completedAt - startedAt,
205209
totalCost: cost,
206210
matchedProvider,
211+
aborted: Boolean(ctx.signal?.aborted),
207212
providers,
208213
}
209214

apps/sim/lib/table/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ export interface EnrichmentRunDetail {
180180
totalCost: number
181181
/** Provider id that produced the match, or `null` on no match. */
182182
matchedProvider: string | null
183+
/** True when the run was cancelled (stop / signal abort) — drives a
184+
* "Cancelled" result rather than inferring no-match/not-run from the cascade. */
185+
aborted: boolean
183186
/** Every configured provider, in cascade order (including `not_run` ones). */
184187
providers: EnrichmentProviderOutcome[]
185188
}

0 commit comments

Comments
 (0)