MCPcopy Index your code
hub / github.com/simstudioai/sim / buildResumeCellWriters

Function buildResumeCellWriters

apps/sim/background/resume-execution.ts:170–292  ·  view source on GitHub ↗
(
  cellContext: {
    tableId: string
    rowId: string
    workspaceId: string
    groupId: string
    workflowId: string
  },
  parentExecutionId: string
)

Source from the content-addressed store, hash-verified

168}
169
170async function buildResumeCellWriters(
171 cellContext: {
172 tableId: string
173 rowId: string
174 workspaceId: string
175 groupId: string
176 workflowId: string
177 },
178 parentExecutionId: string
179): Promise<CellWriters | null> {
180 const { getTableById } = await import('@/lib/table/service')
181 const { writeWorkflowGroupState, buildOutputsByBlockId } = await import('@/lib/table/cell-write')
182 const { pluckByPath } = await import('@/lib/table/pluck')
183
184 const table = await getTableById(cellContext.tableId)
185 const group = table?.schema.workflowGroups?.find((g) => g.id === cellContext.groupId)
186 if (!group) {
187 logger.warn('Cell context found but table or group missing — falling back to plain resume', {
188 parentExecutionId,
189 tableId: cellContext.tableId,
190 groupId: cellContext.groupId,
191 })
192 return null
193 }
194
195 const outputsByBlockId = buildOutputsByBlockId(group)
196 const accumulatedData: RowData = {}
197 const blockErrors: Record<string, string> = {}
198 const writeCtx = {
199 tableId: cellContext.tableId,
200 rowId: cellContext.rowId,
201 workspaceId: cellContext.workspaceId,
202 groupId: cellContext.groupId,
203 executionId: parentExecutionId,
204 requestId: `wfgrp-resume-${parentExecutionId}`,
205 }
206 let writeChain: Promise<void> = Promise.resolve()
207 let terminalWritten = false
208
209 const cellOnBlockComplete = async (blockId: string, output: unknown) => {
210 const outputs = outputsByBlockId.get(blockId)
211 if (!outputs) return
212 const blockResult =
213 output && typeof output === 'object' && 'output' in (output as object)
214 ? (output as { output: unknown }).output
215 : output
216 const errorMessage =
217 blockResult &&
218 typeof blockResult === 'object' &&
219 typeof (blockResult as { error?: unknown }).error === 'string'
220 ? (blockResult as { error: string }).error
221 : null
222 if (errorMessage) {
223 blockErrors[blockId] = errorMessage
224 } else {
225 for (const out of outputs) {
226 const plucked = pluckByPath(blockResult, out.path)
227 if (plucked === undefined) continue

Callers 1

executeResumeJobFunction · 0.85

Calls 4

getTableByIdFunction · 0.85
buildOutputsByBlockIdFunction · 0.85
warnMethod · 0.65
resolveMethod · 0.65

Tested by

no test coverage detected