@@ -6,6 +6,8 @@ import { PlayOutline, Square } from '@sim/emcn/icons'
66import type { ActiveDispatch } from '@/lib/api/contracts/tables'
77import type { TableRow as TableRowType , WorkflowGroup } from '@/lib/table'
88import { getUnmetGroupDeps } from '@/lib/table/deps'
9+ import { getEnrichmentReadiness } from '@/enrichments/readiness'
10+ import { getEnrichment } from '@/enrichments/registry'
911import type { SaveReason } from '../../types'
1012import { CellContent } from './cells'
1113import {
@@ -180,27 +182,48 @@ export const DataRow = React.memo(function DataRow({
180182} : DataRowProps ) {
181183 const sel = normalizedSelection
182184 /**
183- * Per-row "Waiting on …" labels keyed by group id. A group has labels iff
184- * at least one of its dependencies is unmet for this row — drives the
185- * "Waiting" pill rendered by `CellContent` for empty workflow-output cells.
186- * Computed once per render rather than per cell so all cells in a group
187- * share the same array reference.
185+ * Per-row "Waiting on …" labels keyed by group id. A group has labels when
186+ * its dependencies are unmet or an enrichment has no provider that can build
187+ * a valid request from the row. Computed once per render rather than per cell
188+ * so all cells in a group share the same array reference.
188189 */
189190 const waitingByGroupId = React . useMemo ( ( ) => {
190191 if ( workflowGroups . length === 0 ) return null
191192 // Deps are stored as column ids; the "Waiting on …" pill shows display names.
192193 const nameByColumnId = new Map ( columns . map ( ( c ) => [ c . key , c . name ] ) )
193194 const map = new Map < string , string [ ] > ( )
194195 for ( const group of workflowGroups ) {
195- // autoRun=false groups never fire from the scheduler — there's nothing
196- // to wait on. The cell stays empty until the user clicks Run manually.
197- if ( group . autoRun === false ) continue
198- const unmet = getUnmetGroupDeps ( group , row )
199- if ( unmet . columns . length === 0 ) continue
200- map . set (
201- group . id ,
202- unmet . columns . map ( ( id ) => nameByColumnId . get ( id ) ?? id )
203- )
196+ const labels = new Set < string > ( )
197+ if ( group . autoRun !== false ) {
198+ const unmet = getUnmetGroupDeps ( group , row )
199+ for ( const id of unmet . columns ) labels . add ( nameByColumnId . get ( id ) ?? id )
200+ }
201+
202+ if ( group . type === 'enrichment' ) {
203+ const enrichment = getEnrichment ( group . enrichmentId )
204+ if ( enrichment ) {
205+ const inputColumnById = new Map < string , string > ( )
206+ const inputs : Record < string , unknown > = { }
207+ for ( const mapping of group . inputMappings ?? [ ] ) {
208+ inputColumnById . set ( mapping . inputName , mapping . columnName )
209+ inputs [ mapping . inputName ] = row . data [ mapping . columnName ]
210+ }
211+ const readiness = getEnrichmentReadiness ( enrichment , inputs )
212+ if ( ! readiness . ready ) {
213+ const mappedLabels = readiness . missingInputs . flatMap ( ( input ) => {
214+ const columnId = inputColumnById . get ( input . id )
215+ return columnId ? [ nameByColumnId . get ( columnId ) ?? columnId ] : [ ]
216+ } )
217+ const waitingLabels =
218+ mappedLabels . length > 0
219+ ? mappedLabels
220+ : readiness . missingInputs . map ( ( input ) => input . name )
221+ for ( const label of waitingLabels ) labels . add ( label )
222+ }
223+ }
224+ }
225+
226+ if ( labels . size > 0 ) map . set ( group . id , [ ...labels ] )
204227 }
205228 return map
206229 } , [ workflowGroups , row , columns ] )
0 commit comments