Skip to content

Commit e72a0ec

Browse files
committed
fix(tables): follow the folder selector consolidation, and name the real delete guard
Rebasing onto staging after the File folder work landed (#7393). Two adjustments to what that merge changed, and one correction. `readFolderPath` moved from under the sub-block component tree to `lib/folders/selection.ts`, and the `sim-folder-tree-selector` subblock type was consolidated into the pre-existing `folder-selector`. Both are better homes; this follows them. The delete-cascade assertion named the wrong layer. It claimed "the block's own schema is what an Agent tool surface is built from", which contradicts what this same change established for the move destination: `createLLMToolSchema` reads `toolConfig.params`, not the block's subblocks. So the guard that actually keeps a model out of the recursive delete is the TOOL param's `visibility: 'user-only'` — it drives both the omission from the model's schema and `modelBlockedParams`, which `stripModelBlockedParams` then removes from the model's arguments before merge. The subblock's `paramVisibility` governs the tool-input row UI via `isToolParamUserRequired`, which is a real thing but not a guard. Both are still set; the test now asserts the tool param first and says which one enforces.
1 parent 8530364 commit e72a0ec

5 files changed

Lines changed: 23 additions & 12 deletions

File tree

‎apps/sim/blocks/blocks/table-folders.test.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
tableUpdateFolderSchemas,
1212
} from '@/lib/api/contracts/tools/table'
1313
import { TableV2Block } from '@/blocks/blocks/table_v2'
14+
import { tableDeleteFolderTool } from '@/tools/table/folders'
1415

1516
/*
1617
* The block's params transformer feeds the tool dispatch directly, so its output
@@ -237,7 +238,7 @@ describe('table_v2 folder subblocks are wired as canonical pairs', () => {
237238
'destinationParentPath',
238239
'moveTargetFolderPath',
239240
]) {
240-
expect(subBlock(id)?.type).toBe('sim-folder-tree-selector')
241+
expect(subBlock(id)?.type).toBe('folder-selector')
241242
expect(subBlock(id)?.resourceType).toBe('table')
242243
}
243244
})
@@ -342,8 +343,18 @@ describe('table_v2 keeps the destination a model asked for', () => {
342343
expect(params.recursive).toBe(false)
343344
})
344345

345-
it('marks the delete cascade user-only on the subblock, not just the tool', () => {
346-
/* The block's own schema is what an Agent tool surface is built from. */
346+
it('keeps a model out of the delete cascade at the layer that enforces it', () => {
347+
/*
348+
* The enforcing layer is the TOOL param's `visibility: 'user-only'`, not the
349+
* subblock: `createLLMToolSchema` reads `toolConfig.params` to build both the
350+
* model's schema and `modelBlockedParams` (tools/params.ts), and
351+
* `stripModelBlockedParams` drops those keys from the model's arguments
352+
* before they merge (providers/utils.ts). The subblock's `paramVisibility`
353+
* governs the tool-input ROW UI — whether a human must fill the field — via
354+
* `isToolParamUserRequired`. Both are set here, but only the first is a
355+
* guard, so this asserts the tool param and treats the subblock as UI.
356+
*/
357+
expect(tableDeleteFolderTool.params.recursive.visibility).toBe('user-only')
347358
expect(subBlock('deleteFolderRecursive')?.paramVisibility).toBe('user-only')
348359
})
349360
})

‎apps/sim/blocks/blocks/table_v2.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Table } from '@sim/emcn/icons'
22
import { toError } from '@sim/utils/errors'
33
import { encodeFolderPathSegment, ROOT_FOLDER_PATH } from '@/lib/folders/paths'
4+
import { readFolderPath } from '@/lib/folders/selection'
45
import { TABLE_LIMITS } from '@/lib/table/constants'
56
import { filterRulesToPredicate, sortRulesToSortSpec } from '@/lib/table/query-builder/converters'
67
import { normalizeTablePredicate } from '@/lib/table/query-builder/predicate'
@@ -12,7 +13,6 @@ import type {
1213
TablePredicate,
1314
TablePredicateInput,
1415
} from '@/lib/table/types'
15-
import { readFolderPath } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/sim-folder-tree-selector/selection'
1616
import type { BlockConfig, SubBlockType } from '@/blocks/types'
1717
import { parseOptionalNumberInput } from '@/blocks/utils'
1818
import type { TableQueryV2Response } from '@/tools/table/types'
@@ -541,7 +541,7 @@ export const TableV2Block: BlockConfig<TableQueryV2Response> = {
541541
{
542542
id: 'folderSelection',
543543
title: 'Folder',
544-
type: 'sim-folder-tree-selector' as SubBlockType,
544+
type: 'folder-selector' as SubBlockType,
545545
resourceType: 'table',
546546
mode: 'basic',
547547
placeholder: 'Anywhere in the workspace',
@@ -574,7 +574,7 @@ export const TableV2Block: BlockConfig<TableQueryV2Response> = {
574574
{
575575
id: 'folderPath',
576576
title: 'Folder',
577-
type: 'sim-folder-tree-selector' as SubBlockType,
577+
type: 'folder-selector' as SubBlockType,
578578
resourceType: 'table',
579579
canonicalParamId: 'folderRef',
580580
mode: 'basic',
@@ -602,7 +602,7 @@ export const TableV2Block: BlockConfig<TableQueryV2Response> = {
602602
{
603603
id: 'createParentPath',
604604
title: 'Parent Folder',
605-
type: 'sim-folder-tree-selector' as SubBlockType,
605+
type: 'folder-selector' as SubBlockType,
606606
resourceType: 'table',
607607
canonicalParamId: 'createParentRef',
608608
mode: 'basic',
@@ -630,7 +630,7 @@ export const TableV2Block: BlockConfig<TableQueryV2Response> = {
630630
{
631631
id: 'destinationParentPath',
632632
title: 'Move Into',
633-
type: 'sim-folder-tree-selector' as SubBlockType,
633+
type: 'folder-selector' as SubBlockType,
634634
resourceType: 'table',
635635
canonicalParamId: 'destinationParentRef',
636636
mode: 'basic',
@@ -702,7 +702,7 @@ export const TableV2Block: BlockConfig<TableQueryV2Response> = {
702702
{
703703
id: 'moveTargetFolderPath',
704704
title: 'Move Into',
705-
type: 'sim-folder-tree-selector' as SubBlockType,
705+
type: 'folder-selector' as SubBlockType,
706706
resourceType: 'table',
707707
canonicalParamId: 'moveTargetRef',
708708
mode: 'basic',

‎apps/sim/tools/generated/tool-ids.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/generated/tool-metadata.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/generated/tool-outputs.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)