Skip to content

Commit c38d598

Browse files
fix(tables): address review — id-key exec clears + waiting labels, name in upsert error, un-gate group output ids
1 parent 77abb11 commit c38d598

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/data-row.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,22 @@ export const DataRow = React.memo(function DataRow({
181181
*/
182182
const waitingByGroupId = React.useMemo(() => {
183183
if (workflowGroups.length === 0) return null
184+
// Deps are stored as column ids; the "Waiting on …" pill shows display names.
185+
const nameByColumnId = new Map(columns.map((c) => [c.key, c.name]))
184186
const map = new Map<string, string[]>()
185187
for (const group of workflowGroups) {
186188
// autoRun=false groups never fire from the scheduler — there's nothing
187189
// to wait on. The cell stays empty until the user clicks Run manually.
188190
if (group.autoRun === false) continue
189191
const unmet = getUnmetGroupDeps(group, row)
190192
if (unmet.columns.length === 0) continue
191-
map.set(group.id, unmet.columns)
193+
map.set(
194+
group.id,
195+
unmet.columns.map((id) => nameByColumnId.get(id) ?? id)
196+
)
192197
}
193198
return map
194-
}, [workflowGroups, row])
199+
}, [workflowGroups, row, columns])
195200
const isMultiCell = sel !== null && (sel.startRow !== sel.endRow || sel.startCol !== sel.endCol)
196201
const isRowSelected = isRowChecked
197202
/**

apps/sim/lib/table/service.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,10 @@ export async function upsertRow(
22322232
// the persisted type (e.g. a coerced `"123"` → `123` matches existing rows).
22332233
const targetValue = data.data[targetColumnKey]
22342234
if (targetValue === undefined || targetValue === null) {
2235-
throw new Error(`Upsert requires a value for the conflict target column "${targetColumnKey}"`)
2235+
// Surface the display name, not the internal id — v1 callers pass a name.
2236+
const targetColumnName =
2237+
uniqueColumns.find((c) => getColumnId(c) === targetColumnKey)?.name ?? targetColumnKey
2238+
throw new Error(`Upsert requires a value for the conflict target column "${targetColumnName}"`)
22362239
}
22372240

22382241
// `data->` and `data->>` accept the JSON key as a parameterized text value;
@@ -2577,10 +2580,10 @@ function deriveExecClearsForDataPatch(
25772580
// that group's exec entry so the auto-fire reactor re-arms the cell.
25782581
// Also flags the cleared output column as dirty so transitive downstream
25792582
// groups see it.
2580-
for (const [columnName, value] of Object.entries(dataPatch)) {
2583+
for (const [columnId, value] of Object.entries(dataPatch)) {
25812584
const cleared = value === null || value === undefined || value === ''
25822585
if (!cleared) continue
2583-
const col = schema.columns.find((c) => c.name === columnName)
2586+
const col = schema.columns.find((c) => getColumnId(c) === columnId)
25842587
if (col?.workflowGroupId) groupsToClear.add(col.workflowGroupId)
25852588
}
25862589

@@ -3923,12 +3926,12 @@ export async function addWorkflowGroup(
39233926
)
39243927
}
39253928

3926-
// Assign stable ids to the new output columns (flag on), then rewrite the
3927-
// group's column refs from name → id so outputs/deps/inputMappings key on
3928-
// ids — matching the row-data storage key and surviving future renames.
3929+
// Assign stable ids to the new output columns, then rewrite the group's
3930+
// column refs from name → id so outputs/deps/inputMappings key on ids —
3931+
// matching the row-data storage key and surviving future renames.
39293932
const takenIds = new Set(collectColumnIds(schema))
39303933
const outputColumns = data.outputColumns.map((col) => {
3931-
if (col.id || !isTablesFractionalOrderingEnabled) return col
3934+
if (col.id) return col
39323935
const id = generateColumnId(takenIds)
39333936
takenIds.add(id)
39343937
return { ...col, id }

0 commit comments

Comments
 (0)