@@ -4,7 +4,9 @@ import React from 'react'
44import { Button , Checkbox , cn , handleKeyboardActivation } from '@sim/emcn'
55import { PlayOutline , Square } from '@sim/emcn/icons'
66import type { ActiveDispatch } from '@/lib/api/contracts/tables'
7- import type { TableRow as TableRowType , WorkflowGroup } from '@/lib/table'
7+ import type { ColumnDefinition , TableRow as TableRowType , WorkflowGroup } from '@/lib/table'
8+ import { mapInputValues } from '@/lib/table/cell-format'
9+ import { getColumnId } from '@/lib/table/column-keys'
810import { getUnmetGroupDeps } from '@/lib/table/deps'
911import { getEnrichmentReadiness } from '@/enrichments/readiness'
1012import { getEnrichment } from '@/enrichments/registry'
@@ -23,6 +25,7 @@ import { type NormalizedSelection, resolveCellExec } from './utils'
2325export interface DataRowProps {
2426 row : TableRowType
2527 columns : DisplayColumn [ ]
28+ schemaColumns : ColumnDefinition [ ]
2629 /** Current workspace id — forwarded to cells so in-workspace resource URLs
2730 * render as tagged-resource chips. */
2831 workspaceId : string
@@ -106,6 +109,7 @@ function dataRowPropsAreEqual(prev: DataRowProps, next: DataRowProps): boolean {
106109 if (
107110 prev . row !== next . row ||
108111 prev . columns !== next . columns ||
112+ prev . schemaColumns !== next . schemaColumns ||
109113 prev . workspaceId !== next . workspaceId ||
110114 prev . rowIndex !== next . rowIndex ||
111115 prev . isFirstRow !== next . isFirstRow ||
@@ -152,6 +156,7 @@ function dataRowPropsAreEqual(prev: DataRowProps, next: DataRowProps): boolean {
152156export const DataRow = React . memo ( function DataRow ( {
153157 row,
154158 columns,
159+ schemaColumns,
155160 workspaceId,
156161 rowIndex,
157162 isFirstRow,
@@ -190,7 +195,7 @@ export const DataRow = React.memo(function DataRow({
190195 const waitingByGroupId = React . useMemo ( ( ) => {
191196 if ( workflowGroups . length === 0 ) return null
192197 // Deps are stored as column ids; the "Waiting on …" pill shows display names.
193- const nameByColumnId = new Map ( columns . map ( ( c ) => [ c . key , c . name ] ) )
198+ const nameByColumnId = new Map ( schemaColumns . map ( ( c ) => [ getColumnId ( c ) , c . name ] ) )
194199 const map = new Map < string , string [ ] > ( )
195200 for ( const group of workflowGroups ) {
196201 const labels = new Set < string > ( )
@@ -204,12 +209,15 @@ export const DataRow = React.memo(function DataRow({
204209 if ( group . type === 'enrichment' && ( group . autoRun !== false || hasAttemptedManualRun ) ) {
205210 const enrichment = getEnrichment ( group . enrichmentId )
206211 if ( enrichment ) {
212+ const ownOutputColumns = new Set ( group . outputs . map ( ( output ) => output . columnName ) )
213+ const enrichmentInputMappings = ( group . inputMappings ?? [ ] ) . filter (
214+ ( mapping ) => ! ownOutputColumns . has ( mapping . columnName )
215+ )
207216 const inputColumnById = new Map < string , string > ( )
208- const inputs : Record < string , unknown > = { }
209- for ( const mapping of group . inputMappings ?? [ ] ) {
217+ for ( const mapping of enrichmentInputMappings ) {
210218 inputColumnById . set ( mapping . inputName , mapping . columnName )
211- inputs [ mapping . inputName ] = row . data [ mapping . columnName ]
212219 }
220+ const inputs = mapInputValues ( row . data , schemaColumns , enrichmentInputMappings )
213221 const readiness = getEnrichmentReadiness ( enrichment , inputs )
214222 if ( ! readiness . ready ) {
215223 const mappedLabels = readiness . missingInputs . flatMap ( ( input ) => {
@@ -228,7 +236,7 @@ export const DataRow = React.memo(function DataRow({
228236 if ( labels . size > 0 ) map . set ( group . id , [ ...labels ] )
229237 }
230238 return map
231- } , [ workflowGroups , row , columns ] )
239+ } , [ workflowGroups , row , schemaColumns ] )
232240 const isMultiCell = sel !== null && ( sel . startRow !== sel . endRow || sel . startCol !== sel . endCol )
233241 const isRowSelected = isRowChecked
234242 /**
0 commit comments