Skip to content

Commit 5af324a

Browse files
fix(enrichment): show waiting over stale outputs
1 parent b2b0c2d commit 5af324a

2 files changed

Lines changed: 77 additions & 4 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @vitest-environment node
3+
*/
4+
import { describe, expect, it } from 'vitest'
5+
import type { RowExecutionMetadata } from '@/lib/table'
6+
import { resolveCellRender } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/cell-render'
7+
import type { DisplayColumn } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/types'
8+
9+
const COLUMN: DisplayColumn = {
10+
id: 'email',
11+
key: 'email',
12+
name: 'Email',
13+
type: 'string',
14+
workflowGroupId: 'group-1',
15+
groupSize: 1,
16+
groupStartColIndex: 0,
17+
headerLabel: 'Email',
18+
isGroupStart: true,
19+
}
20+
21+
function execution(status: RowExecutionMetadata['status']): RowExecutionMetadata {
22+
return {
23+
status,
24+
executionId: 'execution-1',
25+
jobId: null,
26+
workflowId: 'workflow-1',
27+
error: null,
28+
}
29+
}
30+
31+
describe('resolveCellRender waiting precedence', () => {
32+
it('shows Waiting instead of a stale enrichment output', () => {
33+
expect(
34+
resolveCellRender({
35+
value: 'person@old.example',
36+
exec: undefined,
37+
column: COLUMN,
38+
waitingOnLabels: ['Domain'],
39+
isEnrichmentOutput: true,
40+
})
41+
).toEqual({ kind: 'waiting', labels: ['Domain'] })
42+
})
43+
44+
it('shows Waiting over a stale terminal execution', () => {
45+
expect(
46+
resolveCellRender({
47+
value: 'person@old.example',
48+
exec: execution('completed'),
49+
column: COLUMN,
50+
waitingOnLabels: ['Domain'],
51+
isEnrichmentOutput: true,
52+
})
53+
).toEqual({ kind: 'waiting', labels: ['Domain'] })
54+
})
55+
56+
it('keeps the previous value visible while a replacement is in flight', () => {
57+
expect(
58+
resolveCellRender({
59+
value: 'person@old.example',
60+
exec: execution('running'),
61+
column: COLUMN,
62+
waitingOnLabels: ['Domain'],
63+
isEnrichmentOutput: true,
64+
})
65+
).toEqual({ kind: 'value', text: 'person@old.example' })
66+
})
67+
})

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/cell-render.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ export function resolveCellRender({
7878
exec?.status === 'running' || exec?.status === 'queued' || exec?.status === 'pending'
7979
if (inFlight && blockRunning) return { kind: 'running' }
8080

81+
/**
82+
* A mapped-input edit can invalidate an earlier enrichment result without
83+
* deleting its stored output. Once no attempt is in flight, the actionable
84+
* Waiting state must win over that stale value. Active reruns still keep
85+
* showing the previous value until their replacement lands.
86+
*/
87+
if (!inFlight && waitingOnLabels && waitingOnLabels.length > 0) {
88+
return { kind: 'waiting', labels: waitingOnLabels }
89+
}
90+
8191
// Value wins over pending-upstream: a finished column stays finished even
8292
// while other blocks in the group are still running. An empty string is not
8393
// a value — it falls through so a completed enrichment can show "Not found".
@@ -108,10 +118,6 @@ export function resolveCellRender({
108118
return { kind: 'pending-upstream', paused: false }
109119
}
110120

111-
// Waiting wins over a stale terminal status — show the actionable state.
112-
if (waitingOnLabels && waitingOnLabels.length > 0) {
113-
return { kind: 'waiting', labels: waitingOnLabels }
114-
}
115121
if (exec?.status === 'cancelled') return { kind: 'cancelled' }
116122
if (exec?.status === 'error') return { kind: 'error', message: exec.error }
117123
// Enrichment ran to completion but matched nothing → "Not found".

0 commit comments

Comments
 (0)