Commit 2766139
Ricardo DeMatos
fix(managed-agent): async table seed no longer clobbers in-flight edits
Cursor Bugbot on 9704cec flagged a race in the `Table` sub-block
init effect: `fetchDefaultRows` is async, and the effect's guard on
`storeValue !== undefined && storeValue !== null` was captured at
effect setup time. Between the fetch start and its resolution, a
user could type into the phantom row — persisting the row via
`handleCellChange`'s `setStoreValue([newRow])` — and then the
resolved fetch would call `setStoreValue(defaultRows)` and clobber
their edit.
Fix: re-read the current value from the subblock store inside
`seedWith` right before writing (`useSubBlockStore.getState()
.getValue(blockId, subBlockId)`), and skip the write if the value
has already been populated since the effect started. The
closure-captured `storeValue` was stale; the store's `getState`
returns the LATEST value synchronously.
Other Bugbot comments on this commit are re-fires of items already
fixed on prior commits (they signature-match against static code
shapes without noticing the corrective code that lives beside them):
`Stale labels after connection change` (fixed via `depsEqual` in
`areSubBlockRowPropsEqual`), `Empty table re-seeds defaults` (fixed
via `storeValue !== undefined && storeValue !== null` guard),
`Defaults API lacks authentication` (fixed via
`checkSessionOrInternalAuth`), `Rotate connection hook unused`
(fixed via the new Rotate-key modal wired into the settings UI).
`Empty table shows phantom row` is theoretical — the delete-row
guard (`rows.length === 1`) prevents users from reaching `[]`
through the UI, so the mismatch it warns about isn't reachable in
normal use.1 parent 9704cec commit 2766139
1 file changed
Lines changed: 10 additions & 0 deletions
File tree
- apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/table
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
286 | 294 | | |
287 | 295 | | |
288 | 296 | | |
| |||
310 | 318 | | |
311 | 319 | | |
312 | 320 | | |
| 321 | + | |
| 322 | + | |
313 | 323 | | |
314 | 324 | | |
315 | 325 | | |
| |||
0 commit comments